@kasenri/dsh-orbit 0.5.9 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,10 +3,12 @@
3
3
  Community plugin for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH).
4
4
  Not affiliated with or endorsed by DeepSeek.
5
5
 
6
+ **让 AI 项目可以在无人监管下持续推进。**
7
+ Orbit 会自动规划任务、分工执行、逐步检查并继续完成后续工作;不同环节可以使用不同模型,让低成本模型承担执行任务、强模型负责规划和审核,从而降低整体 AI 使用成本。Watchdog 还会监控运行异常,在任务卡死或中断时协助恢复。
8
+
6
9
  **Orbit — Deterministic Engineering Orchestration for DeepSeek Harness**
7
10
 
8
- Orbit is a deterministic engineering orchestration runtime for DSH, implemented
9
- as a Cordis plugin:
11
+ Technical integration:
10
12
 
11
13
  - an `OrbitService` on `ctx.orbit`
12
14
  - a model-facing `orbit_controller` tool (`cx_controller` remains a legacy alias)
@@ -42,6 +44,7 @@ Executor, Smart Watchdog, durable state and bounded recovery.
42
44
  |---|---|
43
45
  | `@deepseek-ai/dsh` | `0.1.5-rc.2` |
44
46
  | `@deepseek-ai/cordis` | `4.0.2` |
47
+ | `@goodandready/dsh-moa`(可选 MoA 集成) | `0.2.19` |
45
48
  | Node.js | `>= 22.19.0` |
46
49
 
47
50
  Requires the DSH base services: `agents`, `subagents`, `tools`, `sessions`
@@ -54,6 +57,10 @@ mirror remains available when a Git source is preferred:
54
57
 
55
58
  ```bash
56
59
  dsh plugin --profile web add @kasenri/dsh-orbit
60
+
61
+ # 可选:为 Orbit 的关键步骤启用多候选 MoA 选优
62
+ dsh plugin --profile web add @goodandready/dsh-moa@0.2.19
63
+
57
64
  # Git source alternative, tracks the mirror repository HEAD:
58
65
  # dsh plugin --profile web add github:KasenRi/dsh-orbit
59
66
  ```
@@ -110,9 +117,10 @@ provider/model provenance. The parent model and parent tools remain bypassed.
110
117
 
111
118
  ## Model configuration (Web)
112
119
 
