@lynn123411/dsh-model-submenu 0.3.19 → 0.3.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -5,305 +5,9 @@ window.__ModuleLoader__.load({
5
5
  var exports = module.exports;
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
7
  let react = require("react");
8
- let react_jsx_runtime = require("react/jsx-runtime");
9
8
  let react_dom = require("react-dom");
10
9
  let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
11
- //#region src/client/level-color.ts
12
- const NEUTRAL = "var(--dsw-alias-label-dimmed)";
13
- const LOW = [
14
- 77,
15
- 147,
16
- 248
17
- ];
18
- const HIGH = [
19
- 147,
20
- 51,
21
- 234
22
- ];
23
- function ramp(t) {
24
- const mix = (from, to) => Math.round(from + (to - from) * t);
25
- return `rgb(${mix(LOW[0], HIGH[0])}, ${mix(LOW[1], HIGH[1])}, ${mix(LOW[2], HIGH[2])})`;
26
- }
27
- function levelColor(index, count) {
28
- if (index <= 0) return NEUTRAL;
29
- if (isTopLevel(index, count)) return ramp(1);
30
- const span = Math.max(1, count - 2);
31
- return ramp(Math.min(Math.max((index - 1) / span, 0), 1));
32
- }
33
- function isTopLevel(index, count) {
34
- return count > 1 && index === count - 1;
35
- }
36
- const LEVEL_GRADIENT = `linear-gradient(90deg, ${ramp(0)}, ${ramp(1)})`;
37
- //#endregion
38
- //#region src/client/selection.ts
39
- function effortChoices(reasoning) {
40
- if (reasoning === void 0) return [];
41
- return reasoning.efforts.map((level) => ({
42
- key: level.id,
43
- effort: level.id,
44
- label: level.name
45
- }));
46
- }
47
- function planEffortCommit(live, effort) {
48
- if (sameEffort(live.reasoningEffort, effort)) return null;
49
- return {
50
- provider: live.provider,
51
- model: live.model,
52
- ...effort === void 0 ? {} : { reasoningEffort: effort }
53
- };
54
- }
55
- function planModelCommit(live, provider, model, reasoningOf, remembered) {
56
- if (live !== null && sameModel(live, provider, model)) return null;
57
- const offered = reasoningOf(provider, model);
58
- return {
59
- provider,
60
- model,
61
- ...offered !== void 0 && remembered !== void 0 && offered.efforts.some((level) => level.id === remembered) ? { reasoningEffort: remembered } : {}
62
- };
63
- }
64
- function liveReasoning(state) {
65
- return currentCatalogModel(state)?.reasoning;
66
- }
67
- function currentCatalogModel(state) {
68
- const current = state.current;
69
- if (current === null) return void 0;
70
- return state.groups.find((group) => group.id === current.provider)?.models.find((model) => model.id === current.model);
71
- }
72
- function selectionOf(state) {
73
- if (state.current === null) return null;
74
- return state.current.reasoningEffort === void 0 ? {
75
- provider: state.current.provider,
76
- model: state.current.model
77
- } : {
78
- provider: state.current.provider,
79
- model: state.current.model,
80
- reasoningEffort: state.current.reasoningEffort
81
- };
82
- }
83
- function sameModel(live, provider, model) {
84
- return live.provider === provider && live.model === model;
85
- }
86
- function sameEffort(liveEffort, effort) {
87
- return liveEffort === effort;
88
- }
89
- //#endregion
90
- //#region src/client/EffortTint.tsx
91
- function EffortTint({ available, directory }) {
92
- const markerRef = (0, react.useRef)(null);
93
- const [caption, setCaption] = (0, react.useState)(null);
94
- const state = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot());
95
- const levels = effortChoices(liveReasoning(state));
96
- const effort = state.current?.reasoningEffort;
97
- const chosen = effort === void 0 ? -1 : levels.findIndex((level) => level.effort === effort);
98
- const color = available && chosen >= 0 && levels.length >= 2 ? levelColor(chosen, levels.length) : null;
99
- (0, react.useLayoutEffect)(() => {
100
- const next = (markerRef.current?.closest("[data-composer-card]"))?.querySelector("[data-slot=\"conversation.input.model\"] button[aria-haspopup=\"menu\"] span[class*=\"triggerEffort\"]") ?? null;
101
- if (next !== caption) setCaption(next);
102
- });
103
- (0, react.useLayoutEffect)(() => {
104
- if (caption === null || color === null) return;
105
- const saved = caption.style.color;
106
- caption.style.color = color;
107
- return () => {
108
- caption.style.color = saved;
109
- };
110
- }, [caption, color]);
111
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
112
- ref: markerRef,
113
- hidden: true
114
- });
115
- }
116
- const KNOB_RADIUS = 10;
117
- function offsetOf(index, count) {
118
- if (count <= 1) return 0;
119
- return Math.min(Math.max(index, 0), count - 1) / (count - 1);
120
- }
121
- function fractionAt(clientX, left, width) {
122
- const usable = width - 20;
123
- if (usable <= 0) return 0;
124
- const fraction = (clientX - left - KNOB_RADIUS) / usable;
125
- return Math.min(Math.max(fraction, 0), 1);
126
- }
127
- function detentAt(fraction, count) {
128
- if (count <= 1) return 0;
129
- return Math.round(Math.min(Math.max(fraction, 0), 1) * (count - 1));
130
- }
131
- function knobOffset(fraction) {
132
- return `calc(${KNOB_RADIUS}px + ${Math.min(Math.max(fraction, 0), 1)} * (100% - 20px))`;
133
- }
134
- function fillWidth(fraction) {
135
- return `calc(16px + ${Math.min(Math.max(fraction, 0), 1)} * (100% - 16px))`;
136
- }
137
- //#endregion
138
- //#region \0dsh-css:/home/runner/work/my-dsh/my-dsh/plugins/dsh-model-submenu/src/client/ModelOptions.module.css.mjs
139
- const stylesheet = ".TcCbqa_pickerHost{display:contents}.TcCbqa_modelCell.TcCbqa_modelCell{anchor-name:--dsh-quick-model-row;padding-inline-end:14px}.TcCbqa_modelCell>svg:last-child{visibility:hidden}.TcCbqa_modelBrowse{position-anchor:--dsh-quick-model-row;top:anchor(top);bottom:anchor(bottom);border-radius:var(--dsw-radius-md);width:32px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;place-items:center;padding:0;display:grid;position:absolute;inset-inline-end:anchor(end)}.TcCbqa_modelBrowse:hover:not(:disabled),.TcCbqa_modelBrowse:focus-visible{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.TcCbqa_quickOption{border-radius:var(--dsw-radius-md);width:100%;min-height:34px;color:inherit;text-align:start;cursor:pointer;background:0 0;border:0;outline:none;align-items:center;gap:6px;padding:5px 7px;font-size:13px;font-weight:400;line-height:18px;display:flex}.TcCbqa_quickOption:hover:not(:disabled,[aria-disabled=true]),.TcCbqa_quickOption:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_quickOption:disabled,.TcCbqa_quickOption[aria-disabled=true]{color:var(--dsw-alias-label-dimmed);cursor:default}.TcCbqa_quickCopy{flex:1;align-items:center;gap:4px;min-width:0;display:flex}.TcCbqa_quickName{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.TcCbqa_quickBadge{flex:none}.TcCbqa_quickCheck{flex:0 0 14px;place-items:center;display:grid}.TcCbqa_quickFooter{border-block-start:.5px solid var(--dsw-alias-border-l2);margin-block-start:4px;padding-block-start:4px}.TcCbqa_sliderCell{flex:auto;align-self:stretch;align-items:center;min-width:96px;display:flex}.TcCbqa_slider{cursor:pointer;touch-action:none;-webkit-user-select:none;user-select:none;outline:none;flex:1;align-items:center;min-width:0;height:100%;display:flex}.TcCbqa_slider[data-busy]{cursor:default}.TcCbqa_sliderTrack{corner-shape:round;background:var(--dsw-alias-border-l3);border-radius:999px;width:100%;height:16px;position:relative}.TcCbqa_sliderFill{corner-shape:round;pointer-events:none;border-radius:999px;transition:width .16s cubic-bezier(.2,0,0,1);position:absolute;top:0;bottom:0;left:0}.TcCbqa_sliderTick{corner-shape:round;background:var(--dsw-alias-label-tertiary);pointer-events:none;border-radius:50%;width:4px;height:4px;margin:-2px 0 0 -2px;position:absolute;top:50%}.TcCbqa_sliderTick[data-on]{background:#00000047}.TcCbqa_sliderKnob{box-sizing:border-box;corner-shape:round;background:var(--dsw-alias-label-primary-foreground);width:20px;height:20px;box-shadow:var(--dsw-elevation-soft);pointer-events:none;border-radius:50%;margin:-10px 0 0 -10px;transition:left .16s cubic-bezier(.2,0,0,1);position:absolute;top:50%}.TcCbqa_slider[data-dragging] .TcCbqa_sliderKnob,.TcCbqa_slider[data-dragging] .TcCbqa_sliderFill{transition:none}@media (prefers-reduced-motion:reduce){.TcCbqa_sliderKnob,.TcCbqa_sliderFill{transition:none}}.TcCbqa_slider[data-default] .TcCbqa_sliderKnob{background:var(--dsw-alias-bg-layer-1);border:1.5px solid var(--dsw-alias-label-tertiary);box-shadow:none}.TcCbqa_slider[data-busy] .TcCbqa_sliderKnob{opacity:.6}.TcCbqa_slider:focus-visible .TcCbqa_sliderTrack{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:3px}.TcCbqa_rowBadge{flex:none;margin-inline-start:6px}.TcCbqa_row{align-items:center;gap:2px;display:flex}.TcCbqa_rowPick{box-sizing:border-box;width:100%;min-width:0;min-height:34px;color:inherit;text-align:left;cursor:pointer;border-radius:var(--dsw-radius-md);padding-inline:6px;background:0 0;border:none;outline:none;flex:1;align-items:center;gap:4px;padding:5px 7px;display:flex}.TcCbqa_rowPick:hover:not(:disabled),.TcCbqa_rowPick:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_rowPick:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.TcCbqa_rowCopy{flex-direction:column;flex:1;min-width:0;display:flex}.TcCbqa_rowName{color:inherit;text-overflow:ellipsis;white-space:nowrap;font-size:11.5px;font-weight:400;line-height:17px;overflow:hidden}.TcCbqa_rowMeta{color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:18px;overflow:hidden}.TcCbqa_check{color:var(--dsw-alias-label-primary);flex:0 0 15px;place-items:center;display:grid}.TcCbqa_starButton{color:var(--dsw-alias-label-tertiary);cursor:pointer;border-radius:var(--dsw-radius-sm);opacity:0;background:0 0;border:none;outline:none;flex:none;place-items:center;width:26px;height:26px;display:grid}.TcCbqa_starButton:focus-visible{outline:2px solid var(--dsw-alias-border-l3)}.TcCbqa_row:hover .TcCbqa_starButton,.TcCbqa_row:focus-within .TcCbqa_starButton{opacity:1}.TcCbqa_starButton[aria-pressed=true]{color:var(--dsw-alias-state-warn-primary);opacity:1}@media (hover:none){.TcCbqa_starButton{opacity:1}}.TcCbqa_star{flex:none}.TcCbqa_notice{color:var(--dsw-alias-label-tertiary);justify-content:space-between;align-items:flex-start;gap:8px;padding:6px 10px;font-size:12px;line-height:18px;display:flex}.TcCbqa_retry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600;text-decoration:underline}.TcCbqa_pickerDialog.TcCbqa_pickerDialog{gap:0;width:min(680px,100%);height:min(640px,80vh);padding:0}.TcCbqa_pickerContent,.TcCbqa_pickerContent>:last-child{flex-direction:column;flex:1;min-height:0;display:flex}.TcCbqa_pickerSearch{padding:0 20px 12px}.TcCbqa_pickerSearchInput{width:100%}.TcCbqa_pickerTabs{border-bottom:.5px solid var(--dsw-alias-border-l2);overscroll-behavior-x:contain;scrollbar-width:none;flex-wrap:nowrap;gap:2px;padding:0 16px;display:flex;overflow-x:auto}.TcCbqa_pickerTabs::-webkit-scrollbar{display:none}.TcCbqa_pickerTab{color:var(--dsw-alias-label-secondary);cursor:pointer;border-radius:var(--dsw-radius-sm);white-space:nowrap;background:0 0;border:none;outline:none;flex:none;padding:6px 10px;font-size:13px;line-height:18px}.TcCbqa_pickerTab:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_pickerTab[aria-selected=true]{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover);font-weight:600}.TcCbqa_pickerTab:focus-visible{outline:2px solid var(--dsw-alias-border-l3)}.TcCbqa_pickerList{flex:1;min-height:0;padding:8px 12px;overflow-y:auto}.TcCbqa_pickerFooter{border-top:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);justify-content:space-between;align-items:center;gap:12px;padding:10px 20px;font-size:12px;line-height:18px;display:flex}.TcCbqa_footerHint{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.TcCbqa_footerFavorites{text-align:end}";
140
- var ModelOptions_module_css_default = {
141
- "check": "TcCbqa_check",
142
- "footerFavorites": "TcCbqa_footerFavorites",
143
- "footerHint": "TcCbqa_footerHint",
144
- "modelBrowse": "TcCbqa_modelBrowse",
145
- "modelCell": "TcCbqa_modelCell",
146
- "notice": "TcCbqa_notice",
147
- "pickerContent": "TcCbqa_pickerContent",
148
- "pickerDialog": "TcCbqa_pickerDialog",
149
- "pickerFooter": "TcCbqa_pickerFooter",
150
- "pickerHost": "TcCbqa_pickerHost",
151
- "pickerList": "TcCbqa_pickerList",
152
- "pickerSearch": "TcCbqa_pickerSearch",
153
- "pickerSearchInput": "TcCbqa_pickerSearchInput",
154
- "pickerTab": "TcCbqa_pickerTab",
155
- "pickerTabs": "TcCbqa_pickerTabs",
156
- "quickBadge": "TcCbqa_quickBadge",
157
- "quickCheck": "TcCbqa_quickCheck",
158
- "quickCopy": "TcCbqa_quickCopy",
159
- "quickFooter": "TcCbqa_quickFooter",
160
- "quickName": "TcCbqa_quickName",
161
- "quickOption": "TcCbqa_quickOption",
162
- "retry": "TcCbqa_retry",
163
- "row": "TcCbqa_row",
164
- "rowBadge": "TcCbqa_rowBadge",
165
- "rowCopy": "TcCbqa_rowCopy",
166
- "rowMeta": "TcCbqa_rowMeta",
167
- "rowName": "TcCbqa_rowName",
168
- "rowPick": "TcCbqa_rowPick",
169
- "slider": "TcCbqa_slider",
170
- "sliderCell": "TcCbqa_sliderCell",
171
- "sliderFill": "TcCbqa_sliderFill",
172
- "sliderKnob": "TcCbqa_sliderKnob",
173
- "sliderTick": "TcCbqa_sliderTick",
174
- "sliderTrack": "TcCbqa_sliderTrack",
175
- "star": "TcCbqa_star",
176
- "starButton": "TcCbqa_starButton"
177
- };
178
- //#endregion
179
- //#region src/client/EffortSlider.tsx
180
- function EffortSlider({ steps, current, defaultActive, defaultIndex, defaultLabel, busy, label, onCommit }) {
181
- const trackRef = (0, react.useRef)(null);
182
- const dragRef = (0, react.useRef)(null);
183
- const pointerRef = (0, react.useRef)(null);
184
- const [drag, setDrag] = (0, react.useState)(null);
185
- const [hold, setHold] = (0, react.useState)(null);
186
- const dragging = drag !== null;
187
- const resting = defaultActive ? defaultIndex : current;
188
- const active = dragging ? detentAt(drag, steps.length) : resting;
189
- const knobFraction = drag ?? hold ?? offsetOf(resting, steps.length);
190
- const shown = dragging || hold !== null ? detentAt(knobFraction, steps.length) : resting;
191
- const beginDrag = (fraction) => {
192
- dragRef.current = fraction;
193
- setDrag(fraction);
194
- };
195
- (0, react.useEffect)(() => {
196
- if (!busy) {
197
- setHold(null);
198
- return;
199
- }
200
- pointerRef.current = null;
201
- dragRef.current = null;
202
- setDrag(null);
203
- }, [busy]);
204
- (0, react.useEffect)(() => {
205
- setHold(null);
206
- }, [current, defaultActive]);
207
- const fractionAtPointer = (clientX) => {
208
- const track = trackRef.current;
209
- if (track === null) return dragRef.current ?? knobFraction;
210
- const rect = track.getBoundingClientRect();
211
- return fractionAt(clientX, rect.left, rect.width);
212
- };
213
- const onPointerDown = (event) => {
214
- if (busy || event.button !== 0 || pointerRef.current !== null) return;
215
- event.preventDefault();
216
- event.stopPropagation();
217
- setHold(null);
218
- pointerRef.current = event.pointerId;
219
- beginDrag(fractionAtPointer(event.clientX));
220
- try {
221
- event.currentTarget.setPointerCapture(event.pointerId);
222
- } catch {}
223
- event.currentTarget.focus();
224
- };
225
- const onPointerMove = (event) => {
226
- if (pointerRef.current !== event.pointerId || busy) return;
227
- beginDrag(fractionAtPointer(event.clientX));
228
- };
229
- const settle = (event, commit) => {
230
- if (pointerRef.current !== event.pointerId) return;
231
- pointerRef.current = null;
232
- beginDrag(null);
233
- if (!commit || busy) return;
234
- const next = detentAt(fractionAtPointer(event.clientX), steps.length);
235
- if (next !== current || defaultActive) {
236
- setHold(offsetOf(next, steps.length));
237
- onCommit(next);
238
- }
239
- };
240
- const onKeyDown = (event) => {
241
- if (event.nativeEvent.isComposing) return;
242
- const last = steps.length - 1;
243
- const next = event.key === "ArrowRight" || event.key === "ArrowUp" ? Math.min(active + 1, last) : event.key === "ArrowLeft" || event.key === "ArrowDown" ? Math.max(active - 1, 0) : event.key === "Home" ? 0 : event.key === "End" ? last : null;
244
- if (next === null) return;
245
- event.preventDefault();
246
- event.stopPropagation();
247
- if (!busy && (next !== current || defaultActive)) onCommit(next);
248
- };
249
- const offset = knobOffset(knobFraction);
250
- const idle = defaultActive && !dragging && hold === null;
251
- const filled = idle ? 0 : knobFraction;
252
- const fill = isTopLevel(shown, steps.length) ? LEVEL_GRADIENT : levelColor(shown, steps.length);
253
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
254
- ref: trackRef,
255
- className: ModelOptions_module_css_default.slider,
256
- role: "slider",
257
- tabIndex: 0,
258
- "aria-label": label,
259
- "aria-valuemin": 0,
260
- "aria-valuemax": Math.max(0, steps.length - 1),
261
- "aria-valuenow": active,
262
- "aria-valuetext": defaultActive && !dragging ? defaultLabel : steps[active]?.label,
263
- "aria-disabled": busy || void 0,
264
- "data-busy": busy ? "" : void 0,
265
- "data-dragging": dragging ? "" : void 0,
266
- "data-default": idle ? "" : void 0,
267
- onPointerDown,
268
- onPointerMove,
269
- onPointerUp: (event) => {
270
- settle(event, true);
271
- },
272
- onPointerCancel: (event) => {
273
- settle(event, false);
274
- },
275
- onLostPointerCapture: (event) => {
276
- settle(event, false);
277
- },
278
- onKeyDown,
279
- onClick: (event) => {
280
- event.stopPropagation();
281
- },
282
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
283
- className: ModelOptions_module_css_default.sliderTrack,
284
- "aria-hidden": "true",
285
- children: [
286
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
287
- className: ModelOptions_module_css_default.sliderFill,
288
- style: {
289
- width: fillWidth(filled),
290
- background: fill
291
- }
292
- }),
293
- steps.map((step, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
294
- className: ModelOptions_module_css_default.sliderTick,
295
- "data-on": index <= shown && !idle ? "" : void 0,
296
- style: { left: knobOffset(offsetOf(index, steps.length)) }
297
- }, step.key)),
298
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
299
- className: ModelOptions_module_css_default.sliderKnob,
300
- style: { left: offset }
301
- })
302
- ]
303
- })
304
- });
305
- }
306
- //#endregion
10
+ let react_jsx_runtime = require("react/jsx-runtime");
307
11
  //#region src/client/effort-memory.ts
