@kasenri/dsh-orbit 0.5.10 → 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 +47 -1
- package/lib/activation.js +7 -0
- package/lib/client.js +337 -25
- package/lib/decisions.js +4 -0
- package/lib/dsh-host.js +47 -5
- package/lib/index.js +52 -3
- package/lib/kernel.js +67 -3
- package/lib/moa-adapter.js +434 -0
- package/lib/routes.js +28 -0
- package/lib/service.js +34 -3
- package/lib/session-state.js +151 -1
- package/lib/state-store.js +13 -6
- package/lib/supervisor.js +173 -16
- package/lib/types.js +5 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@ Executor, Smart Watchdog, durable state and bounded recovery.
|
|
|
44
44
|
|---|---|
|
|
45
45
|
| `@deepseek-ai/dsh` | `0.1.5-rc.2` |
|
|
46
46
|
| `@deepseek-ai/cordis` | `4.0.2` |
|
|
47
|
+
| `@goodandready/dsh-moa`(可选 MoA 集成) | `0.2.19` |
|
|
47
48
|
| Node.js | `>= 22.19.0` |
|
|
48
49
|
|
|
49
50
|
Requires the DSH base services: `agents`, `subagents`, `tools`, `sessions`
|
|
@@ -56,6 +57,10 @@ mirror remains available when a Git source is preferred:
|
|
|
56
57
|
|
|
57
58
|
```bash
|
|
58
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
|
+
|
|
59
64
|
# Git source alternative, tracks the mirror repository HEAD:
|
|
60
65
|
# dsh plugin --profile web add github:KasenRi/dsh-orbit
|
|
61
66
|
```
|
|
@@ -134,6 +139,40 @@ Commander/Watchdog use settings then explicit config; Executor uses the Session
|
|
|
134
139
|
selection, with explicit config only when there is no Session. Missing or
|
|
135
140
|
unavailable roles block creation of a Run before any child starts.
|
|
136
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
|
+
|
|
137
176
|
## State machine
|
|
138
177
|
|
|
139
178
|
```text
|
|
@@ -190,6 +229,13 @@ PLAN → EXECUTE → EVALUATE → SUCCESS
|
|
|
190
229
|
| `routes.commander` | none | Explicit profile fallback; normally user-selected in Orbit settings. |
|
|
191
230
|
| `routes.executor` | none | Explicit config only without a Session; otherwise follows DSH Session selection. |
|
|
192
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 计算成本;否则不估价。 |
|
|
193
239
|
| `executorTools` | read/read_image/glob/grep | Base read-only subset; mutation tools require Step capabilities. |
|
|
194
240
|
| `browserTools` | `["agent_browser"]` | Browser capability tool names. |
|
|
195
241
|
| `commanderReadOnlyTools` | read/glob/grep/web… | Commander allowlist. |
|
|
@@ -224,7 +270,7 @@ dsh plugin --profile web add github:KasenRi/dsh-orbit
|
|
|
224
270
|
| CX mode | Orbit mode (`orbit模式`; `cx模式` still works) |
|
|
225
271
|
| `ctx.cx` | `ctx.orbit` (same `OrbitService` instance; `ctx.cx` remains an alias) |
|
|
226
272
|
|
|
227
|
-
- `.cx/state.json`
|
|
273
|
+
- `.cx/state.json` 路径保持不变;v0.6.0 写入 schema 3,旧 schema 2 状态可继续读取,并在下一次正常持久化时升级。
|
|
228
274
|
- Legacy `cx模式` remains supported.
|
|
229
275
|
- Existing durable runs do not need migration: Orbit reads the same
|
|
230
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/
|
|
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,22 +94,22 @@ window.__ModuleLoader__.load({
|
|
|
94
94
|
document.head.appendChild(tag);
|
|
95
95
|
}
|
|
96
96
|
var OrbitModelSelect_module_css_default = {
|
|
97
|
+
"rowValueActive": "f77nca_rowValueActive",
|
|
98
|
+
"error": "f77nca_error",
|
|
99
|
+
"rowValue": "f77nca_rowValue",
|
|
100
|
+
"switchRow": "f77nca_switchRow",
|
|
97
101
|
"check": "f77nca_check",
|
|
98
|
-
"chevron": "f77nca_chevron",
|
|
99
|
-
"rowDetail": "f77nca_rowDetail",
|
|
100
|
-
"title": "f77nca_title",
|
|
101
|
-
"separator": "f77nca_separator",
|
|
102
|
-
"row": "f77nca_row",
|
|
103
102
|
"group": "f77nca_group",
|
|
104
103
|
"panel": "f77nca_panel",
|
|
104
|
+
"row": "f77nca_row",
|
|
105
|
+
"title": "f77nca_title",
|
|
106
|
+
"switchControl": "f77nca_switchControl",
|
|
105
107
|
"rowLabel": "f77nca_rowLabel",
|
|
106
|
-
"
|
|
108
|
+
"rowDetail": "f77nca_rowDetail",
|
|
109
|
+
"chevron": "f77nca_chevron",
|
|
110
|
+
"separator": "f77nca_separator",
|
|
107
111
|
"hint": "f77nca_hint",
|
|
108
|
-
"back": "f77nca_back"
|
|
109
|
-
"switchControl": "f77nca_switchControl",
|
|
110
|
-
"switchRow": "f77nca_switchRow",
|
|
111
|
-
"error": "f77nca_error",
|
|
112
|
-
"rowValueActive": "f77nca_rowValueActive"
|
|
112
|
+
"back": "f77nca_back"
|
|
113
113
|
};
|
|
114
114
|
//#endregion
|
|
115
115
|
//#region client/OrbitModelSelect.tsx
|
|
@@ -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) =>
|
|
225
|
-
|
|
226
|
-
|
|
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") :
|
|
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: "推理等级",
|
|
@@ -617,13 +867,33 @@ window.__ModuleLoader__.load({
|
|
|
617
867
|
zh,
|
|
618
868
|
en
|
|
619
869
|
}), "dsh-orbit: model control dictionaries");
|
|
620
|
-
const settings = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
|
|
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
|
+
});
|
|
621
880
|
const adoptView = (view) => {
|
|
622
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
|
+
};
|
|
623
892
|
settings.set({
|
|
624
893
|
status: "ready",
|
|
625
894
|
commander: routeFromSettingsValue(value?.commander),
|
|
626
895
|
watchdog: routeFromSettingsValue(value?.watchdog),
|
|
896
|
+
moa,
|
|
627
897
|
revision: view.revision
|
|
628
898
|
});
|
|
629
899
|
};
|
|
@@ -664,15 +934,28 @@ window.__ModuleLoader__.load({
|
|
|
664
934
|
reloadSettings();
|
|
665
935
|
});
|
|
666
936
|
}, "dsh-orbit: settings mirror");
|
|
667
|
-
const
|
|
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) => {
|
|
668
955
|
const snapshot = settings.getSnapshot();
|
|
669
956
|
if (snapshot.status !== "ready" || snapshot.revision === void 0) return false;
|
|
670
957
|
try {
|
|
671
|
-
const response = await ctx.remote.settings.update(ORBIT_SETTINGS_NS,
|
|
672
|
-
provider: route.provider,
|
|
673
|
-
model: route.model,
|
|
674
|
-
reasoningEffort: route.reasoningEffort ?? ""
|
|
675
|
-
} }, snapshot.revision);
|
|
958
|
+
const response = await ctx.remote.settings.update(ORBIT_SETTINGS_NS, patch, snapshot.revision);
|
|
676
959
|
if (!response.ok) {
|
|
677
960
|
settings.update((draft) => {
|
|
678
961
|
draft.error = response.error.message;
|
|
@@ -690,6 +973,34 @@ window.__ModuleLoader__.load({
|
|
|
690
973
|
return false;
|
|
691
974
|
}
|
|
692
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
|
+
};
|
|
693
1004
|
ctx.inject([
|
|
694
1005
|
"slots",
|
|
695
1006
|
"modelDirectories",
|
|
@@ -709,6 +1020,7 @@ window.__ModuleLoader__.load({
|
|
|
709
1020
|
},
|
|
710
1021
|
selectModel: (selection) => available ? directory.select(selection).then(() => true, () => false) : Promise.resolve(false),
|
|
711
1022
|
writeRole,
|
|
1023
|
+
writeMoaPolicy,
|
|
712
1024
|
setOrbitEnabled: async (enabled) => {
|
|
713
1025
|
const session = sessions.binding(sessionId)?.session;
|
|
714
1026
|
if (session === void 0) return false;
|
package/lib/decisions.js
CHANGED
|
@@ -26,6 +26,7 @@ export const COMMANDER_PLAN_SCHEMA = {
|
|
|
26
26
|
id: { type: 'string', description: '稳定标识,例如 P0。' },
|
|
27
27
|
goal: { type: 'string' },
|
|
28
28
|
capabilities: { type: 'array', items: { type: 'string', enum: CAPABILITY_ENUM } },
|
|
29
|
+
execution_mode: { type: 'string', enum: ['SINGLE', 'MOA'] },
|
|
29
30
|
},
|
|
30
31
|
},
|
|
31
32
|
},
|
|
@@ -40,6 +41,7 @@ export const COMMANDER_STEP_EVALUATE_SCHEMA = {
|
|
|
40
41
|
reason: { type: 'string' },
|
|
41
42
|
next_step_goal: { type: 'string' },
|
|
42
43
|
next_step_capabilities: { type: 'array', items: { type: 'string', enum: CAPABILITY_ENUM } },
|
|
44
|
+
next_step_execution_mode: { type: 'string', enum: ['SINGLE', 'MOA'] },
|
|
43
45
|
},
|
|
44
46
|
};
|
|
45
47
|
export const COMMANDER_FINAL_EVALUATE_SCHEMA = {
|
|
@@ -51,6 +53,7 @@ export const COMMANDER_FINAL_EVALUATE_SCHEMA = {
|
|
|
51
53
|
summary: { type: 'string' },
|
|
52
54
|
next_step_goal: { type: 'string' },
|
|
53
55
|
next_step_capabilities: { type: 'array', items: { type: 'string', enum: CAPABILITY_ENUM } },
|
|
56
|
+
next_step_execution_mode: { type: 'string', enum: ['SINGLE', 'MOA'] },
|
|
54
57
|
next_steps: {
|
|
55
58
|
type: 'array',
|
|
56
59
|
items: {
|
|
@@ -63,6 +66,7 @@ export const COMMANDER_FINAL_EVALUATE_SCHEMA = {
|
|
|
63
66
|
properties: {
|
|
64
67
|
goal: { type: 'string' },
|
|
65
68
|
capabilities: { type: 'array', items: { type: 'string', enum: CAPABILITY_ENUM } },
|
|
69
|
+
execution_mode: { type: 'string', enum: ['SINGLE', 'MOA'] },
|
|
66
70
|
},
|
|
67
71
|
},
|
|
68
72
|
],
|