113
- The Orbit model control sits immediately left of the native composer model
114
- seat (`conversation.input.right` renders before `conversation.input.model`).
115
- Its button names the Commander's model; the menu edits three roles:
120
+ The Orbit model control is the final entry in `conversation.input.right`, so
121
+ other composer-side controls (for example DSH's rollback control) stay to its
122
+ left while the native `conversation.input.model` seat stays immediately to its
123
+ right. Its button names the Commander's model; the menu edits three roles:
116
124
 
117
125
  - **Commander** and **Watchdog** pick from the same native model catalog and
118
126
  persist into the DSH `orbit` settings namespace (`settings.yaml`). Picking a
@@ -131,6 +139,40 @@ Commander/Watchdog use settings then explicit config; Executor uses the Session
131
139
  selection, with explicit config only when there is no Session. Missing or
132
140
  unavailable roles block creation of a Run before any child starts.
133
141
 
142
+ ### Optional MoA execution mode (v0.6.0)
143
+
144
+ Orbit 可以把少量高不确定性步骤标记为 `execution_mode: "MOA"`。这不是新的顶层 Supervisor,也不会把状态机交给 MoA:
145
+
146
+ ```text
147
+ Commander PLAN
148
+
149
+ SINGLE ─────────────→ Executor
150
+ \
151
+ MOA → Candidate 1 ─┐
152
+ Candidate 2 ─┼→ Judge → Orbit controlled promotion → Executor verification
153
+ Candidate 3 ─┘
154
+
155
+ Commander STEP_EVALUATE
156
+ ```
157
+
158
+ 关键边界:
159
+
160
+ - Candidate 和 Judge 都是**零工具**的一次性模型调用,不能直接 `write/edit/bash/subagent`。
161
+ - 候选文件只写入 `.cx/moa/<run>/<step>/candidate-N/`,普通 Executor 不能修改 `.cx`。
162
+ - Judge 只负责在已有候选中做相对选择,必须返回 `WINNER_CANDIDATE_INDEX`;它不能决定 `PASS_CURRENT_STEP`,也不能生成新的综合实现。
163
+ - 胜出候选由 Orbit Supervisor 确定性提升到项目目录;之后仍由 Executor 运行真实测试,最后由 Commander 做绝对验收。
164
+ - 整个 MoA Step 只消耗一个 Orbit loop;候选和 Judge 的内部调用受独立的候选数和 `maxMoaSteps` 限制。
165
+ - 候选数固定为 2–4;至少需要 2 个成功候选。失败不会偷偷回退成单 Executor,也不会自动换 Judge 模型。
166
+ - `peerCritique` 默认关闭;开启时只允许一轮有界互评。
167
+ - 新 Run 会冻结 Candidate/Judge 的 provider、model、reasoningEffort、MoA policy,以及原版 MoA settings 中用户显式配置的价格表(如果存在)。中途修改 UI 只影响下一次 Run。
168
+ - Candidate/Judge 的 input/output/cache Token 来自 DSH 子 Session 的真实 `assistant/message.usage`;如果冻结的价格表能匹配对应 Route,同时记录美元成本;没有价格时只展示 Token,并明确标记无法计算成本,不猜价格。
169
+ - Orbit 会把一个不含目标正文、候选正文、Judge 推理或代码的有界运行快照写进所属 DSH Session projection。Web UI 可显示当前 Step、MoA 阶段、各候选模型/成败、Token、Judge、winner 和总计,刷新/重连后仍可恢复。
170
+ - 冷恢复按 durable phase 继续:`JUDGE` 不重跑 Candidate,`SELECTED` 不重跑 Candidate/Judge,`PROMOTED` 不重跑 Candidate/Judge/Promotion。
171
+ - Orbit ACTIVE 时会在下游 hook 之前阻止独立 `/moa`,避免原版 MoA 的自动 Promotion 与 Orbit 同时争夺 workspace。
172
+ - `@goodandready/dsh-moa` 是可选依赖;未安装时普通 SINGLE 模式完全不受影响。
173
+
174
+ 当前兼容层针对 `@goodandready/dsh-moa@0.2.19`。Orbit 只依赖它公开的项目上下文接口;候选调度、Judge、持久化与 Promotion 权限均由 `moa-adapter.ts` 封装。未来 MoA 提供正式 integration/manual-promotion API 时,只需替换该适配层。
175
+
134
176
  ## State machine
135
177
 
136
178
  ```text
@@ -143,6 +185,11 @@ PLAN → EXECUTE → EVALUATE → SUCCESS
143
185
  ```
144
186
 
145
187
  - Only a normally completed Executor step consumes one loop from the budget.
188
+ - Runs without an explicit user/tool budget start from the historical floor of
189
+ 5 loops; after PLAN, Orbit deterministically reserves two extra bounded slots
190
+ beyond the accepted base plan (`max(5, steps + 2)`, therefore at most 7 for
191
+ the 1–5-step plan schema). Explicit `approved_loop_count` / `max_loops`
192
+ values are never enlarged automatically.
146
193
  - Corrections are limited per base step and reserve budget for the remaining
147
194
  planned steps.
148
195
  - Commander decisions are validated in code (`PASS_CURRENT_STEP` /
@@ -182,6 +229,13 @@ PLAN → EXECUTE → EVALUATE → SUCCESS
182
229
  | `routes.commander` | none | Explicit profile fallback; normally user-selected in Orbit settings. |
183
230
  | `routes.executor` | none | Explicit config only without a Session; otherwise follows DSH Session selection. |
184
231
  | `routes.watchdog` | none | Explicit profile fallback; normally user-selected in Orbit settings. |
232
+ | `moa.enabled` | `false` | 允许 Commander 为关键步骤选择 `MOA` 执行模式。 |
233
+ | `moa.candidateCount` | `3` | 固定候选数量,运行时只允许 2–4。 |
234
+ | `moa.candidates` | none | 用户显式选择的 Candidate routes;不会从 Executor 猜测或继承。 |
235
+ | `moa.judge` | none | 用户显式选择的 Judge route。 |
236
+ | `moa.peerCritique` | `false` | 是否启用一轮有界候选互评。 |
237
+ | `moa.maxMoaSteps` | `2` | 一个 Run 最多允许的 MoA 步骤数(上限受 1–5 步 Plan 约束)。 |
238
+ | MoA prices | none | 若 `dsh-moa` settings 已配置 `prices`,Orbit 在新 Run 冻结该表并据真实 Token 计算成本;否则不估价。 |
185
239
  | `executorTools` | read/read_image/glob/grep | Base read-only subset; mutation tools require Step capabilities. |
186
240
  | `browserTools` | `["agent_browser"]` | Browser capability tool names. |
187
241
  | `commanderReadOnlyTools` | read/glob/grep/web… | Commander allowlist. |
@@ -216,7 +270,7 @@ dsh plugin --profile web add github:KasenRi/dsh-orbit
216
270
  | CX mode | Orbit mode (`orbit模式`; `cx模式` still works) |
217
271
  | `ctx.cx` | `ctx.orbit` (same `OrbitService` instance; `ctx.cx` remains an alias) |
218
272
 
219
- - `.cx/state.json` remains unchanged.
273
+ - `.cx/state.json` 路径保持不变;v0.6.0 写入 schema 3,旧 schema 2 状态可继续读取,并在下一次正常持久化时升级。
220
274
  - Legacy `cx模式` remains supported.
221
275
  - Existing durable runs do not need migration: Orbit reads the same
222
276
  `.cx/state.json`, including historical `CX_*` error strings.
package/lib/activation.js CHANGED
@@ -118,6 +118,13 @@ export function registerOrbitToggleCommand(ctx) {
118
118
  export function installOrbitGestureBoundary(ctx, options = {}) {
119
119
  ctx.on('agent/pre-step', async (payload, next) => {
120
120
  const { agent, messages, signal } = payload;
121
+ const blocked = options.competingMutationBlock?.(agent, messages);
122
+ if (blocked !== undefined) {
123
+ for (const message of messages)
124
+ agent.session.append('user/message', message, { surfaceOp: 'append' });
125
+ options.onBlocked?.(agent, blocked);
126
+ return { kind: 'enter', messages: [] };
127
+ }
121
128
  const decision = await next();
122
129
  if (decision.kind === 'reject')
123
130
  return decision;
package/lib/client.js CHANGED
@@ -83,7 +83,7 @@ window.__ModuleLoader__.load({
83
83
  };
84
84
  }
85
85
  //#endregion
86
- //#region \0dsh-css:/root/code/dsh-pi-parity/packages/orbit/client/OrbitModelSelect.module.css.mjs
86
+ //#region \0dsh-css:/root/.devspace/worktrees/dsh-pi-parity-b411f55f/packages/orbit/client/OrbitModelSelect.module.css.mjs
87
87
  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);text-overflow:ellipsis;white-space:nowrap;padding:6px 8px 2px;font-size:11px;overflow:hidden}.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_switchRow{align-items:center;gap:8px;padding:4px 8px 6px;display:flex}.f77nca_switchControl{margin-left:auto}.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}";
88
88
  const tagId = "@kasenri/dsh-orbit/OrbitModelSelect.module.css";
89
89
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
@@ -94,21 +94,21 @@ window.__ModuleLoader__.load({
94
94
  document.head.appendChild(tag);
95
95
  }
96
96
  var OrbitModelSelect_module_css_default = {
97
- "title": "f77nca_title",
98
- "panel": "f77nca_panel",
99
- "switchControl": "f77nca_switchControl",
97
+ "rowValueActive": "f77nca_rowValueActive",
100
98
  "error": "f77nca_error",
101
- "rowDetail": "f77nca_rowDetail",
102
- "chevron": "f77nca_chevron",
99
+ "rowValue": "f77nca_rowValue",
100
+ "switchRow": "f77nca_switchRow",
101
+ "check": "f77nca_check",
103
102
  "group": "f77nca_group",
103
+ "panel": "f77nca_panel",
104
104
  "row": "f77nca_row",
105
- "switchRow": "f77nca_switchRow",
106
- "hint": "f77nca_hint",
107
- "rowValueActive": "f77nca_rowValueActive",
108
- "rowValue": "f77nca_rowValue",
105
+ "title": "f77nca_title",
106
+ "switchControl": "f77nca_switchControl",
109
107
  "rowLabel": "f77nca_rowLabel",
110
- "check": "f77nca_check",
108
+ "rowDetail": "f77nca_rowDetail",
109
+ "chevron": "f77nca_chevron",
111
110
  "separator": "f77nca_separator",
111
+ "hint": "f77nca_hint",
112
112
  "back": "f77nca_back"
113
113
  };
114
114
  //#endregion
@@ -142,10 +142,11 @@ window.__ModuleLoader__.load({
142
142
  * @param props - injected directory/settings faces plus the locale seat.
143
143
  * @returns the trigger and, while open, the panel.
144
144
  */
145
- function OrbitModelSelect({ t, available, directory, settings, loadModels, selectModel, writeRole, setOrbitEnabled, reloadSettings, useProjection }) {
145
+ function OrbitModelSelect({ t, available, directory, settings, loadModels, selectModel, writeRole, writeMoaPolicy, setOrbitEnabled, reloadSettings, useProjection }) {
146
146
  const dir = (0, react.useSyncExternalStore)((listener) => directory.subscribe(listener), () => directory.getSnapshot());
147
147
  const config = (0, react.useSyncExternalStore)((listener) => settings.subscribe(listener), () => settings.getSnapshot());
148
148
  const orbitSession = useProjection("orbitSession");
149
+ const orbitRuntime = useProjection("orbitRuntime");
149
150
  const [orbitOverride, setOrbitOverride] = (0, react.useState)(null);
150
151
  const [orbitPending, setOrbitPending] = (0, react.useState)(false);
151
152
  const orbitEnabled = orbitOverride ?? orbitSession?.enabled === true;
@@ -198,6 +199,17 @@ window.__ModuleLoader__.load({
198
199
  const watchdogModel = modelOf(dir, watchdogRoute);
199
200
  const watchdogLabel = watchdogRoute === void 0 ? void 0 : routeLabelOf(dir, watchdogRoute) ?? watchdogRoute.model;
200
201
  const watchdogEffort = effortLabelOf(watchdogModel, watchdogRoute?.reasoningEffort);
202
+ const usageText = (usage) => {
203
+ if (!usage) return void 0;
204
+ const tokens = `${usage.total_tokens.toLocaleString()} ${t("moaTokens")}`;
205
+ return usage.cost_usd === void 0 ? tokens : `${tokens} · $${usage.cost_usd.toFixed(4)}`;
206
+ };
207
+ const moaRouteOf = (role) => {
208
+ if (role === "moa-judge") return config.moa.judge;
209
+ if (!role.startsWith("moa-candidate-")) return void 0;
210
+ const index = Number(role.slice(14)) - 1;
211
+ return Number.isInteger(index) ? config.moa.candidates[index] : void 0;
212
+ };
201
213
  const commitRole = async (role, route) => {
202
214
  if (submitting.current || config.status !== "ready") return;
203
215
  submitting.current = true;
@@ -209,6 +221,17 @@ window.__ModuleLoader__.load({
209
221
  setBusy(false);
210
222
  }
211
223
  };
224
+ const commitMoaPolicy = async (patch) => {
225
+ if (submitting.current || config.status !== "ready") return;
226
+ submitting.current = true;
227
+ setBusy(true);
228
+ try {
229
+ await writeMoaPolicy(patch);
230
+ } finally {
231
+ submitting.current = false;
232
+ setBusy(false);
233
+ }
234
+ };
212
235
  const commitExecutor = async (selection) => {
213
236
  if (submitting.current) return;
214
237
  submitting.current = true;
@@ -220,10 +243,34 @@ window.__ModuleLoader__.load({
220
243
  setBusy(false);
221
244
  }
222
245
  };
223
- const currentRouteOf = (role) => role === "commander" ? config.commander : role === "watchdog" ? config.watchdog : executorRoute;
224
- const roleLabelOf = (role) => role === "commander" ? commanderLabel : role === "watchdog" ? watchdogLabel : executorLabel;
225
- const roleModelLabelOf = (role) => t(role === "commander" ? "commanderModel" : role === "executor" ? "executorModel" : "watchdogModel");
226
- const roleEffortLabelOf = (role) => role === "commander" ? commanderEffort : role === "watchdog" ? watchdogEffort : executorEffort;
246
+ const currentRouteOf = (role) => role === "commander" ? config.commander : role === "watchdog" ? config.watchdog : role === "executor" ? executorRoute : moaRouteOf(role);
247
+ const roleLabelOf = (role) => {
248
+ const route = currentRouteOf(role);
249
+ if (role === "commander") return commanderLabel;
250
+ if (role === "watchdog") return watchdogLabel;
251
+ if (role === "executor") return executorLabel;
252
+ return route === void 0 ? void 0 : routeLabelOf(dir, route) ?? route.model;
253
+ };
254
+ const roleTitleOf = (role) => {
255
+ if (role === "commander") return t("commander");
256
+ if (role === "executor") return t("executor");
257
+ if (role === "watchdog") return t("watchdog");
258
+ if (role === "moa-judge") return t("moaJudge");
259
+ return `${t("moaCandidate")} ${role.slice(14)}`;
260
+ };
261
+ const roleModelLabelOf = (role) => {
262
+ if (role === "commander") return t("commanderModel");
263
+ if (role === "executor") return t("executorModel");
264
+ if (role === "watchdog") return t("watchdogModel");
265
+ return t("models");
266
+ };
267
+ const roleEffortLabelOf = (role) => {
268
+ if (role === "commander") return commanderEffort;
269
+ if (role === "watchdog") return watchdogEffort;
270
+ if (role === "executor") return executorEffort;
271
+ const route = moaRouteOf(role);
272
+ return effortLabelOf(modelOf(dir, route), route?.reasoningEffort);
273
+ };
227
274
  const commitEffort = async (role, route, effort) => {
228
275
  const next = {
229
276
  provider: route.provider,
@@ -312,7 +359,7 @@ window.__ModuleLoader__.load({
312
359
  role: pane.role
313
360
  });
314
361
  },
315
- children: `${BACK} ${pane.kind === "role" ? t("back") : t(pane.role)}`
362
+ children: `${BACK} ${pane.kind === "role" ? t("back") : roleTitleOf(pane.role)}`
316
363
  }),
317
364
  settingsError === void 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
318
365
  className: OrbitModelSelect_module_css_default.error,
@@ -353,6 +400,65 @@ window.__ModuleLoader__.load({
353
400
  })]
354
401
  }),
355
402
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: OrbitModelSelect_module_css_default.separator }),
403
+ orbitRuntime ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
404
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
405
+ className: OrbitModelSelect_module_css_default.group,
406
+ children: t("runtime")
407
+ }),
408
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
409
+ className: OrbitModelSelect_module_css_default.row,
410
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
411
+ className: OrbitModelSelect_module_css_default.rowLabel,
412
+ children: orbitRuntime.currentStep?.id ?? orbitRuntime.phase
413
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
414
+ className: OrbitModelSelect_module_css_default.rowValue,
415
+ children: [orbitRuntime.currentStep?.executionMode ?? orbitRuntime.phase, ` · ${orbitRuntime.loop.used}/${orbitRuntime.loop.max}`]
416
+ })]
417
+ }),
418
+ orbitRuntime.moa ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
419
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
420
+ className: OrbitModelSelect_module_css_default.row,
421
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
422
+ className: OrbitModelSelect_module_css_default.rowLabel,
423
+ children: t("moaRuntimePhase")
424
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
425
+ className: OrbitModelSelect_module_css_default.rowValue,
426
+ children: orbitRuntime.moa.phase
427
+ })]
428
+ }),
429
+ orbitRuntime.moa.candidates.map((candidate) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
430
+ className: OrbitModelSelect_module_css_default.row,
431
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
432
+ className: OrbitModelSelect_module_css_default.rowLabel,
433
+ children: `${t("moaCandidate")} ${candidate.index}`
434
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
435
+ className: OrbitModelSelect_module_css_default.rowValue,
436
+ children: [`${candidate.ok ? "✓" : "✗"} ${candidate.provider}/${candidate.model}`, usageText(candidate.usage) ? ` · ${usageText(candidate.usage)}` : ""]
437
+ })]
438
+ }, candidate.index)),
439
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
440
+ className: OrbitModelSelect_module_css_default.row,
441
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
442
+ className: OrbitModelSelect_module_css_default.rowLabel,
443
+ children: t("moaJudge")
444
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
445
+ className: OrbitModelSelect_module_css_default.rowValue,
446
+ children: orbitRuntime.moa.winnerModel ?? orbitRuntime.moa.judgeModel ?? t("moaWaiting")
447
+ })]
448
+ }),
449
+ orbitRuntime.moa.totalUsage ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
450
+ className: OrbitModelSelect_module_css_default.row,
451
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
452
+ className: OrbitModelSelect_module_css_default.rowLabel,
453
+ children: t("moaTotalUsage")
454
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
455
+ className: OrbitModelSelect_module_css_default.rowValue,
456
+ children: [usageText(orbitRuntime.moa.totalUsage), orbitRuntime.moa.totalUsage.cost_usd === void 0 ? ` · ${t("moaCostUnavailable")}` : ""]
457
+ })]
458
+ }) : null
459
+ ] }) : null,
460
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: OrbitModelSelect_module_css_default.separator })
461
+ ] }) : null,
356
462
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
357
463
  type: "button",