308
12
  const EFFORTS_KEY = "dsh-model-submenu.efforts";
309
13
  function readEfforts(storage) {
@@ -389,6 +93,72 @@ window.__ModuleLoader__.load({
389
93
  }
390
94
  }
391
95
  //#endregion
96
+ //#region src/client/selection.ts
97
+ function planModelCommit(live, provider, model, reasoningOf, remembered) {
98
+ if (live !== null && sameModel(live, provider, model)) return null;
99
+ const offered = reasoningOf(provider, model);
100
+ return {
101
+ provider,
102
+ model,
103
+ ...offered !== void 0 && remembered !== void 0 && offered.efforts.some((level) => level.id === remembered) ? { reasoningEffort: remembered } : {}
104
+ };
105
+ }
106
+ function currentCatalogModel(state) {
107
+ const current = state.current;
108
+ if (current === null) return void 0;
109
+ return state.groups.find((group) => group.id === current.provider)?.models.find((model) => model.id === current.model);
110
+ }
111
+ function selectionOf(state) {
112
+ if (state.current === null) return null;
113
+ return state.current.reasoningEffort === void 0 ? {
114
+ provider: state.current.provider,
115
+ model: state.current.model
116
+ } : {
117
+ provider: state.current.provider,
118
+ model: state.current.model,
119
+ reasoningEffort: state.current.reasoningEffort
120
+ };
121
+ }
122
+ function sameModel(live, provider, model) {
123
+ return live.provider === provider && live.model === model;
124
+ }
125
+ //#endregion
126
+ //#region \0dsh-css:/home/runner/work/my-dsh/my-dsh/plugins/dsh-model-submenu/src/client/ModelOptions.module.css.mjs
127
+ const stylesheet = ".TcCbqa_pickerHost{display:contents}.TcCbqa_modelCell.TcCbqa_modelCell{anchor-name:--dsh-quick-model-row;padding-inline-end:14px}.TcCbqa_modelCell>svg:last-child{visibility:hidden}.TcCbqa_modelBrowse{position-anchor:--dsh-quick-model-row;top:anchor(top);bottom:anchor(bottom);border-radius:var(--dsw-radius-md);width:32px;color:var(--dsw-alias-label-tertiary);cursor:pointer;background:0 0;border:0;place-items:center;padding:0;display:grid;position:absolute;inset-inline-end:anchor(end)}.TcCbqa_modelBrowse:hover:not(:disabled),.TcCbqa_modelBrowse:focus-visible{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}.TcCbqa_quickOption{border-radius:var(--dsw-radius-md);width:100%;min-height:34px;color:inherit;text-align:start;cursor:pointer;background:0 0;border:0;outline:none;align-items:center;gap:6px;padding:5px 7px;font-size:13px;font-weight:400;line-height:18px;display:flex}.TcCbqa_quickOption:hover:not(:disabled,[aria-disabled=true]),.TcCbqa_quickOption:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_quickOption:disabled,.TcCbqa_quickOption[aria-disabled=true]{color:var(--dsw-alias-label-dimmed);cursor:default}.TcCbqa_quickCopy{flex:1;align-items:center;gap:4px;min-width:0;display:flex}.TcCbqa_quickName{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.TcCbqa_quickBadge{flex:none}.TcCbqa_quickCheck{flex:0 0 14px;place-items:center;display:grid}.TcCbqa_quickFooter{border-block-start:.5px solid var(--dsw-alias-border-l2);margin-block-start:4px;padding-block-start:4px}.TcCbqa_rowBadge{flex:none;margin-inline-start:6px}.TcCbqa_row{align-items:center;gap:2px;display:flex}.TcCbqa_rowPick{box-sizing:border-box;width:100%;min-width:0;min-height:34px;color:inherit;text-align:left;cursor:pointer;border-radius:var(--dsw-radius-md);padding-inline:6px;background:0 0;border:none;outline:none;flex:1;align-items:center;gap:4px;padding:5px 7px;display:flex}.TcCbqa_rowPick:hover:not(:disabled),.TcCbqa_rowPick:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_rowPick:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}.TcCbqa_rowCopy{flex-direction:column;flex:1;min-width:0;display:flex}.TcCbqa_rowName{color:inherit;text-overflow:ellipsis;white-space:nowrap;font-size:11.5px;font-weight:400;line-height:17px;overflow:hidden}.TcCbqa_rowMeta{color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;font-size:12px;line-height:18px;overflow:hidden}.TcCbqa_check{color:var(--dsw-alias-label-primary);flex:0 0 15px;place-items:center;display:grid}.TcCbqa_starButton{color:var(--dsw-alias-label-tertiary);cursor:pointer;border-radius:var(--dsw-radius-sm);opacity:0;background:0 0;border:none;outline:none;flex:none;place-items:center;width:26px;height:26px;display:grid}.TcCbqa_starButton:focus-visible{outline:2px solid var(--dsw-alias-border-l3)}.TcCbqa_row:hover .TcCbqa_starButton,.TcCbqa_row:focus-within .TcCbqa_starButton{opacity:1}.TcCbqa_starButton[aria-pressed=true]{color:var(--dsw-alias-state-warn-primary);opacity:1}@media (hover:none){.TcCbqa_starButton{opacity:1}}.TcCbqa_star{flex:none}.TcCbqa_notice{color:var(--dsw-alias-label-tertiary);justify-content:space-between;align-items:flex-start;gap:8px;padding:6px 10px;font-size:12px;line-height:18px;display:flex}.TcCbqa_retry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600;text-decoration:underline}.TcCbqa_pickerDialog.TcCbqa_pickerDialog{gap:0;width:min(680px,100%);height:min(640px,80vh);max-height:100%;padding:0}.TcCbqa_pickerContent,.TcCbqa_pickerContent :has(.TcCbqa_pickerBody),.TcCbqa_pickerBody{flex-direction:column;flex:1;min-height:0;display:flex}.TcCbqa_pickerSearch,.TcCbqa_pickerTabs,.TcCbqa_pickerFooter{flex:none}.TcCbqa_pickerSearch{padding:0 20px 12px}.TcCbqa_pickerSearchInput{width:100%}.TcCbqa_pickerTabs{border-bottom:.5px solid var(--dsw-alias-border-l2);overscroll-behavior-x:contain;scrollbar-width:none;flex-wrap:nowrap;gap:2px;padding:0 16px;display:flex;overflow-x:auto}.TcCbqa_pickerTabs::-webkit-scrollbar{display:none}.TcCbqa_pickerTab{color:var(--dsw-alias-label-secondary);cursor:pointer;border-radius:var(--dsw-radius-sm);white-space:nowrap;background:0 0;border:none;outline:none;flex:none;padding:6px 10px;font-size:13px;line-height:18px}.TcCbqa_pickerTab:hover{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover)}.TcCbqa_pickerTab[aria-selected=true]{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-interactive-bg-hover);font-weight:600}.TcCbqa_pickerTab:focus-visible{outline:2px solid var(--dsw-alias-border-l3)}.TcCbqa_pickerList{flex:1;min-height:0;padding:8px 12px;overflow-y:auto}.TcCbqa_pickerFooter{border-top:.5px solid var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);justify-content:space-between;align-items:center;gap:12px;padding:10px 20px;font-size:12px;line-height:18px;display:flex}.TcCbqa_footerHint{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.TcCbqa_footerFavorites{text-align:end}";
128
+ var ModelOptions_module_css_default = {
129
+ "check": "TcCbqa_check",
130
+ "footerFavorites": "TcCbqa_footerFavorites",
131
+ "footerHint": "TcCbqa_footerHint",
132
+ "modelBrowse": "TcCbqa_modelBrowse",
133
+ "modelCell": "TcCbqa_modelCell",
134
+ "notice": "TcCbqa_notice",
135
+ "pickerBody": "TcCbqa_pickerBody",
136
+ "pickerContent": "TcCbqa_pickerContent",
137
+ "pickerDialog": "TcCbqa_pickerDialog",
138
+ "pickerFooter": "TcCbqa_pickerFooter",
139
+ "pickerHost": "TcCbqa_pickerHost",
140
+ "pickerList": "TcCbqa_pickerList",
141
+ "pickerSearch": "TcCbqa_pickerSearch",
142
+ "pickerSearchInput": "TcCbqa_pickerSearchInput",
143
+ "pickerTab": "TcCbqa_pickerTab",
144
+ "pickerTabs": "TcCbqa_pickerTabs",
145
+ "quickBadge": "TcCbqa_quickBadge",
146
+ "quickCheck": "TcCbqa_quickCheck",
147
+ "quickCopy": "TcCbqa_quickCopy",
148
+ "quickFooter": "TcCbqa_quickFooter",
149
+ "quickName": "TcCbqa_quickName",
150
+ "quickOption": "TcCbqa_quickOption",
151
+ "retry": "TcCbqa_retry",
152
+ "row": "TcCbqa_row",
153
+ "rowBadge": "TcCbqa_rowBadge",
154
+ "rowCopy": "TcCbqa_rowCopy",
155
+ "rowMeta": "TcCbqa_rowMeta",
156
+ "rowName": "TcCbqa_rowName",
157
+ "rowPick": "TcCbqa_rowPick",
158
+ "star": "TcCbqa_star",
159
+ "starButton": "TcCbqa_starButton"
160
+ };
161
+ //#endregion
392
162
  //#region src/client/QuickModels.tsx
393
163
  const QUICK_MODELS_PANE = "lynn-quick-models";
394
164
  function confirmOnTab(event) {
@@ -505,43 +275,21 @@ window.__ModuleLoader__.load({
505
275
  const cellLabel = ":scope > span[class*=\"cellLabel\"]";
506
276
  const cellValue = ":scope > span[class*=\"cellValue\"]";
507
277
  const cellChevron = ":scope > svg[class*=\"cellChevron\"]";
508
- function hostCell(surface, index) {
509
- const button = surface.querySelectorAll(":scope > button[role=\"menuitem\"]")[index];
278
+ function hostModelRow(surface) {
279
+ const button = surface.querySelector(":scope > button[role=\"menuitem\"]");
510
280
  if (!button?.querySelector(cellLabel) || !button.querySelector(cellValue) || !button.querySelector(cellChevron)) return null;
511
281
  return button;
512
282
  }
513
- function ModelMenuBridge({ sessionId, picker, locked, dismiss, openPane, reportFailure, available, directory, select, t }) {
283
+ function ModelMenuBridge({ sessionId, picker, locked, dismiss, openPane, available, directory, t }) {
514
284
  const markerRef = (0, react.useRef)(null);
515
- const sliderRef = (0, react.useRef)(null);
516
- const [surface, setSurface] = (0, react.useState)(null);
517
285
  const [modelRow, setModelRow] = (0, react.useState)(null);
518
286
  const [browseMount, setBrowseMount] = (0, react.useState)(null);
519
- const [effortRow, setEffortRow] = (0, react.useState)(null);
520
- const [rowLabel, setRowLabel] = (0, react.useState)(null);
521
287
  const state = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot());
522
- const current = state.current;
523
- const reasoning = liveReasoning(state);
524
- const levels = (0, react.useMemo)(() => effortChoices(reasoning), [reasoning]);
525
- const declared = levels.findIndex((level) => level.effort === reasoning?.defaultEffort);
526
- const chosen = current?.reasoningEffort === void 0 ? -1 : levels.findIndex((level) => level.effort === current.reasoningEffort);
527
- const defaultActive = current !== null && current.reasoningEffort === void 0;
528
- const currentIndex = chosen >= 0 ? chosen : declared >= 0 ? declared : 0;
529
- const defaultIndex = declared >= 0 ? declared : 0;
530
288
  const busy = locked || state.pending !== null;
531
- const canDefault = !busy && !defaultActive;
532
289
  const showQuickModels = available && modelRow !== null && browseMount !== null;
533
- const showSlider = available && levels.length >= 2 && effortRow !== null;
534
- (0, react.useLayoutEffect)(() => {
535
- const nextSurface = markerRef.current?.closest("[data-model-menu][role=\"menu\"]") ?? null;
536
- if (nextSurface !== surface) setSurface(nextSurface);
537
- const nextRow = nextSurface === null ? null : hostCell(nextSurface, 1);
538
- if (nextRow !== effortRow) setEffortRow(nextRow);
539
- const nextLabel = nextRow?.querySelector(cellLabel)?.textContent?.trim() ?? "";
540
- if (nextLabel !== (rowLabel ?? "")) setRowLabel(nextLabel);
541
- });
542
290
  (0, react.useLayoutEffect)(() => {
543
291
  const menu = markerRef.current?.closest("[data-model-menu][role=\"menu\"]");
544
- const row = available && menu ? hostCell(menu, 0) : null;
292
+ const row = available && menu ? hostModelRow(menu) : null;
545
293
  if (row === null) {
546
294
  setModelRow(null);
547
295
  setBrowseMount(null);
@@ -566,150 +314,49 @@ window.__ModuleLoader__.load({
566
314
  else row.setAttribute("aria-haspopup", previousPopup);
567
315
  };
568
316
  }, [available]);
569
- const submit = (selection) => {
570
- if (selection === null || busy || directory.getSnapshot().pending !== null) return;
571
- select(selection).then((result) => {
572
- if (result === void 0 || result.ok) return;
573
- reportFailure(result.error.code === "session/writer-held" ? t("error.sessionInUse") : t("error.action", { message: `${result.error.code}: ${result.error.message}` }));
574
- });
575
- };
576
- const commit = (index) => {
577
- const live = selectionOf(state);
578
- const level = levels[index];
579
- if (live === null || level === void 0) return;
580
- submit(planEffortCommit(live, level.effort));
581
- };
582
- const commitDefault = () => {
583
- const live = selectionOf(state);
584
- if (live === null) return;
585
- submit(planEffortCommit(live, void 0));
586
- };
587
- const openQuickModels = () => openPane({
588
- key: QUICK_MODELS_PANE,
589
- title: t("picker.quick")
590
- });
591
- const latest = (0, react.useRef)({
592
- modelRow,
593
- showQuickModels,
594
- openQuickModels,
595
- busy,
596
- showSlider,
597
- effortRow,
598
- canDefault,
599
- commitDefault
600
- });
601
- (0, react.useLayoutEffect)(() => {
602
- latest.current = {
603
- modelRow,
604
- showQuickModels,
605
- openQuickModels,
606
- busy,
607
- showSlider,
608
- effortRow,
609
- canDefault,
610
- commitDefault
611
- };
612
- });
613
317
  (0, react.useLayoutEffect)(() => {
614
- if (surface === null) return;
318
+ if (!showQuickModels) return;
615
319
  const redirect = (event) => {
616
- const target = event.target;
617
- const request = latest.current;
618
- if (!(target instanceof Node) || event.defaultPrevented) return;
619
- if (request.showQuickModels && request.modelRow?.contains(target)) {
620
- event.preventDefault();
621
- event.stopPropagation();
622
- if (!request.busy) request.openQuickModels();
623
- return;
624
- }
625
- const row = request.effortRow;
626
- if (row === null || !surface.contains(row) || !row.contains(target) || !request.showSlider) return;
320
+ if (event.defaultPrevented) return;
627
321
  event.preventDefault();
628
322
  event.stopPropagation();
629
- if (request.busy || sliderRef.current?.contains(target)) return;
630
- if (request.canDefault && row.querySelector(cellLabel)?.contains(target)) {
631
- request.commitDefault();
632
- return;
633
- }
634
- sliderRef.current?.querySelector("[role=\"slider\"]")?.focus();
635
- };
636
- surface.addEventListener("click", redirect, true);
637
- return () => {
638
- surface.removeEventListener("click", redirect, true);
639
- };
640
- }, [surface]);
641
- (0, react.useLayoutEffect)(() => {
642
- if (effortRow === null || !showSlider) return;
643
- const label = effortRow.querySelector(cellLabel);
644
- const value = effortRow.querySelector(cellValue);
645
- const chevron = effortRow.querySelector(cellChevron);
646
- const saved = {
647
- value: value?.style.display ?? "",
648
- chevron: chevron?.style.display ?? "",
649
- cursor: label?.style.cursor ?? "",
650
- title: label?.getAttribute("title") ?? null
651
- };
652
- if (value !== null) value.style.display = "none";
653
- if (chevron !== null) chevron.style.display = "none";
654
- if (label !== null && canDefault) {
655
- label.style.cursor = "pointer";
656
- label.title = t("effort.useDefault");
657
- }
658
- return () => {
659
- if (value !== null) value.style.display = saved.value;
660
- if (chevron !== null) chevron.style.display = saved.chevron;
661
- if (label !== null) {
662
- label.style.cursor = saved.cursor;
663
- if (saved.title === null) label.removeAttribute("title");
664
- else label.title = saved.title;
665
- }
323
+ if (!busy) openPane({
324
+ key: QUICK_MODELS_PANE,
325
+ title: t("picker.quick")
326
+ });
666
327
  };
328
+ modelRow.addEventListener("click", redirect, true);
329
+ return () => modelRow.removeEventListener("click", redirect, true);
667
330
  }, [
668
- effortRow,
669
- showSlider,
670
- canDefault,
331
+ modelRow,
332
+ showQuickModels,
333
+ busy,
334
+ openPane,
671
335
  t
672
336
  ]);
673
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
674
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
675
- ref: markerRef,
676
- hidden: true
677
- }),
678
- showQuickModels && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
679
- label: t("picker.browseAll"),
680
- delayMs: 300,
337
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
338
+ ref: markerRef,
339
+ hidden: true
340
+ }), showQuickModels && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tooltip, {
341
+ label: t("picker.browseAll"),
342
+ delayMs: 300,
343
+ disabled: busy,
344
+ portal: true,
345
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
346
+ className: ModelOptions_module_css_default.modelBrowse,
347
+ type: "button",
348
+ role: "menuitem",
349
+ "aria-haspopup": "dialog",
350
+ "aria-label": t("picker.browseAll"),
681
351
  disabled: busy,
682
- portal: true,
683
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
684
- className: ModelOptions_module_css_default.modelBrowse,
685
- type: "button",
686
- role: "menuitem",
687
- "aria-haspopup": "dialog",
688
- "aria-label": t("picker.browseAll"),
689
- disabled: busy,
690
- onClick: () => {
691
- if (directory.getSnapshot().pending !== null) return;
692
- dismiss();
693
- picker.open(sessionId);
694
- },
695
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 12 })
696
- })
697
- }), browseMount),
698
- showSlider && effortRow !== null && (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
699
- ref: sliderRef,
700
- className: ModelOptions_module_css_default.sliderCell,
701
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EffortSlider, {
702
- steps: levels,
703
- current: currentIndex,
704
- defaultActive,
705
- defaultIndex,
706
- defaultLabel: t("effort.providerDefault"),
707
- busy,
708
- label: rowLabel !== null && rowLabel !== "" ? rowLabel : t("effort.label"),
709
- onCommit: commit
710
- }, JSON.stringify([current?.provider, current?.model]))
711
- }), effortRow)
712
- ] });
352
+ onClick: () => {
353
+ if (directory.getSnapshot().pending !== null) return;
354
+ dismiss();
355
+ picker.open(sessionId);
356
+ },
357
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 12 })
358
+ })
359
+ }), browseMount)] });
713
360
  }
