@darkbear9494/dsh-model-manager 0.1.0 → 0.2.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 +60 -48
- package/client.js +22 -22
- package/cordis.patch.yml +4 -0
- package/lib/index.js +30 -16
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -22,18 +22,18 @@ configuration card to the Plugins page. There is no build step for either half.
|
|
|
22
22
|
|
|
23
23
|
## Install
|
|
24
24
|
|
|
25
|
-
One command — straight from GitHub, or from a working copy:
|
|
25
|
+
One command — from the registry, straight from GitHub, or from a working copy:
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
# from
|
|
28
|
+
# from npm
|
|
29
|
+
dsh plugin --profile desktop add @darkbear9494/dsh-model-manager@latest
|
|
30
|
+
|
|
31
|
+
# from GitHub, no registry involved; needs git access to the repo
|
|
29
32
|
dsh plugin --profile desktop add github:jyshangguan/dsh-model-manager
|
|
30
33
|
|
|
31
34
|
# from a working copy (path must be absolute)
|
|
32
35
|
git clone https://github.com/jyshangguan/dsh-model-manager.git
|
|
33
36
|
dsh plugin --profile desktop add /absolute/path/to/dsh-model-manager
|
|
34
|
-
|
|
35
|
-
# from npm — only after `npm publish`; see "Not on npm yet" below
|
|
36
|
-
dsh plugin --profile desktop add @darkbear9494/dsh-model-manager@latest
|
|
37
37
|
```
|
|
38
38
|
|
|
39
39
|
Use the profile your app actually boots. `dsh web` and the Web GUI run the `web` profile; the
|
|
@@ -61,29 +61,36 @@ should show row id `model-manager`, `enabled: true`, `fiberPhase: active`.
|
|
|
61
61
|
The Plugins page's **Add plugin** field reads *"Enter the plugin's package name, GitHub repository
|
|
62
62
|
address, or local directory path."* It is the GUI's `install_bundle`, and it parses the string
|
|
63
63
|
through the same `parseInstallSpec` (`@deepseek-ai/dsh-plugin-manager/lib/types/install-spec.js`)
|
|
64
|
-
before handing it to pnpm.
|
|
64
|
+
before handing it to pnpm. All four forms work:
|
|
65
65
|
|
|
66
66
|
| Field input | Spec kind |
|
|
67
67
|
| --- | --- |
|
|
68
|
+
| `@darkbear9494/dsh-model-manager` | registry — the shortest one to type |
|
|
68
69
|
| `github:jyshangguan/dsh-model-manager` | git — the `https://github.com/…` URL works too |
|
|
69
70
|
| `/Users/you/src/dsh-model-manager` | absolute local directory (relative paths are refused) |
|
|
70
|
-
| `/Users/you/dsh-model-manager-0.
|
|
71
|
-
| `@darkbear9494/dsh-model-manager` | registry — needs the package published first |
|
|
71
|
+
| `/Users/you/darkbear9494-dsh-model-manager-0.2.0.tgz` | local tarball — `npm pack` makes one |
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
Registering the plugin by name was verified end-to-end on this runtime: `dsh plugin --profile
|
|
74
|
+
<name> add @darkbear9494/dsh-model-manager` resolves the current release (`^0.1.0` at first
|
|
75
|
+
publish, `^0.2.0` since) from the registry, `reconcile()`
|
|
76
|
+
appends the bundle, the composed tree mounts row `model-manager`, and a boot reaches the LLM stage
|
|
77
|
+
with no peer refusal and no loader error. The git and local-path forms were checked the same way.
|
|
76
78
|
|
|
77
|
-
###
|
|
79
|
+
### The registry copy
|
|
78
80
|
|
|
79
|
-
`@darkbear9494/dsh-model-manager` is
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
81
|
+
`@darkbear9494/dsh-model-manager@0.2.0` is the current release, public access, 8 files, 63.1 kB
|
|
82
|
+
packed (0.1.0, the first publish, was 62.3 kB with the same 8 files). Its
|
|
83
|
+
declared gate is `>=0.1.7-rc.2 <0.3.0`, so it installs on the 0.2.0 line without an exemption.
|
|
84
|
+
|
|
85
|
+
Two things learned while publishing it, in case a future version has to be released:
|
|
86
|
+
|
|
87
|
+
- The scope has to equal the npm account, or name an organization the account belongs to. See
|
|
88
|
+
[Why the package is scoped](#why-the-package-is-scoped-and-why-the-scope-is-darkbear9494).
|
|
89
|
+
- The registry's read path lags the write. Immediately after a successful `npm publish`
|
|
90
|
+
(`PUT 200`, `exit 0`) the packument can still answer `404 Not found` — and so can `npm view`,
|
|
91
|
+
`npm install` and a GUI install — while the tarball URL already returns `200`. It cleared on its
|
|
92
|
+
own in about five minutes here. Wait it out rather than republishing; the second `npm publish`
|
|
93
|
+
would fail on the version already existing.
|
|
87
94
|
|
|
88
95
|
### Why the package is scoped, and why the scope is `@darkbear9494`
|
|
89
96
|
|
|
@@ -111,7 +118,7 @@ peer — only names equal to `@deepseek-ai/dsh` or beginning `@deepseek-ai/dsh-`
|
|
|
111
118
|
command:
|
|
112
119
|
|
|
113
120
|
```bash
|
|
114
|
-
dsh plugin --profile desktop allow-version @darkbear9494/dsh-model-manager@0.
|
|
121
|
+
dsh plugin --profile desktop allow-version @darkbear9494/dsh-model-manager@0.2.0 \
|
|
115
122
|
--dsh-version <exact runtime version> --accept-risk
|
|
116
123
|
```
|
|
117
124
|
|
|
@@ -270,7 +277,9 @@ dsh --profile web --patch ./smoke.patch.yml headless "say ok"
|
|
|
270
277
|
|
|
271
278
|
## The four roles
|
|
272
279
|
|
|
273
|
-
Each role holds an ordered list of routes
|
|
280
|
+
Each role holds an ordered list of routes. Since 0.2.0 the **selection strategy is one
|
|
281
|
+
top-level `pick` for every role** — the per-role `pick` field of 0.1.x is gone, and a config
|
|
282
|
+
that still carries it gets a warning naming the move. A role with no models
|
|
274
283
|
resolves to no route, and requests classified into it pass through unchanged — except
|
|
275
284
|
`vision`, which falls back to `execution`. A subagent never uses `main`.
|
|
276
285
|
|
|
@@ -281,16 +290,17 @@ resolves to no route, and requests classified into it pass through unchanged —
|
|
|
281
290
|
| `execution` | Default tier for delegated implementation. | Every subagent that matches neither keyword list, including a child with an empty label; also the fallback for vision when `vision` has no models. | `pku-corpus/qwen3.8-flash` |
|
|
282
291
|
| `vision` | Image, screenshot, chart and OCR work. | Subagents whose label matches a vision keyword. | `models: []` (falls back to `execution`) |
|
|
283
292
|
|
|
284
|
-
A route is `{ provider, model, reasoningEffort? }
|
|
285
|
-
`round-robin
|
|
293
|
+
A route is `{ provider, model, reasoningEffort? }`. The top-level `pick` is `first`
|
|
294
|
+
(default) or `round-robin` and applies to every role alike; with one model in a role's list
|
|
295
|
+
it has no effect for that role. A role may also carry a
|
|
286
296
|
`note` — free text for humans, printed under the role in the `routes` table and never
|
|
287
297
|
used for routing.
|
|
288
298
|
|
|
289
299
|
## Configure in the UI
|
|
290
300
|
|
|
291
301
|
The client half contributes a configuration card to the Plugins page. It writes exactly the
|
|
292
|
-
values documented under [Configuration](#configuration) — `roles.<role>.models
|
|
293
|
-
`strategy.mode` — so the two paths are interchangeable: use the card to try a routing
|
|
302
|
+
values documented under [Configuration](#configuration) — `roles.<role>.models`, the
|
|
303
|
+
top-level `pick` and `strategy.mode` — so the two paths are interchangeable: use the card to try a routing
|
|
294
304
|
choice, the YAML to pin it. This package's own `cordis.patch.yml` is the declarative source
|
|
295
305
|
that ships with the bundle and is re-read on every boot, and a profile patch overrides it by
|
|
296
306
|
row id; the card never edits patch files, so if a patch layer pins a value, edit the patch.
|
|
@@ -301,7 +311,7 @@ row id; the card never edits patch files, so if a patch layer pins a value, edit
|
|
|
301
311
|
|
|
302
312
|
| Slot | Registration id | What it renders |
|
|
303
313
|
| --- | --- | --- |
|
|
304
|
-
| `settings.section` | `model-manager` | The configuration card: the four roles and their model lists, the
|
|
314
|
+
| `settings.section` | `model-manager` | The configuration card: the four roles and their model lists, the shared selection strategy, the distribution mode. |
|
|
305
315
|
| `conversation.session.header.utilities` | `model-manager-usage` | The per-session model-usage summary the host half folds from the durable log. |
|
|
306
316
|
|
|
307
317
|
So the path is **设置 → 模型管理器** — not Plugins → the row → configure. `plugins.item` and
|
|
@@ -326,12 +336,11 @@ polling on the client, and the numbers survive a restart.
|
|
|
326
336
|
| Model rows, one per role (`Main model`, `Planning and reasoning`, `Execution`, `Image recognition`) | `set roles.<role>.models` | Each configured route is its own row with a `<select>` grouped by provider in `<optgroup>`s, fed by `ctx.remote.session.modelCatalog()` and labelled `name — id`. A route the catalog stopped advertising stays selectable and is marked `(not in catalog)` rather than being silently swapped. An empty list is the YAML default: no route for that role, and `vision` falls back to `execution`. |
|
|
327
337
|
| Add a model | `set roles.<role>.models` | One dashed control under the rows, listing every catalog model the role has not already used, so a model cannot be added twice. |
|
|
328
338
|
| `up` / `remove` | `set roles.<role>.models` | Reorder and delete. The whole list is rewritten in one atomic operation, so a reorder cannot interleave into a partial state. The up control is **disabled on the first row** rather than absent, so the column never changes width. |
|
|
329
|
-
`reasoning.efforts`** in the catalog. `(model default)` writes a route with no `reasoningEffort`, letting the adapter choose; naming a tier explicitly is how you satisfy a model that rejects a request without one. |
|
|
330
339
|
| Reasoning-effort picker | `set roles.<role>.models` (single route with `reasoningEffort`) | Appears **only when the selected model advertises `reasoning.efforts`** in the catalog. `(model default)` writes a route with no `reasoningEffort`, letting the adapter choose; naming a tier explicitly is how you satisfy a model that rejects a request without one. |
|
|
331
|
-
| `Pick` (`first` / `round-robin`) | `set
|
|
340
|
+
| `Pick` (`first` / `round-robin`) | `set pick` | **One control for every role** (since 0.2.0), rendered next to the distribution mode with a hint line. `first` always uses index 0 of each role's list and only advances when a route fails; `round-robin` spreads consecutive requests across each role's list. |
|
|
332
341
|
| Distribution mode | `set strategy.mode` | `hybrid` / `managed` / `advisory`, labelled with the same one-line explanations this README uses. A stored mode the card does not know displays as `hybrid`, mirroring the host half's fallback. |
|
|
333
342
|
|
|
334
|
-
**Layout.** One CSS grid per role, with fixed column tracks `auto minmax(0, 1fr) auto auto` — index, model, effort, actions. That choice is the whole reason the rows line up: in a flex row a control with `flex: 1 1 16rem` takes width from its siblings, so any row that omits one control (a model with no reasoning tiers, a first row with no reorder button) pulls every other row's right edge out of alignment. Under the grid a row with no effort control still emits an empty cell, so the action column sits at the same x everywhere. The two actions are glyphs rather than words, so the column is also the same width in either locale; each keeps an `aria-label` and a native `title`. The add affordance is deliberately unlike a model row — dashed border, no fill, muted text, spanning the value columns
|
|
343
|
+
**Layout.** One CSS grid per role, with fixed column tracks `auto minmax(0, 1fr) auto auto` — index, model, effort, actions. That choice is the whole reason the rows line up: in a flex row a control with `flex: 1 1 16rem` takes width from its siblings, so any row that omits one control (a model with no reasoning tiers, a first row with no reorder button) pulls every other row's right edge out of alignment. Under the grid a row with no effort control still emits an empty cell, so the action column sits at the same x everywhere. The two actions are glyphs rather than words, so the column is also the same width in either locale; each keeps an `aria-label` and a native `title`. The add affordance is deliberately unlike a model row — dashed border, no fill, muted text, spanning the value columns.
|
|
335
344
|
|
|
336
345
|
Each role also carries a hint line (`Top-level agent outside plan mode. Leave unset to keep
|
|
337
346
|
following the composer selection.`, `Used for image, screenshot and OCR work. Pick a model
|
|
@@ -525,8 +534,8 @@ is active and `main` otherwise.
|
|
|
525
534
|
|
|
526
535
|
If `vision.models` is empty when a vision request is routed, the plugin serves it from the
|
|
527
536
|
execution role's models instead. The role recorded for that request is still `vision`;
|
|
528
|
-
the model is the execution role's, and
|
|
529
|
-
counter are the ones used. The `routes` table marks such a role `(via execution)`. If
|
|
537
|
+
the model is the execution role's, and the shared `pick` strategy with the execution
|
|
538
|
+
role's `round-robin` counter are the ones used. The `routes` table marks such a role `(via execution)`. If
|
|
530
539
|
`execution` is empty as well, there is no route and the request passes through. This is
|
|
531
540
|
why the bundled default (`vision: []`) is safe: vision work is served by the execution
|
|
532
541
|
tier until you configure a dedicated vision model.
|
|
@@ -606,7 +615,7 @@ re-reads the config itself — including rebuilding the keyword matchers. A keyw
|
|
|
606
615
|
change saved on the Settings page — or from the [card on the Plugins
|
|
607
616
|
page](#configure-in-the-ui), which writes the same volatile namespace — takes effect on the
|
|
608
617
|
next request, with no restart. The
|
|
609
|
-
event logs `settings reloaded — mode …` on success; a value that cannot be re-read logs
|
|
618
|
+
event logs `settings reloaded — mode …, pick …` on success; a value that cannot be re-read logs
|
|
610
619
|
`could not reload settings; routing keeps the previous config: …` and the previously
|
|
611
620
|
active config stays in force.
|
|
612
621
|
|
|
@@ -615,20 +624,17 @@ Complete key set, with the schema defaults shown in comments:
|
|
|
615
624
|
```yaml
|
|
616
625
|
- id: model-manager
|
|
617
626
|
config:
|
|
627
|
+
pick: first # default: first; "first" | "round-robin" — ONE strategy for every role
|
|
618
628
|
roles:
|
|
619
629
|
main:
|
|
620
630
|
models: [] # default: [] — empty means "leave the composer/model selection alone"
|
|
621
|
-
pick: first # default: first; "first" | "round-robin"
|
|
622
631
|
note: '' # default: none — optional free text, printed by `routes` under the role
|
|
623
632
|
planning:
|
|
624
633
|
models: [] # schema default: [] (this package's own layer sets pku-corpus/qwen3.8-max-0902)
|
|
625
|
-
pick: first
|
|
626
634
|
execution:
|
|
627
635
|
models: [] # schema default: [] (this package's own layer sets pku-corpus/qwen3.8-flash)
|
|
628
|
-
pick: first
|
|
629
636
|
vision:
|
|
630
637
|
models: [] # schema default: [] — empty falls back to the execution role
|
|
631
|
-
pick: first
|
|
632
638
|
strategy:
|
|
633
639
|
mode: hybrid # default: hybrid; "hybrid" | "managed" | "advisory"
|
|
634
640
|
# visionKeywords: omitted = the 20 built-ins; any list you write replaces them
|
|
@@ -741,7 +747,7 @@ The plugin registers one read-only tool, `model_manager`, with four actions:
|
|
|
741
747
|
| Action | Returns |
|
|
742
748
|
| --- | --- |
|
|
743
749
|
| `report` (default) | A `Top-level agents` table — session id, role, model, reason, live status, and whether the session's model was picked by hand or left at the deployment default — then the per-subagent table: child id, role, model, reason, live status, delegation label, and finally the active mode with subagent-only totals by role/model. |
|
|
744
|
-
| `routes` | Role table (role,
|
|
750
|
+
| `routes` | Role table (role, effective models, role `note`), the shared selection strategy, active mode, allow-list audit with a YAML snippet for unlisted routes, the vision image-capability check, and the first 8 keywords of each list. |
|
|
745
751
|
| `usage` | Request and subagent counts per role/model across the whole process, including top-level turns. |
|
|
746
752
|
| `client` | Whether the Host composed this package's Web client half into the browser boot graph, the route serving its bundle, and the current graph revision. Use it when the settings card does not appear. |
|
|
747
753
|
|
|
@@ -880,13 +886,17 @@ model_manager(action: "routes")
|
|
|
880
886
|
```text
|
|
881
887
|
Model manager roles
|
|
882
888
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
889
|
+
Enabled: yes
|
|
890
|
+
|
|
891
|
+
Selection: first — every role starts at its top model and fails over down its list (one strategy for all roles)
|
|
892
|
+
|
|
893
|
+
Role effective model(s)
|
|
894
|
+
---------- ------------------------------------------
|
|
895
|
+
main (unconfigured — passes through)
|
|
896
|
+
planning pku-corpus/qwen3.8-max-0902
|
|
897
|
+
note: use for architecture and migration design
|
|
898
|
+
execution pku-corpus/qwen3.8-flash
|
|
899
|
+
vision pku-corpus/kimi-k3, pku-corpus/qwen3.8-flash, pku-corpus/mystery, pku-corpus/broken
|
|
890
900
|
|
|
891
901
|
Strategy mode: hybrid (apply when the child inherited the parent route)
|
|
892
902
|
|
|
@@ -1133,9 +1143,9 @@ of writing. Each suite also runs on its own: `node test/<name>.test.mjs`.
|
|
|
1133
1143
|
| --- | --- | --- |
|
|
1134
1144
|
| `packaging.test.mjs` | 31 | The package identity that nothing else cross-checks: the scoped name is the one string the bundle patch's loader row, the client half's module id and the host half's `PACKAGE_NAME` must all agree on, while the cordis row id, the client row namespace and the locale namespace must all *stay* unscoped. Plus publishability (not private, public access, a real `@deepseek-ai/dsh` version gate, schemastery still optional) and tarball completeness — every `exports` target and every `files` pattern resolved against disk, so a published package cannot mount-less. The gate is not string-matched: a self-validating semver comparator (prerelease-aware, and checked against the ordering trap first) proves the declared range admits 0.1.7-rc.2, 0.2.0-rc.2 **and** 0.2.0 while refusing 0.1.6 and 0.3.0 — because `<0.2.0` reads as "every 0.2.0 prerelease" while excluding 0.2.0 itself. Each identity assertion was mutation-checked: breaking any one of the four name sites, or "tidying" the row id or locale namespace to match, fails exactly one assertion; reverting the upper bound to `<0.2.0` fails exactly two. |
|
|
1135
1145
|
| `routing.test.mjs` | 9 | The four roles route as documented; label classification; an explicit child route is respected; the tool and system-prompt section register; `apply` survives malformed configs. |
|
|
1136
|
-
| `edge.test.mjs` |
|
|
1146
|
+
| `edge.test.mjs` | 553 | Hostile configs, keyword anchoring and trimming, explicit-`[]`-disables versus absent-uses-defaults, the 0.2.0 pick migration (legacy per-role values warn and are ignored; the top-level value normalizes), round-robin committing only on apply, LRU eviction, the manager-owned rule, volatile settings reload, every `reason` string, the report/usage/routes output, and the generated allow-list YAML round-tripped through the **real** harness validator. |
|
|
1137
1147
|
| `failover.test.mjs` | 24 | The failover chain and every guard: it walks to the end of the list and then stops rather than wrapping; `ABORTED`, `INVALID_REQUEST` and `IMAGE_OFFLOAD_REQUIRED` never fail over; a downstream recovery decision is passed through untouched; the per-step cap holds and resets on a new step; `round-robin` does wrap; single-model and disabled roles do nothing; a route outside the role's list is left alone; hostile payloads never throw; subagent chains fail over too. |
|
|
1138
|
-
| `client-structure.test.mjs` |
|
|
1148
|
+
| `client-structure.test.mjs` | 35 | The client half loads through `window.__ModuleLoader__`, requires **only** `react`, exports `{ inject, apply }`, registers its locale dictionaries and exactly two surfaces, and — because the check mirrors the real `SlotCore.register` validation — fails if a registration ever loses its `name`. It also declares each `remote.<namespace>` used must appear in `inject`, drives the settings-form bindings, renders the usage surface against a stubbed projection face in both its collapsed and expanded states (an empty-projection case proving those render assertions are not vacuous), and pins the 0.2.0 card shape: exactly one shared selection control writing the top-level `pick`, with no per-role pick control left anywhere in the tree. |
|
|
1139
1149
|
| `client-diagnostic.test.mjs` | 17 | Every branch of `model_manager` with `action: "client"`, including the two that matter most: a bundle the Host will not serve, and a bundle that serves but registers the wrong id. |
|
|
1140
1150
|
| `usage-projection.test.mjs` | 42 | The per-session model-usage fold: bucket sums against the harness's own field names, refusal of unsafe or fractional counts without aborting the fold, usage recovered from an embedded stream, separate attribution per provider/model, immutable state transitions, reference stability that suppresses republishing, and both schemas rejecting junk through the only method cordis calls (`.parse`). |
|
|
1141
1151
|
| `explicit-selection.test.mjs` | 25 | The rule that `main` yields to a hand-picked session model, and nothing else does: respected under `hybrid`, still applied under `managed`, untouched by a respected call in the round-robin rotation, and falling back to the old rewriting behaviour when the projection service is absent, when `stateOf` throws, or when the key was never registered. A disabled manager is checked too. Plus the `Top-level agents` report table: the hand-picked versus default-driven verdict, no orphaned subagent header when no subagent exists, a row that outlives its agent degrading to `unknown, agent no longer live`, and — read back out of the renderer's own source — proof that the reason column is still padded past the longest reason string it can print. |
|
|
@@ -1177,7 +1187,9 @@ outside the repository.
|
|
|
1177
1187
|
keeps being managed as long as its route matches the applied one, even after its parent
|
|
1178
1188
|
is gone. If a child legitimately changes its own model to one the parent also uses, the
|
|
1179
1189
|
manager takes it back.
|
|
1180
|
-
- **`round-robin` is per-process
|
|
1190
|
+
- **`round-robin` is per-process; the strategy itself is global.** The pick strategy is one
|
|
1191
|
+
top-level value shared by every role, but the rotation counters are per-role, live in an
|
|
1192
|
+
in-memory `Map` and
|
|
1181
1193
|
reset to index 0 on restart. A role with a single model never advances, and an advance is
|
|
1182
1194
|
committed only when a route is applied, so `advisory` passes and both kinds of respected
|
|
1183
1195
|
route do not rotate. Routing happens per LLM request, not per turn, so a `round-robin`
|
package/client.js
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* Contributes a configuration page for this plugin's own row on the Plugins
|
|
5
5
|
* page. The row gains a configure control that opens a card with one model
|
|
6
6
|
* picker per role (main / planning / execution / vision) fed by the host's live
|
|
7
|
-
* model catalog, plus the
|
|
7
|
+
* model catalog, plus the shared selection strategy, the distribution mode and
|
|
8
|
+
* a per-role reasoning effort.
|
|
8
9
|
*
|
|
9
10
|
* Design constraints (from the harness's own plugin practices):
|
|
10
11
|
* - No Harness Client package is `require`d as a module. React comes from the
|
|
@@ -99,6 +100,7 @@ window.__ModuleLoader__.load({
|
|
|
99
100
|
pick: 'Selection',
|
|
100
101
|
pickFirst: 'first — use the top model, fall back down the list',
|
|
101
102
|
pickRoundRobin: 'round-robin — rotate across the list',
|
|
103
|
+
pickHint: 'One strategy for every role. "first" keeps each list as a failover chain; "round-robin" rotates across it.',
|
|
102
104
|
orderHint: 'Order is the fallback order: the top model is tried first.',
|
|
103
105
|
usageTitle: 'Model usage',
|
|
104
106
|
usageModel: 'Provider / model',
|
|
@@ -148,6 +150,7 @@ window.__ModuleLoader__.load({
|
|
|
148
150
|
pick: '选择方式',
|
|
149
151
|
pickFirst: 'first — 优先用第一个,失败时按顺序向下回退',
|
|
150
152
|
pickRoundRobin: 'round-robin — 在列表内轮流使用',
|
|
153
|
+
pickHint: '所有角色共用这一个选择方式。"first" 把每个角色的列表当作回退链;"round-robin" 在列表内轮流使用。',
|
|
151
154
|
orderHint: '列表顺序即回退顺序:排在最前的模型优先使用。',
|
|
152
155
|
usageTitle: '模型用量',
|
|
153
156
|
usageModel: '提供方 / 模型',
|
|
@@ -231,7 +234,6 @@ window.__ModuleLoader__.load({
|
|
|
231
234
|
color: 'var(--dsw-alias-label-secondary)',
|
|
232
235
|
},
|
|
233
236
|
cellSpan: { gridColumn: '2 / -1' },
|
|
234
|
-
pickLabel: { fontSize: '0.76rem', color: 'var(--dsw-alias-label-secondary)' },
|
|
235
237
|
usage: { position: 'relative', display: 'inline-flex' },
|
|
236
238
|
usageButton: {
|
|
237
239
|
display: 'inline-flex',
|
|
@@ -540,6 +542,7 @@ window.__ModuleLoader__.load({
|
|
|
540
542
|
const value = isObject(snapshot?.value) ? snapshot.value : {};
|
|
541
543
|
const roles = isObject(value.roles) ? value.roles : {};
|
|
542
544
|
const mode = isObject(value.strategy) && typeof value.strategy.mode === 'string' ? value.strategy.mode : 'hybrid';
|
|
545
|
+
const pick = value.pick === 'round-robin' ? 'round-robin' : 'first';
|
|
543
546
|
|
|
544
547
|
const summary = () => {
|
|
545
548
|
const parts = ROLES
|
|
@@ -710,26 +713,6 @@ window.__ModuleLoader__.load({
|
|
|
710
713
|
h('option', { key: '', value: '' }, t('addModel')),
|
|
711
714
|
...modelOptions(used)));
|
|
712
715
|
|
|
713
|
-
if (models.length > 1) {
|
|
714
|
-
const holder = roles[role];
|
|
715
|
-
const pick = holder !== null && typeof holder === 'object' && holder.pick === 'round-robin'
|
|
716
|
-
? 'round-robin' : 'first';
|
|
717
|
-
cells.push(h('span', {
|
|
718
|
-
key: 'pick',
|
|
719
|
-
style: { ...S.cellSpan, display: 'inline-flex', alignItems: 'center', gap: '0.45rem' },
|
|
720
|
-
},
|
|
721
|
-
h('span', { style: S.pickLabel }, t('pick')),
|
|
722
|
-
h('select', {
|
|
723
|
-
style: { ...S.selectGrid, ...S.selectEffortGrid },
|
|
724
|
-
value: pick,
|
|
725
|
-
disabled: !ready,
|
|
726
|
-
'aria-label': `${t(roleKeyFor(role))} — ${t('pick')}`,
|
|
727
|
-
onChange: (event) => write([{ op: 'set', path: ['roles', role, 'pick'], value: event.target.value }]),
|
|
728
|
-
},
|
|
729
|
-
h('option', { key: 'first', value: 'first' }, t('pickFirst')),
|
|
730
|
-
h('option', { key: 'rr', value: 'round-robin' }, t('pickRoundRobin')))));
|
|
731
|
-
}
|
|
732
|
-
|
|
733
716
|
return h('div', { key: role, style: S.row },
|
|
734
717
|
h('label', { style: S.label }, t(roleKeyFor(role))),
|
|
735
718
|
h('span', { style: S.hint }, t(hintKeyFor(role))),
|
|
@@ -748,6 +731,22 @@ window.__ModuleLoader__.load({
|
|
|
748
731
|
onChange: (event) => write([{ op: 'set', path: ['strategy', 'mode'], value: event.target.value }]),
|
|
749
732
|
}, ...MODES.map((name) => h('option', { key: name, value: name }, t(modeKeyFor(name)))))));
|
|
750
733
|
|
|
734
|
+
// One selection strategy for every role (since 0.2.0): the value is
|
|
735
|
+
// top-level, and the per-role controls are gone by design.
|
|
736
|
+
const pickControl = h('div', { style: S.row },
|
|
737
|
+
h('label', { style: S.label }, t('pick')),
|
|
738
|
+
h('div', { style: S.controls },
|
|
739
|
+
h('select', {
|
|
740
|
+
style: S.select,
|
|
741
|
+
value: pick,
|
|
742
|
+
disabled: !ready,
|
|
743
|
+
'aria-label': t('pick'),
|
|
744
|
+
onChange: (event) => write([{ op: 'set', path: ['pick'], value: event.target.value }]),
|
|
745
|
+
},
|
|
746
|
+
h('option', { key: 'first', value: 'first' }, t('pickFirst')),
|
|
747
|
+
h('option', { key: 'rr', value: 'round-robin' }, t('pickRoundRobin')))),
|
|
748
|
+
h('span', { style: S.hint }, t('pickHint')));
|
|
749
|
+
|
|
751
750
|
const notices = [];
|
|
752
751
|
if (!ready && snapshot.status === 'ready') notices.push(h('div', { key: 'ro', style: S.notice }, t('readOnly')));
|
|
753
752
|
if (state.status === 'loading') notices.push(h('div', { key: 'load', style: S.notice }, t('loading')));
|
|
@@ -787,6 +786,7 @@ window.__ModuleLoader__.load({
|
|
|
787
786
|
h('p', { style: S.help }, t('help')),
|
|
788
787
|
enableToggle,
|
|
789
788
|
...ROLES.map((role) => row(role)),
|
|
789
|
+
pickControl,
|
|
790
790
|
modeControl,
|
|
791
791
|
...notices);
|
|
792
792
|
}
|
package/cordis.patch.yml
CHANGED
|
@@ -15,6 +15,10 @@
|
|
|
15
15
|
- id: model-manager
|
|
16
16
|
name: '@darkbear9494/dsh-model-manager'
|
|
17
17
|
config:
|
|
18
|
+
# One selection strategy for every role (0.2.0): first | round-robin.
|
|
19
|
+
# `first` treats each role's ordered list as a failover chain;
|
|
20
|
+
# `round-robin` rotates across each role's list.
|
|
21
|
+
pick: first
|
|
18
22
|
roles:
|
|
19
23
|
# Main agent outside plan mode. Empty = leave the composer choice alone.
|
|
20
24
|
main:
|
package/lib/index.js
CHANGED
|
@@ -47,8 +47,8 @@ export const name = 'model-manager';
|
|
|
47
47
|
|
|
48
48
|
const ROLE_NAMES = ['main', 'planning', 'execution', 'vision'];
|
|
49
49
|
|
|
50
|
-
const KNOWN_TOP_KEYS = ['enabled', 'roles', 'strategy'];
|
|
51
|
-
const KNOWN_ROLE_KEYS = ['models', '
|
|
50
|
+
const KNOWN_TOP_KEYS = ['enabled', 'pick', 'roles', 'strategy'];
|
|
51
|
+
const KNOWN_ROLE_KEYS = ['models', 'note'];
|
|
52
52
|
const KNOWN_ROUTE_KEYS = ['provider', 'model', 'reasoningEffort'];
|
|
53
53
|
const KNOWN_STRATEGY_KEYS = ['mode', 'visionKeywords', 'planningKeywords', 'historyLimit'];
|
|
54
54
|
|
|
@@ -135,7 +135,6 @@ function buildConfigSchema(z) {
|
|
|
135
135
|
|
|
136
136
|
const RoleSchema = z.object({
|
|
137
137
|
models: z.array(RouteSchema).default([]),
|
|
138
|
-
pick: z.union([z.const('first'), z.const('round-robin')]).default('first'),
|
|
139
138
|
note: z.string(),
|
|
140
139
|
});
|
|
141
140
|
|
|
@@ -157,6 +156,12 @@ function buildConfigSchema(z) {
|
|
|
157
156
|
return z.object({
|
|
158
157
|
/** Master switch: when false the manager observes and reports but never rewrites a route. */
|
|
159
158
|
enabled: z.boolean().default(true).volatile(),
|
|
159
|
+
/**
|
|
160
|
+
* One selection strategy for every role (0.2.0). `first` treats each role's
|
|
161
|
+
* ordered list as a failover chain: index 0 first, failures move down.
|
|
162
|
+
* `round-robin` rotates across each role's list instead.
|
|
163
|
+
*/
|
|
164
|
+
pick: z.union([z.const('first'), z.const('round-robin')]).default('first').volatile(),
|
|
160
165
|
roles: z.object({
|
|
161
166
|
main: RoleSchema.default({}),
|
|
162
167
|
planning: RoleSchema.default({}),
|
|
@@ -242,7 +247,9 @@ function readConfig(raw) {
|
|
|
242
247
|
for (const key of unknownKeys(rolesRaw, ROLE_NAMES)) warnings.push(`unknown role "${key}" ignored`);
|
|
243
248
|
for (const key of ROLE_NAMES) {
|
|
244
249
|
for (const bad of unknownKeys(readVal(rolesRaw?.[key]), KNOWN_ROLE_KEYS)) {
|
|
245
|
-
warnings.push(
|
|
250
|
+
warnings.push(bad === 'pick'
|
|
251
|
+
? `"roles.${key}.pick" moved to the top-level "pick" in 0.2.0; the per-role value is ignored`
|
|
252
|
+
: `unknown key "roles.${key}.${bad}" ignored`);
|
|
246
253
|
}
|
|
247
254
|
}
|
|
248
255
|
for (const key of unknownKeys(strategyRaw, KNOWN_STRATEGY_KEYS)) warnings.push(`unknown key "strategy.${key}" ignored`);
|
|
@@ -259,7 +266,6 @@ function readConfig(raw) {
|
|
|
259
266
|
}
|
|
260
267
|
return {
|
|
261
268
|
models,
|
|
262
|
-
pick: role.pick === 'round-robin' ? 'round-robin' : 'first',
|
|
263
269
|
note: typeof role.note === 'string' && role.note.trim() !== '' ? role.note.trim() : undefined,
|
|
264
270
|
};
|
|
265
271
|
};
|
|
@@ -270,6 +276,8 @@ function readConfig(raw) {
|
|
|
270
276
|
// Only an explicit `false` switches the manager off. A missing or malformed
|
|
271
277
|
// value keeps it on, so a typo can never silently disable routing.
|
|
272
278
|
enabled: readVal(raw?.enabled) !== false,
|
|
279
|
+
// One strategy for every role; anything that is not 'round-robin' is 'first'.
|
|
280
|
+
pick: readVal(raw?.pick) === 'round-robin' ? 'round-robin' : 'first',
|
|
273
281
|
roles: Object.fromEntries(ROLE_NAMES.map((key) => [key, readRole(key)])),
|
|
274
282
|
strategy: {
|
|
275
283
|
mode: mode === 'managed' || mode === 'advisory' ? mode : 'hybrid',
|
|
@@ -515,7 +523,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
515
523
|
*
|
|
516
524
|
* The counter is committed only when the route is actually applied, so an
|
|
517
525
|
* advisory pass or a respected explicit choice does not consume a turn of the
|
|
518
|
-
* rotation.
|
|
526
|
+
* rotation. One strategy (`config.pick`) governs every role; the rotation
|
|
527
|
+
* counter itself stays per-role so each list rotates independently.
|
|
519
528
|
*
|
|
520
529
|
* `sessionId` selects the failover position for `pick: 'first'`, where the
|
|
521
530
|
* ordered list is a failover chain rather than a rotation.
|
|
@@ -525,7 +534,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
525
534
|
if (models.length === 0) return undefined;
|
|
526
535
|
if (models.length === 1) return { route: models[0], commit() {} };
|
|
527
536
|
const owner = roleOf(key)?.models.length > 0 ? key : 'execution';
|
|
528
|
-
if (
|
|
537
|
+
if (config.pick === 'round-robin') {
|
|
529
538
|
const index = roundRobin.get(owner) ?? 0;
|
|
530
539
|
return {
|
|
531
540
|
route: models[index],
|
|
@@ -826,7 +835,7 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
826
835
|
if (failedAt < 0) return undefined;
|
|
827
836
|
|
|
828
837
|
const owner = roleOf(role)?.models.length > 0 ? role : 'execution';
|
|
829
|
-
const rotating =
|
|
838
|
+
const rotating = config.pick === 'round-robin';
|
|
830
839
|
const nextIndex = rotating
|
|
831
840
|
? (failedAt + 1) % models.length
|
|
832
841
|
: Math.min(failedAt + 1, models.length - 1);
|
|
@@ -974,8 +983,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
974
983
|
}
|
|
975
984
|
|
|
976
985
|
function roleTable() {
|
|
977
|
-
const lines = ['Role
|
|
978
|
-
lines.push('
|
|
986
|
+
const lines = ['Role effective model(s)'];
|
|
987
|
+
lines.push('---------- ------------------------------------------');
|
|
979
988
|
for (const key of ROLE_NAMES) {
|
|
980
989
|
const role = roleOf(key);
|
|
981
990
|
const models = effectiveModels(key);
|
|
@@ -983,8 +992,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
983
992
|
const detail = models.length === 0
|
|
984
993
|
? '(unconfigured — passes through)'
|
|
985
994
|
: models.map((route) => `${route.provider}/${route.model}${route.reasoningEffort ? ` (${route.reasoningEffort})` : ''}`).join(', ');
|
|
986
|
-
lines.push(`${key.padEnd(12)} ${
|
|
987
|
-
if (role.note !== undefined) lines.push(`${' '.repeat(
|
|
995
|
+
lines.push(`${key.padEnd(12)} ${detail}${via}`);
|
|
996
|
+
if (role.note !== undefined) lines.push(`${' '.repeat(14)}note: ${role.note}`);
|
|
988
997
|
}
|
|
989
998
|
return lines.join('\n');
|
|
990
999
|
}
|
|
@@ -1162,6 +1171,10 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1162
1171
|
'',
|
|
1163
1172
|
`Enabled: ${config.enabled ? 'yes' : 'NO — observing and reporting only, no route is rewritten'}`,
|
|
1164
1173
|
'',
|
|
1174
|
+
`Selection: ${config.pick === 'round-robin'
|
|
1175
|
+
? 'round-robin — every role rotates across its own list'
|
|
1176
|
+
: 'first — every role starts at its top model and fails over down its list'} (one strategy for all roles)`,
|
|
1177
|
+
'',
|
|
1165
1178
|
roleTable(),
|
|
1166
1179
|
'',
|
|
1167
1180
|
`Strategy mode: ${config.strategy.mode}`
|
|
@@ -1414,11 +1427,11 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1414
1427
|
ctx.on('loader/volatile-update', () => {
|
|
1415
1428
|
try {
|
|
1416
1429
|
const next = readConfig(rawConfig);
|
|
1417
|
-
config = { enabled: next.enabled, roles: next.roles, strategy: next.strategy, warnings: next.warnings };
|
|
1430
|
+
config = { enabled: next.enabled, pick: next.pick, roles: next.roles, strategy: next.strategy, warnings: next.warnings };
|
|
1418
1431
|
visionMatch = keywordMatcher(config.strategy.visionKeywords);
|
|
1419
1432
|
planningMatch = keywordMatcher(config.strategy.planningKeywords);
|
|
1420
1433
|
for (const warning of config.warnings) log('warn', warning);
|
|
1421
|
-
log('info', `settings reloaded — mode ${config.strategy.mode}; `
|
|
1434
|
+
log('info', `settings reloaded — mode ${config.strategy.mode}, pick ${config.pick}; `
|
|
1422
1435
|
+ ROLE_NAMES
|
|
1423
1436
|
.map((key) => `${key}=${config.roles[key].models.length === 0 ? '-' : config.roles[key].models.map((r) => `${r.provider}/${r.model}`).join('|')}`)
|
|
1424
1437
|
.join(' '));
|
|
@@ -1437,7 +1450,8 @@ function createEngine(initialConfig, ctx, log, rawConfig) {
|
|
|
1437
1450
|
+ 'conversation and whether the manager yielded to a model a person picked in the '
|
|
1438
1451
|
+ 'composer, then one row per subagent with its label, role, reason, live status and '
|
|
1439
1452
|
+ 'totals. action "routes": the four role assignments '
|
|
1440
|
-
+ '(including the vision->execution fallback), the
|
|
1453
|
+
+ '(including the vision->execution fallback), the shared selection strategy (first or round-robin), '
|
|
1454
|
+
+ 'the active distribution mode, and whether each '
|
|
1441
1455
|
+ 'route is dispatchable by the delegation tool, with the YAML to add any that are not. '
|
|
1442
1456
|
+ 'action "usage": request and subagent counts by role and model across the whole process. '
|
|
1443
1457
|
+ 'action "client": whether the Host composed this plugin\'s Web client half into the browser '
|
|
@@ -1581,7 +1595,7 @@ export function apply(ctx, rawConfig) {
|
|
|
1581
1595
|
for (const warning of config.warnings) log('warn', warning);
|
|
1582
1596
|
const engine = createEngine(config, ctx, log, rawConfig);
|
|
1583
1597
|
engine.attach();
|
|
1584
|
-
log('info', `active — mode ${config.strategy.mode}; `
|
|
1598
|
+
log('info', `active — mode ${config.strategy.mode}, pick ${config.pick}; `
|
|
1585
1599
|
+ ROLE_NAMES
|
|
1586
1600
|
.map((key) => `${key}=${config.roles[key].models.length === 0 ? '-' : config.roles[key].models.map((r) => `${r.provider}/${r.model}`).join('|')}`)
|
|
1587
1601
|
.join(' '));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darkbear9494/dsh-model-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Role-based model manager for DeepSeek Harness: assign models to planning, execution, vision and main roles, route subagent work by role, and report which model every subagent used.",
|
|
6
6
|
"license": "MIT",
|