358
464
  role: "menuitem",
@@ -434,6 +540,124 @@ window.__ModuleLoader__.load({
434
540
  children: CHEVRON
435
541
  })
436
542
  ]
543
+ }),
544
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: OrbitModelSelect_module_css_default.separator }),
545
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
546
+ className: OrbitModelSelect_module_css_default.switchRow,
547
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
548
+ className: OrbitModelSelect_module_css_default.rowLabel,
549
+ children: t("moa")
550
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
551
+ className: OrbitModelSelect_module_css_default.switchControl,
552
+ checked: config.moa.enabled,
553
+ disabled: busy,
554
+ label: t("moaEnable"),
555
+ onChange: (next) => {
556
+ commitMoaPolicy({ enabled: next });
557
+ }
558
+ })]
559
+ }),
560
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
561
+ type: "button",
562
+ role: "menuitem",
563
+ className: OrbitModelSelect_module_css_default.row,
564
+ disabled: busy,
565
+ onClick: () => {
566
+ commitMoaPolicy({ candidateCount: config.moa.candidateCount >= 4 ? 2 : config.moa.candidateCount + 1 });
567
+ },
568
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
569
+ className: OrbitModelSelect_module_css_default.rowLabel,
570
+ children: t("moaCandidateCount")
571
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
572
+ className: OrbitModelSelect_module_css_default.rowValue,
573
+ children: config.moa.candidateCount
574
+ })]
575
+ }),
576
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
577
+ className: OrbitModelSelect_module_css_default.switchRow,
578
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
579
+ className: OrbitModelSelect_module_css_default.rowLabel,
580
+ children: t("moaPeerCritique")
581
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
582
+ className: OrbitModelSelect_module_css_default.switchControl,
583
+ checked: config.moa.peerCritique,
584
+ disabled: busy,
585
+ label: t("moaPeerCritique"),
586
+ onChange: (next) => {
587
+ commitMoaPolicy({ peerCritique: next });
588
+ }
589
+ })]
590
+ }),
591
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
592
+ type: "button",
593
+ role: "menuitem",
594
+ className: OrbitModelSelect_module_css_default.row,
595
+ disabled: busy,
596
+ onClick: () => {
597
+ commitMoaPolicy({ maxMoaSteps: config.moa.maxMoaSteps >= 5 ? 1 : config.moa.maxMoaSteps + 1 });
598
+ },
599
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
600
+ className: OrbitModelSelect_module_css_default.rowLabel,
601
+ children: t("moaMaxSteps")
602
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
603
+ className: OrbitModelSelect_module_css_default.rowValue,
604
+ children: config.moa.maxMoaSteps
605
+ })]
606
+ }),
607
+ Array.from({ length: config.moa.candidateCount }, (_, offset) => {
608
+ const role = `moa-candidate-${offset + 1}`;
609
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
610
+ type: "button",
611
+ role: "menuitem",
612
+ className: OrbitModelSelect_module_css_default.row,
613
+ disabled: busy,
614
+ onClick: () => {
615
+ setPane({
616
+ kind: "role",
617
+ role
618
+ });
619
+ },
620
+ children: [
621
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
622
+ className: OrbitModelSelect_module_css_default.rowLabel,
623
+ children: `${t("moaCandidate")} ${offset + 1}`
624
+ }),
625
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
626
+ className: OrbitModelSelect_module_css_default.rowValue,
627
+ children: roleLabelOf(role) ?? t("triggerFallback")
628
+ }),
629
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
630
+ className: OrbitModelSelect_module_css_default.chevron,
631
+ children: CHEVRON
632
+ })
633
+ ]
634
+ }, role);
635
+ }),
636
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
637
+ type: "button",
638
+ role: "menuitem",
639
+ className: OrbitModelSelect_module_css_default.row,
640
+ disabled: busy,
641
+ onClick: () => {
642
+ setPane({
643
+ kind: "role",
644
+ role: "moa-judge"
645
+ });
646
+ },
647
+ children: [
648
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
649
+ className: OrbitModelSelect_module_css_default.rowLabel,
650
+ children: t("moaJudge")
651
+ }),
652
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
653
+ className: OrbitModelSelect_module_css_default.rowValue,
654
+ children: roleLabelOf("moa-judge") ?? t("triggerFallback")
655
+ }),
656
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
657
+ className: OrbitModelSelect_module_css_default.chevron,
658
+ children: CHEVRON
659
+ })
660
+ ]
437
661
  })
