dsh-aperture 0.3.2 → 0.4.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.en.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dsh-aperture
2
2
 
3
- Discover the models an [Aperture](https://tailscale.com/kb/1542/aperture) gateway serves, and publish them to DeepSeek Harness as `llm-pi-ai` provider routes — so they simply appear in the model selector. Once installed, one Aperture address is all you configure.
3
+ Discover the models an [Aperture](https://tailscale.com/kb/1542/aperture) gateway serves and, by the endpoint each one answers on, register them as this plugin's own provider routes in DeepSeek Harness — so they simply appear in the model selector. Once installed, one Aperture address is all you configure.
4
4
 
5
5
  ## Install
6
6
 
@@ -32,7 +32,7 @@ allowBuilds:
32
32
 
33
33
  > That authorization lets this package run code on your machine at install time, outside any agent sandbox. Authorize only source you trust.
34
34
 
35
- When editing the code locally, install the checkout directory instead (run `npm run build` first):
35
+ When editing the code locally, install the checkout directory instead (run `pnpm run build` first):
36
36
 
37
37
  ```sh
38
38
  npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
@@ -59,70 +59,89 @@ npx @deepseek-ai/dsh --profile web --dump-config # should show a "# == dsh-ape
59
59
 
60
60
  ### 4. Confirm
61
61
 
62
- The models appear in the selector under the route `Aperture`. This package's configuration page at **Plugins → dsh-aperture** is that page — the instance address and sync toggle on top, one row per discovered model below.
62
+ The models appear in the selector under the route `Aperture`. Settings live in two places: this package's configuration page at **Plugins → dsh-aperture** carries the instance address, the registration toggle and a "Refresh now" button, while the model list is on the official **Settings → Models** page, in this plugin's route cards.
63
63
 
64
64
  ```
65
- Instance address Overridden Reset to default
65
+ (Plugins → dsh-aperture)
66
+ Instance address overridden Reset to default
66
67
  [https://ai.example.ts.net ]
67
68
  Where Aperture listens; leave it empty to go dormant and stop discovering models.
68
69
 
69
- Sync automatically Overridden Reset to default ●━
70
- After each discovery round, write the models into dsh's llm-pi-ai routes. [Save]
70
+ Sync automatically overridden Reset to default ●━
71
+ After each discovery round, register these models as this plugin’s own provider routes in dsh. [Save]
71
72
 
72
73
  Saved: rediscovered and published.
73
74
 
74
- Models 18 ⟳ Refresh now
75
- One model per row; expand a row to edit its overrides, and Save writes only that row. The order comes from discovery, with anything no route can serve last.
75
+ The model list and its per-model overrides live on the Settings → Models page, in this plugin’s route cards: open that row and the models are listed below it. ⟳ Refresh now
76
+ 1 more model has no route to serve it (gemini-2.5-flash): give it a models[].protocol in the configuration and it gets a route;
77
+ anything that cannot be served can simply be deleted.
78
+ ```
79
+
80
+ ```
81
+ (Settings → Models)
82
+ DeepSeek Edit
83
+ Aperture (OpenAI Chat Completions) Custom Edit
84
+ ────────────────────────────────────────────────────
85
+ Models 18 ⌄
86
+ One model per row; expand a row to edit its overrides, and Save writes only that row. The order comes from discovery.
76
87
 
77
- ● deepseek-v4-flash
78
- route aperture · protocol openai-completions · context 1,048,576 · output 384,000 · modalities text+image · reasoning on · 1 overridden
79
- ● gemini-2.5-flash
80
- route aperture · protocol openai-completions · context 128,000 · modalities text · reasoning off
81
- ● qwen3-vl-32b unserved
82
- context 262,144 · modalities text+image · reasoning on
88
+ ● deepseek-v4-flash
89
+ context 1,048,576 · output 384,000 · input types text+image · reasoning on · 1 overridden
83
90
 
84
- (expand a row and you get that row's override editor: name and protocol in one group, capacity in another,
85
- modalities beside reasoning, and Save / Clear overrides / Cancel underneath)
91
+ (expand a row and you get that row's override editor: name and protocol in one group, capacity in another,
92
+ input types and reasoning each on a row of their own, and Save / Clear overrides / Cancel underneath. Every
93
+ row in one card serves the same route, which the card head already names, so the rows leave "route / protocol" out)
94
+
95
+ + Add model provider
86
96
  ```
87
97
 
88
- **The instance address and the sync toggle** are two fields of one official settings form: where a field says "Overridden", a "Reset to default" right beside it drops that key from your settings file (the same two words in the same position as the official plugin-config page), and Save writes only the fields you actually changed. The per-model override editor is covered under [Usage](#usage). Headings and spacing separate the groups, while a model row is a card (a hairline outline with a large radius, coloured only with theme tokens this page really defines), and the only thing you can expand is a model row.
98
+ **The instance address and the registration toggle** are two fields of one official settings form: where a field says "overridden", a "Reset to default" right beside it drops that key from your settings file (the same two words in the same position as the official plugin-config page), and Save writes only the fields you actually changed. Headings and spacing separate the groups, while a model row is a card (a hairline outline with a large radius, coloured only with theme tokens this page really defines), and the only thing you can expand is a model row.
99
+
100
+ (English labels are shown above; both pages are bilingual.)
89
101
 
90
- (English labels are shown above; the page itself is bilingual.)
102
+ **The model list hangs off an extension seat inside this plugin's own rows on the official Models page** (the page owner's own name for them is Extension slots): every route this plugin registers is one row on that page, and that row gets a block of its own drawing **that one route's** models — so a model listed on that page always really has a route. The models no route can serve (the ones written by hand in the configuration, the ones the catalog never listed) take up no seat there; the Plugins page says one sentence about them instead: how many, which ones, and where to give them a protocol. That block **starts collapsed**: the header (a row of this plugin's own drawing, under a hairline) carries the title and the model count on the left and a permanent chevron on the right, and one click unfolds this block — every row on that page has this block, and unfolded it is a dozen lines, so collapsed is what keeps it from taking over. Inside a route card every row serves the same route, which the card head already names, so those rows leave "route / protocol" out.
91
103
 
92
104
  ## Usage
93
105
 
94
- The interface is at **Plugins → dsh-aperture**: open this plugin in the plugin list; the configuration page hangs off the package, so there is no separate Configure button. The page header's name, icon and description come from the package's `locale/*.json` and `package.json`'s `icon`; the page itself is drawn by the Plugins page. The address, the toggle and the per-model parameters stay drafts until you press Save; models are **one row at a time**, and collapsing a row does not throw its draft away — the "unsaved edits" tag stays visible.
106
+ The interface lives in two places, each minding its own business:
107
+
108
+ - **Plugins → dsh-aperture**: open this plugin in the plugin list; the settings page hangs off the package, so there is no separate Configure button. The page header's name, icon and description come from the package's `locale/*.json` and `package.json`'s `icon`; the page itself is drawn by the Plugins page. This page holds two things only: the instance address and the registration toggle.
109
+ - **Settings → Models**: this plugin's model list hangs off that official page — one block inside each route's row (that row's own models); the models no route can serve do not appear on that page at all, the Plugins page's sentence covers them. The page owner declares that seat's name; this plugin only registers content into it.
110
+
111
+ The address, the toggle and the per-model parameters stay drafts until you press Save; models are **one row at a time**, and collapsing a row does not throw its draft away — the "unsaved edits" tag stays visible.
95
112
 
96
113
  | Where | Effect |
97
114
  | --- | --- |
98
- | Configuration page · Instance address | edits `baseUrl` (written through the settings seam; when it says "Overridden", the "Reset to default" beside it falls back to the default) |
99
- | Configuration page · Sync toggle | edits `sync`: off discovers without writing `llm-pi-ai`, and that round withdraws whatever this plugin had published (only the three keys it owns; every other provider in the section is left alone); carries the same "Overridden / Reset to default" pair |
100
- | Configuration page · Save | below the form: writes the address and toggle drafts into the settings document; it is revision-fenced, so a form that has drifted from the settings document is refused rather than overwriting someone else's edit; it returns only once that round of re-discovery has landed, so the interface shows the new configuration right away |
101
- | Configuration page · Models | one row per model, one card per row: a state dot at its head (green: this round wrote it into the routes; grey: this round synced but did not write it; amber: no route can serve it — hovering it, or a screen reader, hears exactly that), then the name with its "unserved / N overridden / unsaved edits" tags on the first line and labelled facts (route, protocol, capacities, modalities, reasoning, alias) on the second, with long names ellipsised and facts wrapping; expanded, it is that row's override editor — display name, alias and protocol as one group of text fields, context window and max output as the "capacity" group, and two modality checkboxes beside a three-way reasoning switch (follow discovery / on / off); a field keeps only one line naming where its value comes from ("Source: Aperture"), while how-to copy ("Leave it empty to use the discovered name") lives behind the "i" next to the label and only takes up room once opened; the "Refresh now" action at its top right discovers and republishes immediately, and the list and every row's status follow that round |
102
- | Configuration page · Save / Clear overrides / Cancel | write that row only, clear only the fields the backend report says really were overridden, or drop that row's draft; Save likewise waits for a round of re-discovery, so what you see afterwards is the new value |
115
+ | Plugins page · Instance address | edits `baseUrl` (written through the settings seam; when it says "overridden", the "Reset to default" beside it falls back to the default) |
116
+ | Plugins page · Registration toggle | edits `sync`: off discovers without registering, and that round withdraws the three routes this plugin had registered — routes of the same name registered elsewhere are left alone; carries the same "overridden / Reset to default" pair |
117
+ | Plugins page · Save | below the form: writes the address and toggle drafts into the settings document; it is revision-fenced, so a form that has drifted from the settings document is refused rather than overwriting someone else's edit; it returns only once that round of re-discovery has landed, so the interface shows the new configuration right away |
118
+ | Plugins page · Refresh now | the button beside Save: it writes no settings and simply runs one round of discovery and registration; the outcome (success, or the reason it failed) lands on the same page, and the "what went wrong this round" line follows it |
119
+ | Models page · Models in a route card | one row per model, one card per row: a state dot at its head (green: this round registered it as a route; grey: registration ran this round but did not include it — hovering it, or a screen reader, hears exactly that), then the name with its "N overridden / unsaved edits" tags on the first line and labelled facts (capacities, input types, reasoning, alias; route and protocol are identical across a card and already named by its head, so rows leave them out) on the second, with long names ellipsised and facts wrapping; expanded, it is that row's override editor — display name, catalog alias and API protocol as one group of text fields, context window and max output tokens as the "capacity" group, and two input-type checkboxes and a three-way reasoning switch (follow discovery / on / off) each on a row of its own; a field keeps only one line naming where its value comes from ("Source: Aperture"), while how-to copy ("Leave it empty to use the discovered name") lives behind the "i" next to the label and only takes up room once opened |
120
+ | Models page · Save / Clear overrides / Cancel | write that row only, clear only the fields the backend report says really were overridden, or drop that row's draft; Save likewise waits for a round of re-discovery, so what you see afterwards is the new value |
121
+ | Plugins page · Unserved models | how many models the report found with no route to serve them, and their names (at most five, then "and N more"): give them a `models[].protocol` and they get a route, anything that cannot be served can simply be deleted; when no route got registered at all, one sentence says that instead |
103
122
 
104
- In-place edits are configuration: capacities and modalities land on the matching `aperture.models` entry, the catalog alias lands on `aperture.modelAliases[id]`, and writes merge per field — a field the interface never mentions (say `reasoningEfforts`) survives untouched, while an emptied field drops that override and falls back to discovery and the catalog. Capacities accept the `1M` / `100K` spelling (decimal suffixes, the same vocabulary as the official Models page: `1M` is 1000000, not 1048576); what gets stored is still a plain token count, and the field spells it back in the shortest form that survives a round trip (`384000` → `384K`, while `1048576` is not a whole thousand and stays written out). The protocol field is the only way out for an unserved model: filling it in publishes a model that only answers on its native endpoint under the matching route.
123
+ In-place edits are configuration: capacities and input types land on the matching `aperture.models` entry, the catalog alias lands on `aperture.modelAliases[id]`, and writes merge per field — a field the interface never mentions (say `reasoningEfforts`) survives untouched, while an emptied field drops that override and falls back to discovery and the catalog. Capacities accept the `1M` / `100K` spelling (decimal suffixes, the same vocabulary as the official Models page: `1M` is 1000000, not 1048576); what gets stored is still a plain token count, and the field spells it back in the shortest form that survives a round trip (`384000` → `384K`, while `1048576` is not a whole thousand and stays written out). An unserved model does not appear on this page; its way out is in the configuration — write a `protocol` on that `models` entry and a model that only answers on its native endpoint gets published under the matching route.
105
124
 
106
125
  ## Configuration
107
126
 
108
- Every key lives under that row's `config:` in the profile patch document (user layer); anything you leave out falls back to the defaults below. `baseUrl`, `sync` and the per-model parameters inside `models` and `modelAliases` can also be edited in place on the configuration page; every other key needs the file.
127
+ Every key lives under that row's `config:` in the profile patch document (user layer); anything you leave out falls back to the defaults below. `baseUrl` and `sync` can be edited in place on the Plugins page, and the per-model parameters inside `models` and `modelAliases` on the Settings → Models page; every other key needs the file.
109
128
 
110
129
  | Key | Default | Meaning |
111
130
  | --- | --- | --- |
112
- | `baseUrl` | `''` | Aperture instance root. A trailing `/v1` is tolerated and stripped; empty leaves the plugin dormant |
113
- | `route` | `aperture` | Route key for Chat Completions models; Responses and Anthropic append `-responses` and `-anthropic`, with all three selector labels derived from it |
114
- | `apiKeyEnv` | `''` | Credential-seam reference; non-empty suppresses the placeholder header |
115
- | `headers` | `{}` | Extra request headers; they **win over** the placeholder |
131
+ | `baseUrl` | `''` | Aperture instance root. A trailing `/v1` is tolerated and stripped; empty leaves the plugin dormant (no discovery, no registration) |
132
+ | `routePrefix` | `aperture` | Common prefix of the three route names: a route key is the prefix plus its protocol name in lowercase with dashes — `aperture-openai-chat-completions`, `aperture-openai-responses`, `aperture-anthropic-messages`; the three selector labels come from the same prefix and spell out the same protocol names: `Aperture (OpenAI Chat Completions)`, `Aperture (OpenAI Responses)`, `Aperture (Anthropic Messages)` — those three names are the official Models page's product names for the protocols, word for word |
133
+ | `apiKeyEnv` | `''` | Credential-seam reference; non-empty stops sending the placeholder credential |
134
+ | `headers` | `{}` | Extra request headers; on a name collision the **attribution header** and the **placeholder credential** are still filled in per protocol |
116
135
  | `enabledModelIds` | `[]` | Non-empty restricts discovery to these ids (explicit `models` entries are exempt) |
117
136
  | `modelAliases` | `{}` | Gateway id → models.dev id |
118
- | `models` | `[]` | Per-model overrides and extras: `id`, `name`, `api`, `contextWindow`, `maxTokens`, `input`, `thinking`, `reasoningEfforts` |
137
+ | `models` | `[]` | Per-model overrides and extras: `id`, `name`, `protocol`, `contextWindow`, `maxTokens`, `input`, `thinking`, `reasoningEfforts` |
119
138
  | `modelMetadataUrl` | `https://models.dev/models.json` | Catalog URL; `''` disables enrichment |
120
- | `images` | `ignore` | `metadata` adopts models.dev input modalities (images) |
139
+ | `images` | `ignore` | `metadata` adopts models.dev input types (images) |
121
140
  | `reasoning` | `auto` | `off` declares every model non-reasoning |
122
- | `sync` | `true` | `false` discovers without writing (the configuration page still reports) |
141
+ | `sync` | `true` | `false` discovers without registering routes (the configuration page still reports) |
123
142
  | `refreshIntervalMinutes` | `0` | Periodic refresh; `0` refreshes only at load and on change |
124
143
 
125
- Missing capacity and reasoning levels are filled in from Aperture's own fields → [models.dev](https://models.dev) → a conservative default (the fallback capacity, 128000, and the 20s per-request timeout are constants in the code, not configuration). An unstated `maxTokens` is deliberately **omitted**: in `llm-pi-ai` it is also the per-request `max_tokens` cap, so inventing a value would truncate every request.
144
+ Missing capacity and reasoning levels are filled in from Aperture's own fields → [models.dev](https://models.dev) → a conservative default (the fallback capacity, 128000, the 20s per-request timeout, and the five-minute streaming idle cap are constants in the code, not configuration). `maxTokens` is reported to the Host as a **default output cap** only when the model declares one itself: nothing is reported when it does not, and inventing a value would truncate every request to it.
126
145
 
127
146
  ## Troubleshooting
128
147
 
@@ -138,7 +157,7 @@ Missing capacity and reasoning levels are filled in from Aperture's own fields
138
157
  git config --global url."git@github.com:".insteadOf "https://github.com/"
139
158
  ```
140
159
 
141
- **Some models never show up in the selector?** Look at the rows tagged `未服务` (unserved) in the Models section of the configuration page. Models that only offer Gemini's native `generateContent` endpoint cannot be attached — this plugin can publish Chat Completions, OpenAI Responses, and Anthropic Messages, but does not translate Gemini's native protocol. Using the wrong endpoint fails loudly, and Aperture names the right one:
160
+ **Some models never show up in the selector?** Look at the sentence on this plugin's configuration page at **Plugins → dsh-aperture** — it says how many models have no route to serve them and what they are called (the route cards on the Models page list only the models that route really serves). Models that only offer Gemini's native `generateContent` endpoint cannot be attached — this plugin can publish OpenAI Chat Completions, OpenAI Responses, and Anthropic Messages, but does not translate Gemini's native protocol. Using the wrong endpoint fails loudly, and Aperture names the right one:
142
161
 
143
162
  ```
144
163
  404 model "gemini-2.5-flash" is available via gemini_generate_content, not openai_chat
@@ -162,7 +181,7 @@ git config --global url."git@github.com:".insteadOf "https://github.com/"
162
181
  max: max
163
182
  ```
164
183
 
165
- **Want a model the gateway did not list?** Add it explicitly with `models` — for instance those four Gemini models, if you know they work on an OpenAI-compatible endpoint after all:
184
+ **Want a model the gateway did not list?** Add it explicitly with `models` — for instance the Gemini models that sentence on the configuration page reports, if you know they work on an OpenAI-compatible endpoint after all:
166
185
 
167
186
  ```yaml
168
187
  # ~/.dsh/profiles/web/cordis.patch.yml
@@ -184,17 +203,21 @@ git config --global url."git@github.com:".insteadOf "https://github.com/"
184
203
  k3: moonshotai/kimi-k3
185
204
  ```
186
205
 
187
- **The configuration page says `设置:未写入(已处于同步状态)`?** That is the normal steady state: the settings already hold the current catalog.
206
+ **The interface says `没注册(路由 aperture-openai-responses 已被另一个适配器注册…)`?** One of the route keys it asks for is already served by someone else — most often by an **older version of this plugin**: 0.2 and earlier only discovered, and it wrote the routes it found into `llm-pi-ai.providers`. This plugin will not rewrite someone else's configuration for you, so fix it by hand following the key name that line gives you: delete the matching `providers.<key>` from the `llm-pi-ai` section, or, if that route name belongs to another plugin, change this plugin's `routePrefix` (all three route keys move with it). The next change to the adapter set — a reload after that edit, or pressing the "Refresh now" action on the Plugins page — retries registration; no restart is needed. (The host writes that line in Chinese, as do its action summaries.)
207
+
208
+ **Coming from 0.2 or earlier, do I have to delete those `aperture*` keys in `llm-pi-ai.providers` myself?** Yes — and this time no key will point them out for you: the plugin's route keys are now the prefix plus the protocol name (by default `aperture-openai-chat-completions`, `aperture-openai-responses`, `aperture-anthropic-messages`), none of which matches the `aperture`, `aperture-responses` or `aperture-anthropic` written back then, so registration never collides. Leaving them behind only lets `llm-pi-ai` keep serving a stale route (duplicate models in the selector); delete them while upgrading.
209
+
210
+ **Where did the `route` key go?** It was renamed to `routePrefix`. The old key raises no error — the schema ignores it, so the prefix quietly falls back to the default `aperture`. If you had renamed the prefix (`route: my-gateway`), copy it onto `routePrefix` after upgrading; if you only ever wrote the default, just delete the old key.
188
211
 
189
212
  **Saved but not in effect?** DSH's patch layers stack: above the profile patch document sit higher-priority layers such as `$DSH_HOME/cordis.patch.yml`. If the `aperture` row is written there too, a save from the configuration page lands in the profile patch document but is shadowed by that layer (the settings service may also refuse the write outright, in which case the page says so). Delete the row from the higher-priority layer, or edit it there instead.
190
213
 
191
214
  **Upgrading from 0.2 — where did my `settings.yaml` go?** As of 0.1.7 settings no longer live in a file of their own; they live in the profile patch document. On the first start `$DSH_HOME/settings.yaml` is renamed to `settings.yaml.imported` and each section is moved into the patch document under its settings namespace — the `aperture:` section moves as-is, and every key and value that still passes the schema is unchanged, so the address and the per-model overrides are all still there. From then on only the patch document is read, and `settings.yaml.imported` is just an archive; editing it does nothing. A section whose values no longer validate stays in that archive too, with a line in the log saying so.
192
215
 
193
- **No Plugins page / no GUI in this deployment?** The configuration page only exists in the Web GUI (it works over Typert Remote endpoints). A headless profile still discovers and still writes, it just has no clickable page. If the deployment has no manageable profile at all, the `settings` service does not exist and the plugin stays `PENDING` on its hard dependency — its only job is writing settings, so with nowhere to write it deliberately does nothing.
216
+ **No Plugins page / no GUI in this deployment?** Both interfaces only exist in the Web GUI (the Plugins-page half works over Typert Remote endpoints). A headless profile still discovers and still registers routes, it just has no clickable page. The models also show up as rows on the official Models page (only the protocols that really carry models take a row): that row's own editor is read-only for this plugin (its settings section is `aperture`, not the Models page's generic form), but this plugin hangs one editor of its own inside that row, so editing a model is still that page's business (models no route can serve do not appear there; when the GUI is around, the Plugins page's sentence covers them); with no GUI, edit the configuration.
194
217
 
195
- **Need a real key instead of the placeholder header?** Aperture authenticates by network identity (Tailscale) and needs none; the plugin writes `authorization: Bearer dsh-aperture` / `x-api-key: dsh-aperture` only to make the adapter willing to send the request. It is **not a key**. When a real credential is needed, point `apiKeyEnv` at a credential-seam record and no placeholder is written.
218
+ **Need a real key instead of the placeholder credential?** Aperture authenticates by network identity (Tailscale) and needs none; the plugin sends `authorization: Bearer dsh-aperture` on every request (the Anthropic route sends `x-api-key: dsh-aperture`), only to make pi-ai willing to send the request. It is **not a key**. When a real credential is needed, point `apiKeyEnv` at a credential-seam record and the placeholder credential is no longer sent.
196
219
 
197
- **The old route is still there after changing `route`?** The plugin only knows the three keys it currently owns (`route`, `route` + `-responses`, and `route` + `-anthropic`), not the names it used before, so the old key stays in `llm-pi-ai.providers`. It does no harm and simply stops refreshing; delete the entry by hand to clean it up.
220
+ **Is the old route still there after changing `routePrefix`?** The plugin only knows the three keys it currently asks for (`<prefix>-openai-chat-completions`, `<prefix>-openai-responses`, `<prefix>-anthropic-messages`); once the process exits, the old key has no one serving it. It no longer appears in the selector and needs no cleanup, unless another adapter takes that key over.
198
221
 
199
222
  ## What it does
200
223
 
@@ -202,25 +225,25 @@ git config --global url."git@github.com:".insteadOf "https://github.com/"
202
225
  GET {baseUrl}/v1/models
203
226
  │
204
227
  ├─ per model: supported_endpoints ──► routing
205
- │ /v1/chat/completions ──► route (openai-completions)
206
- │ /v1/responses ──► route + -responses (openai-responses)
207
- │ /v1/messages ──► route + -anthropic (anthropic-messages)
208
- │ native generateContent only ──► not published (reported under 未服务)
228
+ │ /v1/chat/completions ──► routePrefix + -openai-chat-completions (openai-completions)
229
+ │ /v1/responses ──► routePrefix + -openai-responses (openai-responses)
230
+ │ /v1/messages ──► routePrefix + -anthropic-messages (anthropic-messages)
231
+ │ native generateContent only ──► not published (named by the Plugins page)
209
232
  │
210
233
  ├─ capacity: Aperture fields ─► models.dev ─► default
211
234
  ├─ reasoning: Aperture fields ─► models.dev ─► off
212
235
  │
213
- └─ llm-pi-ai providers.<route>, written into the profile patch document by revision
236
+ └─ registered as three provider routes (<routePrefix> + the protocol name, lowercased with dashes)
214
237
  ```
215
238
 
216
- Writes touch only the three keys under `llm-pi-ai.providers` that this plugin owns: an unchanged section is not rewritten; writes are path-addressed so your hand-written providers survive untouched; a failed discovery never wipes the published catalog; a route that lost its models is removed. Design notes — protocol routing, where each fact comes from, lifecycle and dependencies, write behaviour — are in [docs/internals.md](https://github.com/he0119/dsh-aperture/blob/main/docs/internals.md) (Chinese).
239
+ Each route carries exactly one protocol, and a model id is the gateway's id; the plugin writes no configuration at all, so a discovery result only lives in that one registration (after a restart the first discovery round decides again). When another adapter already holds a route key, the plugin does not force its way in: it skips registration, names the key in the report, and retries on its own whenever the adapter set changes. Why each decision is what it is — and which alternatives were rejected — is in [.agents/notes/implemented/](https://github.com/he0119/dsh-aperture/tree/main/.agents/notes/implemented) (Chinese); current mechanisms and known limits are in [docs/internals.md](https://github.com/he0119/dsh-aperture/blob/main/docs/internals.md) (Chinese).
217
240
 
218
241
  ## Development
219
242
 
220
243
  ```sh
221
- npm install
222
- npm run build # tsdown -> lib/index.js + lib/types/index.d.ts + lib/client.js
223
- npm test # unit tests + end-to-end (offline; devDependencies must be installed)
244
+ pnpm install
245
+ pnpm run build # tsdown -> lib/index.js + lib/types/index.d.ts + lib/client.js
246
+ pnpm test # unit tests + end-to-end (offline; devDependencies must be installed)
224
247
  ```
225
248
 
226
249
  Working on the plugin — build, tests, and a dedicated development instance — is in [docs/development.md](https://github.com/he0119/dsh-aperture/blob/main/docs/development.md) (Chinese); the release process and what the published package contains are in [docs/releasing.md](https://github.com/he0119/dsh-aperture/blob/main/docs/releasing.md) (Chinese).
@@ -231,7 +254,7 @@ Working on the plugin — build, tests, and a dedicated development instance —
231
254
  - [xiaoyuyu6420/dsh-backup](https://github.com/xiaoyuyu6420/dsh-backup): the reference implementation this plugin follows for the interface wiring — the Remote endpoint shape comes from it, while the way the configuration page is mounted now comes from the Plugins page's slot contract as of 0.1.7.
232
255
  - [Aperture](https://tailscale.com/kb/1542/aperture) (Tailscale): the gateway being discovered.
233
256
  - [models.dev](https://models.dev): enriches capacity and capabilities Aperture does not declare.
234
- - `@deepseek-ai/dsh-llm-pi-ai`: this plugin only discovers; the adapter does the protocol work.
257
+ - [pi-ai](https://www.npmjs.com/package/@earendil-works/pi-ai) (`@earendil-works/pi-ai`): it implements the three wire protocols; this plugin only translates discovery results into its model descriptors.
235
258
 
236
259
  ## License
237
260
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dsh-aperture
2
2
 
3
- 把 [Aperture](https://tailscale.com/kb/1542/aperture) 网关上的模型自动发现出来,写进 DeepSeek Harness 的 `llm-pi-ai` 设置,让它们直接出现在模型选择器里。装好后你只需要填一个 Aperture 地址,其余交给插件。
3
+ 把 [Aperture](https://tailscale.com/kb/1542/aperture) 网关上的模型自动发现出来,按模型自己在哪个端点上应答,注册成 DeepSeek Harness 里本插件自己的 provider 路由,让它们直接出现在模型选择器里。装好后你只需要填一个 Aperture 地址,其余交给插件。
4
4
 
5
5
  ## 安装
6
6
 
@@ -32,7 +32,7 @@ allowBuilds:
32
32
 
33
33
  > 这项授权等于允许该包在你机器上、于 agent 沙箱之外执行安装脚本。只对信任的源码授权。
34
34
 
35
- 本地改代码时,直接装仓库目录(先 `npm run build`):
35
+ 本地改代码时,直接装仓库目录(先 `pnpm run build`):
36
36
 
37
37
  ```sh
38
38
  npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
@@ -59,67 +59,86 @@ npx @deepseek-ai/dsh --profile web --dump-config # 应出现 "# == dsh-apertur
59
59
 
60
60
  ### 4. 确认
61
61
 
62
- 模型会出现在选择器里,路由名 `Aperture`。**插件 → dsh-aperture** 这个包的配置页就是这一页——上面是实例地址与同步开关,下面按行列出发现的模型。
62
+ 模型会出现在选择器里,路由名 `Aperture`。设置分在两处:**插件 → dsh-aperture** 那个包的配置页上是实例地址、注册开关与「立刻刷新」,模型目录在官方**设置 → 模型**页里本插件的路由卡上。
63
63
 
64
64
  ```
65
+ (插件 → dsh-aperture)
65
66
  实例地址 已覆盖 恢复默认
66
67
  [https://ai.example.ts.net ]
67
68
  填 Aperture 的地址;留空即休眠,不再发现模型。
68
69
 
69
70
  自动同步 已覆盖 恢复默认 ●━
70
- 每轮发现之后,把模型与参数写进 dsh 的 llm-pi-ai 路由。 [保存]
71
+ 每轮发现之后,把这批模型注册成 dsh 里本插件自己的 provider 路由。 [保存]
71
72
 
72
73
  已保存:已重新发现并发布。
73
74
 
74
- 模型 18 个 ⟳ 立刻刷新
75
- 一行一个模型;展开改这一行的覆盖,「保存」只写这一行。顺序来自发现顺序,没有路由可服务的排在最后。
75
+ 模型目录与逐模型覆盖在「设置 → 模型」页里本插件的路由卡上:点开那一行,模型就列在下面。 ⟳ 立刻刷新
76
+ 另有 1 个模型没有路由可服务(gemini-2.5-flash):在配置里给它们写上 models[].protocol 就有路由;
77
+ 接不进来的删掉即可。
78
+ ```
79
+
80
+ ```
81
+ (设置 → 模型)
82
+ DeepSeek 编辑
83
+ Aperture (OpenAI Chat Completions) 自定义 编辑
84
+ ────────────────────────────────────────────────────
85
+ 模型 18 个 ⌄
86
+ 一行一个模型;展开改这一行的覆盖,「保存」只写这一行。顺序来自发现顺序。
76
87
 
77
- ● deepseek-v4-flash
78
- 路由 aperture · 协议 openai-completions · 上下文 1,048,576 · 输出 384,000 · 模态 文本+图像 · 推理 开 · 已覆盖 1 项
79
- ● gemini-2.5-flash
80
- 路由 aperture · 协议 openai-completions · 上下文 128,000 · 模态 文本 · 推理 关
81
- ● qwen3-vl-32b 未服务
82
- 上下文 262,144 · 模态 文本+图像 · 推理 开
88
+ ● deepseek-v4-flash
89
+ 上下文 1,048,576 · 输出 384,000 · 输入类型 文本+图像 · 推理 开 · 已覆盖 1 项
83
90
 
84
- (点开一行,就是这一行的覆盖编辑器:名称与协议一组、容量一组,模态与推理并排,下面是「保存 / 清空覆盖 / 取消」)
91
+ (点开一行就是这一行的覆盖编辑器:名称与协议一组、容量一组,输入类型与推理各占一行,下面是「保存 / 清空覆盖 / 取消」。
92
+ 同一张卡里每一行都是同一条路由,卡片头已经写着它,行内不再重复「路由 / 协议」)
93
+
94
+ + 添加模型提供商
85
95
  ```
86
96
 
87
- **地址与同步开关**是同一份官方设置表单里的两个字段:写着「已覆盖」时,右边那颗「恢复默认」把它从设置文件里删掉(与官方「插件配置」页同一对词、同一个位置),按「保存」只发真的改动过的那一项。逐模型的覆盖编辑器见[使用](#使用)。分组靠标题与间距分开,模型那一行则是一张卡(发丝描边加大圆角,颜色只用本页真的定义过的主题 token),能点开的只有模型行。
97
+ **地址与注册开关**是同一份官方设置表单里的两个字段:写着「已覆盖」时,右边那颗「恢复默认」把它从设置文件里删掉(与官方「插件配置」页同一对词、同一个位置),按「保存」只发真的改动过的那一项。分组靠标题与间距分开,模型那一行则是一张卡(发丝描边加大圆角,颜色只用本页真的定义过的主题 token),能点开的只有模型行。
98
+
99
+ **模型目录挂在官方「模型」页本插件那几行的扩展位上**(页主自己叫 Extension slots):本插件注册的每一条路由就是那一页上的一行,那一行里挂一块,只画**那一条路由**的模型——能列在那一页上的模型因此一定真的有路由。没有路由可服务的模型(配置里手写的、目录里没有的那些)不在那一页占座位,它们由配置页一句话交代:几个、叫什么,以及去哪儿给它们写协议。这一块**默认收着**:折叠头(自己画的一行,上面一条细线)左边是标题与模型数目,右边常驻一枚箭头,点一下才摊开这一块——那一页的每一行都有这一块,摊开一次是十几行,收着才不喧宾夺主。同一张卡里每一行都是同一条路由,卡片头已经写着它,行内因此不再重复「路由 / 协议」。
88
100
 
89
101
  ## 使用
90
102
 
91
- 界面在 **插件 → dsh-aperture**:在插件列表里点开本插件,配置页挂在包上,所以没有单独的「配置」按钮。页头的名字、图标与那句描述来自本包的 `locale/*.json` 与 `package.json` 的 `icon`,页面本身由插件页画出。地址、开关与逐模型参数在按下「保存」之前都只是草稿;模型那部分**按行来**,收起一行不算放弃,行上的「有未保存的改动」标签会一直挂着。
103
+ 界面分两处,各管各的:
104
+
105
+ - **插件 → dsh-aperture**:在插件列表里点开本插件,设置页挂在包上,所以没有单独的「配置」按钮。页头的名字、图标与那句描述来自本包的 `locale/*.json` 与 `package.json` 的 `icon`,页面本身由插件页画出。这一页只有实例地址与注册开关两项。
106
+ - **设置 → 模型**:本插件的模型目录挂在官方那一页上——每条路由的行里一块(那一行自己的模型);没有路由可服务的模型不在这一页出现,它们由插件页那句话交代。那个座位的名字由页主自己声明,本插件只往里注册内容。
107
+
108
+ 地址、开关与逐模型参数在按下「保存」之前都只是草稿;模型那部分**按行来**,收起一行不算放弃,行上的「有未保存的改动」标签会一直挂着。
92
109
 
93
110
  | 位置 | 作用 |
94
111
  | --- | --- |
95
- | 配置页 · 实例地址 | 改 `baseUrl`(写入设置接缝;写着「已覆盖」时旁边那颗「恢复默认」把它放回缺省值) |
96
- | 配置页 · 同步开关 | 改 `sync`:关掉就只探测、不写 `llm-pi-ai`——那一轮刷新会顺手把本插件已经发布的路由撤下来(只撤它拥有的三个键,配置段里其他 provider 原样留着);同样带「已覆盖 / 恢复默认」这一对 |
97
- | 配置页 · 保存 | 表单下方,把地址与开关的草稿写进设置文档;有版本设栅,表单已经与设置文档脱节时会拒绝写入,而不是覆盖别处的改动;写完等这一轮重新发现落地才返回,界面随即显示新配置 |
98
- | 配置页 · 模型 | 一行一个模型,一行一张卡:行首一颗状态点(绿=这一轮写进了路由,灰=这一轮同步过而它没写进去,黄=没有路由能服务它,鼠标停在上面或读屏都能听到这句话),第一行是名字与「未服务 / 已覆盖 N 项 / 有未保存的改动」几枚标签,第二行是带标签的事实(路由、协议、容量、模态、推理、别名),长名字省略、事实随宽度换行;点开就是这一行的覆盖编辑器——显示名、别名、协议三个输入框一组,「容量」一组(上下文容量、最大输出),模态两个勾选框与推理一个三段开关(跟随发现 / 开 / 关)并排;字段下面只留一句来源(「来源:Aperture」),「留空即用发现到的名字」这类怎么做的话在标签旁边那颗「i」里,点开才占位置;右上角「立刻刷新」立刻重新发现并发布,清单与每一行的状态跟着变新 |
99
- | 配置页 · 保存 / 清空覆盖 / 取消 | 只写这一行,或者只清掉后台报告里确实被覆盖过的那几项,或者把这一行的草稿整个丢掉;「保存」同样等一轮重新发现落地,所以按完看到的就是新值 |
112
+ | 插件页 · 实例地址 | 改 `baseUrl`(写入设置接缝;写着「已覆盖」时旁边那颗「恢复默认」把它放回缺省值) |
113
+ | 插件页 · 注册开关 | 改 `sync`:关掉就只探测、不注册——那一轮刷新会把本插件已经注册出去的三条路由撤下来,别处注册的同名路由不受影响;同样带「已覆盖 / 恢复默认」这一对 |
114
+ | 插件页 · 保存 | 表单下方,把地址与开关的草稿写进设置文档;有版本设栅,表单已经与设置文档脱节时会拒绝写入,而不是覆盖别处的改动;写完等这一轮重新发现落地才返回,界面随即显示新配置 |
115
+ | 插件页 · 立刻刷新 | 保存按钮旁边那一颗:不写设置,直接重跑一轮发现与注册,结果(成功,或者失败的原因)贴在同一页上,「这一轮哪里不对」那句话跟着变新 |
116
+ | 模型页 · 路由卡里的模型 | 一行一个模型,一行一张卡:行首一颗状态点(绿=这一轮注册上了路由,灰=这一轮注册过而它没注册上,鼠标停在上面或读屏都能听到这句话),第一行是名字与「已覆盖 N 项 / 有未保存的改动」几枚标签,第二行是带标签的事实(容量、输入类型、推理、别名;路由与协议同卡每一行都一样,卡片头已经写着,行内不再重复),长名字省略、事实随宽度换行;点开就是这一行的覆盖编辑器——显示名称、目录别名、API 协议三个输入框一组,「容量」一组(上下文窗口、最大输出 token 数),输入类型两个勾选框与推理一个三段开关(跟随发现 / 开 / 关)各占一行;字段下面只留一句来源(「来源:Aperture」),「留空即用发现到的名字」这类怎么做的话在标签旁边那颗「i」里,点开才占位置 |
117
+ | 模型页 · 保存 / 清空覆盖 / 取消 | 只写这一行,或者只清掉后台报告里确实被覆盖过的那几项,或者把这一行的草稿整个丢掉;「保存」同样等一轮重新发现落地,所以按完看到的就是新值 |
118
+ | 插件页 · 未服务的模型 | 报告里没有路由可服务的模型有几个、叫什么(最多报五个名字,多的写「等 N 个」):给它们写上 `models[].protocol` 就有路由,接不进来的删掉即可;一条路由都没注册时改说这一句 |
100
119
 
101
- 就地编辑写的都是配置:容量与模态等落在 `aperture.models` 的对应条目上,清单别名落在 `aperture.modelAliases[id]`,写入按字段合并——界面没提到的字段原样留着(比如 `reasoningEfforts`),留空则表示这一项不覆盖、回落到发现值与清单。容量认 `1M`、`100K` 这种写法(十进制后缀,跟官方「模型」页同一套词汇:`1M` 是 1000000,不是 1048576),存下去的仍是普通 token 数,输入框回写成能原样读回来的最短那个(`384000` → `384K`,而 `1048576` 不是整千,照原样写)。协议那一项是「未服务」模型唯一的出路:填上它就能让只在原生端点上应答的模型在对应路由上发布。
120
+ 就地编辑写的都是配置:容量与输入类型等落在 `aperture.models` 的对应条目上,目录别名落在 `aperture.modelAliases[id]`,写入按字段合并——界面没提到的字段原样留着(比如 `reasoningEfforts`),留空则表示这一项不覆盖、回落到发现值与目录。容量认 `1M`、`100K` 这种写法(十进制后缀,跟官方「模型」页同一套词汇:`1M` 是 1000000,不是 1048576),存下去的仍是普通 token 数,输入框回写成能原样读回来的最短那个(`384000` → `384K`,而 `1048576` 不是整千,照原样写)。「未服务」的模型不在这一页出现,它们的出路在配置里:给 `models` 里那一条写上 `protocol`,只在原生端点上应答的模型就能在对应路由上发布。
102
121
 
103
122
  ## 配置
104
123
 
105
- 所有键都写在 profile 补丁文档里那一行的 `config:` 下(用户层),不写的键一律回落下面这些缺省值。`baseUrl`、`sync` 与 `models`、`modelAliases` 里的逐模型参数也能在配置页上就地编辑;其余键只有配置文件这一条路。
124
+ 所有键都写在 profile 补丁文档里那一行的 `config:` 下(用户层),不写的键一律回落下面这些缺省值。`baseUrl` 与 `sync` 能在插件页上就地编辑,`models`、`modelAliases` 里的逐模型参数能在「设置 → 模型」页里就地编辑;其余键只有配置文件这一条路。
106
125
 
107
126
  | 键 | 默认 | 说明 |
108
127
  | --- | --- | --- |
109
- | `baseUrl` | `''` | Aperture 实例地址。末尾 `/v1` 会被容忍并去掉;空值表示休眠(不探测、不写入) |
110
- | `route` | `aperture` | Chat Completions 模型的路由名;Responses、Anthropic 路由分别追加 `-responses`、`-anthropic`,三个选择器名称也由它推出来 |
111
- | `apiKeyEnv` | `''` | 凭据 seam 里的引用名;非空时不再写占位头 |
112
- | `headers` | `{}` | 每条请求额外带的头,**优先于**占位头 |
128
+ | `baseUrl` | `''` | Aperture 实例地址。末尾 `/v1` 会被容忍并去掉;空值表示休眠(不探测、不注册) |
129
+ | `routePrefix` | `aperture` | 三条路由名的共同前缀:路由键是前缀加上协议名的小写连字符写法——`aperture-openai-chat-completions`、`aperture-openai-responses`、`aperture-anthropic-messages`;三个选择器名称同样由它推出来,各自写出同一串协议名:`Aperture (OpenAI Chat Completions)`、`Aperture (OpenAI Responses)`、`Aperture (Anthropic Messages)`(这三个名字逐字取官方「模型」页给协议用的产品名) |
130
+ | `apiKeyEnv` | `''` | 凭据 seam 里的引用名;非空时不再带占位凭据 |
131
+ | `headers` | `{}` | 每条请求额外带的头;同名时**归因头**与**占位凭据**仍会按协议补齐 |
113
132
  | `enabledModelIds` | `[]` | 非空时只保留这些 id(`models` 里显式列出的不受限) |
114
133
  | `modelAliases` | `{}` | 网关 id → models.dev id |
115
- | `models` | `[]` | 逐模型覆盖或补充:`id`、`name`、`api`、`contextWindow`、`maxTokens`、`input`、`thinking`、`reasoningEfforts` |
134
+ | `models` | `[]` | 逐模型覆盖或补充:`id`、`name`、`protocol`、`contextWindow`、`maxTokens`、`input`、`thinking`、`reasoningEfforts` |
116
135
  | `modelMetadataUrl` | `https://models.dev/models.json` | 目录地址;设成 `''` 关闭补全 |
117
- | `images` | `ignore` | `metadata` = 采用 models.dev 的输入模态(图片) |
136
+ | `images` | `ignore` | `metadata` = 采用 models.dev 的输入类型(图片) |
118
137
  | `reasoning` | `auto` | `off` = 所有模型都当不会推理 |
119
- | `sync` | `true` | `false` = 只探测不写设置(配置页仍可查看) |
138
+ | `sync` | `true` | `false` = 只探测不注册路由(配置页仍可查看) |
120
139
  | `refreshIntervalMinutes` | `0` | 定时刷新间隔;`0` = 只在启动和配置变化时刷新 |
121
140
 
122
- 容量与推理档位缺失时,按 Aperture 字段 → [models.dev](https://models.dev) → 保守默认值补全(兜底容量 128000、单次请求超时 20s 是代码里的常量,不是配置项);`maxTokens` 没人声明时**故意不写**(在 `llm-pi-ai` 里它同时是每次请求的 `max_tokens` 上限,凭空编一个值会把请求截断)。
141
+ 容量与推理等级缺失时,按 Aperture 字段 → [models.dev](https://models.dev) → 保守默认值补全(兜底容量 128000、单次请求超时 20s、流式空闲上限 5 分钟是代码里的常量,不是配置项)。`maxTokens` 只有模型自己声明过才会作为**默认输出上限**报给宿主:没人声明时不报,凭空编一个值会让每次请求都按它截断。
123
142
 
124
143
  ## 常见问题
125
144
 
@@ -135,14 +154,14 @@ npx @deepseek-ai/dsh --profile web --dump-config # 应出现 "# == dsh-apertur
135
154
  git config --global url."git@github.com:".insteadOf "https://github.com/"
136
155
  ```
137
156
 
138
- **有些模型没出现在选择器里?** 看配置页「模型」那一段里带「未服务」标签的行。只提供 Gemini 原生 `generateContent` 端点的模型接不进来——本插件可发布 Chat Completions、OpenAI Responses 与 Anthropic Messages,不能转换 Gemini 原生协议。走错端点时 Aperture 会明确告诉你该用哪个:
157
+ **有些模型没出现在选择器里?** 看**插件 → dsh-aperture** 配置页上那句话——它说有几个模型没有路由可服务、都叫什么(本插件的路由卡下面列的是那一条路由真的能服务的模型)。只提供 Gemini 原生 `generateContent` 端点的模型接不进来——本插件可发布 OpenAI Chat Completions、OpenAI Responses 与 Anthropic Messages,不能转换 Gemini 原生协议。走错端点时 Aperture 会明确告诉你该用哪个:
139
158
 
140
159
  ```
141
160
  404 model "gemini-2.5-flash" is available via gemini_generate_content, not openai_chat
142
161
  404 model "MiniMax-M3" is available via anthropic_messages, not openai_chat
143
162
  ```
144
163
 
145
- **想给某个模型更多推理档位?** 默认只给保守的两档(DeepSeek 系 `off/high/max`,其它会推理的模型 `off/high`),自己加:
164
+ **想给某个模型更多推理等级?** 默认只给保守的两档(DeepSeek 系 `off/high/max`,其它会推理的模型 `off/high`),自己加:
146
165
 
147
166
  ```yaml
148
167
  # ~/.dsh/profiles/web/cordis.patch.yml
@@ -153,7 +172,7 @@ git config --global url."git@github.com:".insteadOf "https://github.com/"
153
172
  reasoningEfforts: { off: disabled, minimal: minimal, low: low, medium: medium, high: high, max: max }
154
173
  ```
155
174
 
156
- **网关没列出的模型也想接?** 用 `models` 显式补一条即可(比如配置页里「未服务」的那几个 Gemini 模型,只要你知道它在 OpenAI 兼容端点上确实能用):
175
+ **网关没列出的模型也想接?** 用 `models` 显式补一条即可(比如配置页那句话里报出来的那几个 Gemini 模型,只要你知道它在 OpenAI 兼容端点上确实能用):
157
176
 
158
177
  ```yaml
159
178
  # ~/.dsh/profiles/web/cordis.patch.yml
@@ -175,17 +194,21 @@ git config --global url."git@github.com:".insteadOf "https://github.com/"
175
194
  k3: moonshotai/kimi-k3
176
195
  ```
177
196
 
178
- **配置页上说 `设置:未写入(已处于同步状态)`?** 正常状态,表示设置里已经是最新内容。
197
+ **界面上说 `没注册(路由 aperture-openai-responses 已被另一个适配器注册…)`?** 说明请求的路由键里有一个已经被别人服务了——最常见的原因是**旧版本的本插件**:0.2 及更早只做发现,它会把自己发现的路由写进 `llm-pi-ai.providers`。本插件不替你改别人的配置,照那一行给出的键名手工处理:删掉 `llm-pi-ai` 段里对应的 `providers.<键>`;如果那个路由名是别的插件在用的,就改本插件配置里的 `routePrefix`(三条路由键一起变)。下一个适配器集合变化(改完配置的重载、或者在插件页按那颗「立刻刷新」)就会重新尝试注册,不必重启。
198
+
199
+ **从 0.2 或更早升上来,`llm-pi-ai.providers` 里那几个 `aperture*` 键要不要自己删?** 要,而且这次没有哪个键会替你报错:本插件现在的路由键是前缀加协议名(默认 `aperture-openai-chat-completions` / `aperture-openai-responses` / `aperture-anthropic-messages`),与那时写下的 `aperture`、`aperture-responses`、`aperture-anthropic` 一个都不同名,因此注册不会撞键。那三个遗留键留着只会让 `llm-pi-ai` 继续服务一份过期的路由(选择器里出现重复模型),升级时一并删掉即可。
200
+
201
+ **配置里的 `route` 键去哪了?** 它改名成了 `routePrefix`。旧键不报错,但会被 schema 忽略——前缀于是静默回到缺省的 `aperture`。当初把前缀写成了别的名字(`route: my-gateway`)的话,升级后要把它抄到 `routePrefix` 上;只写过缺省值的话,把旧键删掉即可。
179
202
 
180
203
  **保存了但没生效?** DSH 的补丁层是叠加的:profile 的补丁文档之上还有 `$DSH_HOME/cordis.patch.yml` 这类更高优先级的层。如果 `aperture` 这一行在那里也被写过,配置页上的保存会落在 profile 的补丁文档里、却被上面那层盖住(这一笔也可能被设置接缝直接拒收,配置页会说没被收下)。把那一行从高优先级的层里删掉,或者直接改那一处。
181
204
 
182
205
  **从 0.2 升上来,我的 `settings.yaml` 去哪了?** 0.1.7 起设置不再有独立文件,而是落在 profile 的补丁文档里。首次启动时 `$DSH_HOME/settings.yaml` 会被改名成 `settings.yaml.imported`,各段按设置命名空间搬进补丁文档——`aperture:` 段原样搬过去,仍能过 schema 的键与值都不变,所以地址与逐模型覆盖都还在。此后被读的只有补丁文档,`settings.yaml.imported` 只是留档,改它没有用;搬不过去的段(值已不合法)也只留在那份留档里,并在日志里说一声。
183
206
 
184
- **本部署没有「插件」页 / 没有界面?** 配置页只在 Web 界面里有(它靠 Typert Remote 端点工作)。headless profile 里插件照常发现、照常写入,只是没有可点按的页面。若这个部署连可管理的 profile 都没有,`settings` 服务不存在,插件按硬依赖停在 `PENDING`——它唯一的职责就是写设置,没有设置可写时宁可不动。
207
+ **本部署没有「插件」页 / 没有界面?** 两处界面都只在 Web 界面里有(插件页那一份靠 Typert Remote 端点工作)。headless profile 里插件照常发现、照常注册路由,只是没有可点按的页面。模型在官方「模型」页里也会出现相应的行(只有真的有模型的那几种协议才占一行):那一行自己的编辑器对本插件是只读的(设置段是 `aperture`,不是模型页的通用表单),但本插件在那一行里挂了自己的一块编辑器,所以改模型还是那一页上的事(没有路由可服务的模型不在那一页出现,界面在时由插件页那句话交代);没有界面时改配置。
185
208
 
186
- **需要真密钥而不是占位头?** Aperture 靠网络身份(Tailscale)认证,本不需要密钥;插件默认写入 `authorization: Bearer dsh-aperture` / `x-api-key: dsh-aperture`,只是让适配器愿意发请求,**不是密钥**。真要密钥时把 `apiKeyEnv` 指向凭据 seam 里的记录,占位头就不会写入。
209
+ **需要真密钥而不是占位凭据?** Aperture 靠网络身份(Tailscale)认证,本不需要密钥;插件默认在每条请求上带 `authorization: Bearer dsh-aperture`(Anthropic 路由是 `x-api-key: dsh-aperture`),只是让 pi-ai 愿意把请求发出去,**不是密钥**。真要密钥时把 `apiKeyEnv` 指向凭据 seam 里的记录,占位凭据就不再带。
187
210
 
188
- **改了 `route` 之后旧路由还在?** 插件只认自己当前拥有的三个键(`route`、`route` + `-responses`、`route` + `-anthropic`),不知道历史上用过哪些名字,所以旧键会留在 `llm-pi-ai.providers` 里。它不报错、只是不再刷新;要清理就手动删掉那一行。
211
+ **改了 `routePrefix` 之后旧路由还在?** 插件只认自己当前请求的三个键(`<前缀>-openai-chat-completions`、`<前缀>-openai-responses`、`<前缀>-anthropic-messages`),进程退出后旧键就没有服务者了;它不再出现在选择器里,也不需要清理,除非有别的适配器顶上那个键。
189
212
 
190
213
  ## 它做了什么
191
214
 
@@ -193,23 +216,23 @@ git config --global url."git@github.com:".insteadOf "https://github.com/"
193
216
  GET {baseUrl}/v1/models
194
217
  │
195
218
  ├─ 每个模型:supported_endpoints ──► 分流
196
- │ /v1/chat/completions ──► route (openai-completions)
197
- │ /v1/responses ──► route + -responses (openai-responses)
198
- │ /v1/messages ──► route + -anthropic (anthropic-messages)
199
- │ 只有原生 generateContent ──► 不发布(列进「未服务」)
219
+ │ /v1/chat/completions ──► routePrefix + -openai-chat-completions (openai-completions)
220
+ │ /v1/responses ──► routePrefix + -openai-responses (openai-responses)
221
+ │ /v1/messages ──► routePrefix + -anthropic-messages (anthropic-messages)
222
+ │ 只有原生 generateContent ──► 不发布(配置页那句话里报出来)
200
223
  ├─ 容量:Aperture 字段 ─► models.dev ─► 默认值
201
224
  ├─ 推理:Aperture 字段 ─► models.dev ─► 关闭
202
- └─ 生成 llm-pi-ai 的 providers.<route>,按 revision 写进 profile 的补丁文档
225
+ └─ 注册成三条 provider 路由(<routePrefix> + 协议名的小写写法)
203
226
  ```
204
227
 
205
- 写入只碰 `llm-pi-ai.providers` 下属于本插件的三个键:内容没变就不写;用路径操作写,你手写的其它 provider 原样保留;探测失败绝不删空已有目录;路由没模型了就删掉。实现细节(协议分流、容量与推理的来源优先级、生命周期与依赖、写入行为)见 [docs/internals.md](https://github.com/he0119/dsh-aperture/blob/main/docs/internals.md)。
228
+ 三条路由各自只承载一种协议,模型 id 就是网关的 id;本插件不写任何配置,发现结果只活在这一次注册里(重启后由第一轮发现重新决定)。路由键被别的适配器占着时本插件不硬闯:它跳过注册、在报告里点名那个键,并在适配器集合发生变化时自己重试。每条决策为什么是这样、放弃了哪些替代方案,见 [.agents/notes/implemented/](https://github.com/he0119/dsh-aperture/tree/main/.agents/notes/implemented)(中文);当前机制与已知边界见 [docs/internals.md](https://github.com/he0119/dsh-aperture/blob/main/docs/internals.md)。
206
229
 
207
230
  ## 开发
208
231
 
209
232
  ```sh
210
- npm install
211
- npm run build # tsdown -> lib/index.js + lib/types/index.d.ts + lib/client.js
212
- npm test # 单元测试 + 端到端(离线运行;需要已安装的 devDependencies)
233
+ pnpm install
234
+ pnpm run build # tsdown -> lib/index.js + lib/types/index.d.ts + lib/client.js
235
+ pnpm test # 单元测试 + 端到端(离线运行;需要已安装的 devDependencies)
213
236
  ```
214
237
 
215
238
  改代码、跑测试与开发实例见 [docs/development.md](https://github.com/he0119/dsh-aperture/blob/main/docs/development.md),发布流程与产物构成见 [docs/releasing.md](https://github.com/he0119/dsh-aperture/blob/main/docs/releasing.md)。
@@ -220,7 +243,7 @@ npm test # 单元测试 + 端到端(离线运行;需要已安装
220
243
  - [xiaoyuyu6420/dsh-backup](https://github.com/xiaoyuyu6420/dsh-backup):界面接线的参考实现,Remote 端点的形状来自这个插件;配置页本身的挂载方式在 0.1.7 之后改由插件页的槽位契约给出。
221
244
  - [Aperture](https://tailscale.com/kb/1542/aperture)(Tailscale):提供被发现的网关。
222
245
  - [models.dev](https://models.dev):为 Aperture 未声明的容量与能力做补全。
223
- - `@deepseek-ai/dsh-llm-pi-ai`:本插件只做发现,协议对接交给它。
246
+ - [pi-ai](https://www.npmjs.com/package/@earendil-works/pi-ai)(`@earendil-works/pi-ai`):三种线缆协议的实现来自它,本插件只负责把发现结果翻译成它的模型描述符。
224
247
 
225
248
  ## License
226
249