dsh-autorouter 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +86 -0
- package/LICENSE +21 -0
- package/README.md +244 -2
- package/bundle/cordis.patch.yml +13 -0
- package/client.js +1892 -0
- package/docs/README.zh-CN.md +245 -0
- package/icon.svg +10 -0
- package/index.js +226 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +70 -4
- package/src/adapter.js +141 -0
- package/src/config.js +350 -0
- package/src/http.js +371 -0
- package/src/router/classify.js +94 -0
- package/src/router/effort.js +142 -0
- package/src/router/model-info.js +103 -0
- package/src/router/select.js +107 -0
- package/src/router/walk.js +303 -0
- package/src/state.js +170 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to `dsh-autorouter`. The shape follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/) and the project uses semantic versioning.
|
|
5
|
+
Every version below was a working bundle: the suite passes on each tagged commit.
|
|
6
|
+
|
|
7
|
+
## 0.2.1
|
|
8
|
+
|
|
9
|
+
- README rewritten in the house style of the sibling `research-team-preset` plugin: badge row,
|
|
10
|
+
at-a-glance table, install specs for both the plugins page and the CLI, first-run walkthrough,
|
|
11
|
+
one troubleshooting entry per symptom, and limitations stated as limitations.
|
|
12
|
+
- the Chinese translation now lives in `docs/README.zh-CN.md` and cross-links both ways; the root
|
|
13
|
+
`README.zh-CN.md` is gone, and `docs` ships in the package.
|
|
14
|
+
|
|
15
|
+
## 0.2.0
|
|
16
|
+
|
|
17
|
+
- **a fresh install ships no route plan**: `DEFAULT_PROFILE` is gone and
|
|
18
|
+
`normalizeConfig` no longer re-adds default profiles, so nothing is routed until the
|
|
19
|
+
operator builds a chain from the providers they actually have credentials for. The routes tab
|
|
20
|
+
explains the empty state, and an unknown model reports "no profile yet" instead of a
|
|
21
|
+
four-entry list. A configuration that already exists on disk is never rewritten.
|
|
22
|
+
- locale completeness is now a test, not a habit: both dictionaries must carry the same keys,
|
|
23
|
+
and every `t('…')` the page uses must exist in both.
|
|
24
|
+
- README is English-first with a Chinese translation next to it; the package gained a
|
|
25
|
+
licence, keywords and author metadata.
|
|
26
|
+
|
|
27
|
+
## 0.1.15
|
|
28
|
+
- feat(ui): drop the gateway enable switch too
|
|
29
|
+
|
|
30
|
+
## 0.1.14
|
|
31
|
+
- feat(ui): drop the per-profile enable switch
|
|
32
|
+
- docs: describe the post-restart self-check and the current behaviour
|
|
33
|
+
|
|
34
|
+
## 0.1.13
|
|
35
|
+
- fix: never report a failed routed call as success
|
|
36
|
+
|
|
37
|
+
## 0.1.12
|
|
38
|
+
- fix: drop an effort the target cannot declare instead of failing the call
|
|
39
|
+
|
|
40
|
+
## 0.1.11
|
|
41
|
+
- fix: never hand the host metadata its validator rejects
|
|
42
|
+
|
|
43
|
+
## 0.1.10
|
|
44
|
+
- feat: drop the peak/off-peak preset and let the page try one real request
|
|
45
|
+
- fix(ui): name the old-host case when the try check has no route
|
|
46
|
+
|
|
47
|
+
## 0.1.9
|
|
48
|
+
- fix: answer a save with the written config, not a lagging projection
|
|
49
|
+
- feat: show which host build the page is talking to
|
|
50
|
+
|
|
51
|
+
## 0.1.8
|
|
52
|
+
- feat: let one named time window cover several disjoint stretches
|
|
53
|
+
|
|
54
|
+
## 0.1.7
|
|
55
|
+
- feat(ui): give every time window its own fallback chain
|
|
56
|
+
|
|
57
|
+
## 0.1.6
|
|
58
|
+
- fix(ui): fold time windows and policy into the card as visible sections
|
|
59
|
+
|
|
60
|
+
## 0.1.5
|
|
61
|
+
- feat(ui): keep windows and policy inside each profile card, split live status into its own tab
|
|
62
|
+
|
|
63
|
+
## 0.1.4
|
|
64
|
+
- feat: drop the request budget and let the settings cards collapse
|
|
65
|
+
- chore: pin line endings to LF so a checkout never rewrites the sources
|
|
66
|
+
- fix(ui): drop the unlabelled selector dot from the profile card
|
|
67
|
+
|
|
68
|
+
## 0.1.3
|
|
69
|
+
- feat: route strictly by chain order and add peak/off-peak time windows
|
|
70
|
+
- docs(ui): explain the request budget and drop dead weight labels
|
|
71
|
+
- fix: await settings.replace so a save response carries the new revision
|
|
72
|
+
|
|
73
|
+
## 0.1.2
|
|
74
|
+
- fix: mark the Config schema volatile so settings.describe projects it
|
|
75
|
+
|
|
76
|
+
## 0.1.1
|
|
77
|
+
- fix: declare @deepseek-ai peers so the linked bundle resolves at import
|
|
78
|
+
- test: boot apply() and client registration against stubbed peers
|
|
79
|
+
- docs: record the peerDependencies rule and the recompose-without-restart path
|
|
80
|
+
- fix(client): keep profile input focus, follow host dark scheme, add nav icon
|
|
81
|
+
- fix: resolve the settings row by entry id, follow the painted theme for select popups
|
|
82
|
+
- docs: the settings section needs a profile row
|
|
83
|
+
|
|
84
|
+
## 0.1.0
|
|
85
|
+
- feat: AutoRouter provider with settings page, routing core and tests
|
|
86
|
+
- fix(http): probe provider directory shapes and keep conflict config live
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ruixin Zhan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,245 @@
|
|
|
1
|
-
#
|
|
1
|
+
# AutoRouter
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/deepseek-ai/deepseek-harness) [](https://github.com/deepseek-ai/deepseek-harness) [](LICENSE)
|
|
4
|
+
|
|
5
|
+
**A DSH plugin that makes every provider and model you already registered look like one provider, with a fallback chain behind it.**
|
|
6
|
+
|
|
7
|
+
**Version 0.2.1** · **Updated 2026-11-26**
|
|
8
|
+
|
|
9
|
+
<p align="center"><strong>English</strong> · <a href="docs/README.zh-CN.md">简体中文</a></p>
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
AutoRouter registers one native DSH provider, `autorouter` (shown as **AutoRouter**), and routes each request along a chain of routes that already exist in the host. You keep using the credentials, dialects and model registrations DSH already knows; AutoRouter only decides which registered route serves this request, and what to do when that route fails.
|
|
16
|
+
|
|
17
|
+
It is not a proxy. Every attempt is dispatched through DSH's own `llm.stream()` to the provider that owns it, so images, attachments, tool history and replay state stay inside the adapter that understands them. There is no HTTP hop, no second key store, and no translation layer that could lose a field.
|
|
18
|
+
|
|
19
|
+
The plugin also owns the settings page under **Settings → AutoRouter**, where the chain, the per-window chains, the cooldowns and the live status are edited. Nothing about routing is hidden in a config file you have to hand-edit.
|
|
20
|
+
|
|
21
|
+
## At a glance
|
|
22
|
+
|
|
23
|
+
| | |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| **Visible surface** | One provider id, `autorouter`; one picker row per profile, `AutoRouter / <profile>` |
|
|
26
|
+
| **Routing** | The chain array is the order: top to bottom, first usable route wins. No weights, no cost or quality scoring |
|
|
27
|
+
| **Failover** | Only before the first output block; `block-start` and any content delta commit the attempt. After that a failure is forwarded, not switched |
|
|
28
|
+
| **Spend accounting** | `usage` never commits an attempt; it is buffered and replayed before a switch, so the number never disappears |
|
|
29
|
+
| **Quota** | No local budget. The upstream's 429 and the per-route failure count are the signal; a route that keeps failing cools down |
|
|
30
|
+
| **Reasoning effort** | Inherited: the virtual model advertises the union of the chain's efforts, each attempt maps the request onto the target, clamping by default |
|
|
31
|
+
| **Time windows** | A window is a name for one or more disjoint stretches of the day, and owns a **complete fallback chain** of its own |
|
|
32
|
+
| **Sessions** | Sticky by `sessionId` for the sticky TTL, which keeps the upstream prompt cache warm |
|
|
33
|
+
| **Runtime** | A native `LlmAdapter`; every attempt is a nested `llm.stream()` on an already registered route |
|
|
34
|
+
|
|
35
|
+
## Who it is for
|
|
36
|
+
|
|
37
|
+
- Setups with several routes for the same job — a subscription, a cheap mirror, an account with its own quota — where you want one picker entry instead of switching by hand.
|
|
38
|
+
- Work that must survive a route going down mid-project: `AUTH`, `QUOTA`, `RATE_LIMIT` and network failures move to the next route without touching the session.
|
|
39
|
+
- Anyone who wants the peak/off-peak ordering of the same routes to follow the clock instead of a manual switch.
|
|
40
|
+
- Users who would rather have the plan edited in a settings page than in YAML.
|
|
41
|
+
|
|
42
|
+
**Not for:** a single provider with a single key. Adding a chain of one only adds a layer; point the model at the route directly. It is also not a way to multiply one provider's quota — DSH binds one credential per route, so a "key pool" is a list of routes, each with its own credential.
|
|
43
|
+
|
|
44
|
+
## Requirements
|
|
45
|
+
|
|
46
|
+
AutoRouter is a **profile-level DSH bundle**. It installs nothing else and enables nothing else: the routes it walks are the ones your profile already has.
|
|
47
|
+
|
|
48
|
+
| Capability | Provider | Notes |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| DSH | [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) `0.2.x` | Developed against `0.2.2-rc.3`; the LLM service contract it uses (`registerAdapter`, `resolveModelInfo`, `prepareCall`) is stable across the series |
|
|
51
|
+
| At least one registered route | your own provider rows | `autorouter` walks `llm.listProviders()`; a route with no credential resolves but fails at request time |
|
|
52
|
+
| Node | `>= 22` | The host runs it; only matters when you test the package outside DSH |
|
|
53
|
+
|
|
54
|
+
**Optional:** a fallback-chain plugin such as `dsh-llm-fallbacks` is not required and not used. If both are installed they are independent providers; keep one of them in the picker to avoid routing the same request through two layers.
|
|
55
|
+
|
|
56
|
+
If the profile has no route with a working credential, AutoRouter still loads and the settings page still works — the `试一次` button reports the upstream failure that a real request would get.
|
|
57
|
+
|
|
58
|
+
## Install
|
|
59
|
+
|
|
60
|
+
AutoRouter ships as a DSH bundle and is published on npm as `dsh-autorouter`.
|
|
61
|
+
|
|
62
|
+
### Install from the DSH plugins page
|
|
63
|
+
|
|
64
|
+
1. Open **Settings → Plugins** and click **Add**.
|
|
65
|
+
2. Paste the install spec: `dsh-autorouter@0.2.1` for the npm package, `github:ZhanRuiXin/dsh-autorouter#v0.2.1` to pin the source, or `link:/absolute/path/to/dsh-autorouter` for a local checkout.
|
|
66
|
+
3. **Restart DSH.** The host half registers the adapter and the HTTP routes at startup; the client half loads with the page.
|
|
67
|
+
4. Open **Settings → AutoRouter**, create a profile, and add the routes you want in the chain.
|
|
68
|
+
|
|
69
|
+
### Install from the CLI
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
dsh plugin add dsh-autorouter@0.2.1
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To pin the source instead of the registry:
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
dsh plugin add github:ZhanRuiXin/dsh-autorouter#v0.2.1
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
> The bundle is profile-level: installing it in one profile does not enable it in another, and the settings page appears only in the profile where the row is enabled.
|
|
82
|
+
|
|
83
|
+
## First run
|
|
84
|
+
|
|
85
|
+
A fresh install ships **no route plan** on purpose: nothing is routed until you build a chain from the providers you actually have. Start by opening **Settings → AutoRouter**:
|
|
86
|
+
|
|
87
|
+
1. **+ New profile** — the profile id becomes the model id (`auto` → `AutoRouter / auto`).
|
|
88
|
+
2. **Add route** — pick a provider and a model from the registered ones. Repeat for each route; the order in the card is the order they are tried.
|
|
89
|
+
3. **Save**. The header version line should read `host v0.2.1`; if it says the host has not reported a version, DSH is still running the old process.
|
|
90
|
+
4. **Try once** on the status tab. It sends one real minimal request through `autorouter/<profile>` and reports the route that served it, the elapsed time and the text.
|
|
91
|
+
5. Pick `AutoRouter / <profile>` in the model picker, or point `agent-default-model` at `{ "provider": "autorouter", "model": "auto" }`.
|
|
92
|
+
|
|
93
|
+
A typical chain, in the order it is tried:
|
|
94
|
+
|
|
95
|
+
```text
|
|
96
|
+
AutoRouter / auto
|
|
97
|
+
├─ opendesign/deepseek-v4.1-flash-eco cheap mirror, first when it is up
|
|
98
|
+
├─ commandcode/deepseek/deepseek-v4.1-flash
|
|
99
|
+
└─ deepseek-account/deepseek-flash the account that must not be wasted
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## How a request is routed
|
|
103
|
+
|
|
104
|
+
Candidate selection is `chain order → usability → active time window → sticky pin`. Usability drops a route that is cooling down; the window reorders what is left; the sticky pin moves the route that served this session last to the front.
|
|
105
|
+
|
|
106
|
+
An attempt is committed the moment the adapter yields `block-start`, text, reasoning or a tool-call delta. Before that, a terminal failure with a trigger code (`AUTH`, `QUOTA`, `RATE_LIMIT`, `NETWORK`, and the HTTP statuses in the trigger list) moves to the next route. After it, the failure is forwarded exactly as the upstream reported it: a half-streamed answer is never silently restarted on another provider.
|
|
107
|
+
|
|
108
|
+
A route that fails is booked and cools down (`cooldownMs`, `5` minutes by default, with optional jitter). Retry-After from the upstream is honoured when `honorRetryAfter` is on. Repeated failures inside `failureWindowMs` back off exponentially up to `backoffMaxMs`. A cooling route is skipped, not removed, and comes back on its own; the **live status** tab lists each one and can clear a single cooldown.
|
|
109
|
+
|
|
110
|
+
`maxSwitches` is a fuse, not a target: the walk stops after that many switches in one step and reports the last failure instead of looping.
|
|
111
|
+
|
|
112
|
+
## Reasoning effort
|
|
113
|
+
|
|
114
|
+
DSH's default agent model carries `reasoningEffort: max`, and a chain mixes routes that declare different effort sets — or none at all. AutoRouter handles that instead of letting the request die before any I/O:
|
|
115
|
+
|
|
116
|
+
- The virtual model advertises the **union** of the efforts declared along the chain, so `max` stays selectable even if one route only declares `low` and `high`.
|
|
117
|
+
- Each attempt resolves the request as `entry.effortMap[effort]` → the target's declared `defaultEffort` → omit the parameter. `effortPolicy` decides what happens when the target cannot take it: `clamp` (default) uses the closest declared effort, `drop` omits it, `fail` refuses the attempt.
|
|
118
|
+
- A target that declares no reasoning at all is a known-no-reasoning target: the parameter is dropped rather than forwarded, because forwarding it makes DSH reject the call before the adapter runs. If an upstream still answers `UNSUPPORTED_REASONING_EFFORT`, the parameter is removed and the same route is retried once — a route is never abandoned for a parameter the caller could not have known about.
|
|
119
|
+
|
|
120
|
+
## Time windows
|
|
121
|
+
|
|
122
|
+
A window is a label plus one or more `ranges` of local clock time, and it owns a complete ordering of the profile's routes. Hitting any of its ranges makes it the active window, and its `order` becomes the chain. Routes the window does not list keep their configured position and run last, so a window can never empty the candidate set.
|
|
123
|
+
|
|
124
|
+
```text
|
|
125
|
+
deepseek-offpeak 00:30–08:30, 22:00–23:30 deepseek-account/* first, everything else after
|
|
126
|
+
default order the chain as edited on the default tab
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Ranges are half-open (`from` inclusive, `to` exclusive) and wrap when `from > to`; `from === to` means all day. Local time is the profile's `utcOffsetMinutes` (UTC+8 by default), so the plan does not shift when the machine's zone changes. A legacy single `{ from, to }` is folded into one range automatically.
|
|
130
|
+
|
|
131
|
+
In the settings page the window buttons sit above the chain: pick a button and the arrows reorder **that window's** chain; pick `default order` to edit the chain used when no window matches. A new window starts as a copy of the current chain.
|
|
132
|
+
|
|
133
|
+
## The settings page
|
|
134
|
+
|
|
135
|
+
Three tabs, nothing else:
|
|
136
|
+
|
|
137
|
+
- **Routes** — one card per profile, the card head is the expand/collapse control. Inside, three sections separated by hairlines: **chain**, **time windows**, **policy**. There is no "selected profile": every setting lives in the card it belongs to, so a change can never land on a profile you were not looking at.
|
|
138
|
+
- **Live status** — cooldowns and failure counts per route, the sticky sessions, the request counters, `Try once`, and the `host vX.Y.Z` line. It is deliberately not on the routes tab: editing a chain should not have a table ticking every two seconds next to it.
|
|
139
|
+
- **JSON** — the whole configuration, editable, folded back into the form on apply.
|
|
140
|
+
|
|
141
|
+
**Save** is always clickable and answers with the configuration that was actually written, then refreshes the page from the server. **Undo** is the local inverse: it drops unsaved edits and restores the last saved configuration without a network round trip. Writes go through `settings.replace(ns, value, revision)`, so a stale tab gets `409` instead of overwriting someone else's save.
|
|
142
|
+
|
|
143
|
+
## Where settings are stored
|
|
144
|
+
|
|
145
|
+
The configuration lives in the profile patch row that the bundle inserts, and the settings page writes it back there:
|
|
146
|
+
|
|
147
|
+
```yaml
|
|
148
|
+
- id: llm-autorouter
|
|
149
|
+
name: dsh-autorouter
|
|
150
|
+
config:
|
|
151
|
+
enabled: true
|
|
152
|
+
profiles:
|
|
153
|
+
- id: auto
|
|
154
|
+
name: Auto
|
|
155
|
+
chain: [ … ]
|
|
156
|
+
policy: { maxSwitches: 8, cooldownMs: 300000, sticky: true, … }
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```text
|
|
160
|
+
%USERPROFILE%\.dsh\profiles\<profile>\cordis.patch.yml ($DSH_HOME/profiles/<profile>/cordis.patch.yml)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
- The row id is `llm-autorouter`; the bundle's own patch inserts it as `include:llm-autorouter`, and the host matches `llm-autorouter`, `include:llm-autorouter`, then `*:llm-autorouter` instead of hard-coding one name.
|
|
164
|
+
- The config schema must stay `volatile` (`z.object({…}).extra('volatile', true)`). `settings.describe()` only projects config with a volatile field; without it the entry is skipped and every save reports `no profile entry`.
|
|
165
|
+
- The JSON tab is the escape hatch for a hand-edited document; a field AutoRouter does not know is preserved, an illegal route is dropped by `normalizeConfig` rather than crashing the walk.
|
|
166
|
+
- Cooldowns, counters and sticky sessions are **in-process**: a restart clears them, and they describe failures seen on this machine, not the upstream's real quota.
|
|
167
|
+
|
|
168
|
+
## Configuration reference
|
|
169
|
+
|
|
170
|
+
| Setting | Where | Notes |
|
|
171
|
+
| --- | --- | --- |
|
|
172
|
+
| `profiles[].id` | config | Becomes the model id: `autorouter/<id>`; also the display name in the picker |
|
|
173
|
+
| `profiles[].chain[]` | config | Ordered routes; `provider` + `model` must exist in the host. `cooldownMs` and `effortMap` are per route |
|
|
174
|
+
| `profiles[].policy.maxSwitches` | config | Fuse for one step; the walk stops instead of looping |
|
|
175
|
+
| `policy.cooldownMs` / `cooldownJitterRatio` | config | Cooldown after a booked failure, plus optional spread so routes do not come back in lockstep |
|
|
176
|
+
| `policy.sticky` / `stickinessTtlMs` | config | Session stickiness and how long a pin survives before the route is re-chosen |
|
|
177
|
+
| `policy.triggerCodes` / `triggerStatuses` | config | What counts as "switch to the next route"; anything else is forwarded |
|
|
178
|
+
| `policy.honorRetryAfter` / `retryOnNetwork` | config | Upstream `Retry-After`, and whether transport failures are retryable |
|
|
179
|
+
| `policy.effortPolicy` / `contextPolicy` | config | `clamp` / `drop` / `fail`; `min` / `max` for the advertised context window |
|
|
180
|
+
| `policy.timeWindows[]` | config | `{ id, label, ranges[], utcOffsetMinutes, order[] }`; `order` is the window's full chain |
|
|
181
|
+
| `/api/autorouter/*` | host | Same-origin HTTP surface used by the page; `auth: 'required'` on the existing DSH port |
|
|
182
|
+
|
|
183
|
+
## How it works
|
|
184
|
+
|
|
185
|
+
- **Adapter** — `src/adapter.js` extends `LlmAdapter` and registers the single provider `autorouter`. `listModels` returns one row per profile, `resolveModel` builds the virtual model info from the chain (effort union, smallest known context window, `toolUpdate` taken conservatively), and `stream` hands the request to the walk.
|
|
186
|
+
- **Walk** — `src/router/walk.js` iterates the candidates, dispatches each attempt as a nested `llm.stream()` on the real provider, buffers `usage`, and re-throws only when it is before any output. It owns the fuse, the parameter repair and the replay envelope.
|
|
187
|
+
- **Classify** — `src/router/classify.js` turns a terminal finish into a switch/skip/forward decision from the trigger set, the status code and the request-scoped codes DSH reports (a request that is too big is not a broken route).
|
|
188
|
+
- **Effort** — `src/router/effort.js` builds the union, resolves one attempt's effort and reports the coercion so the transcript can explain a dropped `max`.
|
|
189
|
+
- **State** — `src/state.js` holds cooldowns, failure windows, counters and session pins; everything is in-process and disposable.
|
|
190
|
+
- **HTTP + client** — `src/http.js` serves `/api/autorouter/{state,config,catalog,probe,cooldown,selection,try}`, `index.js` wires the adapter, the routes and the settings row, and `client.js` registers the settings section plus its nav icon.
|
|
191
|
+
|
|
192
|
+
`src/config.js`, `src/state.js` and `src/router/*` do not import `@deepseek-ai/*`, so the routing core runs and tests outside DSH; `test/plugin.test.js` stubs the peers for the integration path, and `test/client-render.test.js` renders the real page with a small React double.
|
|
193
|
+
|
|
194
|
+
## Troubleshooting
|
|
195
|
+
|
|
196
|
+
### The settings page saves, then shows the old values
|
|
197
|
+
|
|
198
|
+
The page asks the host for the configuration right after saving, and the host used to answer from a projection that lagged the write. Version `0.1.9` fixed it: the save response carries the configuration that was written, and the page no longer refetches the draft afterwards. If you still see it, check the `host vX.Y.Z` line — a host older than `0.1.9` is running the old code path.
|
|
199
|
+
|
|
200
|
+
### `no profile entry "llm-autorouter"` on save
|
|
201
|
+
|
|
202
|
+
`settings.describe()` had no entry for this plugin, so the write had nowhere to land. Two causes, in order of likelihood:
|
|
203
|
+
|
|
204
|
+
- the running host is older than `0.1.2`, which is when the config schema was marked volatile;
|
|
205
|
+
- the bundle is installed but not enabled in this profile.
|
|
206
|
+
|
|
207
|
+
Restart DSH after updating and confirm the row is enabled in **Settings → Plugins**.
|
|
208
|
+
|
|
209
|
+
### No `AutoRouter` row in the model picker
|
|
210
|
+
|
|
211
|
+
The adapter is registered by the host half at startup. Restart DSH and reload the page; a client-only refresh cannot register a provider. If the row is still missing, `cordis_inspect` on the `llm` service should list `autorouter` among the providers.
|
|
212
|
+
|
|
213
|
+
### The routes tab says there is no profile yet
|
|
214
|
+
|
|
215
|
+
That is the shipped default: a fresh install routes nothing. Use **+ New profile**, add routes, save. An existing configuration is never rewritten by an upgrade.
|
|
216
|
+
|
|
217
|
+
### `Try once` answers 404
|
|
218
|
+
|
|
219
|
+
The `/api/autorouter/try` route only exists in `0.1.10` and later. Restart DSH on the current build; the page names this case explicitly instead of showing a generic failure.
|
|
220
|
+
|
|
221
|
+
### A route fails with `UNSUPPORTED_REASONING_EFFORT`
|
|
222
|
+
|
|
223
|
+
Fixed in `0.1.12`: an effort the target cannot declare is dropped (or clamped) instead of being forwarded, and a route that still rejects the parameter is retried once without it. If you see it on a current build, the profile's `effortPolicy` is `fail` — that is the setting refusing the call on purpose.
|
|
224
|
+
|
|
225
|
+
### A route stays in cooldown
|
|
226
|
+
|
|
227
|
+
Cooldowns are per route and per process. The **live status** tab shows the remaining time and clears a single route; a restart clears all of them. Nothing is persisted, so an upgrade or restart does not inherit a stale cooldown.
|
|
228
|
+
|
|
229
|
+
## Known limitations
|
|
230
|
+
|
|
231
|
+
- The assistant message source is recorded as `autorouter/<profile>`, so DSH does not retain the upstream `replayState`. Every turn resends the full history; the upstream prompt cache still helps, but a replay-style adapter gets no delta. Preserving it needs a route-tagged envelope and a source rewrite, which the host contract does not expose today.
|
|
232
|
+
- Cooldowns, counters and sticky pins are in-process. A restart starts from zero, and the numbers describe this machine's experience, not the upstream's quota ledger.
|
|
233
|
+
- The catalog only lists what DSH has registered. Nothing is discovered over the network, so a provider that is out of favour but still registered stays selectable.
|
|
234
|
+
- The model picker shows `AutoRouter / <profile>`; the profile id is the model id, so renaming a profile changes the model a session must ask for.
|
|
235
|
+
- There is no HTTP facade: AutoRouter is a native adapter, not an OpenAI-compatible endpoint. A `baseURL` gateway that would let non-DSH clients share the same chain is a separate design (`DESIGN.md` §9) and is not implemented.
|
|
236
|
+
|
|
237
|
+
## License
|
|
238
|
+
|
|
239
|
+
MIT. See [LICENSE](LICENSE).
|
|
240
|
+
|
|
241
|
+
## Acknowledgements
|
|
242
|
+
|
|
243
|
+
Built on [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) and [Cordis](https://github.com/cordiverse/cordis). The failover contract deliberately copies the one `dsh-llm-fallbacks` established — switch only before output, book failures, never restart a half-streamed answer — so a session behaves the same whichever router is in the picker.
|
|
244
|
+
|
|
245
|
+
Design notes, the host contract this plugin is built against, and the failure matrix live in [DESIGN.md](DESIGN.md); the release history is in [CHANGELOG.md](CHANGELOG.md).
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# The dsh-autorouter profile-bundle patch: ONE plugin row added over the
|
|
2
|
+
# profile's bundle stack (`dsh.profile.bundles` order, later layers win per
|
|
3
|
+
# row). The plugin needs the `llm`, `settings` and `webServer` services, which
|
|
4
|
+
# dsh-base already provides, so its position after the base bundles is enough.
|
|
5
|
+
#
|
|
6
|
+
# A patch replaces the targeted row's whole `config` rather than merging into
|
|
7
|
+
# it. This row ships neutral defaults (`normalizeConfig` fills the rest); the
|
|
8
|
+
# profile-layer `cordis.patch.yml` override wins and is what the Settings page
|
|
9
|
+
# writes through `settings.replace`.
|
|
10
|
+
- insert:
|
|
11
|
+
- id: llm-autorouter
|
|
12
|
+
name: 'dsh-autorouter'
|
|
13
|
+
config: {}
|