438
662
  ] }) : null,
439
663
  pane.kind === "role" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
@@ -552,6 +776,19 @@ window.__ModuleLoader__.load({
552
776
  commanderModel: "Commander model",
553
777
  executorModel: "Executor model",
554
778
  watchdogModel: "Watchdog model",
779
+ moa: "MoA",
780
+ moaEnable: "Enable MoA for eligible steps",
781
+ moaCandidate: "Candidate",
782
+ moaCandidateCount: "Candidate count",
783
+ moaJudge: "Judge",
784
+ moaPeerCritique: "Peer critique",
785
+ moaMaxSteps: "Max MoA steps per run",
786
+ runtime: "Current run",
787
+ moaRuntimePhase: "MoA phase",
788
+ moaTokens: "tokens",
789
+ moaTotalUsage: "MoA total",
790
+ moaCostUnavailable: "cost unavailable",
791
+ moaWaiting: "Waiting",
555
792
  followsSession: "Follows current session model",
556
793
  models: "Model",
557
794
  effort: "Reasoning effort",
@@ -577,6 +814,19 @@ window.__ModuleLoader__.load({
577
814
  commanderModel: "指挥官模型",
578
815
  executorModel: "执行员模型",
579
816
  watchdogModel: "监控模型",
817
+ moa: "MoA 多候选模式",
818
+ moaEnable: "允许关键步骤使用 MoA",
819
+ moaCandidate: "候选模型",
820
+ moaCandidateCount: "候选数量",
821
+ moaJudge: "Judge 评审模型",
822
+ moaPeerCritique: "候选互评",
823
+ moaMaxSteps: "每个 Run 最多 MoA 步骤",
824
+ runtime: "当前运行",
825
+ moaRuntimePhase: "MoA 阶段",
826
+ moaTokens: "Token",
827
+ moaTotalUsage: "MoA 总计",
828
+ moaCostUnavailable: "未配置价格,无法计算成本",
829
+ moaWaiting: "等待中",
580
830
  followsSession: "跟随当前会话模型",
581
831
  models: "模型",
582
832
  effort: "推理等级",
@@ -592,6 +842,13 @@ window.__ModuleLoader__.load({
592
842
  //#region client/index.ts
593
843
  /** The host settings namespace Orbit registers for its own two roles. */
594
844
  const ORBIT_SETTINGS_NS = "orbit";
845
+ /**
846
+ * Keep Orbit as the final list entry in `conversation.input.right`.
847
+ * DSH renders the whole right list before the named model seat, so this gives
848
+ * the stable local order: other right-side controls → Orbit → model selector.
849
+ */
850
+ const ORBIT_INPUT_RIGHT_PRIORITY = Number.MAX_SAFE_INTEGER;
851
+ const ORBIT_INPUT_RIGHT_ORDER = Number.MAX_SAFE_INTEGER;
595
852
  /** Required client services: slots, the shared model directory, Remote (settings namespace), and locale. */
596
853
  const inject = [
597
854
  "slots",
@@ -610,13 +867,33 @@ window.__ModuleLoader__.load({
610
867
  zh,
611
868
  en
612
869
  }), "dsh-orbit: model control dictionaries");
613
- const settings = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({ status: "loading" });
870
+ const settings = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
871
+ status: "loading",
872
+ moa: {
873
+ enabled: false,
874
+ candidateCount: 3,
875
+ peerCritique: false,
876
+ maxMoaSteps: 2,
877
+ candidates: []
878
+ }
879
+ });
614
880
  const adoptView = (view) => {
615
881
  const value = view.value;
882
+ const rawMoa = value?.moa;
883
+ const rawCandidates = Array.isArray(rawMoa?.["candidates"]) ? rawMoa?.["candidates"] : [];
884
+ const moa = {
885
+ enabled: rawMoa?.["enabled"] === true,
886
+ candidateCount: typeof rawMoa?.["candidateCount"] === "number" ? rawMoa["candidateCount"] : 3,
887
+ peerCritique: rawMoa?.["peerCritique"] === true,
888
+ maxMoaSteps: typeof rawMoa?.["maxMoaSteps"] === "number" ? rawMoa["maxMoaSteps"] : 2,
889
+ candidates: rawCandidates.map(routeFromSettingsValue).filter((route) => route !== void 0),
890
+ judge: routeFromSettingsValue(rawMoa?.["judge"])
891
+ };
616
892
  settings.set({
617
893
  status: "ready",
618
894
  commander: routeFromSettingsValue(value?.commander),
619
895
  watchdog: routeFromSettingsValue(value?.watchdog),
896
+ moa,
620
897
  revision: view.revision
621
898
  });
622
899
  };
@@ -657,15 +934,28 @@ window.__ModuleLoader__.load({
657
934
  reloadSettings();
658
935
  });
659
936
  }, "dsh-orbit: settings mirror");
660
- const writeRole = async (role, route) => {
937
+ const wireRoute = (route) => ({
938
+ provider: route.provider,
939
+ model: route.model,
940
+ reasoningEffort: route.reasoningEffort ?? ""
941
+ });
942
+ const moaWire = (moa) => ({
943
+ enabled: moa.enabled,
944
+ candidateCount: moa.candidateCount,
945
+ peerCritique: moa.peerCritique,
946
+ maxMoaSteps: moa.maxMoaSteps,
947
+ candidates: moa.candidates.map((route) => wireRoute(route)),
948
+ judge: moa.judge ? wireRoute(moa.judge) : {
949
+ provider: "",
950
+ model: "",
951
+ reasoningEffort: ""
952
+ }
953
+ });
954
+ const updateSettings = async (patch) => {
661
955
  const snapshot = settings.getSnapshot();
662
956
  if (snapshot.status !== "ready" || snapshot.revision === void 0) return false;
663
957
  try {
664
- const response = await ctx.remote.settings.update(ORBIT_SETTINGS_NS, { [role]: {
665
- provider: route.provider,
666
- model: route.model,
667
- reasoningEffort: route.reasoningEffort ?? ""
668
- } }, snapshot.revision);
958
+ const response = await ctx.remote.settings.update(ORBIT_SETTINGS_NS, patch, snapshot.revision);
669
959
  if (!response.ok) {
670
960
  settings.update((draft) => {
671
961
  draft.error = response.error.message;
@@ -683,6 +973,34 @@ window.__ModuleLoader__.load({
683
973
  return false;
684
974
  }
685
975
  };
976
+ const writeRole = async (role, route) => {
977
+ const snapshot = settings.getSnapshot();
978
+ if (role === "commander" || role === "watchdog") return updateSettings({ [role]: wireRoute(route) });
979
+ const nextMoa = {
980
+ ...snapshot.moa,
981
+ candidates: [...snapshot.moa.candidates]
982
+ };
983
+ if (role === "moa-judge") nextMoa.judge = route;
984
+ else {
985
+ const index = Number(role.slice(14)) - 1;
986
+ if (!Number.isInteger(index) || index < 0 || index > 3) return false;
987
+ while (nextMoa.candidates.length <= index) nextMoa.candidates.push({
988
+ provider: "",
989
+ model: ""
990
+ });
991
+ nextMoa.candidates[index] = route;
992
+ }
993
+ return updateSettings({ moa: moaWire(nextMoa) });
994
+ };
995
+ const writeMoaPolicy = async (patch) => {
996
+ const snapshot = settings.getSnapshot();
997
+ const nextMoa = {
998
+ ...snapshot.moa,
999
+ ...patch,
1000
+ candidates: [...snapshot.moa.candidates]
1001
+ };
1002
+ return updateSettings({ moa: moaWire(nextMoa) });
1003
+ };
686
1004
  ctx.inject([
687
1005
  "slots",
688
1006
  "modelDirectories",
@@ -702,6 +1020,7 @@ window.__ModuleLoader__.load({
702
1020
  },
703
1021
  selectModel: (selection) => available ? directory.select(selection).then(() => true, () => false) : Promise.resolve(false),
704
1022
  writeRole,
1023
+ writeMoaPolicy,
705
1024
  setOrbitEnabled: async (enabled) => {
706
1025
  const session = sessions.binding(sessionId)?.session;
707
1026
  if (session === void 0) return false;
@@ -718,13 +1037,16 @@ window.__ModuleLoader__.load({
718
1037
  scope.slots.inject("conversation.input.right", () => scope.slots.register({
719
1038
  name: "conversation.input.right",
720
1039
  id: "orbit-model",
721
- order: 10,
1040
+ priority: ORBIT_INPUT_RIGHT_PRIORITY,
1041
+ order: ORBIT_INPUT_RIGHT_ORDER,
722
1042
  locale: NS,
723
1043
  inject: injected
724
1044
  }, OrbitModelSelect));
725
1045
  });
726
1046
  }
727
1047
  //#endregion
1048
+ exports.ORBIT_INPUT_RIGHT_ORDER = ORBIT_INPUT_RIGHT_ORDER;
1049
+ exports.ORBIT_INPUT_RIGHT_PRIORITY = ORBIT_INPUT_RIGHT_PRIORITY;
728
1050
  exports.ORBIT_SETTINGS_NS = ORBIT_SETTINGS_NS;
729
1051
  exports.apply = apply;
730
1052
  exports.inject = inject;