@kasenri/dsh-orbit 0.5.1

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 ADDED
@@ -0,0 +1,625 @@
1
+ window.__ModuleLoader__.load({
2
+ id: "@kasenri/dsh-orbit",
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
6
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
7
+ let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
8
+ let react = require("react");
9
+ let react_dom = require("react-dom");
10
+ let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
11
+ let react_jsx_runtime = require("react/jsx-runtime");
12
+ //#region client/model-options.ts
13
+ /** Find one catalog model for a stored route. */
14
+ function modelOf(state, route) {
15
+ if (route === void 0) return void 0;
16
+ for (const group of state.groups) {
17
+ if (group.id !== route.provider) continue;
18
+ for (const model of group.models) if (model.id === route.model) return model;
19
+ }
20
+ }
21
+ /** Human effort label for a stored effort id; falls back to the raw id. */
22
+ function effortLabelOf(model, effort) {
23
+ if (effort === void 0 || effort === "") return void 0;
24
+ return model?.reasoning?.efforts.find((entry) => entry.id === effort)?.name ?? effort;
25
+ }
26
+ /** Display name for a stored route: catalog name, then its model id. */
27
+ function routeLabelOf(state, route) {
28
+ if (route === void 0) return void 0;
29
+ return modelOf(state, route)?.name ?? route.model;
30
+ }
31
+ /**
32
+ * Route for a freshly picked model: the model's own default effort. A model
33
+ * without effort metadata yields no effort — a previous model's effort is
34
+ * never inherited.
35
+ */
36
+ function routeForModel(provider, model) {
37
+ const defaultEffort = model.reasoning?.defaultEffort;
38
+ return {
39
+ provider,
40
+ model: model.id,
41
+ ...defaultEffort === void 0 ? {} : { reasoningEffort: defaultEffort }
42
+ };
43
+ }
44
+ /**
45
+ * Selection for the shared Session directory: preserve the current effort
46
+ * when the route did not change, otherwise use the picked model's default.
47
+ */
48
+ function selectionForModel(state, provider, model) {
49
+ const effort = state.current?.provider === provider && state.current.model === model.id ? state.current?.reasoningEffort ?? model.reasoning?.defaultEffort : model.reasoning?.defaultEffort;
50
+ return {
51
+ provider,
52
+ model: model.id,
53
+ ...effort === void 0 ? {} : { reasoningEffort: effort }
54
+ };
55
+ }
56
+ /** Effort rows for one model; empty when the adapter publishes none. */
57
+ function effortChoicesOf(model, providerDefaultLabel) {
58
+ const reasoning = model?.reasoning;
59
+ if (reasoning === void 0) return [];
60
+ const choices = [];
61
+ if (reasoning.defaultEffort !== void 0) choices.push({
62
+ id: "provider-default",
63
+ label: providerDefaultLabel,
64
+ effort: void 0
65
+ });
66
+ for (const effort of reasoning.efforts) choices.push({
67
+ id: `effort:${effort.id}`,
68
+ label: effort.name,
69
+ effort: effort.id
70
+ });
71
+ return choices;
72
+ }
73
+ /** Normalize one settings wire value into a complete route. */
74
+ function routeFromSettingsValue(value) {
75
+ if (value === null || typeof value !== "object") return void 0;
76
+ const record = value;
77
+ const provider = record["provider"];
78
+ const model = record["model"];
79
+ if (typeof provider !== "string" || provider === "") return void 0;
80
+ if (typeof model !== "string" || model === "") return void 0;
81
+ const reasoningEffort = record["reasoningEffort"];
82
+ return {
83
+ provider,
84
+ model,
85
+ ...typeof reasoningEffort === "string" && reasoningEffort !== "" ? { reasoningEffort } : {}
86
+ };
87
+ }
88
+ //#endregion
89
+ //#region \0dsh-css:/root/code/dsh-pi-parity/packages/orbit/client/OrbitModelSelect.module.css.mjs
90
+ const css = ".f77nca_panel{z-index:60;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-specific-menu);min-width:260px;max-width:420px;max-height:min(55vh,420px);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);border-radius:12px;flex-direction:column;padding:6px;font-size:13px;line-height:1.4;display:flex;position:fixed;overflow:auto}.f77nca_title{color:var(--dsw-alias-label-tertiary);letter-spacing:.04em;text-transform:uppercase;padding:6px 8px 2px;font-size:11px}.f77nca_group{color:var(--dsw-alias-label-tertiary);padding:8px 8px 2px;font-size:11px}.f77nca_row{width:100%;color:inherit;font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:8px;align-items:center;gap:8px;padding:7px 8px;display:flex}.f77nca_row:hover{background:var(--dsw-alias-interactive-bg-hover)}.f77nca_rowLabel{flex:none}.f77nca_rowValue{max-width:190px;color:var(--dsw-alias-label-tertiary);text-overflow:ellipsis;white-space:nowrap;margin-left:auto;overflow:hidden}.f77nca_rowValueActive{color:var(--dsw-alias-label-primary)}.f77nca_rowDetail{color:var(--dsw-alias-label-tertiary);margin-left:auto;font-size:11px}.f77nca_check{color:var(--dsw-alias-state-business-primary);flex:none;margin-left:6px}.f77nca_chevron{color:var(--dsw-alias-label-tertiary);flex:none;margin-left:6px}.f77nca_separator{background:var(--dsw-alias-border-l1);height:1px;margin:6px 4px}.f77nca_hint{color:var(--dsw-alias-label-tertiary);padding:6px 8px;font-size:11px}.f77nca_error{color:var(--dsw-alias-state-error-primary);align-items:center;gap:8px;padding:8px;font-size:12px;display:flex}.f77nca_back{width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;text-align:left;cursor:pointer;background:0 0;border:0;align-items:center;gap:6px;padding:6px 8px 8px;font-size:12px;display:flex}";
91
+ const tagId = "@kasenri/dsh-orbit/OrbitModelSelect.module.css";
92
+ if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
93
+ const tag = document.createElement("style");
94
+ tag.dataset.plugin = "@kasenri/dsh-orbit";
95
+ tag.dataset.pluginCss = tagId;
96
+ tag.textContent = css;
97
+ document.head.appendChild(tag);
98
+ }
99
+ var OrbitModelSelect_module_css_default = {
100
+ "rowValue": "f77nca_rowValue",
101
+ "rowValueActive": "f77nca_rowValueActive",
102
+ "row": "f77nca_row",
103
+ "hint": "f77nca_hint",
104
+ "title": "f77nca_title",
105
+ "group": "f77nca_group",
106
+ "chevron": "f77nca_chevron",
107
+ "error": "f77nca_error",
108
+ "panel": "f77nca_panel",
109
+ "back": "f77nca_back",
110
+ "rowLabel": "f77nca_rowLabel",
111
+ "rowDetail": "f77nca_rowDetail",
112
+ "check": "f77nca_check",
113
+ "separator": "f77nca_separator"
114
+ };
115
+ //#endregion
116
+ //#region client/OrbitModelSelect.tsx
117
+ /**
118
+ * OrbitModelSelect: the compact Orbit model control registered as a list entry
119
+ * before the native composer model seat.
120
+ *
121
+ * Root: Commander / Executor / Watchdog current values. Commander and Watchdog
122
+ * pick from the shared catalog and persist into the `orbit` settings
123
+ * namespace; the Executor picks through the SAME per-session ModelDirectory the
124
+ * native seat uses, so the two controls are one state.
125
+ */
126
+ const CHEVRON = "›";
127
+ const CARET = "▾";
128
+ const BACK = "‹";
129
+ /** Design cap for the panel; the anchored clamp only ever lowers it. */
130
+ const PANEL_MAX_HEIGHT = 420;
131
+ /**
132
+ * Hidden but laid-out first paint: the panel must be measurable before the
133
+ * anchored position is known, otherwise it would be placed with height 0 and
134
+ * grow downward off the trigger.
135
+ */
136
+ const MEASURE_STYLE = {
137
+ visibility: "hidden",
138
+ left: 0,
139
+ top: 0
140
+ };
141
+ /**
142
+ * Render the Orbit model control.
143
+ * @param props - injected directory/settings faces plus the locale seat.
144
+ * @returns the trigger and, while open, the panel.
145
+ */
146
+ function OrbitModelSelect({ t, available, directory, settings, loadModels, selectModel, writeRole, reloadSettings }) {
147
+ const dir = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot());
148
+ const config = (0, react.useSyncExternalStore)((listener) => settings.subscribe(listener), () => settings.getSnapshot());
149
+ const [open, setOpen] = (0, react.useState)(false);
150
+ const [pane, setPane] = (0, react.useState)({ kind: "root" });
151
+ const [busy, setBusy] = (0, react.useState)(false);
152
+ const triggerRef = (0, react.useRef)(null);
153
+ const panelRef = (0, react.useRef)(null);
154
+ const position = (0, _deepseek_ai_dsh_client_ui_primitives.useAnchoredPosition)({
155
+ open,
156
+ anchorRef: triggerRef,
157
+ panelRef,
158
+ side: "top",
159
+ gap: 8,
160
+ margin: 12
161
+ });
162
+ const maxHeight = (0, _deepseek_ai_dsh_client_ui_primitives.useAnchoredMaxHeight)(panelRef, PANEL_MAX_HEIGHT, position);
163
+ (0, _deepseek_ai_dsh_client_ui_primitives.useDismissOnOutsidePointer)(triggerRef, open, setOpen, panelRef);
164
+ (0, react.useEffect)(() => {
165
+ if (open) loadModels();
166
+ }, [open, loadModels]);
167
+ (0, react.useEffect)(() => {
168
+ if (!open) setPane({ kind: "root" });
169
+ }, [open]);
170
+ if (!available) return null;
171
+ const commanderRoute = config.commander;
172
+ const commanderModel = modelOf(dir, commanderRoute);
173
+ const commanderLabel = commanderRoute === void 0 ? t("triggerFallback") : routeLabelOf(dir, commanderRoute) ?? commanderRoute.model;
174
+ const commanderEffort = effortLabelOf(commanderModel, commanderRoute?.reasoningEffort);
175
+ const executorRoute = dir.current === null ? void 0 : {
176
+ provider: dir.current.provider,
177
+ model: dir.current.model,
178
+ ...dir.current.reasoningEffort === void 0 ? {} : { reasoningEffort: dir.current.reasoningEffort }
179
+ };
180
+ const executorModel = modelOf(dir, executorRoute);
181
+ const executorLabel = executorRoute === void 0 ? void 0 : routeLabelOf(dir, executorRoute) ?? executorRoute.model;
182
+ const executorEffort = effortLabelOf(executorModel, executorRoute?.reasoningEffort);
183
+ const watchdogRoute = config.watchdog;
184
+ const watchdogModel = modelOf(dir, watchdogRoute);
185
+ const watchdogLabel = watchdogRoute === void 0 ? void 0 : routeLabelOf(dir, watchdogRoute) ?? watchdogRoute.model;
186
+ const watchdogEffort = effortLabelOf(watchdogModel, watchdogRoute?.reasoningEffort);
187
+ const commitRole = async (role, route) => {
188
+ setBusy(true);
189
+ const ok = await writeRole(role, route);
190
+ setBusy(false);
191
+ if (ok) setOpen(false);
192
+ };
193
+ const commitExecutor = async (selection) => {
194
+ setBusy(true);
195
+ const ok = await selectModel(selection);
196
+ setBusy(false);
197
+ if (ok) setOpen(false);
198
+ };
199
+ const currentRouteOf = (role) => role === "commander" ? config.commander : role === "watchdog" ? config.watchdog : executorRoute;
200
+ const modelRow = (role, provider, providerName, model) => {
201
+ const current = currentRouteOf(role);
202
+ const active = current?.provider === provider && current.model === model.id;
203
+ const reasoning = model.reasoning;
204
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
205
+ type: "button",
206
+ role: "menuitem",
207
+ className: OrbitModelSelect_module_css_default.row,
208
+ disabled: busy,
209
+ onClick: () => {
210
+ if (reasoning !== void 0 && reasoning.efforts.length > 0) {
211
+ const effort = active ? current?.reasoningEffort ?? reasoning.defaultEffort : reasoning.defaultEffort;
212
+ setPane({
213
+ kind: "efforts",
214
+ role,
215
+ provider,
216
+ modelId: model.id,
217
+ effort
218
+ });
219
+ return;
220
+ }
221
+ if (role === "executor") {
222
+ commitExecutor(selectionForModel(dir, provider, model));
223
+ return;
224
+ }
225
+ commitRole(role, routeForModel(provider, model));
226
+ },
227
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
228
+ className: OrbitModelSelect_module_css_default.rowLabel,
229
+ children: [model.name, /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
230
+ className: OrbitModelSelect_module_css_default.rowDetail,
231
+ children: [" ", providerName]
232
+ })]
233
+ }), active ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
234
+ className: OrbitModelSelect_module_css_default.check,
235
+ children: "✓"
236
+ }) : null]
237
+ }, `${provider}/${model.id}`);
238
+ };
239
+ const effortRow = (role, provider, modelId, id, label, effort, currentEffort) => {
240
+ const healthy = pane.kind === "efforts" ? pane.effort : currentEffort;
241
+ const active = id === "provider-default" ? healthy === void 0 : healthy === effort;
242
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
243
+ type: "button",
244
+ role: "menuitem",
245
+ className: OrbitModelSelect_module_css_default.row,
246
+ disabled: busy,
247
+ onClick: () => {
248
+ if (role === "executor") {
249
+ commitExecutor({
250
+ provider,
251
+ model: modelId,
252
+ ...effort === void 0 ? {} : { reasoningEffort: effort }
253
+ });
254
+ return;
255
+ }
256
+ commitRole(role, {
257
+ provider,
258
+ model: modelId,
259
+ ...effort === void 0 ? {} : { reasoningEffort: effort }
260
+ });
261
+ },
262
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
263
+ className: OrbitModelSelect_module_css_default.rowLabel,
264
+ children: label
265
+ }), active ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
266
+ className: OrbitModelSelect_module_css_default.check,
267
+ children: "✓"
268
+ }) : null]
269
+ }, id);
270
+ };
271
+ const settingsError = config.error;
272
+ const modelError = dir.status === "error" ? dir.error ?? t("loadFailed") : void 0;
273
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
274
+ ref: triggerRef,
275
+ style: { display: "inline-flex" },
276
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_deepseek_ai_dsh_client_ui_primitives.Button, {
277
+ variant: "ghost",
278
+ size: "sm",
279
+ title: t("tooltip"),
280
+ disabled: busy,
281
+ onClick: () => {
282
+ setOpen((value) => !value);
283
+ },
284
+ children: [
285
+ commanderLabel,
286
+ commanderEffort === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
287
+ style: { color: "var(--dsw-alias-label-tertiary)" },
288
+ children: ` ${commanderEffort}`
289
+ }),
290
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
291
+ className: OrbitModelSelect_module_css_default.chevron,
292
+ children: CARET
293
+ })
294
+ ]
295
+ })
296
+ }), open ? (0, react_dom.createPortal)(/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
297
+ ref: panelRef,
298
+ className: OrbitModelSelect_module_css_default.panel,
299
+ style: {
300
+ ...position ?? MEASURE_STYLE,
301
+ maxHeight
302
+ },
303
+ role: "menu",
304
+ children: [
305
+ pane.kind !== "root" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
306
+ type: "button",
307
+ className: OrbitModelSelect_module_css_default.back,
308
+ onClick: () => {
309
+ setPane({ kind: "root" });
310
+ },
311
+ children: `${BACK} ${t("back")}`
312
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
313
+ className: OrbitModelSelect_module_css_default.title,
314
+ children: t("title")
315
+ }),
316
+ settingsError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
317
+ className: OrbitModelSelect_module_css_default.error,
318
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: `${t("settingsFailed")}: ${settingsError}` }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
319
+ variant: "outline",
320
+ size: "sm",
321
+ onClick: () => {
322
+ reloadSettings();
323
+ },
324
+ children: t("retry")
325
+ })]
326
+ }),
327
+ modelError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
328
+ className: OrbitModelSelect_module_css_default.error,
329
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: modelError }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
330
+ variant: "outline",
331
+ size: "sm",
332
+ onClick: () => {
333
+ loadModels();
334
+ },
335
+ children: t("retry")
336
+ })]
337
+ }),
338
+ pane.kind === "root" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
339
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
340
+ type: "button",
341
+ role: "menuitem",
342
+ className: OrbitModelSelect_module_css_default.row,
343
+ disabled: busy,
344
+ onClick: () => {
345
+ setPane({
346
+ kind: "models",
347
+ role: "commander"
348
+ });
349
+ },
350
+ children: [
351
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
352
+ className: OrbitModelSelect_module_css_default.rowLabel,
353
+ children: t("commander")
354
+ }),
355
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
356
+ className: OrbitModelSelect_module_css_default.rowValue,
357
+ children: [commanderLabel, commanderEffort === void 0 ? "" : ` · ${commanderEffort}`]
358
+ }),
359
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
360
+ className: OrbitModelSelect_module_css_default.chevron,
361
+ children: CHEVRON
362
+ })
363
+ ]
364
+ }),
365
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
366
+ type: "button",
367
+ role: "menuitem",
368
+ className: OrbitModelSelect_module_css_default.row,
369
+ disabled: busy,
370
+ onClick: () => {
371
+ setPane({
372
+ kind: "models",
373
+ role: "executor"
374
+ });
375
+ },
376
+ children: [
377
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
378
+ className: OrbitModelSelect_module_css_default.rowLabel,
379
+ children: t("executor")
380
+ }),
381
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
382
+ className: OrbitModelSelect_module_css_default.rowValue,
383
+ children: [executorLabel ?? t("triggerFallback"), executorEffort === void 0 ? "" : ` · ${executorEffort}`]
384
+ }),
385
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
386
+ className: OrbitModelSelect_module_css_default.rowDetail,
387
+ children: t("followsSession")
388
+ }),
389
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
390
+ className: OrbitModelSelect_module_css_default.chevron,
391
+ children: CHEVRON
392
+ })
393
+ ]
394
+ }),
395
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
396
+ type: "button",
397
+ role: "menuitem",
398
+ className: OrbitModelSelect_module_css_default.row,
399
+ disabled: busy,
400
+ onClick: () => {
401
+ setPane({
402
+ kind: "models",
403
+ role: "watchdog"
404
+ });
405
+ },
406
+ children: [
407
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
408
+ className: OrbitModelSelect_module_css_default.rowLabel,
409
+ children: t("watchdog")
410
+ }),
411
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
412
+ className: OrbitModelSelect_module_css_default.rowValue,
413
+ children: [watchdogLabel ?? t("triggerFallback"), watchdogEffort === void 0 ? "" : ` · ${watchdogEffort}`]
414
+ }),
415
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
416
+ className: OrbitModelSelect_module_css_default.chevron,
417
+ children: CHEVRON
418
+ })
419
+ ]
420
+ })
421
+ ] }) : null,
422
+ pane.kind === "models" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
423
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
424
+ className: OrbitModelSelect_module_css_default.group,
425
+ children: `${t(pane.role)} · ${t("models")}`
426
+ }),
427
+ dir.groups.map((group) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
428
+ className: OrbitModelSelect_module_css_default.group,
429
+ children: group.name
430
+ }), group.models.map((model) => modelRow(pane.role, group.id, group.name, model))] }, group.id)),
431
+ dir.failures.map((failure) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
432
+ className: OrbitModelSelect_module_css_default.error,
433
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: `${failure.name}: ${failure.message}` })
434
+ }, failure.id))
435
+ ] }) : null,
436
+ pane.kind === "efforts" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
437
+ className: OrbitModelSelect_module_css_default.group,
438
+ children: `${t(pane.role)} · ${t("effort")}`
439
+ }), effortChoicesOf((() => {
440
+ for (const group of dir.groups) {
441
+ if (group.id !== pane.provider) continue;
442
+ for (const model of group.models) if (model.id === pane.modelId) return model;
443
+ }
444
+ })(), t("providerDefault")).map((choice) => effortRow(pane.role, pane.provider, pane.modelId, choice.id, choice.label, choice.effort, pane.effort))] }) : null,
445
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: OrbitModelSelect_module_css_default.separator }),
446
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
447
+ className: OrbitModelSelect_module_css_default.hint,
448
+ children: t("nextRunOnly")
449
+ })
450
+ ]
451
+ }), document.body) : null] });
452
+ }
453
+ //#endregion
454
+ //#region client/locales.ts
455
+ const NS = "orbit-model";
456
+ /** English strings (the key-set source of truth for this pair). */
457
+ const en = {
458
+ triggerFallback: "Orbit",
459
+ tooltip: "Orbit model configuration",
460
+ title: "Orbit",
461
+ commander: "Commander",
462
+ executor: "Executor",
463
+ watchdog: "Watchdog",
464
+ followsSession: "Follows current session model",
465
+ models: "Models",
466
+ effort: "Reasoning effort",
467
+ providerDefault: "Provider default",
468
+ back: "Back",
469
+ retry: "Retry",
470
+ loadFailed: "Failed to load models",
471
+ settingsFailed: "Failed to load Orbit settings",
472
+ saveFailed: "Failed to save Orbit settings",
473
+ nextRunOnly: "Changes apply to the next Orbit run"
474
+ };
475
+ /** Chinese strings. */
476
+ const zh = {
477
+ triggerFallback: "Orbit",
478
+ tooltip: "Orbit 模型配置",
479
+ title: "Orbit",
480
+ commander: "指挥官",
481
+ executor: "执行员",
482
+ watchdog: "监控模型",
483
+ followsSession: "跟随当前会话模型",
484
+ models: "模型",
485
+ effort: "推理强度",
486
+ providerDefault: "提供方默认",
487
+ back: "返回",
488
+ retry: "重试",
489
+ loadFailed: "模型列表加载失败",
490
+ settingsFailed: "Orbit 设置加载失败",
491
+ saveFailed: "Orbit 设置保存失败",
492
+ nextRunOnly: "更改应用于下一个新的 Orbit 运行"
493
+ };
494
+ //#endregion
495
+ //#region client/index.ts
496
+ /** The host settings namespace Orbit registers for its own two roles. */
497
+ const ORBIT_SETTINGS_NS = "orbit";
498
+ /** Required client services: slots, the shared model directory, Remote (settings namespace), and locale. */
499
+ const inject = [
500
+ "slots",
501
+ "modelDirectories",
502
+ "remote",
503
+ "remote.settings",
504
+ "locale"
505
+ ];
506
+ /**
507
+ * Mount the Orbit model control over `ctx.modelDirectories` and the `orbit`
508
+ * settings namespace.
509
+ * @param ctx - client root context.
510
+ */
511
+ function apply(ctx) {
512
+ ctx.effect(() => ctx.locale.register(NS, {
513
+ zh,
514
+ en
515
+ }), "dsh-orbit: model control dictionaries");
516
+ const settings = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({ status: "loading" });
517
+ const adoptView = (view) => {
518
+ const value = view.value;
519
+ settings.set({
520
+ status: "ready",
521
+ commander: routeFromSettingsValue(value?.commander),
522
+ watchdog: routeFromSettingsValue(value?.watchdog),
523
+ revision: view.revision
524
+ });
525
+ };
526
+ const reloadSettings = () => {
527
+ (async () => {
528
+ settings.update((draft) => {
529
+ draft.status = "loading";
530
+ });
531
+ try {
532
+ const response = await ctx.remote.settings.describe();
533
+ if (!response.ok) {
534
+ settings.update((draft) => {
535
+ draft.status = "error";
536
+ draft.error = response.error.message;
537
+ });
538
+ return;
539
+ }
540
+ const view = response.value.namespaces.find((entry) => entry.ns === ORBIT_SETTINGS_NS);
541
+ if (view === void 0) {
542
+ settings.update((draft) => {
543
+ draft.status = "error";
544
+ draft.error = `settings namespace "${ORBIT_SETTINGS_NS}" is not registered`;
545
+ });
546
+ return;
547
+ }
548
+ adoptView(view);
549
+ } catch (error) {
550
+ settings.update((draft) => {
551
+ draft.status = "error";
552
+ draft.error = error instanceof Error ? error.message : String(error);
553
+ });
554
+ }
555
+ })();
556
+ };
557
+ ctx.effect(() => {
558
+ reloadSettings();
559
+ return ctx.remote.$on("settings/document-updated", () => {
560
+ reloadSettings();
561
+ });
562
+ }, "dsh-orbit: settings mirror");
563
+ const writeRole = async (role, route) => {
564
+ const snapshot = settings.getSnapshot();
565
+ try {
566
+ const response = await ctx.remote.settings.update(ORBIT_SETTINGS_NS, { [role]: {
567
+ provider: route.provider,
568
+ model: route.model,
569
+ reasoningEffort: route.reasoningEffort ?? ""
570
+ } }, snapshot.revision);
571
+ if (!response.ok) {
572
+ settings.update((draft) => {
573
+ draft.error = response.error.message;
574
+ });
575
+ reloadSettings();
576
+ return false;
577
+ }
578
+ adoptView(response.value);
579
+ return true;
580
+ } catch (error) {
581
+ settings.update((draft) => {
582
+ draft.error = error instanceof Error ? error.message : String(error);
583
+ });
584
+ reloadSettings();
585
+ return false;
586
+ }
587
+ };
588
+ ctx.inject([
589
+ "slots",
590
+ "modelDirectories",
591
+ "sessions"
592
+ ], (scope) => {
593
+ const models = scope.modelDirectories;
594
+ const sessions = scope.sessions;
595
+ const injected = (sessionId) => {
596
+ const directory = models.directoryFor(sessionId);
597
+ const available = sessions.subagentAddress(sessionId) === void 0;
598
+ return {
599
+ available,
600
+ directory: directory.store,
601
+ settings,
602
+ loadModels: () => {
603
+ if (available) directory.load().catch(() => {});
604
+ },
605
+ selectModel: (selection) => available ? directory.select(selection).then(() => true, () => false) : Promise.resolve(false),
606
+ writeRole,
607
+ reloadSettings
608
+ };
609
+ };
610
+ scope.slots.inject("conversation.input.right", () => scope.slots.register({
611
+ name: "conversation.input.right",
612
+ id: "orbit-model",
613
+ order: 10,
614
+ locale: NS,
615
+ inject: injected
616
+ }, OrbitModelSelect));
617
+ });
618
+ }
619
+ //#endregion
620
+ exports.ORBIT_SETTINGS_NS = ORBIT_SETTINGS_NS;
621
+ exports.apply = apply;
622
+ exports.inject = inject;
623
+ return module.exports;
624
+ }
625
+ });