714
361
  //#endregion
715
362
  //#region src/client/icons.tsx
@@ -778,19 +425,12 @@ window.__ModuleLoader__.load({
778
425
  ]
779
426
  });
780
427
  }
428
+ const ACCOUNT_FACTS_PATH = "/api/dsh-model-submenu/account-model-facts";
781
429
  //#endregion
782
430
  //#region src/client/model-facts.ts
783
- const FAMILY_DEFAULTS = { "deepseek-account": [{
784
- id: "deepseek-flash",
785
- contextWindow: 1e6,
786
- images: true
787
- }, {
788
- id: "deepseek-v4-pro",
789
- contextWindow: 1e6,
790
- images: false
791
- }] };
792
- function buildModelFacts(providers, namespaces) {
431
+ function buildModelFacts(providers, namespaces, accountModels = []) {
793
432
  const byName = new Map(namespaces.map((row) => [row.ns, row.value]));
433
+ const accountById = new Map(accountModels.map((model) => [model.id, model]));
794
434
  const profiles = /* @__PURE__ */ new Map();
795
435
  for (const row of providers) {
796
436
  const profile = readPath(byName.get(row.settingsNs), row.settingsPath);
@@ -798,26 +438,25 @@ window.__ModuleLoader__.load({
798
438
  }
799
439
  return (provider, model) => {
800
440
  const profile = profiles.get(provider);
801
- const entry = profile?.models === void 0 ? void 0 : profile.models.find((candidate) => candidate.id === model);
802
- if (profile !== void 0 && entry !== void 0) return {
803
- contextWindow: typeof entry.contextWindow === "number" && entry.contextWindow > 0 ? entry.contextWindow : void 0,
804
- images: imageAnswer(entry, profile)
805
- };
441
+ if (profile !== void 0 && Array.isArray(profile.models)) {
442
+ const entry = profile.models.find((candidate) => isRecord(candidate) && candidate.id === model);
443
+ if (entry !== void 0) return {
444
+ contextWindow: contextWindow(entry.contextWindow),
445
+ images: imageAnswer(entry, profile)
446
+ };
447
+ }
806
448
  const override = readOverride(profile, model);
807
- if (override !== void 0) return {
808
- contextWindow: typeof override.contextWindow === "number" && override.contextWindow > 0 ? override.contextWindow : void 0,
809
- images: Array.isArray(override.inputModalities) ? containsImage(override.inputModalities) : "unknown"
810
- };
811
- const family = FAMILY_DEFAULTS[provider]?.find((candidate) => candidate.id === model);
812
- return family === void 0 ? {
813
- contextWindow: void 0,
814
- images: "unknown"
815
- } : {
816
- contextWindow: family.contextWindow,
817
- images: family.images ? "yes" : "no"
449
+ const account = provider === "deepseek-account" ? accountById.get(model) : void 0;
450
+ const modalities = Array.isArray(override?.inputModalities) ? override.inputModalities : account?.inputModalities;
451
+ return {
452
+ contextWindow: contextWindow(override?.contextWindow) ?? contextWindow(account?.contextWindow),
453
+ images: modalities === void 0 ? "unknown" : containsImage(modalities)
818
454
  };
819
455
  };
820
456
  }
457
+ function contextWindow(value) {
458
+ return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
459
+ }
821
460
  function imageAnswer(entry, profile) {
822
461
  if (Array.isArray(entry.inputModalities)) return containsImage(entry.inputModalities);
823
462
  const defaultInput = Array.isArray(profile.defaultInput) ? profile.defaultInput : void 0;
@@ -2212,7 +1851,7 @@ window.__ModuleLoader__.load({
2212
1851
  cleanup
2213
1852
  };
2214
1853
  //#endregion
2215
- //#region node_modules/.pnpm/@deepseek-ai+dsh-util-text-search@0.2.3-alpha.3_@deepseek-ai+cordis@4.2.0-alpha.2/node_modules/@deepseek-ai/dsh-util-text-search/lib/index.js
1854
+ //#region node_modules/.pnpm/@deepseek-ai+dsh-util-text-search@0.2.3-alpha.4_@deepseek-ai+cordis@4.2.0-alpha.3/node_modules/@deepseek-ai/dsh-util-text-search/lib/index.js
2216
1855
  /**
2217
1856
  * Multilingual fuzzy search over an in-memory list.
2218
1857
  *
@@ -2527,123 +2166,126 @@ window.__ModuleLoader__.load({
2527
2166
  const failures = state.failures.filter((failure) => tab === "*" || failure.id === tab);
2528
2167
  const failed = state.error !== null && state.status === "error";
2529
2168
  const loading = state.status === "loading";
2530
- return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
2169
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Modal, {
2531
2170
  open,
2532
2171
  onClose,
2533
2172
  title: t("picker.title"),
2534
2173
  closeLabel: t("picker.close"),
2535
2174
  className: ModelOptions_module_css_default.pickerDialog ?? "",
2536
2175
  contentClassName: ModelOptions_module_css_default.pickerContent ?? "",
2537
- children: [
2538
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2539
- className: ModelOptions_module_css_default.pickerSearch,
2540
- children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
2541
- className: ModelOptions_module_css_default.pickerSearchInput ?? "",
2542
- type: "text",
2543
- role: "searchbox",
2544
- "aria-label": t("picker.search"),
2545
- "aria-controls": `${id}-list`,
2546
- placeholder: t("picker.search"),
2547
- icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSearchOutlineRegular, { size: 14 }),
2548
- value: query,
2549
- readOnly: busy,
2550
- onChange: (event) => {
2551
- setQuery(event.target.value);
2552
- },
2553
- "data-modal-autofocus": (0, _deepseek_ai_dsh_client_ui_primitives.isMobileDevice)() ? void 0 : ""
2554
- })
2555
- }),
2556
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2557
- className: ModelOptions_module_css_default.pickerTabs,
2558
- role: "tablist",
2559
- "aria-label": t("picker.title"),
2560
- children: tabs.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2561
- type: "button",
2562
- role: "tab",
2563
- id: `${id}-tab-${entry.id}`,
2564
- "aria-selected": entry.id === tab,
2565
- "aria-controls": `${id}-list`,
2566
- tabIndex: 0,
2567
- className: ModelOptions_module_css_default.pickerTab,
2568
- onClick: () => {
2569
- setTab(entry.id);
2570
- },
2571
- children: entry.label
2572
- }, entry.id))
2573
- }),
2574
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2575
- ref: listRef,
2576
- id: `${id}-list`,
2577
- className: ModelOptions_module_css_default.pickerList,
2578
- children: [
2579
- loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2580
- className: ModelOptions_module_css_default.notice,
2581
- children: t("status.loading")
2582
- }),
2583
- failed && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2584
- className: ModelOptions_module_css_default.notice,
2585
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("status.failed", { message: state.error ?? "" }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2586
- type: "button",
2587
- className: ModelOptions_module_css_default.retry,
2588
- onClick: onReload,
2589
- children: t("action.reload")
2590
- })]
2591
- }),
2592
- failures.map((failure) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2593
- className: ModelOptions_module_css_default.notice,
2594
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("status.providerFailed", {
2595
- name: failure.name,
2596
- message: failure.message
2597
- }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2598
- type: "button",
2599
- className: ModelOptions_module_css_default.retry,
2600
- onClick: onReload,
2601
- children: t("action.reload")
2602
- })]
2603
- }, failure.id)),
2604
- visible.length === 0 && !loading && !failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2605
- className: ModelOptions_module_css_default.notice,
2606
- children: state.groups.length === 0 ? t("status.empty") : t("picker.searchEmpty")
2607
- }),
2608
- visible.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelRow, {
2609
- name: row.entry.name,
2610
- badge: row.entry.badge === void 0 ? void 0 : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
2611
- tone: row.entry.badge.tone,
2612
- className: ModelOptions_module_css_default.rowBadge,
2613
- children: resolveText(row.entry.badge.text)
2176
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2177
+ className: ModelOptions_module_css_default.pickerBody,
2178
+ children: [
2179
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2180
+ className: ModelOptions_module_css_default.pickerSearch,
2181
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Input, {
2182
+ className: ModelOptions_module_css_default.pickerSearchInput ?? "",
2183
+ type: "text",
2184
+ role: "searchbox",
2185
+ "aria-label": t("picker.search"),
2186
+ "aria-controls": `${id}-list`,
2187
+ placeholder: t("picker.search"),
2188
+ icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconSearchOutlineRegular, { size: 14 }),
2189
+ value: query,
2190
+ readOnly: busy,
2191
+ onChange: (event) => {
2192
+ setQuery(event.target.value);
2193
+ },
2194
+ "data-modal-autofocus": (0, _deepseek_ai_dsh_client_ui_primitives.isMobileDevice)() ? void 0 : ""
2195
+ })
2196
+ }),
2197
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2198
+ className: ModelOptions_module_css_default.pickerTabs,
2199
+ role: "tablist",
2200
+ "aria-label": t("picker.title"),
2201
+ children: tabs.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2202
+ type: "button",
2203
+ role: "tab",
2204
+ id: `${id}-tab-${entry.id}`,
2205
+ "aria-selected": entry.id === tab,
2206
+ "aria-controls": `${id}-list`,
2207
+ tabIndex: 0,
2208
+ className: ModelOptions_module_css_default.pickerTab,
2209
+ onClick: () => {
2210
+ setTab(entry.id);
2211
+ },
2212
+ children: entry.label
2213
+ }, entry.id))
2214
+ }),
2215
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2216
+ ref: listRef,
2217
+ id: `${id}-list`,
2218
+ className: ModelOptions_module_css_default.pickerList,
2219
+ children: [
2220
+ loading && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2221
+ className: ModelOptions_module_css_default.notice,
2222
+ children: t("status.loading")
2614
2223
  }),
2615
- selected: live?.provider === row.provider && live.model === row.model,
2616
- busy,
2617
- favorited: isFavorite(favorites, row.provider, row.model),
2618
- meta: metaLine({
2619
- row,
2620
- facts: facts(row.provider, row.model),
2621
- providerName: tab === "*" ? row.providerName : void 0,
2622
- thinks: row.entry.reasoning !== void 0,
2623
- effortLabel: t("meta.effort"),
2624
- imageLabel: t("meta.images")
2224
+ failed && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2225
+ className: ModelOptions_module_css_default.notice,
2226
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("status.failed", { message: state.error ?? "" }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2227
+ type: "button",
2228
+ className: ModelOptions_module_css_default.retry,
2229
+ onClick: onReload,
2230
+ children: t("action.reload")
2231
+ })]
2625
2232
  }),
2626
- starLabel: isFavorite(favorites, row.provider, row.model) ? t("picker.unfavorite", { model: row.entry.name }) : t("picker.favorite", { model: row.entry.name }),
2627
- onPick: () => {
2628
- pick(row);
2629
- },
2630
- onToggleFavorite: () => {
2631
- onToggleFavorite(row.provider, row.model);
2632
- }
2633
- }) }, `${row.provider}/${row.model}`))
2634
- ]
2635
- }),
2636
- /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2637
- className: ModelOptions_module_css_default.pickerFooter,
2638
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2639
- className: ModelOptions_module_css_default.footerHint,
2640
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.ShortcutKeys, { keys: ["Esc"] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("picker.hintClose") })]
2641
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2642
- className: ModelOptions_module_css_default.footerFavorites,
2643
- children: t("picker.hintFavorites")
2644
- })]
2645
- })
2646
- ]
2233
+ failures.map((failure) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2234
+ className: ModelOptions_module_css_default.notice,
2235
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("status.providerFailed", {
2236
+ name: failure.name,
2237
+ message: failure.message
2238
+ }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
2239
+ type: "button",
2240
+ className: ModelOptions_module_css_default.retry,
2241
+ onClick: onReload,
2242
+ children: t("action.reload")
2243
+ })]
2244
+ }, failure.id)),
2245
+ visible.length === 0 && !loading && !failed && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
2246
+ className: ModelOptions_module_css_default.notice,
2247
+ children: state.groups.length === 0 ? t("status.empty") : t("picker.searchEmpty")
2248
+ }),
2249
+ visible.map((row) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelRow, {
2250
+ name: row.entry.name,
2251
+ badge: row.entry.badge === void 0 ? void 0 : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
2252
+ tone: row.entry.badge.tone,
2253
+ className: ModelOptions_module_css_default.rowBadge,
2254
+ children: resolveText(row.entry.badge.text)
2255
+ }),
2256
+ selected: live?.provider === row.provider && live.model === row.model,
2257
+ busy,
2258
+ favorited: isFavorite(favorites, row.provider, row.model),
2259
+ meta: metaLine({
2260
+ row,
2261
+ facts: facts(row.provider, row.model),
2262
+ providerName: tab === "*" ? row.providerName : void 0,
2263
+ thinks: row.entry.reasoning !== void 0,
2264
+ effortLabel: t("meta.effort"),
2265
+ imageLabel: t("meta.images")
2266
+ }),
2267
+ starLabel: isFavorite(favorites, row.provider, row.model) ? t("picker.unfavorite", { model: row.entry.name }) : t("picker.favorite", { model: row.entry.name }),
2268
+ onPick: () => {
2269
+ pick(row);
2270
+ },
2271
+ onToggleFavorite: () => {
2272
+ onToggleFavorite(row.provider, row.model);
2273
+ }
2274
+ }) }, `${row.provider}/${row.model}`))
2275
+ ]
2276
+ }),
2277
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2278
+ className: ModelOptions_module_css_default.pickerFooter,
2279
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
2280
+ className: ModelOptions_module_css_default.footerHint,
2281
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.ShortcutKeys, { keys: ["Esc"] }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("picker.hintClose") })]
2282
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
2283
+ className: ModelOptions_module_css_default.footerFavorites,
2284
+ children: t("picker.hintFavorites")
2285
+ })]
2286
+ })
2287
+ ]
2288
+ })
2647
2289
  });
2648
2290
  }
2649
2291
  function metaLine(input) {
@@ -2796,13 +2438,9 @@ window.__ModuleLoader__.load({
2796
2438
  });
2797
2439
  function createFactsSource(deps) {
2798
2440
  const listeners = /* @__PURE__ */ new Set();
2799
- let providers = [];
2800
2441
  let lookup = EMPTY;
2801
- const rebuild = () => {
2802
- const namespaces = deps.describe.getSnapshot().view?.namespaces ?? [];
2803
- lookup = providers.length === 0 || namespaces.length === 0 ? EMPTY : buildModelFacts(providers, namespaces);
2804
- for (const listener of [...listeners]) listener();
2805
- };
2442
+ let stop;
2443
+ let readOnDemand;
2806
2444
  return {
2807
2445
  source: {
2808
2446
  getSnapshot: () => lookup,
@@ -2813,21 +2451,91 @@ window.__ModuleLoader__.load({
2813
2451
  };
2814
2452
  }
2815
2453
  },
2454
+ refresh: () => readOnDemand?.(),
2816
2455
  start: () => {
2817
- const off = deps.describe.subscribe(rebuild);
2818
- deps.describe.ensure().catch(() => {});
2819
- deps.listProviders().then((answer) => {
2820
- providers = answer.ok && answer.value !== void 0 ? answer.value : [];
2456
+ stop?.();
2457
+ const lifetime = new AbortController();
2458
+ let providers = [];
2459
+ let accountModels = [];
2460
+ let view = deps.describe.getSnapshot().view;
2461
+ let accountRequested = false;
2462
+ const rebuild = () => {
2463
+ lookup = buildModelFacts(providers, view?.namespaces ?? [], accountModels);
2464
+ for (const listener of [...listeners]) listener();
2465
+ };
2466
+ const readDirectory = refreshReader(lifetime.signal, async () => {
2467
+ const answer = await deps.listProviders();
2468
+ return answer.ok ? answer.value : void 0;
2469
+ }, (rows) => {
2470
+ providers = rows;
2821
2471
  rebuild();
2822
- }, () => {});
2823
- rebuild();
2824
- return () => {
2825
- off();
2472
+ });
2473
+ const readAccount = refreshReader(lifetime.signal, async () => deps.loadAccountModels?.(lifetime.signal), (rows) => {
2474
+ accountModels = rows;
2475
+ rebuild();
2476
+ });
2477
+ const refresh = (invalidate) => {
2478
+ readDirectory(invalidate);
2479
+ if (accountRequested) readAccount(invalidate);
2480
+ };
2481
+ const offDescribe = deps.describe.subscribe(() => {
2482
+ const next = deps.describe.getSnapshot().view;
2483
+ if (next === view) return;
2484
+ view = next;
2485
+ rebuild();
2486
+ refresh(true);
2487
+ });
2488
+ const offInvalidation = deps.subscribeInvalidation?.(() => refresh(true));
2489
+ readOnDemand = () => {
2490
+ accountRequested = true;
2491
+ refresh(false);
2492
+ };
2493
+ stop = () => {
2494
+ if (lifetime.signal.aborted) return;
2495
+ lifetime.abort();
2496
+ offDescribe();
2497
+ offInvalidation?.();
2826
2498
  listeners.clear();
2499
+ readOnDemand = void 0;
2500
+ stop = void 0;
2827
2501
  };
2502
+ rebuild();
2503
+ refresh(false);
2504
+ deps.describe.ensure().catch(() => {});
2505
+ return stop;
2506
+ }
2507
+ };
2508
+ }
2509
+ function refreshReader(signal, read, publish) {
2510
+ let reading = false;
2511
+ let queued = false;
2512
+ return (invalidate) => {
2513
+ if (signal.aborted) return;
2514
+ if (reading) {
2515
+ queued ||= invalidate;
2516
+ return;
2828
2517
  }
2518
+ reading = true;
2519
+ (async () => {
2520
+ try {
2521
+ do {
2522
+ queued = false;
2523
+ const value = await read().catch(() => void 0);
2524
+ if (!signal.aborted && !queued && value !== void 0) publish(value);
2525
+ } while (!signal.aborted && queued);
2526
+ } finally {
2527
+ reading = false;
2528
+ }
2529
+ })();
2829
2530
  };
2830
2531
  }
2532
+ async function readAccountModels(signal) {
2533
+ const response = await fetch(ACCOUNT_FACTS_PATH, { signal });
2534
+ if (!response.ok) throw new Error(`Account model metadata unavailable (${response.status})`);
2535
+ const rows = await response.json();
2536
+ if (!Array.isArray(rows)) throw new Error("Invalid account model metadata");
2537
+ return rows;
2538
+ }
2831
2539
  //#endregion
2832
2540
  //#region src/client/locales.ts
2833
2541
  const NS = "modelSubmenu";
@@ -2852,10 +2560,7 @@ window.__ModuleLoader__.load({
2852
2560
  "picker.hintClose": "关闭",
2853
2561
  "picker.hintFavorites": "收藏的模型置顶,并加入快捷菜单",
2854
2562
  "meta.effort": "思考",
2855
- "meta.images": "图片输入",
2856
- "effort.label": "推理等级",
2857
- "effort.providerDefault": "Default",
2858
- "effort.useDefault": "切换为默认档位"
2563
+ "meta.images": "图片输入"
2859
2564
  };
2860
2565
  const en = {
2861
2566
  "status.loading": "Loading models…",
@@ -2878,10 +2583,7 @@ window.__ModuleLoader__.load({
2878
2583
  "picker.hintClose": "close",
2879
2584
  "picker.hintFavorites": "Favorites first, also in the quick menu",
2880
2585
  "meta.effort": "Effort",
2881
- "meta.images": "Images",
2882
- "effort.label": "Reasoning effort",
2883
- "effort.providerDefault": "Default",
2884
- "effort.useDefault": "Switch to the provider default"
2586
+ "meta.images": "Images"
2885
2587
  };
2886
2588
  //#endregion
2887
2589
  //#region src/client/index.ts
@@ -2919,7 +2621,18 @@ window.__ModuleLoader__.load({
2919
2621
  const picker = createPickerStore();
2920
2622
  const facts = createFactsSource({
2921
2623
  describe: scope.configForms.describe(),
2922
- listProviders: () => scope.remote.llm.listConfigurableProviders()
2624
+ listProviders: () => scope.remote.llm.listConfigurableProviders(),
2625
+ loadAccountModels: readAccountModels,
2626
+ subscribeInvalidation: (listener) => {
2627
+ const off = [
2628
+ scope.on("connection/reset", listener),
2629
+ scope.remote.$on("llm/adapters-updated", listener),
2630
+ scope.remote.$on("llm/models-updated", listener)
2631
+ ];
2632
+ return () => {
2633
+ for (const dispose of off) dispose();
2634
+ };
2635
+ }
2923
2636
  });
2924
2637
  scope.effect(() => facts.start(), "dsh-model-submenu: model metadata");
2925
2638
  const faceOf = (sessionId) => {
@@ -2933,7 +2646,9 @@ window.__ModuleLoader__.load({
2933
2646
  directory: directory.store,
2934
2647
  factsSource: facts.source,
2935
2648
  load: () => {
2936
- if (available) directory.load().catch(() => {});
2649
+ if (!available) return;
2650
+ facts.refresh();
2651
+ directory.load().catch(() => {});
2937
2652
  },
2938
2653
  resolveText: (text) => ctx.locale.resolveText(text),
2939
2654
  select: (selection) => available ? directory.select(selection) : Promise.resolve(void 0)
@@ -2967,16 +2682,9 @@ window.__ModuleLoader__.load({
2967
2682
  locale: NS,
2968
2683
  inject: faceOf
2969
2684
  }, ModelPickerFallback));
2970
- scope.slots.inject("conversation.input.overlay", () => scope.slots.register({
2971
- name: "conversation.input.overlay",
2972
- id: "model-effort-tint",
2973
- registrant: "@lynn123411/dsh-model-submenu",
2974
- inject: faceOf
2975
- }, EffortTint));
2976
2685
  });
2977
2686
  }
2978
2687
  //#endregion
2979
- exports.EffortTint = EffortTint;
2980
2688
  exports.ModelMenuBridge = ModelMenuBridge;
2981
2689
  exports.ModelPickerHost = ModelPickerHost;
2982
2690
  exports.apply = apply;