dsh-openrouter-plus 0.0.0-stage → 0.1.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/CHANGELOG.md ADDED
@@ -0,0 +1,46 @@
1
+ # Changelog
2
+
3
+ Notable changes to `dsh-openrouter-plus`. Format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versions follow
5
+ [SemVer](https://semver.org/), and the project stays below 1.0 while the routing presets and
6
+ the config keys can still change.
7
+
8
+ ## [Unreleased]
9
+
10
+ Nothing yet.
11
+
12
+ ## [0.1.0] — 2026-10-26
13
+
14
+ First release: a loopback relay that applies an OpenRouter **routing preset** to a request at
15
+ send time, chosen per Session from the composer.
16
+
17
+ ### Added
18
+
19
+ - **Nine routing presets**, each a named wire effect rather than a price promise: *No pin*,
20
+ Standard (`service_tier: "default"`), Fastest · any price (`provider.sort: "throughput"`),
21
+ Fastest · standard price, Cheapest (`provider.sort: "price"`), Flex
22
+ (`service_tier: "flex"`), Priority (`service_tier: "priority"`), Ultra
23
+ (`service_tier: "ultrafast"`), Floor (the `:floor` model variant).
24
+ - **A preset chip in the composer**, next to the model selector: the choice applies to one
25
+ Session, is never written to a provider row, and the first entry returns the Session to the
26
+ profile default.
27
+ - **OpenRouter Plus settings page**: relay state and origin, one pinned base URL per preset with
28
+ a copy button, live request/token counters per tier, the measured effective multiplier, recent
29
+ requests, and a provider-route switch that repoints one existing row at the relay.
30
+ - **Pinned base URLs** (`/v1`, `/default/v1`, `/flex/v1`, `/priority/v1`, `/ultrafast/v1`) for the
31
+ case a per-Session choice cannot cover: a route pinned this way keeps its preset for every
32
+ Session on it and across restarts.
33
+ - **`defaultPreset`** — the preset an unchosen Session inherits, edited on the settings page.
34
+ - **A relay control API** on loopback only: `status`, `targets`, `tier`, `traffic`, plus the
35
+ route attach/detach/repair endpoints the settings page drives.
36
+ - **Reasoning-effort fill** for relay-routed models, so a route that points at the relay keeps the
37
+ thinking-level selector.
38
+
39
+ ### Notes on the wire
40
+
41
+ - No preset is ever sent as `provider.sort` together with `service_tier: "flex"`, and `default`
42
+ is only written when the preset asks for it, never as a default for an unset choice.
43
+ - `ultrafast` is OpenAI-only and needs `max_tokens`; the relay warns when a Session sets it
44
+ without one and never injects the field.
45
+ - A `provider` block on the request is merged, not replaced, so `provider.only`, `provider.order`
46
+ and `provider.ignore` survive every preset.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 dsh-openrouter-plus contributors
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,400 @@
1
- # Temporary Holding Version
1
+ # dsh-openrouter-plus
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ **Service-tier routing for OpenRouter — as a DeepSeek Harness plugin, with no patched packages.**
4
+
5
+ OpenRouter lets you steer where a request is served from: `flex` endpoints bill half price on a
6
+ slower pool, `priority` endpoints bill a multiplier for lower latency, and the throughput or price
7
+ comparators reorder the pool in between. In `@deepseek-ai/dsh-llm-pi-ai` none of that is reachable —
8
+ provider profiles expose `baseURL` and `headers`, but no request-body fields
9
+ ([discussion #9787](https://github.com/deepseek-ai/deepseek-harness/discussions/9787)).
10
+
11
+ This plugin reaches the same wire result from the outside. It runs a **loopback relay**; a provider
12
+ route points at it, and the relay writes the routing fields into the request body on the way
13
+ upstream — `service_tier`, `provider.sort`, or the `:floor` model variant, depending on the
14
+ **preset** you picked. Because it only uses schema fields the profile already has, it survives
15
+ `bun install -g` upgrades and never touches `~/.bun/install/global`.
16
+
17
+ The preset is chosen **per session, at request time**. One provider row keeps serving every preset, so
18
+ switching never mints a provider, a route or a model list.
19
+
20
+ ```
21
+ composer chip: this session runs on «priority»
22
+ │
23
+ ▼
24
+ dsh-llm-pi-ai ──► dsh-openrouter-plus relay ──► https://openrouter.ai/api/v1
25
+ baseURL = │ reads the session from x-session-id / prompt_cache_key,
26
+ 127.0.0.1:8791/t/<id>/v1 │ applies that session's preset to the body
27
+ └── /__openrouter-plus/* ──► OpenRouter Plus settings page
28
+ ```
29
+
30
+ ## What you get
31
+
32
+ - **One provider row, any preset.** A routed provider keeps its key, protocol and models and gains
33
+ one thing: a composable **preset** that the relay applies to each request. No per-preset provider
34
+ copies, no sibling route per preset, no model list duplicated nine times.
35
+ - **Pinned base URLs** for what a chip cannot cover — `/v1` (no pin), `/default/v1` (Standard),
36
+ `/flex/v1` (Flex), `/priority/v1` (Priority), `/ultrafast/v1` (Ultra). Paste one into an
37
+ OpenAI-compatible provider route and that preset applies to *every* Session on the route,
38
+ subagents included, and survives a restart. The relay still serves the older names
39
+ (`/auto/v1`, `/fast/v1`, `/scale/v1`); the settings page lists one mount per preset so it never
40
+ offers the same choice twice.
41
+ - **Its own settings page** (Settings → OpenRouter Plus) showing relay state, one pinned base URL
42
+ per preset with a copy button, live request/token counters per tier, the weighted cost
43
+ multiplier, and recent requests.
44
+ - **A preset chip in the composer** — next to the model selector, a compact chip shows the preset
45
+ this Session will actually apply and switches it in one click. The switch is **per session**: it
46
+ changes what the next request from *this* conversation carries, so two conversations can sit on
47
+ `Flex` and `Priority` at the same time. It shows up on a brand-new Session too — before the first
48
+ message the chip reads the profile default, so a preset can be picked *before* you start typing.
49
+ The reasoning effort you chose stays put: switching a preset touches no provider row and no model
50
+ list.
51
+ - **A switch on every provider row** — in Settings → Models, each `llm-pi-ai` provider gets a
52
+ **Route through OpenRouter Plus** checkbox. Tick it and that provider's traffic flows through the
53
+ relay to the endpoint you already gave it; untick it and the endpoint comes back. Your provider
54
+ entry, protocol, key and models are left exactly as they were.
55
+ - **A default preset for the profile** — the settings page sets what an unchosen Session inherits
56
+ (and explains what every preset sends), and the composer chip's `Profile default (…)` entry hands
57
+ a Session back to it.
58
+ - **Zero risk to your existing setup** — the relay holds no API key, forwards your `Authorization`
59
+ header verbatim, binds only to loopback, and the only profile changes it makes are reversible by
60
+ construction.
61
+
62
+ ## Install
63
+
64
+ `--profile` is not optional — `dsh plugin` manages the plugins of one named profile, so pass the
65
+ one you actually boot (`web` for `dsh web`, `default` for a bare `dsh`). Without it the CLI stops
66
+ with `required option '--profile <name>' not specified`.
67
+
68
+ ```bash
69
+ dsh plugin --profile web add github:GnaneshKunal/dsh-openrouter-plus # latest main
70
+ dsh plugin --profile web add github:GnaneshKunal/dsh-openrouter-plus#v0.1.0 # a tag, once tagged
71
+ ```
72
+
73
+ From a clone, which is what development uses:
74
+
75
+ ```bash
76
+ git clone https://github.com/GnaneshKunal/dsh-openrouter-plus
77
+ dsh plugin --profile web add ./dsh-openrouter-plus # or, from a session:
78
+ # plugin_manager { action: install_bundle, target: "./dsh-openrouter-plus" }
79
+ ```
80
+
81
+ The manifest declares `engines.dsh`, so the plugin manager refuses a harness older than the build
82
+ it was tested against instead of mounting something that cannot work.
83
+
84
+ The plugin adds one entry to Settings navigation: **OpenRouter Plus**, directly after *Models*. If
85
+ the relay is up, the page shows the origin (`http://127.0.0.1:8791`) and its mounts.
86
+
87
+ ## Releasing
88
+
89
+ `.github/workflows/ci.yml` runs `npm run check`, `npm test` and `npm pack --dry-run` on every push
90
+ and pull request. `.github/workflows/release.yml` turns a tag into a release:
91
+
92
+ ```bash
93
+ $EDITOR package.json CHANGELOG.md # version 0.2.0, and a "## [0.2.0] — 2026-11-02" section
94
+ git commit -am "chore: 0.2.0" && git push
95
+ git tag v0.2.0 && git push origin v0.2.0
96
+ ```
97
+
98
+ The job refuses a tag that disagrees with `package.json`, runs the suite, publishes to npm, and
99
+ opens the GitHub Release with the matching `CHANGELOG.md` section as its notes. It fails rather
100
+ than skipping when npm already has that version: a release is a new version, never a re-upload.
101
+
102
+ npm needs the package to exist before it can trust a publisher, so the first version goes up by
103
+ hand, once, from a logged-in machine:
104
+
105
+ ```bash
106
+ npm login
107
+ npm publish --access public
108
+ npm trust github dsh-openrouter-plus --file release.yml \
109
+ --repo GnaneshKunal/dsh-openrouter-plus --env release --allow-publish
110
+ ```
111
+
112
+ After that the tag does everything: the workflow run's OIDC identity is accepted, npm attaches a
113
+ provenance attestation linking the tarball to the commit and run that built it, and no
114
+ `NPM_TOKEN` exists in the repository. `npm trust list dsh-openrouter-plus` shows the grant.
115
+
116
+ Publishing to npm is optional for users: `dsh plugin --profile web add github:…` installs the same code from a
117
+ tag, which is how most of the community ships.
118
+
119
+ ## Use it
120
+
121
+ ### Two clicks: tick the provider, pick the preset
122
+
123
+ 1. **Settings → Models** → tick **Route through OpenRouter Plus** on the provider you already use
124
+ (for example `openrouter-custom`). That provider's traffic now flows through the relay; its
125
+ `api`, `apiKeyEnv`, headers and models are untouched.
126
+ 2. Open the composer of any Session and pick a preset in the chip next to the model selector. Every
127
+ request that Session sends now applies that preset.
128
+
129
+ Nothing else to create, and nothing to clean up: the provider row is the only row that ever existed,
130
+ and the preset is a per-Session choice rather than a provider.
131
+
132
+ The settings page manages the profile-level **Service tier for new sessions** — with a short table
133
+ of what each preset sends — and lists the routes that currently point at this relay (with **Remove**
134
+ for the ones you no longer want).
135
+
136
+ ### From a provider row (the switch)
137
+
138
+ In **Settings → Models**, every `llm-pi-ai` provider row carries a compact strip added by this
139
+ plugin: a **Route through OpenRouter Plus** checkbox.
140
+
141
+ Ticking it does three things, all through the control API:
142
+
143
+ 1. records the endpoint that row currently points at (that is your real base URL) as a *target* in
144
+ this plugin's own config;
145
+ 2. gives that target a mount — `http://127.0.0.1:8791/t/<targetId>/v1` — which *mounts* the
146
+ endpoint without pinning a service tier: the presets come from the Sessions that call it;
147
+ 3. repoints **only** that provider row's `baseURL` at the mount. `api`, `apiKeyEnv`, headers and
148
+ models are not touched, and no plugin bookkeeping is written into the provider entry (it is
149
+ schema-validated, so it stays clean).
150
+
151
+ **The first attach reloads the plugin.** Recording a new target is a write to this plugin's own
152
+ config, so the Loader re-applies the Host row and the listener rebinds — which can cut the HTTP
153
+ response to that very request. It is not a failure: the strip re-probes `/health`, re-reads
154
+ `/targets` and shows the truth, and every write here is idempotent, so a retry lands cleanly. Later
155
+ attaches (a detach, a re-attach of a known endpoint) reuse the target row and do not reload anything.
156
+ **A preset switch never writes anything**, so it never reloads anything either.
157
+
158
+ What happens to a request: the relay strips the mount prefix, appends the rest of the path to your
159
+ recorded endpoint, resolves the preset the Session carrying that request chose, and applies it to the
160
+ JSON body. `No pin` sends neither a tier nor a comparator — and a `service_tier` the client put there
161
+ itself is removed, so a Session that pinned nothing stays unpinned rather than inheriting whatever a
162
+ UI happened to send.
163
+
164
+ Untick it (**Detach**) and the row's `baseURL` goes back to the endpoint recorded for that target;
165
+ the mount stays until you remove the target. Everything is idempotent: the same endpoint always maps
166
+ to the same target id, so ticking the box twice cannot fork the table or repoint anything twice.
167
+
168
+ > **Why the switch is on the row and not inside the add-provider form.** The obvious place for this
169
+ > checkbox is the "Custom model API" form itself. A plugin cannot put it there: the
170
+ > `settings.models.provider-card` extension slot hands an extension `{provider, configured,
171
+ > keyConfigured}` and no setter, the draft Base URL lives in a private `useState` inside the editor,
172
+ > and that card dispatches no extension at all before the provider is saved. The saved row is the
173
+ > earliest surface a plugin can reach — same page, one save later. The same class of limitation is
174
+ > why a re-picked model loses hand-declared fields (tracked upstream as
175
+ > [discussion #11097](https://github.com/deepseek-ai/deepseek-harness/discussions/11097)).
176
+
177
+ ### By hand
178
+
179
+ Point any OpenAI-compatible provider route's `baseURL` at a mount:
180
+
181
+ ```yaml
182
+ - id: llm-pi-ai
183
+ config:
184
+ providers:
185
+ my-flex-route:
186
+ api: openai-responses
187
+ apiKeyEnv: OPENROUTER_API_KEY
188
+ baseURL: http://127.0.0.1:8791/flex/v1
189
+ models:
190
+ - id: deepseek/deepseek-v4.1-flash
191
+ # Optional but recommended — see "Reasoning effort" below.
192
+ reasoningEfforts:
193
+ off: null
194
+ low: low
195
+ medium: medium
196
+ high: high
197
+ max: max
198
+ ```
199
+
200
+ Or route a provider to its own endpoint through a target mount — no provider config needed beyond
201
+ the base URL:
202
+
203
+ ```yaml
204
+ - id: llm-pi-ai
205
+ config:
206
+ providers:
207
+ acme-gateway:
208
+ api: openai-completions
209
+ apiKeyEnv: ACME_API_KEY
210
+ baseURL: http://127.0.0.1:8791/t/acme-gw-9f3a/flex/v1
211
+ models:
212
+ - id: acme-large
213
+ ```
214
+
215
+ `/t/<targetId>/v1` is the shape the switch writes: it mounts the endpoint and pins nothing, so each
216
+ Session's chip decides. `/t/<targetId>/<tier>/v1` is the older pinned shape and still works — useful
217
+ when a row must sit on one tier regardless of who calls it. The target's endpoint is declared once,
218
+ in the plugin's config (see `targets` below), so one listener can front any number of OpenAI- or
219
+ Anthropic-style endpoints.
220
+
221
+ ### Reasoning effort on a relay route
222
+
223
+ A relay route is a provider key the installed catalog has never seen, so
224
+ `@deepseek-ai/dsh-llm-pi-ai` cannot inherit a model's reasoning capability for it. Without an
225
+ explicit `reasoningEfforts` the model materializes as `reasoning: false` and the composer shows
226
+ **"This model provides no reasoning effort levels."** — no effort selector, no error, nothing in the
227
+ log. The relay itself is not involved; it never touches reasoning fields.
228
+
229
+ The plugin fills that gap when it creates a route, from the best evidence available:
230
+
231
+ 1. a capability the model already declares (in the source route), kept byte-identical;
232
+ 2. a declaration for another variant of the same id — `google/gemini-4-argon:flex` teaches the
233
+ plugin about `google/gemini-4-argon`;
234
+ 3. the configured `reasoningEfforts` map, as a fallback for everything else.
235
+
236
+ Set `reasoningEfforts: false` to switch filling off, or omit it to fill only from evidence 1–2.
237
+ A model that declares `reasoningEfforts: false` is itself opted out: the fill leaves it alone.
238
+
239
+ **The fill also re-applies itself.** Re-picking a model in Settings → Models rebuilds that row from
240
+ the catalog — `id`, `name`, context window, max tokens — and drops `reasoningEfforts` along with
241
+ every other hand-declared field. That is the shape of this bug: the effort selector works, you touch
242
+ the model list afterwards, and it is gone. The cause is upstream rather than here (`adopt()` in
243
+ `@deepseek-ai/dsh-client-ui-settings-models` copies a fixed field list), so the plugin watches the
244
+ profile instead: a debounced pass runs on every config settle and restores the capability a moment
245
+ after the edit lands. Set `autoRepairReasoning: false` to keep the plugin out of your config
246
+ entirely, and use **Add reasoning to N models** in the settings page (or
247
+ `POST /__openrouter-plus/routes/repair`) when you want the fill on demand.
248
+
249
+ Either way it only ever touches routes whose `baseURL` points at the relay, never overwrites a
250
+ declared map, never resurrects an explicit `false`, and writes nothing when there is nothing to do.
251
+
252
+ ## Presets
253
+
254
+ A service tier is not one field. OpenRouter exposes three levers — `service_tier` (which pools may
255
+ serve, and in what order), `provider.sort` (the comparator over that pool) and two slug suffixes
256
+ (`:nitro`, `:floor`) that mix the two — and each preset is a combination the API actually defines:
257
+
258
+ | Preset | Sends | What it does |
259
+ | --- | --- | --- |
260
+ | **No pin** | nothing | OpenRouter's own routing. |
261
+ | **Standard** | `service_tier: "default"` | The standard tier only; priority endpoints are excluded. |
262
+ | **Fastest · any price** | `provider.sort: "throughput"` | The whole eligible pool sorted by throughput. On an open-weight model this *is* nitro — its priority endpoints already compete in default routing. On a closed-weight one it stops short, because those endpoints are opt-in. |
263
+ | **Fastest · standard price** | `sort: "throughput"` + `service_tier: "default"` | The same race over the standard pool only, so the priority premium is unreachable. |
264
+ | **Cheapest** | `provider.sort: "price"` | Lowest price over the standard pool — usually a quantized version of the model. It never admits a flex endpoint, so it cannot reach a flex rate. |
265
+ | **Flex** | `service_tier: "flex"` | Flex endpoints only, at flex rates. Not necessarily the cheapest, and a flex capacity error surfaces instead of falling back to standard. |
266
+ | **Priority** | `service_tier: "priority"` | Priority endpoints serve first, then standard. OpenAI calls this Fast mode. The premium is charged only when a priority endpoint actually serves, and within each group endpoints sort by throughput unless you set a comparator. |
267
+ | **Ultra** | `service_tier: "ultrafast"` | ultrafast, then priority, then standard. OpenAI models only, and it needs `max_tokens` to hold — without one it silently degrades to priority. |
268
+ | **Floor** | `model: "…:floor"` | A blind price sort across the standard **and** flex pools. No parameter form exists for this, which is why it is a slug. `:nitro` is deliberately not offered separately: for the models where it changes the outcome, **Fastest · any price** is the same race. |
269
+
270
+ Two rows sit between "no tier" and "priority" for a reason: `provider.sort` and `service_tier`
271
+ decide different things. Sorting by throughput reorders whatever pool the tier admitted; pinning
272
+ `service_tier: "default"` is what keeps the premium out of it. Neither one alone can say
273
+ "fastest, and never at a premium".
274
+
275
+ ### From the composer (the preset chip)
276
+
277
+ Once a provider row is routed, a compact chip appears in the composer next to the model selector,
278
+ showing the preset the next request will apply. Picking another one there does **not** rewrite any
279
+ config and does **not** mint a provider: the Host records the choice for this Session in memory, and
280
+ the relay applies it to the request body on the way out.
281
+
282
+ The menu carries labels only — `Fastest · any price`, `Cheapest`, `Flex`, `Priority`, … — and the
283
+ long explanation of what each one sends lives on the settings page, where it is read once. The first
284
+ entry, **Profile default (…)**, stops choosing for this Session and shows which preset it will
285
+ inherit.
286
+
287
+ That is why it is per session: two conversations can be on `Flex` and `Priority` at the same time,
288
+ neither of them rewrites the other's provider row, and the reasoning effort you selected survives
289
+ the switch because the selection itself never changes.
290
+
291
+ The choice lives in the Host's memory — it is runtime state, like the effort level — so it survives
292
+ the whole Session but not a Host restart (a default-preset write reloads the plugin, which drops
293
+ those choices too). Want a preset that outlives every restart? Either set the profile **Service tier
294
+ for new sessions** or point a provider at a pinned mount by hand (`/flex/v1`).
295
+
296
+ The chip only appears when the Session's current provider is routed through a mount
297
+ (`/t/<targetId>/…`). Elsewhere the Models-page switch is the control: it is the one that moves the
298
+ provider itself.
299
+
300
+ ## Control API
301
+
302
+ Served on the same loopback listener, outside the proxy path space:
303
+
304
+ | Endpoint | Purpose |
305
+ | --- | --- |
306
+ | `GET /__openrouter-plus/health` | liveness |
307
+ | `GET /__openrouter-plus/status` | address, upstream, mounts, metrics |
308
+ | `GET /__openrouter-plus/targets` | source routes, routes on this relay, the `targets` table, and the preset table (`{ default, presets }`) |
309
+ | `GET /__openrouter-plus/tier?session=<id>` | what that Session would apply now: `preset`, `wire`, `chosen`, `default`, `presets` |
310
+ | `POST /__openrouter-plus/tier` | `{ session, preset }` — choose this Session's preset; `preset: null` hands it back to the profile default. **Memory only, never a config write** |
311
+ | `POST /__openrouter-plus/tier/default` | `{ preset }` — the preset an unchosen Session inherits; omit it (or send `none`) to pin nothing |
312
+ | `POST /__openrouter-plus/routes/remove` | `{ name }` |
313
+ | `POST /__openrouter-plus/routes/repair` | adds missing `reasoningEfforts` to the routes this plugin owns |
314
+ | `POST /__openrouter-plus/routes/attach` | `{ route, upstream }` — record the endpoint and point that provider at the relay |
315
+ | `POST /__openrouter-plus/routes/detach` | `{ route, id }` — put that provider back on its own endpoint |
316
+ | `POST /__openrouter-plus/targets/register` | `{ upstream, tier?, id? }` — record an endpoint without touching a provider |
317
+ | `POST /__openrouter-plus/targets/remove` | `{ id }` — refuse while a provider still routes through it |
318
+
319
+ `attach`/`detach` are what the Models-page switch calls; both are idempotent and report
320
+ `changed: false` when the row is already in the requested state. A rejected request answers `400`
321
+ with `{ error: { message } }` — for example a body that is not an http(s) URL, or one that points
322
+ back at the relay. `POST /tier` answers `400` for an unknown preset (`turbo`) or a missing
323
+ `session`, and accepts `preset: null` (or no `preset` at all) to clear. The tier-era body shape is still
324
+ read: `tier: "fast"` maps onto the `priority` preset, and any other legacy name maps onto the preset
325
+ that sends the same field.
326
+
327
+ Everything in `/tier` is deliberately write-free: a config write would re-apply this plugin row and
328
+ restart the listener, which is not something a mid-conversation click should risk. Only
329
+ `/tier/default` writes, because it is a preference rather than one Session's state.
330
+
331
+ `POST` requires `x-oorp-client: web`. CORS is reflected only for loopback GUI origins.
332
+
333
+ ```bash
334
+ curl -s http://127.0.0.1:8791/__openrouter-plus/status | jq .metrics.byTier
335
+ ```
336
+
337
+ ## Configuration
338
+
339
+ `cordis.patch.yml` ships the defaults; override them in your profile's patch layer:
340
+
341
+ | Key | Default | Meaning |
342
+ | --- | --- | --- |
343
+ | `enabled` | `true` | `false` keeps the plugin installed but binds nothing |
344
+ | `host` | `127.0.0.1` | bind address — loopback only, deliberately |
345
+ | `port` | `8791` | preferred port |
346
+ | `portFallback` | `true` | fall forward to the next free port (the page probes 8791–8794) |
347
+ | `upstream` | `https://openrouter.ai/api/v1` | where requests are forwarded, no trailing slash |
348
+ | `routes` | tier mounts | mount path → tier, for pinned URLs (`/flex/v1`); `null` tier is a pure passthrough. Accepted names are `default`, `flex`, `priority`, `ultrafast`, and the aliases `auto`/`scale` (both mean *no pin*) and `fast` (= `priority`). The per-session design needs only `/v1` |
349
+ | `upstreamTimeoutMs` | `0` | `0` disables the upstream timeout (long SSE completions) |
350
+ | `reasoningEfforts` | `false`-able map | levels written onto relay routes' models; `false` disables, omit for evidence-only |
351
+ | `autoRepairReasoning` | boolean, default `true` | re-apply that fill whenever the profile changes, so editing a route's models cannot silently strip the effort selector |
352
+ | `defaultPreset` | `none` | the preset an unchosen Session inherits; `none` pins nothing. A tier-era `defaultTier` is read forward onto the equivalent preset. Written by **Service tier for new sessions** on the settings page |
353
+ | `targets` | `{}` | extra endpoints served from `/t/<id>/…` mounts: `{ "<id>": { upstream } }`. Written by the switch; edit by hand only if you want one without a provider row |
354
+
355
+ ## Security model
356
+
357
+ - **Loopback only.** The relay forwards the caller's `Authorization` verbatim and stores no key.
358
+ Do not bind a routable interface.
359
+ - **Read-only telemetry.** The status API exposes counts and token sums, never prompts or keys.
360
+ - **Reversible by construction.** The plugin only ever adds a provider route whose `baseURL` points
361
+ at its own origin, and only removes routes that pass that same test. The switch is the same idea
362
+ one level down: the endpoint it took over is recorded in the plugin's config, and **Detach** —
363
+ or deleting the target — puts it back, so a provider is never left pointing at a dead mount.
364
+
365
+ ## Troubleshooting
366
+
367
+ | Symptom | Cause and fix |
368
+ | --- | --- |
369
+ | Card says *relay offline* | The port range is busy, or the row is `enabled: false`. Check the Host log for `[openrouter-plus]`; set a fixed `port`. |
370
+ | A model errors after disabling the plugin | That model belongs to a route pointing at the relay. Re-enable the plugin or remove the route on the OpenRouter Plus page. |
371
+ | Requests work but nothing is steered | The Session is on **No pin** (or the profile default is), the mount is a bare `/v1` passthrough, or the request is not `POST` with a JSON body. |
372
+ | The chip shows a preset, but another Session still bills full price | Every preset is per Session by design. Set it in that Session's composer, or set a profile **Service tier for new sessions**. |
373
+ | The chip disappeared after a Host restart | Choices are runtime state and the memory table is dropped on restart (and on a default-preset write, which reloads the plugin). Re-pick it, or set the profile default. |
374
+ | `Flex` still bills full price | The provider decides which endpoint served; a preset only decides which ones may be asked. Confirm the served endpoint with `usage` or the OpenRouter dashboard. |
375
+ | `Fastest · any price` did not get faster | The comparator only reorders the pool the tier admitted. On a closed-weight model the fastest endpoints are priority-only, so use **Priority** — or compare against the `:nitro` slug in the OpenRouter dashboard. |
376
+ | `Ultra` behaves like `Priority` | `ultrafast` only holds on OpenAI models that receive a `max_tokens` limit; without one the API degrades to priority. The relay never invents a limit, so set one on the model row. |
377
+ | The page says *failed to render*, and switching the chip says *the relay did not confirm the change* | The tab is running the browser half from before the update against the restarted Host. Reload the page (or reopen the app window); only a document reload re-fetches the client bundle, and a Host restart alone keeps the old module in memory. |
378
+ | No effort selector for a relay route's model | The model has no `reasoningEfforts` — usually because the model list was edited in Settings → Models afterwards. It is restored automatically; if `autoRepairReasoning` is off, press **Add reasoning to N models** on the OpenRouter Plus page. See "Reasoning effort on a relay route". |
379
+
380
+ ## Uninstall
381
+
382
+ Remove the route(s) in Settings → Models, then:
383
+
384
+ ```bash
385
+ dsh plugin --profile web remove dsh-openrouter-plus
386
+ ```
387
+
388
+ ## Development
389
+
390
+ ```bash
391
+ node --check index.js && node --check client.js
392
+ node --test # 99 tests, no network, no profile writes
393
+ ```
394
+
395
+ See [`docs/ARCHITECTURE.md`](docs/ARCHITECTURE.md) for the module contract, and
396
+ `docs/DESIGN.md` for the design rationale against the upstream discussion.
397
+
398
+ MIT.
399
+
400
+ [![](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white)](https://github.com/deepseek-ai/deepseek-harness)