dsh-edge 0.18.0 → 0.19.0-alpha.2

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 (118) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +8 -8
  3. package/README.zh.md +8 -8
  4. package/THIRD_PARTY_NOTICES.md +2011 -449
  5. package/dist/assets/fonts/Montserrat-OFL.txt +93 -0
  6. package/dist/assets/fonts/montserrat-light-Cvd2VjE_.woff2 +0 -0
  7. package/dist/assets/fonts/montserrat-medium-B4OyO9CN.woff2 +0 -0
  8. package/dist/assets/fonts/montserrat-regular-DYep38cA.woff2 +0 -0
  9. package/dist/assets/index-Cq6ljTv2.css +1 -0
  10. package/dist/assets/index-Dy0OhsZ5.js +127 -0
  11. package/dist/assets/langs/asciidoc-Ve4PFQV2.js +2 -0
  12. package/dist/assets/langs/bat-BkioyH1T.js +2 -0
  13. package/dist/assets/langs/bibtex-CHM0blh-.js +2 -0
  14. package/dist/assets/langs/clojure-P80f7IUj.js +2 -0
  15. package/dist/assets/langs/cmake-D1j8_8rp.js +2 -0
  16. package/dist/assets/langs/csv-fuZLfV_i.js +2 -0
  17. package/dist/assets/langs/dart-bE4Kk8sk.js +2 -0
  18. package/dist/assets/langs/diff-D97Zzqfu.js +2 -0
  19. package/dist/assets/langs/dotenv-Da5cRb03.js +2 -0
  20. package/dist/assets/langs/elixir-CvYZzuDY.js +2 -0
  21. package/dist/assets/langs/erlang-DsQrWhSR.js +2 -0
  22. package/dist/assets/langs/fish-BvzEVeQv.js +2 -0
  23. package/dist/assets/langs/fsharp-CXgrBDvD.js +2 -0
  24. package/dist/assets/langs/graphql-DujV8YkJ.js +2 -0
  25. package/dist/assets/langs/groovy-gcz8RCvz.js +2 -0
  26. package/dist/assets/langs/haskell-Df6bDoY_.js +2 -0
  27. package/dist/assets/langs/hcl-BWvSN4gD.js +2 -0
  28. package/dist/assets/langs/html-derivative-DOyKdj44.js +2 -0
  29. package/dist/assets/langs/html-fwsONPVS.js +2 -0
  30. package/dist/assets/langs/http-DcV90OkR.js +2 -0
  31. package/dist/assets/langs/javascript-DI5JR1nB.js +2 -0
  32. package/dist/assets/langs/julia-BpJ6DjL_.js +2 -0
  33. package/dist/assets/langs/latex-B4C7GdlO.js +2 -0
  34. package/dist/assets/langs/log-2UxHyX5q.js +2 -0
  35. package/dist/assets/langs/make-CHLpvVh8.js +2 -0
  36. package/dist/assets/langs/nix-CwoSXNpI.js +2 -0
  37. package/dist/assets/langs/perl-DsWkoyyU.js +2 -0
  38. package/dist/assets/langs/php-LEPfNACG.js +2 -0
  39. package/dist/assets/langs/powershell-Dpen1YoG.js +2 -0
  40. package/dist/assets/langs/proto-C7zT0LnQ.js +2 -0
  41. package/dist/assets/langs/r-Dspwwk_N.js +2 -0
  42. package/dist/assets/langs/rst-BbocfKWr.js +2 -0
  43. package/dist/assets/langs/ruby-R292Iif0.js +2 -0
  44. package/dist/assets/langs/scala-C151Ov-r.js +2 -0
  45. package/dist/assets/langs/svelte-DNMY6jOf.js +2 -0
  46. package/dist/assets/langs/system-verilog-CnnmHF94.js +2 -0
  47. package/dist/assets/langs/vb-D17OF-Vu.js +2 -0
  48. package/dist/assets/langs/verilog-BQ8w6xss.js +2 -0
  49. package/dist/assets/langs/vue-Dq2x6432.js +2 -0
  50. package/dist/favicon-dark.svg +3 -0
  51. package/dist/favicon.svg +0 -5
  52. package/dist/index.html +5 -4
  53. package/dist/manifest.webmanifest +3 -4
  54. package/dist/plugins/@deepseek-ai/dsh-api-gateway/client.js +353 -101
  55. package/dist/plugins/@deepseek-ai/dsh-api-job-controller/client.js +367 -0
  56. package/dist/plugins/@deepseek-ai/dsh-api-remotes/client.js +7223 -3584
  57. package/dist/plugins/@deepseek-ai/dsh-api-session-controller/client.js +1107 -991
  58. package/dist/plugins/@deepseek-ai/dsh-api-workspace-controller/client.js +119 -6
  59. package/dist/plugins/@deepseek-ai/dsh-api-workspace-files/client.js +41 -35
  60. package/dist/plugins/@deepseek-ai/dsh-client-connection/client.js +354 -5279
  61. package/dist/plugins/@deepseek-ai/dsh-client-file-upload/client.js +10 -23
  62. package/dist/plugins/@deepseek-ai/dsh-client-locale/client.js +234 -80
  63. package/dist/plugins/@deepseek-ai/dsh-client-modules/client.js +554 -46
  64. package/dist/plugins/@deepseek-ai/dsh-client-shortcuts/client.js +2006 -0
  65. package/dist/plugins/@deepseek-ai/dsh-client-ui-agent-preset/client.js +1090 -914
  66. package/dist/plugins/@deepseek-ai/dsh-client-ui-approval/client.js +79 -6
  67. package/dist/plugins/@deepseek-ai/dsh-client-ui-attachment/client.js +126 -155
  68. package/dist/plugins/@deepseek-ai/dsh-client-ui-chat/client.js +5776 -1593
  69. package/dist/plugins/@deepseek-ai/dsh-client-ui-commands/client.js +375 -121
  70. package/dist/plugins/@deepseek-ai/dsh-client-ui-conversation/client.js +3524 -1923
  71. package/dist/plugins/@deepseek-ai/dsh-client-ui-deliverables/client.js +1615 -258
  72. package/dist/plugins/@deepseek-ai/dsh-client-ui-directory-picker-browse/client.js +9 -9
  73. package/dist/plugins/@deepseek-ai/dsh-client-ui-goal/client.js +25 -10
  74. package/dist/plugins/@deepseek-ai/dsh-client-ui-input-trigger/client.js +169 -24
  75. package/dist/plugins/@deepseek-ai/dsh-client-ui-jobs/client.js +413 -63
  76. package/dist/plugins/@deepseek-ai/dsh-client-ui-layout/client.js +131 -14
  77. package/dist/plugins/@deepseek-ai/dsh-client-ui-message-feedback/client.js +24 -22
  78. package/dist/plugins/@deepseek-ai/dsh-client-ui-model-selection/client.js +281 -128
  79. package/dist/plugins/@deepseek-ai/dsh-client-ui-open-in-app/client.js +674 -223
  80. package/dist/plugins/@deepseek-ai/dsh-client-ui-plan/client.js +596 -18
  81. package/dist/plugins/@deepseek-ai/dsh-client-ui-reference/client.js +92 -9
  82. package/dist/plugins/@deepseek-ai/dsh-client-ui-renderer/client.js +467 -59
  83. package/dist/plugins/@deepseek-ai/dsh-client-ui-session/client.js +231 -72
  84. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings/client.js +281 -117
  85. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-general/client.js +642 -122
  86. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-models/client.js +1565 -438
  87. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/client.js +201 -75
  88. package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugins/client.js +30 -1628
  89. package/dist/plugins/@deepseek-ai/dsh-client-ui-shortcuts/client.js +1163 -0
  90. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar/client.js +165 -39
  91. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-browser/client.js +1648 -0
  92. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client.js +5515 -25622
  93. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-files/client.js +419 -118
  94. package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-right/client.js +5692 -260
  95. package/dist/plugins/@deepseek-ai/dsh-client-ui-skill/client.js +156 -41
  96. package/dist/plugins/@deepseek-ai/dsh-client-ui-subagent/client.js +386 -263
  97. package/dist/plugins/@deepseek-ai/dsh-client-ui-theme/client.js +183 -73
  98. package/dist/plugins/@deepseek-ai/dsh-client-ui-tool/client.js +2367 -429
  99. package/dist/plugins/@deepseek-ai/dsh-client-ui-trajectory/client.js +788 -270
  100. package/dist/plugins/@deepseek-ai/dsh-client-ui-user-questions/client.js +87 -79
  101. package/dist/plugins/@deepseek-ai/dsh-client-ui-workflow-run/client.js +28 -14
  102. package/dist/plugins/@deepseek-ai/dsh-client-ui-workspace/client.js +2647 -1044
  103. package/dist/plugins/@deepseek-ai/dsh-typert-registry/client.js +22 -7
  104. package/dist/plugins/dsh-edge-client-ui/client.js +1 -10
  105. package/package.json +96 -86
  106. package/scripts/cli.mjs +16 -4
  107. package/scripts/install.d.mts +12 -2
  108. package/scripts/install.mjs +36 -9
  109. package/scripts/legal-files.mjs +15 -0
  110. package/worker/direct/index.js +2564 -1822
  111. package/worker/isolated/index.js +2144 -1402
  112. package/dist/assets/index-BKQ_L1z6.js +0 -117
  113. package/dist/assets/index-DPX2bQLO.css +0 -1
  114. package/dist/assets/langs/html-CfGypltT.js +0 -2
  115. package/dist/assets/langs/php-DJl5gRdb.js +0 -2
  116. package/dist/assets/langs/ruby-5eNB0pDK.js +0 -2
  117. package/dist/plugins/@deepseek-ai/dsh-client-ui-permission-presets/client.js +0 -505
  118. package/dist/plugins/@deepseek-ai/dsh-client-ui-schedule/client.js +0 -307
@@ -4,12 +4,75 @@ window.__ModuleLoader__.load({
4
4
  var module = { exports: {} };
5
5
  var exports = module.exports;
6
6
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
7
8
  let _deepseek_ai_cordis = require("@deepseek-ai/cordis");
8
9
  let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
9
10
  let react_jsx_runtime = require("react/jsx-runtime");
10
11
  let react = require("react");
11
12
  let react_dom = require("react-dom");
12
- let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
13
+ //#region ../../util/values/src/index.ts
14
+ /**
15
+ * Weak-key lookup with a strongly retained iterable set of associated values.
16
+ *
17
+ * Each value must belong to only one key. The container performs no automatic
18
+ * cleanup; owners delete associations or clear the container at lifecycle end.
19
+ */
20
+ var WeakMapWithValues = class {
21
+ keys = /* @__PURE__ */ new WeakMap();
22
+ valueSet = /* @__PURE__ */ new Set();
23
+ /** Live strongly retained values in insertion order. */
24
+ values = this.valueSet;
25
+ /**
26
+ * Read the value associated with a key.
27
+ * @param key - weakly held lookup key.
28
+ * @returns the associated value, or absence.
29
+ */
30
+ get(key) {
31
+ return this.keys.get(key);
32
+ }
33
+ /**
34
+ * Test whether a key has an association.
35
+ * @param key - weakly held lookup key.
36
+ * @returns whether the key is present.
37
+ */
38
+ has(key) {
39
+ return this.keys.has(key);
40
+ }
41
+ /**
42
+ * Associate one key with one caller-unique value.
43
+ * @param key - weakly held lookup key.
44
+ * @param value - strongly retained value that belongs to no other key.
45
+ * @returns this container.
46
+ */
47
+ set(key, value) {
48
+ if (this.keys.has(key)) {
49
+ const previous = this.keys.get(key);
50
+ if (previous === value) return this;
51
+ this.valueSet.delete(previous);
52
+ }
53
+ this.keys.set(key, value);
54
+ this.valueSet.add(value);
55
+ return this;
56
+ }
57
+ /**
58
+ * Remove one association and its strongly retained value.
59
+ * @param key - weakly held lookup key.
60
+ * @returns whether an association was removed.
61
+ */
62
+ delete(key) {
63
+ if (!this.keys.has(key)) return false;
64
+ const value = this.keys.get(key);
65
+ const deleted = this.keys.delete(key);
66
+ this.valueSet.delete(value);
67
+ return deleted;
68
+ }
69
+ /** Remove every association and strongly retained value. */
70
+ clear() {
71
+ this.keys = /* @__PURE__ */ new WeakMap();
72
+ this.valueSet.clear();
73
+ }
74
+ };
75
+ //#endregion
13
76
  //#region lib/types/client/catalog.js
14
77
  /** One Host-generation model catalog shared by every Session selector. */
15
78
  /** Loads at most one model catalog for the current Host generation. */
@@ -21,6 +84,15 @@ window.__ModuleLoader__.load({
21
84
  status: "idle",
22
85
  error: null
23
86
  });
87
+ reasoning = /* @__PURE__ */ new Map();
88
+ /**
89
+ * Read the last advertised reasoning metadata, including unavailable models.
90
+ * @param selection - provider and model whose effort is displayed.
91
+ * @returns reasoning metadata observed during this Host generation.
92
+ */
93
+ reasoningFor(selection) {
94
+ return this.reasoning.get(JSON.stringify([selection.provider, selection.model]));
95
+ }
24
96
  generation = 0;
25
97
  inflight;
26
98
  /**
@@ -45,11 +117,14 @@ window.__ModuleLoader__.load({
45
117
  });
46
118
  const operation = this.ctx.remote.session.modelCatalog().then((response) => {
47
119
  if (!response.ok) throw new Error(`${response.error.code}: ${response.error.message}`);
48
- if (generation === this.generation) this.store.set({
49
- value: response.value,
50
- status: "ready",
51
- error: null
52
- });
120
+ if (generation === this.generation) {
121
+ for (const group of response.value.groups) for (const model of group.models) this.reasoning.set(JSON.stringify([group.id, model.id]), model.reasoning);
122
+ this.store.set({
123
+ value: response.value,
124
+ status: "ready",
125
+ error: null
126
+ });
127
+ }
53
128
  return response.value;
54
129
  }).catch((error) => {
55
130
  if (generation === this.generation) this.store.update((draft) => {
@@ -84,6 +159,7 @@ window.__ModuleLoader__.load({
84
159
  }
85
160
  /** Clear Host-specific values and load the replacement Host generation. */
86
161
  resetGeneration() {
162
+ this.reasoning.clear();
87
163
  this.invalidate(true);
88
164
  this.load().catch(() => {});
89
165
  }
@@ -97,6 +173,8 @@ window.__ModuleLoader__.load({
97
173
  available;
98
174
  catalog;
99
175
  projected;
176
+ isBlank;
177
+ track;
100
178
  /** The shared snapshot both entries render from (uSES-safe store). */
101
179
  store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
102
180
  current: null,
@@ -104,12 +182,12 @@ window.__ModuleLoader__.load({
104
182
  groups: [],
105
183
  failures: [],
106
184
  status: "idle",
185
+ pending: null,
107
186
  error: null
108
187
  });
109
188
  /** Latest selection operation wins; an older response never overwrites a newer one. */
110
189
  generation = 0;
111
190
  disposed = false;
112
- resolved = false;
113
191
  unsubscribeCatalog;
114
192
  unsubscribeSelection;
115
193
  /**
@@ -118,13 +196,17 @@ window.__ModuleLoader__.load({
118
196
  * @param available - whether this session may use Agent-bound model RPCs.
119
197
  * @param catalog - Host-generation catalog shared by every Session.
120
198
  * @param projected - durable model selection projected from Session history.
199
+ * @param isBlank - whether this Session has no first message yet.
200
+ * @param track - desktop-only callback after a successful user selection.
121
201
  */
122
- constructor(sessions, sessionId, available, catalog, projected) {
202
+ constructor(sessions, sessionId, available, catalog, projected, isBlank, track) {
123
203
  this.sessions = sessions;
124
204
  this.sessionId = sessionId;
125
205
  this.available = available;
126
206
  this.catalog = catalog;
127
207
  this.projected = projected;
208
+ this.isBlank = isBlank;
209
+ this.track = track;
128
210
  this.unsubscribeCatalog = catalog.store.subscribe(() => {
129
211
  this.syncInputs();
130
212
  });
@@ -134,7 +216,7 @@ window.__ModuleLoader__.load({
134
216
  this.syncInputs();
135
217
  }
136
218
  /**
137
- * Ensure the Host generation's shared advisory catalog is loaded.
219
+ * Ensure the Host generation's shared available catalog is loaded.
138
220
  * @returns the fresh directory value.
139
221
  */
140
222
  async load() {
@@ -146,14 +228,19 @@ window.__ModuleLoader__.load({
146
228
  /**
147
229
  * Select the complete provider/model/reasoning selection. The durable
148
230
  * projection frame updates the shared current; failures surface on the store
149
- * and throw so each entry's own retry surface engages.
231
+ * and return with the operation so each entry can present its own failure.
150
232
  * @param selection - provider, provider-owned model id, and optional adapter-owned effort.
233
+ * @returns the selection outcome, including the original Remote failure.
151
234
  */
152
235
  async select(selection) {
153
236
  this.assertAvailable();
237
+ const previous = this.store.getSnapshot().current;
238
+ const previousEffort = previous?.reasoningEffort ?? (previous === null ? void 0 : this.catalog.reasoningFor(previous)?.defaultEffort);
239
+ const nextEffort = selection.reasoningEffort ?? this.catalog.reasoningFor(selection)?.defaultEffort;
154
240
  const generation = ++this.generation;
155
241
  this.store.update((s) => {
156
242
  s.status = "selecting";
243
+ s.pending = selection;
157
244
  s.error = null;
158
245
  });
159
246
  const result = await this.sessions.selectModel({
@@ -162,22 +249,43 @@ window.__ModuleLoader__.load({
162
249
  model: selection.model,
163
250
  ...selection.reasoningEffort === void 0 ? {} : { reasoningEffort: selection.reasoningEffort }
164
251
  });
165
- if (this.disposed || generation !== this.generation) {
166
- if (!result.ok) throw new Error(`${result.error.code}: ${result.error.message}`);
167
- return;
168
- }
252
+ if (this.disposed || generation !== this.generation) return result.ok ? {
253
+ ok: true,
254
+ value: void 0
255
+ } : result;
169
256
  if (!result.ok) {
170
257
  this.store.update((s) => {
171
258
  s.status = "error";
259
+ s.pending = null;
172
260
  s.error = `${result.error.code}: ${result.error.message}`;
173
261
  });
174
- throw new Error(`session.selectModel failed: ${result.error.code}: ${result.error.message}`);
262
+ return result;
263
+ }
264
+ if (previous !== null) {
265
+ const from = `${previous.provider}/${previous.model}`;
266
+ const to = `${selection.provider}/${selection.model}`;
267
+ if (from !== to) this.track?.("model_switch", {
268
+ ...this.isBlank() ? {} : { session_id: this.sessionId },
269
+ switch_from: from,
270
+ switch_to: to
271
+ });
272
+ if (from === to && previousEffort !== nextEffort) this.track?.("thinking_level_switch", {
273
+ ...this.isBlank() ? {} : { session_id: this.sessionId },
274
+ model_name: to,
275
+ switch_from: previousEffort ?? "default",
276
+ switch_to: nextEffort ?? "default"
277
+ });
175
278
  }
176
279
  this.store.update((s) => {
177
280
  s.status = "ready";
281
+ s.pending = null;
178
282
  s.error = null;
179
283
  });
180
284
  this.syncInputs();
285
+ return {
286
+ ok: true,
287
+ value: void 0
288
+ };
181
289
  }
182
290
  /**
183
291
  * Invalidate an in-flight selection response from the previous Host generation.
@@ -187,6 +295,7 @@ window.__ModuleLoader__.load({
187
295
  ++this.generation;
188
296
  this.store.update((state) => {
189
297
  if (state.status === "selecting") state.status = "idle";
298
+ state.pending = null;
190
299
  state.error = null;
191
300
  });
192
301
  this.syncInputs();
@@ -204,32 +313,33 @@ window.__ModuleLoader__.load({
204
313
  if (this.disposed) return;
205
314
  const catalog = this.catalog.store.getSnapshot();
206
315
  const projected = modelSelectionProjection(this.projected.getSnapshot());
316
+ const intended = projected?.next ?? catalog.value?.default;
317
+ const reasoning = intended === void 0 ? void 0 : this.catalog.reasoningFor(intended);
318
+ const effort = intended?.reasoningEffort ?? reasoning?.defaultEffort;
319
+ const retainedEffort = effort === void 0 ? void 0 : reasoning?.efforts.find((level) => level.id === effort)?.name ?? effort;
207
320
  if (catalog.status !== "ready" || catalog.value === null || projected === void 0) {
208
- if (this.resolved) {
209
- if (catalog.status === "error") this.store.update((state) => {
210
- state.status = "error";
211
- state.error = catalog.error;
212
- });
213
- return;
214
- }
215
321
  this.store.set({
216
- current: null,
322
+ current: catalog.value === null ? null : this.store.getSnapshot().current,
323
+ ...retainedEffort === void 0 ? {} : { retainedEffort },
217
324
  routable: null,
218
- groups: [],
219
- failures: [],
325
+ groups: catalog.value?.groups ?? [],
326
+ failures: catalog.value?.failures ?? [],
220
327
  status: catalog.status === "error" ? "error" : "loading",
328
+ pending: this.store.getSnapshot().pending,
221
329
  error: catalog.error
222
330
  });
223
331
  return;
224
332
  }
225
- const current = projected.next ?? catalog.value.default;
226
- this.resolved = true;
333
+ const selection = projected.next ?? catalog.value.default;
334
+ const routable = catalog.value.groups.some((group) => group.id === selection.provider && group.models.some((model) => model.id === selection.model));
227
335
  this.store.set({
228
- current,
229
- routable: catalog.value.routableProviders.includes(current.provider),
336
+ current: selection,
337
+ ...retainedEffort === void 0 ? {} : { retainedEffort },
338
+ routable,
230
339
  groups: catalog.value.groups,
231
340
  failures: catalog.value.failures,
232
341
  status: this.store.getSnapshot().status === "selecting" ? "selecting" : "ready",
342
+ pending: this.store.getSnapshot().pending,
233
343
  error: null
234
344
  });
235
345
  }
@@ -239,20 +349,6 @@ window.__ModuleLoader__.load({
239
349
  }
240
350
  //#endregion
241
351
  //#region lib/types/client/service.js
242
- /**
243
- * ModelDirectoryResolver (`ctx.modelDirectories`): the root owner of per-session
244
- * {@link ModelDirectory} instances. Both selection entries (the /model popup
245
- * and the composer model seat) resolve their session's directory through
246
- * this service, which is what makes the dual entry one shared state.
247
- *
248
- * Per-session storage follows the client service pattern (InputTriggerService /
249
- * CommandUiRuntime): a lazy service-internal map whose entry is deleted by the
250
- * owning scope's disposer. The host `dsh-scope` ScopedLayers registry does
251
- * does not belong here: it derives scope from the host carrier mechanism
252
- * (object-keyed), while client scopes tag contexts with branded SessionId
253
- * strings, and it models global+shadow named registries — this is a
254
- * per-session singleton with no global layer to merge.
255
- */
256
352
  /** The `ctx.modelDirectories` session model-selection service. */
257
353
  var ModelDirectoryResolver = class extends _deepseek_ai_cordis.Service {
258
354
  static inject = [
@@ -260,22 +356,18 @@ window.__ModuleLoader__.load({
260
356
  "remote",
261
357
  "remote.session"
262
358
  ];
263
- live = { directories: /* @__PURE__ */ new Map() };
359
+ live = { directories: new WeakMapWithValues() };
264
360
  catalog;
265
- /** Localized composer-block copy; this plugin owns the string it raises. */
266
- blockReason;
267
361
  /**
268
362
  * @param ctx - owning root context (the service registers itself as `models`).
269
- * @param config - the bound translator for this plugin's own dictionary.
270
363
  */
271
- constructor(ctx, config) {
364
+ constructor(ctx) {
272
365
  super(ctx, "modelDirectories");
273
- this.blockReason = config.blockReason;
274
366
  this.catalog = new ModelCatalogDirectory(ctx);
275
367
  this.catalog.load().catch(() => {});
276
368
  ctx.on("connection/reset", () => {
277
369
  this.catalog.resetGeneration();
278
- for (const directory of this.live.directories.values()) directory.resetConnected();
370
+ for (const directory of this.live.directories.values) directory.resetConnected();
279
371
  });
280
372
  ctx.remote.$on("llm/adapters-updated", () => {
281
373
  this.catalog.refresh();
@@ -283,6 +375,9 @@ window.__ModuleLoader__.load({
283
375
  ctx.remote.$on("settings/document-updated", () => {
284
376
  this.catalog.refresh();
285
377
  });
378
+ ctx.remote.$on("credentials/record-updated", () => {
379
+ this.catalog.refresh();
380
+ });
286
381
  ctx.remote.$on("credentials/reference-updated", () => {
287
382
  this.catalog.refresh();
288
383
  });
@@ -295,32 +390,18 @@ window.__ModuleLoader__.load({
295
390
  */
296
391
  directoryFor(sessionId) {
297
392
  const { live } = this;
298
- const existing = live.directories.get(sessionId);
299
- if (existing !== void 0) return existing;
300
393
  const sessions = this.ctx.sessions;
301
394
  const actx = sessions.scope(sessionId);
302
395
  if (actx === void 0) throw new Error(`ui-model-selection: session "${String(sessionId)}" resolved no scope`);
303
396
  const binding = sessions.binding(sessionId);
304
397
  if (binding === void 0) throw new Error(`ui-model-selection: session "${String(sessionId)}" resolved no binding`);
305
- const directory = new ModelDirectory(this.ctx.remote.session, sessionId, () => sessions.subagentAddress(sessionId) === void 0, this.catalog, binding.session.projections.faceOf("modelSelection"));
306
- live.directories.set(sessionId, directory);
307
- const conversation = this.ctx.get("conversation");
308
- if (conversation !== void 0) {
309
- const publish = () => {
310
- conversation.blocks.set(sessionId, directory.store.getSnapshot().routable === false ? { reason: this.blockReason() } : void 0);
311
- };
312
- publish();
313
- actx.effect(() => {
314
- const stop = directory.store.subscribe(publish);
315
- return () => {
316
- stop();
317
- conversation.blocks.set(sessionId, void 0);
318
- };
319
- }, "ui-model-selection: composer block");
320
- }
398
+ const existing = live.directories.get(binding);
399
+ if (existing !== void 0) return existing;
400
+ const directory = new ModelDirectory(this.ctx.remote.session, sessionId, () => sessions.subagentAddress(sessionId) === void 0, this.catalog, binding.session.projections.faceOf("modelSelection"), () => binding.session.getSnapshot().blank, (name, attributes) => this.ctx.get("productAnalytics")?.track(name, attributes));
401
+ live.directories.set(binding, directory);
321
402
  actx.effect(() => () => {
322
403
  directory.dispose();
323
- live.directories.delete(sessionId);
404
+ live.directories.delete(binding);
324
405
  }, "ui-model-selection: session directory");
325
406
  return directory;
326
407
  }
@@ -342,7 +423,7 @@ window.__ModuleLoader__.load({
342
423
  }
343
424
  //#endregion
344
425
  //#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-model-selection/src/client/ModelSelect.module.css.mjs
345
- const css = "._7KE1Ra_root{min-width:0;position:relative}._7KE1Ra_trigger{min-width:0;max-width:min(360px,45cqw);height:28px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:24px;outline:none;align-items:center;gap:4px;padding:0 4px 0 8px;font-size:13px;font-weight:500;line-height:20px;display:flex}._7KE1Ra_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}._7KE1Ra_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-alias-border-l3)}._7KE1Ra_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}._7KE1Ra_triggerLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}._7KE1Ra_triggerEffort{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-caption);flex-shrink:1000;overflow:hidden}._7KE1Ra_triggerIcon{flex:none;display:none}@container (width<=360px){._7KE1Ra_triggerIcon{display:block}._7KE1Ra_triggerLabel,._7KE1Ra_triggerEffort{display:none}}._7KE1Ra_chevron{color:var(--dsw-alias-label-caption);flex:none;transition:transform .12s}._7KE1Ra_chevronOpen{transform:rotate(180deg)}._7KE1Ra_menu{z-index:1100;background:var(--dsw-specific-menu);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);width:max-content;min-width:min(240px,100vw - 32px);max-width:min(420px,100vw - 32px);max-height:min(360px,100vh - 96px);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;border-radius:20px;flex-direction:column;padding:4px;display:flex;position:fixed;overflow:hidden}._7KE1Ra_status,._7KE1Ra_empty{color:var(--dsw-alias-label-tertiary);padding:10px;font-size:13px;line-height:20px}._7KE1Ra_error,._7KE1Ra_warning{background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);border-radius:8px;justify-content:space-between;align-items:flex-start;gap:8px;margin-bottom:4px;padding:7px 8px;font-size:12px;line-height:18px;display:flex}._7KE1Ra_warning{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-state-warn-label)}._7KE1Ra_retry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600}._7KE1Ra_groups{min-height:0;overflow-y:auto}._7KE1Ra_group+._7KE1Ra_group{margin-top:4px}._7KE1Ra_groupTitle{z-index:1;background:var(--dsw-specific-menu);color:var(--dsw-alias-label-tertiary);padding:5px 8px 3px;font-size:12px;font-weight:500;line-height:18px;position:sticky;top:0}._7KE1Ra_option{box-sizing:border-box;width:auto;min-width:100%;min-height:38px;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;border-radius:10px;outline:none;align-items:center;gap:8px;padding:6px 8px;display:flex}._7KE1Ra_option:hover:not(:disabled),._7KE1Ra_option:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}._7KE1Ra_selected{background:0 0}._7KE1Ra_option:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}._7KE1Ra_optionCopy{flex-direction:column;flex:1;min-width:0;display:flex}._7KE1Ra_modelName{color:inherit;text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:500;line-height:20px;overflow:hidden}._7KE1Ra_check{color:var(--dsw-alias-label-primary);flex:0 0 18px;place-items:center;display:grid}._7KE1Ra_cell{box-sizing:border-box;width:auto;min-width:100%;height:40px;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border:none;border-radius:10px;align-items:center;gap:8px;padding:0 10px;font-size:14px;line-height:22px;display:flex}._7KE1Ra_cell:hover{background:var(--dsw-alias-interactive-bg-hover)}._7KE1Ra_cellLabel{white-space:nowrap;flex:none}._7KE1Ra_cellValue{text-overflow:ellipsis;white-space:nowrap;text-align:right;min-width:0;color:var(--dsw-alias-label-tertiary);flex:auto;overflow:hidden}._7KE1Ra_cellChevron{color:var(--dsw-alias-label-tertiary);flex:none}";
426
+ const css = "._7KE1Ra_root{min-width:0;position:relative}._7KE1Ra_trigger{border-radius:var(--dsw-radius-sm);min-width:0;max-width:min(360px,45cqw);height:28px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;outline:none;align-items:center;gap:4px;padding:0 4px 0 8px;font-size:13px;font-weight:400;line-height:20px;display:flex}._7KE1Ra_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}._7KE1Ra_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}._7KE1Ra_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}._7KE1Ra_triggerLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}._7KE1Ra_triggerEffort{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-caption);flex-shrink:1000;overflow:hidden}._7KE1Ra_triggerIcon{display:var(--dsh-composer-model-icon-display,none);flex:none}._7KE1Ra_triggerLabel,._7KE1Ra_triggerEffort{display:var(--dsh-composer-model-text-display,block)}._7KE1Ra_chevron{color:var(--dsw-alias-label-caption);flex:none;transition:transform .12s}._7KE1Ra_chevronOpen{transform:rotate(180deg)}._7KE1Ra_menu{z-index:1100;--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);width:max-content;min-width:min(240px,100vw - 32px);max-width:min(420px,100vw - 32px);max-height:min(360px,100vh - 96px);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex-direction:column;padding:4px;display:flex;position:fixed;overflow:hidden}._7KE1Ra_status,._7KE1Ra_empty{color:var(--dsw-alias-label-tertiary);padding:8px;font-size:12px;line-height:18px}._7KE1Ra_error,._7KE1Ra_warning{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:flex-start;gap:6px;margin-bottom:3px;padding:6px 7px;font-size:11px;line-height:16px;display:flex}._7KE1Ra_warning{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-state-warn-label)}._7KE1Ra_retry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600}._7KE1Ra_groups{min-height:0;overflow-y:auto}._7KE1Ra_group+._7KE1Ra_group{margin-top:3px}._7KE1Ra_groupTitle{z-index:1;background:var(--dsw-specific-menu);color:var(--dsw-alias-label-tertiary);padding:4px 7px 2px;font-size:11px;font-weight:500;line-height:16px;position:sticky;top:0}._7KE1Ra_option{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:auto;min-width:100%;min-height:34px;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;outline:none;align-items:center;gap:6px;padding:5px 7px;display:flex}._7KE1Ra_option:hover:not(:disabled),._7KE1Ra_option:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}._7KE1Ra_selected{background:0 0}._7KE1Ra_option:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}._7KE1Ra_optionCopy{flex-direction:column;flex:1;min-width:0;display:flex}._7KE1Ra_modelName{color:inherit;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:500;line-height:18px;overflow:hidden}._7KE1Ra_check{color:var(--dsw-alias-label-primary);flex:0 0 14px;place-items:center;display:grid}._7KE1Ra_check svg{width:14px;height:14px}._7KE1Ra_cell{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:auto;min-width:100%;height:34px;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border:none;align-items:center;gap:6px;padding:0 8px;font-size:13px;line-height:20px;display:flex}._7KE1Ra_cell:hover{background:var(--dsw-alias-interactive-bg-hover)}._7KE1Ra_cellLabel{white-space:nowrap;flex:none}._7KE1Ra_cellValue{text-overflow:ellipsis;white-space:nowrap;text-align:right;min-width:0;color:var(--dsw-alias-label-tertiary);flex:auto;overflow:hidden}._7KE1Ra_cellChevron{width:12px;height:12px;color:var(--dsw-alias-menu-icon);flex:none}";
346
427
  const tagId = "@deepseek-ai/dsh-client-ui-model-selection/ModelSelect.module.css";
347
428
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
348
429
  const tag = document.createElement("style");
@@ -387,11 +468,19 @@ window.__ModuleLoader__.load({
387
468
  * each drilling into its own list — the provider-grouped model list over
388
469
  * the shared directory, and the effort levels. The trigger (313:14108's
389
470
  * ToggleButton) shows both: model name + effort in the caption tone.
390
- * Data and submission ride the SAME per-session ModelDirectory as the
391
- * /model popup; exact-model reasoning metadata and the selected effort come
392
- * from the Host rather than a client-owned vocabulary. A rejected selection
393
- * announces through the shared transient Toast anchored to the composer
394
- * card; the in-menu strip with Retry remains the catalog-load surface.
471
+ * While open, ↑/↓ move focus across the rows of the shown pane (wrapping; a
472
+ * step taken while the trigger still holds focus enters at the near end), Tab
473
+ * settles like Enter, and Escape and Shift+Tab leave a drilled pane first and
474
+ * otherwise close back to the trigger. A drilled pane hands focus to the row
475
+ * of the value in use, and returning to the root pane hands it back to the
476
+ * cell that opened it. Data and submission ride the SAME per-session
477
+ * ModelDirectory as the /model popup; exact-model reasoning metadata and the
478
+ * selected effort come from the Host rather than a client-owned vocabulary. A
479
+ * rejected selection announces through the shared transient Toast anchored to
480
+ * the composer card; the in-menu strip with Retry remains the catalog-load
481
+ * surface. While the directory's pending selection is unsettled, the trigger
482
+ * shows a spinner in place of its chevron, and each row whose value that
483
+ * selection carries shows one in place of its check mark.
395
484
  */
396
485
  /** Unplaced portal card: hidden but laid out at a fixed origin so offsetWidth/offsetHeight are real (Menu primitive's measure pass). */
397
486
  const MEASURE_STYLE = {
@@ -418,7 +507,8 @@ window.__ModuleLoader__.load({
418
507
  const [menuPos, setMenuPos] = (0, react.useState)(null);
419
508
  const itemRefs = (0, react.useRef)([]);
420
509
  const id = (0, react.useId)();
421
- const choices = (0, react.useMemo)(() => state.groups.flatMap((group) => group.models.map((model) => ({
510
+ const groups = (0, react.useMemo)(() => state.groups.toSorted((left, right) => (left.id === "deepseek-account" ? 0 : left.id === "deepseek-official" ? 1 : 2) - (right.id === "deepseek-account" ? 0 : right.id === "deepseek-official" ? 1 : 2)), [state.groups]);
511
+ const choices = (0, react.useMemo)(() => groups.flatMap((group) => group.models.map((model) => ({
422
512
  group,
423
513
  model,
424
514
  selection: {
@@ -426,11 +516,11 @@ window.__ModuleLoader__.load({
426
516
  model: model.id,
427
517
  ...model.reasoning?.defaultEffort === void 0 ? {} : { reasoningEffort: model.reasoning.defaultEffort }
428
518
  }
429
- }))), [state.groups]);
519
+ }))), [groups]);
430
520
  const currentChoice = choices[state.current === null ? -1 : choices.findIndex((c) => c.selection.provider === state.current?.provider && c.selection.model === state.current.model)];
431
521
  const reasoning = currentChoice?.model.reasoning;
432
522
  const effectiveEffort = state.current?.reasoningEffort ?? reasoning?.defaultEffort;
433
- const effortLabel = reasoning === void 0 ? void 0 : effectiveEffort === void 0 ? t("effort.providerDefault") : reasoning.efforts.find((level) => level.id === effectiveEffort)?.name ?? effectiveEffort;
523
+ const effortLabel = reasoning === void 0 ? state.retainedEffort : effectiveEffort === void 0 ? t("effort.providerDefault") : reasoning.efforts.find((level) => level.id === effectiveEffort)?.name ?? effectiveEffort;
434
524
  const effortChoices = (0, react.useMemo)(() => reasoning === void 0 ? [] : [...reasoning.defaultEffort === void 0 ? [{
435
525
  key: "provider-default",
436
526
  effort: void 0,
@@ -440,7 +530,8 @@ window.__ModuleLoader__.load({
440
530
  effort: effort.id,
441
531
  label: effort.name
442
532
  }))], [reasoning, t]);
443
- const busy = state.status === "selecting";
533
+ const { pending } = state;
534
+ const busy = pending !== null;
444
535
  const reload = () => {
445
536
  lastActionRef.current = "load";
446
537
  load();
@@ -457,6 +548,18 @@ window.__ModuleLoader__.load({
457
548
  document.removeEventListener("mousedown", closeOutside);
458
549
  };
459
550
  }, [open]);
551
+ const paneFocus = (0, react.useRef)(null);
552
+ (0, react.useEffect)(() => {
553
+ const intent = paneFocus.current;
554
+ paneFocus.current = null;
555
+ if (!open || intent === null) return;
556
+ if (intent === "drill") {
557
+ (menuRef.current?.querySelector("[role=\"menuitemradio\"][aria-checked=\"true\"]:not([disabled])") ?? itemRefs.current.find((item) => item !== null && !item.disabled) ?? triggerRef.current)?.focus();
558
+ return;
559
+ }
560
+ const cell = itemRefs.current[intent === "effort" ? 1 : 0];
561
+ (cell !== null && cell !== void 0 && !cell.disabled ? cell : triggerRef.current)?.focus();
562
+ }, [open, pane]);
460
563
  (0, react.useLayoutEffect)(() => {
461
564
  if (!open) {
462
565
  setMenuPos(null);
@@ -492,7 +595,9 @@ window.__ModuleLoader__.load({
492
595
  ]);
493
596
  if (!available) return null;
494
597
  const show = () => {
495
- setPane("root");
598
+ triggerRef.current?.focus();
599
+ if (state.current === null) paneFocus.current = "drill";
600
+ setPane(state.current === null ? "model" : "root");
496
601
  setOpen(true);
497
602
  reload();
498
603
  };
@@ -503,20 +608,48 @@ window.__ModuleLoader__.load({
503
608
  triggerRef.current?.focus();
504
609
  });
505
610
  };
611
+ const drill = (next) => {
612
+ paneFocus.current = "drill";
613
+ setPane(next);
614
+ };
615
+ /** Leave a drilled pane for the root one, handing the keyboard back to its cell. */
616
+ const back = (from) => {
617
+ paneFocus.current = from;
618
+ setPane("root");
619
+ };
506
620
  const moveFocus = (offset) => {
507
621
  const items = itemRefs.current.filter((item) => item !== null);
508
622
  if (items.length === 0) return;
509
623
  const active = items.findIndex((item) => item === document.activeElement);
510
- items[(Math.max(active, 0) + offset + items.length) % items.length]?.focus();
624
+ items[active === -1 ? offset > 0 ? 0 : items.length - 1 : (active + offset + items.length) % items.length]?.focus();
511
625
  };
512
626
  const onRootKeyDown = (event) => {
513
627
  if (event.key === "Escape" && open) {
514
628
  event.preventDefault();
515
- if (pane !== "root") setPane("root");
629
+ if (pane !== "root" && state.current !== null) back(pane);
516
630
  else close(true);
517
631
  return;
518
632
  }
519
633
  if (!open) return;
634
+ if (event.key === "Tab") {
635
+ if (event.shiftKey) {
636
+ event.preventDefault();
637
+ if (pane !== "root" && state.current !== null) back(pane);
638
+ else close(true);
639
+ return;
640
+ }
641
+ const focused = document.activeElement;
642
+ const rows = itemRefs.current.filter((item) => item !== null);
643
+ if (focused instanceof HTMLButtonElement && rows.includes(focused)) {
644
+ event.preventDefault();
645
+ focused.click();
646
+ return;
647
+ }
648
+ if (focused !== triggerRef.current) return;
649
+ event.preventDefault();
650
+ (menuRef.current?.querySelector("[role=\"menuitemradio\"][aria-checked=\"true\"]:not([disabled])") ?? rows.find((item) => !item.disabled))?.focus();
651
+ return;
652
+ }
520
653
  if (event.key === "ArrowDown" || event.key === "ArrowUp") {
521
654
  event.preventDefault();
522
655
  moveFocus(event.key === "ArrowDown" ? 1 : -1);
@@ -526,27 +659,30 @@ window.__ModuleLoader__.load({
526
659
  if (event.relatedTarget instanceof Node && (rootRef.current?.contains(event.relatedTarget) === true || menuRef.current?.contains(event.relatedTarget) === true)) return;
527
660
  close();
528
661
  };
529
- const settleSelection = (accepted) => {
530
- if (accepted) {
662
+ const settleSelection = (result) => {
663
+ if (result === void 0) return;
664
+ if (result.ok) {
531
665
  if (rootRef.current !== null) close(true);
532
666
  return;
533
667
  }
534
- const message = directory.getSnapshot().error;
535
- if (message !== null) {
536
- toastSeq.current += 1;
537
- setToast({
538
- seq: toastSeq.current,
539
- text: t("error.action", { message })
540
- });
541
- }
668
+ const { error } = result;
669
+ toastSeq.current += 1;
670
+ setToast({
671
+ seq: toastSeq.current,
672
+ text: error.code === "session/writer-held" ? t("error.sessionInUse") : t("error.action", { message: `${error.code}: ${error.message}` })
673
+ });
674
+ };
675
+ const submit = (selection) => {
676
+ lastActionRef.current = "select";
677
+ triggerRef.current?.focus();
678
+ select(selection).then(settleSelection);
542
679
  };
543
680
  const choose = (selection) => {
544
681
  if (state.current?.provider === selection.provider && state.current.model === selection.model) {
545
682
  close(true);
546
683
  return;
547
684
  }
548
- lastActionRef.current = "select";
549
- select(selection).then(settleSelection);
685
+ submit(selection);
550
686
  };
551
687
  const chooseEffort = (effort) => {
552
688
  if (state.current === null) return;
@@ -554,13 +690,11 @@ window.__ModuleLoader__.load({
554
690
  close(true);
555
691
  return;
556
692
  }
557
- const selection = {
693
+ submit({
558
694
  provider: state.current.provider,
559
695
  model: state.current.model,
560
696
  ...effort === void 0 ? {} : { reasoningEffort: effort }
561
- };
562
- lastActionRef.current = "select";
563
- select(selection).then(settleSelection);
697
+ });
564
698
  };
565
699
  const waiting = state.current === null && state.status === "loading";
566
700
  const modelLabel = waiting ? t("trigger.loading") : currentChoice?.model.name ?? (state.current === null ? t("trigger.fallback") : `${state.current.provider}/${state.current.model}`);
@@ -582,6 +716,9 @@ window.__ModuleLoader__.load({
582
716
  className: ModelSelect_module_css_default.root,
583
717
  onKeyDown: onRootKeyDown,
584
718
  onBlur,
719
+ onMouseDown: (event) => {
720
+ if (event.target instanceof Element && event.target.closest("button") !== null) event.preventDefault();
721
+ },
585
722
  children: [
586
723
  (0, react_jsx_runtime.jsxs)("button", {
587
724
  ref: triggerRef,
@@ -592,13 +729,14 @@ window.__ModuleLoader__.load({
592
729
  "aria-expanded": open,
593
730
  "aria-controls": open ? `${id}-menu` : void 0,
594
731
  title: triggerLabel,
732
+ "aria-busy": busy,
595
733
  disabled: locked,
596
734
  onClick: () => {
597
- if (open) close();
735
+ if (open) close(true);
598
736
  else show();
599
737
  },
600
738
  children: [
601
- (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconDataOutline16, {
739
+ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconDataOutlineRegular, {
602
740
  className: ModelSelect_module_css_default.triggerIcon,
603
741
  size: 16
604
742
  }),
@@ -610,10 +748,10 @@ window.__ModuleLoader__.load({
610
748
  className: ModelSelect_module_css_default.triggerEffort,
611
749
  children: effortLabel
612
750
  }),
613
- (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { className: clsx(ModelSelect_module_css_default.chevron, open && ModelSelect_module_css_default.chevronOpen) })
751
+ busy ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "ongoing" }) : (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutlineRegular, { className: clsx(ModelSelect_module_css_default.chevron, open && ModelSelect_module_css_default.chevronOpen) })
614
752
  ]
615
753
  }),
616
- open && (0, react_dom.createPortal)((0, react_jsx_runtime.jsxs)("div", {
754
+ open && (0, react_dom.createPortal)((0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.MenuSurface, {
617
755
  ref: menuRef,
618
756
  id: `${id}-menu`,
619
757
  className: ModelSelect_module_css_default.menu,
@@ -628,7 +766,7 @@ window.__ModuleLoader__.load({
628
766
  role: "menuitem",
629
767
  className: ModelSelect_module_css_default.cell,
630
768
  onClick: () => {
631
- setPane("model");
769
+ drill("model");
632
770
  },
633
771
  children: [
634
772
  (0, react_jsx_runtime.jsx)("span", {
@@ -639,7 +777,7 @@ window.__ModuleLoader__.load({
639
777
  className: ModelSelect_module_css_default.cellValue,
640
778
  children: modelLabel
641
779
  }),
642
- (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutline14, { className: ModelSelect_module_css_default.cellChevron })
780
+ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { className: ModelSelect_module_css_default.cellChevron })
643
781
  ]
644
782
  }), reasoning !== void 0 && (0, react_jsx_runtime.jsxs)("button", {
645
783
  ref: itemRef(),
@@ -647,7 +785,7 @@ window.__ModuleLoader__.load({
647
785
  role: "menuitem",
648
786
  className: ModelSelect_module_css_default.cell,
649
787
  onClick: () => {
650
- setPane("effort");
788
+ drill("effort");
651
789
  },
652
790
  children: [
653
791
  (0, react_jsx_runtime.jsx)("span", {
@@ -658,7 +796,7 @@ window.__ModuleLoader__.load({
658
796
  className: ModelSelect_module_css_default.cellValue,
659
797
  children: effortLabel
660
798
  }),
661
- (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutline14, { className: ModelSelect_module_css_default.cellChevron })
799
+ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { className: ModelSelect_module_css_default.cellChevron })
662
800
  ]
663
801
  })] }),
664
802
  pane === "model" && (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
@@ -678,7 +816,7 @@ window.__ModuleLoader__.load({
678
816
  state.failures.map((failure) => (0, react_jsx_runtime.jsxs)("div", {
679
817
  className: ModelSelect_module_css_default.warning,
680
818
  children: [(0, react_jsx_runtime.jsx)("span", { children: t("warning.groupLoad", {
681
- name: failure.name,
819
+ name: failure.id === "deepseek-account" ? t("provider.account") : failure.name,
682
820
  message: failure.message
683
821
  }) }), (0, react_jsx_runtime.jsx)("button", {
684
822
  type: "button",
@@ -689,7 +827,7 @@ window.__ModuleLoader__.load({
689
827
  }, failure.id)),
690
828
  (0, react_jsx_runtime.jsx)("div", {
691
829
  className: clsx(ModelSelect_module_css_default.groups, "scrollable"),
692
- children: state.groups.map((group) => {
830
+ children: groups.map((group) => {
693
831
  const headingId = `${id}-${group.id}`;
694
832
  return (0, react_jsx_runtime.jsxs)("section", {
695
833
  role: "group",
@@ -698,7 +836,7 @@ window.__ModuleLoader__.load({
698
836
  children: [(0, react_jsx_runtime.jsx)("div", {
699
837
  className: ModelSelect_module_css_default.groupTitle,
700
838
  id: headingId,
701
- children: group.name
839
+ children: group.id === "deepseek-account" ? t("provider.account") : group.name
702
840
  }), group.models.map((model) => {
703
841
  const selected = state.current?.provider === group.id && state.current.model === model.id;
704
842
  return (0, react_jsx_runtime.jsxs)("button", {
@@ -723,7 +861,7 @@ window.__ModuleLoader__.load({
723
861
  })
724
862
  }), (0, react_jsx_runtime.jsx)("span", {
725
863
  className: ModelSelect_module_css_default.check,
726
- children: selected ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, {}) : null
864
+ children: pending?.provider === group.id && pending.model === model.id ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "ongoing" }) : selected ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, {}) : null
727
865
  })]
728
866
  }, model.id);
729
867
  })]
@@ -764,14 +902,14 @@ window.__ModuleLoader__.load({
764
902
  })
765
903
  }), (0, react_jsx_runtime.jsx)("span", {
766
904
  className: ModelSelect_module_css_default.check,
767
- children: effectiveEffort === level.effort ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutline16, {}) : null
905
+ children: pending !== null && pending.provider === state.current?.provider && pending.model === state.current.model && pending.reasoningEffort === level.effort ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.StateDot, { state: "ongoing" }) : effectiveEffort === level.effort ? (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconCheckOutlineRegular, {}) : null
768
906
  })]
769
907
  }, level.key))] })
770
908
  ]
771
909
  }), document.body),
772
910
  toast !== null && (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Toast, {
773
911
  text: toast.text,
774
- icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutline16, {}),
912
+ icon: (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconWarningOutlineRegular, {}),
775
913
  anchor: rootRef.current?.closest("[data-composer-card]") ?? null,
776
914
  onDone: () => {
777
915
  setToast(null);
@@ -793,13 +931,15 @@ window.__ModuleLoader__.load({
793
931
  */
794
932
  /** Simplified Chinese dictionary (the key-set source of truth). */
795
933
  const zh = {
934
+ "provider.account": "DeepSeek 账号",
935
+ "command.label": "模型",
796
936
  "command.description": "选择本会话使用的模型",
797
937
  "option.loadError": "目录加载失败:{message}",
798
938
  "option.deepseekV4Flash.description": "快速、高效且经济;适合目标明确、常规或并行任务。",
799
939
  "option.deepseekV4Pro.description": "更强的自主编码、知识与复杂推理能力;适合复杂或质量优先的任务,但成本更高。",
800
- "trigger.fallback": "选择模型",
940
+ "trigger.fallback": "请选择模型",
801
941
  "trigger.loading": "正在加载模型…",
802
- "trigger.selectAria": "选择模型",
942
+ "trigger.selectAria": "请选择模型",
803
943
  "trigger.aria": "选择模型,当前 {model}",
804
944
  "trigger.ariaEffort": "选择模型,当前 {model},推理等级 {effort}",
805
945
  "menu.aria": "模型与推理等级",
@@ -808,14 +948,16 @@ window.__ModuleLoader__.load({
808
948
  "effort.providerDefault": "Default",
809
949
  "status.loading": "正在刷新模型列表…",
810
950
  "error.action": "模型操作失败:{message}",
951
+ "error.sessionInUse": "当前会话已被占用,可能是其他正在运行的 DSH 导致的(如其他 dsh web、桌面端),请退出其他正在运行的 DSH 后重试。",
811
952
  "action.reload": "重新加载",
812
953
  "warning.groupLoad": "{name} 加载失败:{message}",
813
954
  "empty.models": "没有可用的模型。",
814
- "blocked.composer": "当前模型不可用,请先选择模型",
815
955
  "empty.efforts": "当前模型未提供推理等级。"
816
956
  };
817
957
  /** English dictionary, checked complete against the zh key set. */
818
958
  const en = {
959
+ "provider.account": "DeepSeek Account",
960
+ "command.label": "Model",
819
961
  "command.description": "Select the model for this conversation",
820
962
  "option.loadError": "Catalog failed to load: {message}",
821
963
  "option.deepseekV4Flash.description": "Fast, efficient, and economical; suited to focused, routine, or parallel tasks.",
@@ -831,10 +973,10 @@ window.__ModuleLoader__.load({
831
973
  "effort.providerDefault": "Default",
832
974
  "status.loading": "Refreshing model list…",
833
975
  "error.action": "Model operation failed: {message}",
976
+ "error.sessionInUse": "This session is already in use, possibly by another running DSH instance (such as dsh web or the desktop app). Quit other running DSH instances and try again.",
834
977
  "action.reload": "Reload",
835
978
  "warning.groupLoad": "{name} failed to load: {message}",
836
979
  "empty.models": "No models available.",
837
- "blocked.composer": "This model is unavailable — select one to continue",
838
980
  "empty.efforts": "This model provides no reasoning effort levels."
839
981
  };
840
982
  //#endregion
@@ -844,6 +986,8 @@ window.__ModuleLoader__.load({
844
986
  return `${providerId}/${modelId}`;
845
987
  }
846
988
  const BUILTIN_DESCRIPTION_KEYS = {
989
+ "deepseek-account/deepseek-v4-flash": "option.deepseekV4Flash.description",
990
+ "deepseek-account/deepseek-v4-pro": "option.deepseekV4Pro.description",
847
991
  "deepseek-official/deepseek-v4-flash": "option.deepseekV4Flash.description",
848
992
  "deepseek-official/deepseek-v4-pro": "option.deepseekV4Pro.description"
849
993
  };
@@ -854,18 +998,21 @@ window.__ModuleLoader__.load({
854
998
  /** Flatten the directory into popup rows; failure rows are listed for visibility but never selectable. */
855
999
  function optionsOf(directory, t) {
856
1000
  const rows = [];
857
- for (const group of directory.groups) for (const model of group.models) {
858
- const description = descriptionOf(group.id, model, t);
859
- rows.push({
860
- id: rowId(group.id, model.id),
861
- label: model.name,
862
- detail: description !== void 0 ? `${group.name} · ${description}` : group.name,
863
- ...directory.current !== null && directory.current.provider === group.id && directory.current.model === model.id ? { active: true } : {}
864
- });
1001
+ for (const group of directory.groups) {
1002
+ const name = group.id === "deepseek-account" ? t("provider.account") : group.name;
1003
+ for (const model of group.models) {
1004
+ const description = descriptionOf(group.id, model, t);
1005
+ rows.push({
1006
+ id: rowId(group.id, model.id),
1007
+ label: model.name,
1008
+ detail: description !== void 0 ? `${name} · ${description}` : name,
1009
+ ...directory.current !== null && directory.current.provider === group.id && directory.current.model === model.id ? { active: true } : {}
1010
+ });
1011
+ }
865
1012
  }
866
1013
  for (const failure of directory.failures) rows.push({
867
1014
  id: `failure/${failure.id}`,
868
- label: failure.name,
1015
+ label: failure.id === "deepseek-account" ? t("provider.account") : failure.name,
869
1016
  detail: t("option.loadError", { message: failure.message })
870
1017
  });
871
1018
  return rows;
@@ -911,14 +1058,16 @@ window.__ModuleLoader__.load({
911
1058
  en
912
1059
  }), "ui-model-selection: dictionaries");
913
1060
  const t = ctx.locale.bind(NS);
914
- ctx.plugin(ModelDirectoryResolver, { blockReason: () => t("blocked.composer") });
1061
+ ctx.plugin(ModelDirectoryResolver);
915
1062
  ctx.inject(["commandUi", "modelDirectories"], (scope) => {
916
1063
  const command = scope.get("commandUi");
917
1064
  const models = scope.modelDirectories;
918
1065
  const sessions = scope.sessions;
919
1066
  scope.effect(() => command.register({
920
1067
  name: "model",
1068
+ label: () => t("command.label"),
921
1069
  description: () => t("command.description"),
1070
+ icon: _deepseek_ai_dsh_client_ui_primitives.IconDataOutlineRegular,
922
1071
  available: (session) => sessions.subagentAddress(session.sessionId) === void 0,
923
1072
  ui: {
924
1073
  kind: "popupSelect",
@@ -931,7 +1080,11 @@ window.__ModuleLoader__.load({
931
1080
  const directory = models.directoryFor(session.sessionId);
932
1081
  const selection = selectionOf(directory.store.getSnapshot(), option.id);
933
1082
  if (selection === void 0) throw new Error("this provider's catalog failed to load — pick a model from a loaded group");
934
- await directory.select(selection);
1083
+ const result = await directory.select(selection);
1084
+ if (!result.ok) {
1085
+ if (result.error.code === "session/writer-held") throw new Error(t("error.sessionInUse"));
1086
+ throw result.error;
1087
+ }
935
1088
  }
936
1089
  }
937
1090
  }), "ui-model-selection: /model contribution");
@@ -951,7 +1104,7 @@ window.__ModuleLoader__.load({
951
1104
  load: () => {
952
1105
  if (available) directory.load().catch(() => {});
953
1106
  },
954
- select: (selection) => available ? directory.select(selection).then(() => true, () => false) : Promise.resolve(false)
1107
+ select: (selection) => available ? directory.select(selection) : Promise.resolve(void 0)
955
1108
  };
956
1109
  }
957
1110
  }, ModelSelect));