dsh-aperture 0.4.0 → 0.4.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/README.en.md CHANGED
@@ -8,19 +8,18 @@ Requirements: Node ^22.19.0 or ≥24.0.0 (matching DSH), and an Aperture instanc
8
8
 
9
9
  ### 1. Add the plugin
10
10
 
11
- From [npm](https://www.npmjs.com/package/dsh-aperture) (recommended):
12
-
13
11
  ```sh
12
+ # npm (recommended): the published artifact ships a compiled lib/, so no build script has to be authorized
14
13
  npx @deepseek-ai/dsh plugin --profile web add dsh-aperture
15
- ```
16
-
17
- The published artifact ships a compiled `lib/`, so no build script has to be authorized. To pin a commit, or to follow unreleased changes, install from git:
18
14
 
19
- ```sh
15
+ # git: pulls source, compiled by a prepare script during install; pins a commit
20
16
  npx @deepseek-ai/dsh plugin --profile web add github:he0119/dsh-aperture#<sha>
17
+
18
+ # a local checkout: run pnpm run build first
19
+ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
21
20
  ```
22
21
 
23
- A git install pulls **source**, compiled by a `prepare` script during install. pnpm ≥10 refuses to run a git dependency's build scripts until it is explicitly allowed, so **the first `add` fails**: dsh prints the package key you need, which you write into the profile's `pnpm-workspace.yaml` before running `add` again.
22
+ pnpm ≥10 refuses to run a git dependency's build scripts, so the git line **fails the first time**: dsh prints the package key you need, which you write into the profile's `pnpm-workspace.yaml` before running it again (the key takes the **map** form with `true`).
24
23
 
25
24
  ```yaml
26
25
  # ~/.dsh/profiles/web/pnpm-workspace.yaml
@@ -28,16 +27,8 @@ allowBuilds:
28
27
  dsh-aperture: true
29
28
  ```
30
29
 
31
- (The key takes the **map** form with `true`; a list is not accepted.)
32
-
33
30
  > That authorization lets this package run code on your machine at install time, outside any agent sandbox. Authorize only source you trust.
34
31
 
35
- When editing the code locally, install the checkout directory instead (run `pnpm run build` first):
36
-
37
- ```sh
38
- npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
39
- ```
40
-
41
32
  ### 2. Point it at your instance
42
33
 
43
34
  ```yaml
@@ -47,7 +38,7 @@ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
47
38
  baseUrl: https://ai.example.ts.net
48
39
  ```
49
40
 
50
- This layer (the profile patch document, i.e. the user layer) is this plugin's settings namespace, `aperture`. Patch layers **replace the whole row** rather than deep-merging — this row's `config` supersedes the `cordis.patch.yml` this package ships (the composition layer) outright, and since the composition row only declares the row and writes no `config`, what you write is all there is; every key's default lives in the schema, so keys you leave out fall back to the defaults. You can also fill it in from the GUI: on the **Plugins** page open this package, and the first field of its configuration page ("Instance address") writes the same `aperture.baseUrl`; saving lands in the same file.
41
+ This row is the plugin's settings namespace, `aperture`. Patch layers **replace the whole row** rather than deep-merging: what you write is all there is, and keys you leave out fall back to the schema's defaults. You can also fill it in from the GUI: on the **Plugins** page open this package, and its "Instance address" writes the same `aperture.baseUrl`; saving lands in the same file.
51
42
 
52
43
  ### 3. Restart DSH
53
44
 
@@ -59,78 +50,34 @@ npx @deepseek-ai/dsh --profile web --dump-config # should show a "# == dsh-ape
59
50
 
60
51
  ### 4. Confirm
61
52
 
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
-
64
- ```
65
- (Plugins → dsh-aperture)
66
- Instance address overridden Reset to default
67
- [https://ai.example.ts.net ]
68
- Where Aperture listens; leave it empty to go dormant and stop discovering models.
69
-
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]
72
-
73
- Saved: rediscovered and published.
74
-
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.
87
-
88
- ● deepseek-v4-flash
89
- context 1,048,576 · output 384,000 · input types text+image · reasoning on · 1 overridden
90
-
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
96
- ```
97
-
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.
53
+ The models appear in the selector under the route `Aperture`. The interface lives in two places:
99
54
 
100
- (English labels are shown above; both pages are bilingual.)
55
+ - **Plugins → dsh-aperture**: the instance address, the registration toggle and "Refresh now". The settings page hangs off the package, so there is no separate Configure button.
56
+ - **Settings → Models**: every route this plugin registers is one row on that page, and the row carries a **collapsed** model list — unfold it to get the models that route really serves and the per-model override editor (display name, catalog alias, protocol, capacity, input types, reasoning). Models no route can serve take up no seat there; the Plugins page says one sentence about them: how many, which ones, and where to give them a protocol.
101
57
 
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.
58
+ How the interface is laid out, and where each limit comes from, is in [docs/internals.md](https://github.com/he0119/dsh-aperture/blob/main/docs/internals.md) (Chinese).
103
59
 
104
60
  ## Usage
105
61
 
106
- The interface lives in two places, each minding its own business:
62
+ 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.
107
63
 
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.
64
+ - **Plugins page · instance address and registration toggle**: Save writes only the fields you actually changed, and a form that has drifted from the settings document is refused rather than overwriting someone else's edit; where a field says "overridden", the "Reset to default" beside it drops that key from your settings file (the same two words in the same position as the official plugin-config page).
65
+ - **Plugins page · Refresh now**: writes no settings and simply runs one round of discovery and registration; success, or the reason it failed, lands on the same page.
66
+ - **Plugins page · registration toggle**: off discovers without registering — that round withdraws the three routes this plugin had registered, while routes of the same name registered elsewhere are left alone.
67
+ - **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.
68
+ - **Capacities**: accept the `1M` / `100K` spelling (decimal suffixes: `1M` is 1000000, not 1048576); an emptied field drops that override and falls back to discovery and the catalog.
110
69
 
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.
112
-
113
- | Where | Effect |
114
- | --- | --- |
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 |
122
-
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.
70
+ 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.
124
71
 
125
72
  ## Configuration
126
73
 
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.
74
+ Every key lives under that row's `config:` in the profile patch document; anything you leave out falls back to the defaults below (a `—` in the Default column means the key has no default: leaving it out leaves it absent). `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.
128
75
 
129
76
  | Key | Default | Meaning |
130
77
  | --- | --- | --- |
131
78
  | `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 |
79
+ | `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`), and the three selector labels come from the same prefix, spelling out the official Models page's product names for the protocols word for word: `Aperture (OpenAI Chat Completions)`, `Aperture (OpenAI Responses)`, `Aperture (Anthropic Messages)` |
80
+ | `apiKeyEnv` | `—` | Credential-seam reference (must match `^[A-Za-z_][A-Za-z0-9_]*$`); leave the key out to keep sending the placeholder credential. An empty string is not a reference — do not write one |
134
81
  | `headers` | `{}` | Extra request headers; on a name collision the **attribution header** and the **placeholder credential** are still filled in per protocol |
135
82
  | `enabledModelIds` | `[]` | Non-empty restricts discovery to these ids (explicit `models` entries are exempt) |
136
83
  | `modelAliases` | `{}` | Gateway id → models.dev id |
@@ -141,102 +88,100 @@ Every key lives under that row's `config:` in the profile patch document (user l
141
88
  | `sync` | `true` | `false` discovers without registering routes (the configuration page still reports) |
142
89
  | `refreshIntervalMinutes` | `0` | Periodic refresh; `0` refreshes only at load and on change |
143
90
 
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.
91
+ Three common examples:
92
+
93
+ ```yaml
94
+ # ~/.dsh/profiles/web/cordis.patch.yml
95
+ - id: aperture
96
+ config:
97
+ models:
98
+ # more reasoning levels for one model (only two conservative ones are offered by default)
99
+ - id: deepseek-v4-pro
100
+ reasoningEfforts: { off: disabled, minimal: minimal, low: low, medium: medium, high: high, max: max }
101
+ # a model the gateway did not list
102
+ - id: gemini-2.5-pro
103
+ api: openai-completions
104
+ modelAliases:
105
+ # the gateway renamed it, so models.dev does not match
106
+ deepseek-flash: deepseek/deepseek-v4-flash
107
+ k3: moonshotai/kimi-k3
108
+ ```
109
+
110
+ 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, and nothing is reported when it does not.
145
111
 
146
112
  ## Troubleshooting
147
113
 
148
- **The first `add` from git fails, saying build scripts were ignored?** Add the `allowBuilds` line from the git part of step 1, then re-run — or install from npm, which needs no authorization at all.
114
+ ### The first `add` from git fails, saying build scripts were ignored?
115
+
116
+ Add the `allowBuilds` line from the git part of step 1, then re-run — or install from npm, which needs no authorization at all.
117
+
118
+ ### `Issues with peer dependencies found` during install?
149
119
 
150
- **`Issues with peer dependencies found` during install?** Expected: the `@deepseek-ai/cordis`, `@deepseek-ai/schemastery` and `@deepseek-ai/dsh-settings` packages this plugin peers on ship with DSH and are resolved by DSH itself (they never enter the profile's `node_modules`), so pnpm not seeing them does not affect running the plugin.
120
+ Expected: the `@deepseek-ai/cordis`, `@deepseek-ai/schemastery` and `@deepseek-ai/dsh-settings` packages this plugin peers on ship with DSH and are resolved by DSH itself (they never enter the profile's `node_modules`), so pnpm not seeing them does not affect running the plugin.
151
121
 
152
- **`Failed to resolve dependency: The filename, directory name, or volume label syntax is incorrect. (os error 123)`?** The git spec is scp-style (`git@github.com:he0119/dsh-aperture.git`) — on Windows the colon reads as a drive letter, so it is parsed as a **local path**. Use a spec pnpm recognises: `github:he0119/dsh-aperture`, `git+https://…` or `git+ssh://…`.
122
+ ### `Failed to resolve dependency: The filename, directory name, or volume label syntax is incorrect. (os error 123)`?
153
123
 
154
- **git over HTTPS is unusable on this machine (schannel / `SEC_E_NO_CREDENTIALS`)?**
124
+ The git spec is scp-style (`git@github.com:he0119/dsh-aperture.git`) — on Windows the colon reads as a drive letter, so it is parsed as a **local path**. Use a spec pnpm recognises: `github:he0119/dsh-aperture`, `git+https://…` or `git+ssh://…`.
125
+
126
+ ### git over HTTPS is unusable on this machine (schannel / `SEC_E_NO_CREDENTIALS`)?
155
127
 
156
128
  ```sh
157
129
  git config --global url."git@github.com:".insteadOf "https://github.com/"
158
130
  ```
159
131
 
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:
132
+ ### Some models never show up in the selector?
161
133
 
162
- ```
163
- 404 model "gemini-2.5-flash" is available via gemini_generate_content, not openai_chat
164
- 404 model "MiniMax-M3" is available via anthropic_messages, not openai_chat
165
- ```
134
+ 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 list only the models that route really serves). Models that only offer Gemini's native `generateContent` endpoint cannot be attached — this plugin publishes OpenAI Chat Completions, OpenAI Responses and Anthropic Messages only. Using the wrong endpoint fails loudly, for instance `404 model "gemini-2.5-flash" is available via gemini_generate_content, not openai_chat`.
166
135
 
167
- **Want more reasoning levels for a model?** Only two conservative levels are offered by default (DeepSeek family `off/high/max`, every other reasoning model `off/high`). Add your own:
136
+ ### Want more reasoning levels for a model?
168
137
 
169
- ```yaml
170
- # ~/.dsh/profiles/web/cordis.patch.yml
171
- - id: aperture
172
- config:
173
- models:
174
- - id: deepseek-v4-pro
175
- reasoningEfforts:
176
- off: disabled
177
- minimal: minimal
178
- low: low
179
- medium: medium
180
- high: high
181
- max: max
182
- ```
138
+ Only two conservative levels are offered by default (DeepSeek family `off/high/max`, every other reasoning model `off/high`); give that `models` entry a `reasoningEfforts`, as in [Configuration](#configuration).
183
139
 
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:
140
+ ### Want a model the gateway did not list?
185
141
 
186
- ```yaml
187
- # ~/.dsh/profiles/web/cordis.patch.yml
188
- - id: aperture
189
- config:
190
- models:
191
- - id: gemini-2.5-pro
192
- api: openai-completions
193
- ```
142
+ Add it explicitly to `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; see [Configuration](#configuration).
194
143
 
195
- **Capacity or reasoning flags were not filled in?** Gateways rename things, and models.dev may not match (in practice `deepseek-flash` and `k3` are `deepseek/deepseek-v4-flash` and `moonshotai/kimi-k3` there). Bridge it explicitly:
144
+ ### Capacity or reasoning flags were not filled in?
196
145
 
197
- ```yaml
198
- # ~/.dsh/profiles/web/cordis.patch.yml
199
- - id: aperture
200
- config:
201
- modelAliases:
202
- deepseek-flash: deepseek/deepseek-v4-flash
203
- k3: moonshotai/kimi-k3
204
- ```
146
+ Gateways rename things, and models.dev may not match (in practice `deepseek-flash` and `k3` are `deepseek/deepseek-v4-flash` and `moonshotai/kimi-k3` there); bridge it with `modelAliases`, as in [Configuration](#configuration).
147
+
148
+ ### The interface says `没注册(路由 aperture-openai-responses 已被另一个适配器注册…)`?
205
149
 
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.)
150
+ 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: delete the matching `providers.<key>` from the `llm-pi-ai` section following the key name that line gives you, 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 "Refresh now" — retries registration; no restart is needed. (The host writes that line in Chinese, as do its action summaries.)
207
151
 
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.
152
+ ### Coming from 0.2 or earlier, do I have to delete those `aperture*` keys in `llm-pi-ai.providers` myself?
209
153
 
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.
154
+ Yes — and this time no key will point them out for you: the 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).
211
155
 
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.
156
+ ### Where did the `route` key go?
213
157
 
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.
158
+ 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`; if you only ever wrote the default, just delete the old key.
215
159
 
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.
160
+ ### Saved but not in effect?
217
161
 
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.
162
+ 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.
219
163
 
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.
164
+ ### Upgrading from 0.2 — where did my `settings.yaml` go?
165
+
166
+ 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 that archive does nothing when edited; a section whose values no longer validate stays in the archive too, with a line in the log saying so.
167
+
168
+ ### No Plugins page / no GUI in this deployment?
169
+
170
+ Both interfaces only exist in the Web GUI. A headless profile still discovers and still registers routes, it just has no clickable page — edit the configuration instead. The models also show up as rows on the official Models page; that row's own editor is read-only for this plugin (its settings section is `aperture`), and what you do edit is the block this plugin hangs inside it.
171
+
172
+ ### Need a real key instead of the placeholder credential?
173
+
174
+ No: Aperture authenticates by network identity (Tailscale). 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 — this 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.
175
+
176
+ ### Is the old route still there after changing `routePrefix`?
177
+
178
+ The plugin only knows the three keys it currently asks for; 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.
221
179
 
222
180
  ## What it does
223
181
 
224
- ```
225
- GET {baseUrl}/v1/models
226
- │
227
- ├─ per model: supported_endpoints ──► routing
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)
232
- │
233
- ├─ capacity: Aperture fields ─► models.dev ─► default
234
- ├─ reasoning: Aperture fields ─► models.dev ─► off
235
- │
236
- └─ registered as three provider routes (<routePrefix> + the protocol name, lowercased with dashes)
237
- ```
182
+ The plugin asks the gateway for one `GET {baseUrl}/v1/models` listing and routes each model by its `supported_endpoints`: `/v1/chat/completions` to `openai-completions`, `/v1/responses` to `openai-responses`, `/v1/messages` to `anthropic-messages`, each on one of the three routes sharing the same prefix; a model that only offers native `generateContent` is not published, and the configuration page's sentence names it.
238
183
 
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).
184
+ 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. 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 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).
240
185
 
241
186
  ## Development
242
187
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # dsh-aperture
2
2
 
3
- 把 [Aperture](https://tailscale.com/kb/1542/aperture) 网关上的模型自动发现出来,按模型自己在哪个端点上应答,注册成 DeepSeek Harness 里本插件自己的 provider 路由,让它们直接出现在模型选择器里。装好后你只需要填一个 Aperture 地址,其余交给插件。
3
+ 把 [Aperture](https://tailscale.com/kb/1542/aperture) 网关上的模型自动发现出来,按模型自己在哪个端点上应答,注册成 DeepSeek Harness 里本插件自己的 provider 路由,让它们直接出现在模型选择器里。装好后你只需要填一个 Aperture 地址。
4
4
 
5
5
  ## 安装
6
6
 
@@ -8,19 +8,18 @@
8
8
 
9
9
  ### 1. 装上插件
10
10
 
11
- 从 [npm](https://www.npmjs.com/package/dsh-aperture) 装(推荐):
12
-
13
11
  ```sh
12
+ # npm(推荐):发布产物里带着编译好的 lib/,安装时不需要授权任何构建脚本
14
13
  npx @deepseek-ai/dsh plugin --profile web add dsh-aperture
15
- ```
16
-
17
- 发布产物里带着编译好的 `lib/`,安装时不需要授权任何构建脚本。想锁 commit、或跟进未发布的改动,就从 git 装:
18
14
 
19
- ```sh
15
+ # git:拉下来的是源码,靠 prepare 脚本在安装时编译,可以锁 commit
20
16
  npx @deepseek-ai/dsh plugin --profile web add github:he0119/dsh-aperture#<sha>
17
+
18
+ # 本地仓库:先 pnpm run build
19
+ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
21
20
  ```
22
21
 
23
- git 安装拉下来的是**源码**,靠 `prepare` 脚本在安装时编译。pnpm ≥10 默认拒绝运行 git 依赖的构建脚本,所以**第一次 `add` 会失败**:dsh 会把你需要的包键打印出来,写进 profile 的 `pnpm-workspace.yaml` 后重跑一次即可。
22
+ pnpm ≥10 默认拒绝运行 git 依赖的构建脚本,所以 git 那条**第一次会失败**:dsh 会把要授权的包键打印出来,写进 profile 的 `pnpm-workspace.yaml` 后重跑一次即可(键是**映射**形式,值为 `true`)。
24
23
 
25
24
  ```yaml
26
25
  # ~/.dsh/profiles/web/pnpm-workspace.yaml
@@ -28,16 +27,8 @@ allowBuilds:
28
27
  dsh-aperture: true
29
28
  ```
30
29
 
31
- (键是**映射**形式,值为 `true`;写成列表无效。)
32
-
33
30
  > 这项授权等于允许该包在你机器上、于 agent 沙箱之外执行安装脚本。只对信任的源码授权。
34
31
 
35
- 本地改代码时,直接装仓库目录(先 `pnpm run build`):
36
-
37
- ```sh
38
- npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
39
- ```
40
-
41
32
  ### 2. 填上你的 Aperture 地址
42
33
 
43
34
  ```yaml
@@ -47,7 +38,7 @@ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
47
38
  baseUrl: https://ai.example.ts.net
48
39
  ```
49
40
 
50
- 这一层(profile 的补丁文档,即用户层)就是本插件的设置命名空间 `aperture`。补丁层是**整行替换**而不是深合并——这一行的 `config` 会整个取代本包自带 `cordis.patch.yml`(组合层)那一行的,而组合层只声明这一行、不写 `config`,所以你写几项就只有几项;每个键的缺省值都在 schema 里,不写的键回落缺省值。也可以直接在界面里填:**插件**页里点开本插件,配置页上第一个格子「实例地址」写的就是同一个 `aperture.baseUrl`,保存后落在同一个文件里。
41
+ 这一行就是本插件的设置命名空间 `aperture`。补丁层是**整行替换**而不是深合并:你写几项就只有几项,没写的键回落 schema 里的缺省值。也可以直接在界面里填:**插件**页里点开本插件,「实例地址」写的就是同一个 `aperture.baseUrl`,保存后落在同一个文件里。
51
42
 
52
43
  ### 3. 重启 DSH
53
44
 
@@ -59,75 +50,34 @@ npx @deepseek-ai/dsh --profile web --dump-config # 应出现 "# == dsh-apertur
59
50
 
60
51
  ### 4. 确认
61
52
 
62
- 模型会出现在选择器里,路由名 `Aperture`。设置分在两处:**插件 → dsh-aperture** 那个包的配置页上是实例地址、注册开关与「立刻刷新」,模型目录在官方**设置 → 模型**页里本插件的路由卡上。
63
-
64
- ```
65
- (插件 → dsh-aperture)
66
- 实例地址 已覆盖 恢复默认
67
- [https://ai.example.ts.net ]
68
- 填 Aperture 的地址;留空即休眠,不再发现模型。
69
-
70
- 自动同步 已覆盖 恢复默认 ●━
71
- 每轮发现之后,把这批模型注册成 dsh 里本插件自己的 provider 路由。 [保存]
72
-
73
- 已保存:已重新发现并发布。
53
+ 模型出现在选择器里,路由名 `Aperture`。界面分两处:
74
54
 
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
- 一行一个模型;展开改这一行的覆盖,「保存」只写这一行。顺序来自发现顺序。
55
+ - **插件 → dsh-aperture**:实例地址、注册开关与「立刻刷新」。设置挂在插件这个包上,因此没有单独的「配置」按钮。
56
+ - **设置 → 模型**:本插件的每一条路由是那一页上的一行,行里一块**默认收着**的模型目录——点开就是这条路由能服务的模型,以及逐模型的覆盖编辑器(显示名称、目录别名、协议、容量、输入类型、推理)。没有路由可服务的模型不占座位,由插件页那句话交代:几个、叫什么、去哪儿给它们写协议。
87
57
 
88
- ● deepseek-v4-flash
89
- 上下文 1,048,576 · 输出 384,000 · 输入类型 文本+图像 · 推理 开 · 已覆盖 1 项
90
-
91
- (点开一行就是这一行的覆盖编辑器:名称与协议一组、容量一组,输入类型与推理各占一行,下面是「保存 / 清空覆盖 / 取消」。
92
- 同一张卡里每一行都是同一条路由,卡片头已经写着它,行内不再重复「路由 / 协议」)
93
-
94
- + 添加模型提供商
95
- ```
96
-
97
- **地址与注册开关**是同一份官方设置表单里的两个字段:写着「已覆盖」时,右边那颗「恢复默认」把它从设置文件里删掉(与官方「插件配置」页同一对词、同一个位置),按「保存」只发真的改动过的那一项。分组靠标题与间距分开,模型那一行则是一张卡(发丝描边加大圆角,颜色只用本页真的定义过的主题 token),能点开的只有模型行。
98
-
99
- **模型目录挂在官方「模型」页本插件那几行的扩展位上**(页主自己叫 Extension slots):本插件注册的每一条路由就是那一页上的一行,那一行里挂一块,只画**那一条路由**的模型——能列在那一页上的模型因此一定真的有路由。没有路由可服务的模型(配置里手写的、目录里没有的那些)不在那一页占座位,它们由配置页一句话交代:几个、叫什么,以及去哪儿给它们写协议。这一块**默认收着**:折叠头(自己画的一行,上面一条细线)左边是标题与模型数目,右边常驻一枚箭头,点一下才摊开这一块——那一页的每一行都有这一块,摊开一次是十几行,收着才不喧宾夺主。同一张卡里每一行都是同一条路由,卡片头已经写着它,行内因此不再重复「路由 / 协议」。
58
+ 界面怎么排、每条限制的来历,见 [docs/internals.md](https://github.com/he0119/dsh-aperture/blob/main/docs/internals.md)。
100
59
 
101
60
  ## 使用
102
61
 
103
- 界面分两处,各管各的:
104
-
105
- - **插件 → dsh-aperture**:在插件列表里点开本插件,设置页挂在包上,所以没有单独的「配置」按钮。页头的名字、图标与那句描述来自本包的 `locale/*.json` 与 `package.json` 的 `icon`,页面本身由插件页画出。这一页只有实例地址与注册开关两项。
106
- - **设置 → 模型**:本插件的模型目录挂在官方那一页上——每条路由的行里一块(那一行自己的模型);没有路由可服务的模型不在这一页出现,它们由插件页那句话交代。那个座位的名字由页主自己声明,本插件只往里注册内容。
107
-
108
- 地址、开关与逐模型参数在按下「保存」之前都只是草稿;模型那部分**按行来**,收起一行不算放弃,行上的「有未保存的改动」标签会一直挂着。
62
+ 地址、开关与逐模型参数在按下「保存」之前都只是草稿;模型那部分**按行来**,收起一行不算放弃。
109
63
 
110
- | 位置 | 作用 |
111
- | --- | --- |
112
- | 插件页 · 实例地址 | 改 `baseUrl`(写入设置接缝;写着「已覆盖」时旁边那颗「恢复默认」把它放回缺省值) |
113
- | 插件页 · 注册开关 | 改 `sync`:关掉就只探测、不注册——那一轮刷新会把本插件已经注册出去的三条路由撤下来,别处注册的同名路由不受影响;同样带「已覆盖 / 恢复默认」这一对 |
114
- | 插件页 · 保存 | 表单下方,把地址与开关的草稿写进设置文档;有版本设栅,表单已经与设置文档脱节时会拒绝写入,而不是覆盖别处的改动;写完等这一轮重新发现落地才返回,界面随即显示新配置 |
115
- | 插件页 · 立刻刷新 | 保存按钮旁边那一颗:不写设置,直接重跑一轮发现与注册,结果(成功,或者失败的原因)贴在同一页上,「这一轮哪里不对」那句话跟着变新 |
116
- | 模型页 · 路由卡里的模型 | 一行一个模型,一行一张卡:行首一颗状态点(绿=这一轮注册上了路由,灰=这一轮注册过而它没注册上,鼠标停在上面或读屏都能听到这句话),第一行是名字与「已覆盖 N 项 / 有未保存的改动」几枚标签,第二行是带标签的事实(容量、输入类型、推理、别名;路由与协议同卡每一行都一样,卡片头已经写着,行内不再重复),长名字省略、事实随宽度换行;点开就是这一行的覆盖编辑器——显示名称、目录别名、API 协议三个输入框一组,「容量」一组(上下文窗口、最大输出 token 数),输入类型两个勾选框与推理一个三段开关(跟随发现 / 开 / 关)各占一行;字段下面只留一句来源(「来源:Aperture」),「留空即用发现到的名字」这类怎么做的话在标签旁边那颗「i」里,点开才占位置 |
117
- | 模型页 · 保存 / 清空覆盖 / 取消 | 只写这一行,或者只清掉后台报告里确实被覆盖过的那几项,或者把这一行的草稿整个丢掉;「保存」同样等一轮重新发现落地,所以按完看到的就是新值 |
118
- | 插件页 · 未服务的模型 | 报告里没有路由可服务的模型有几个、叫什么(最多报五个名字,多的写「等 N 个」):给它们写上 `models[].protocol` 就有路由,接不进来的删掉即可;一条路由都没注册时改说这一句 |
64
+ - **插件页 · 实例地址与注册开关**:保存只发真的改动过的那一项,并按版本设栅挡住已经与设置文档脱节的表单;写着「已覆盖」的键旁边那颗「恢复默认」把它从设置文件里删掉(与官方「插件配置」页同一对词、同一个位置)。
65
+ - **插件页 · 立刻刷新**:不写设置,直接重跑一轮发现与注册,成功或失败的原因贴在同一页上。
66
+ - **插件页 · 注册开关**:关掉就只探测、不注册——那一轮会把本插件已经注册出去的三条路由撤下来,别处注册的同名路由不受影响。
67
+ - **模型页 · 保存 / 清空覆盖 / 取消**:只写这一行;或者只清掉后台报告里确实覆盖过的那几项;或者丢掉这一行的草稿。「保存」等一轮重新发现落地才返回,所以按完看到的就是新值。
68
+ - **容量写法**:认 `1M`、`100K`(十进制后缀,`1M` 是 1000000,不是 1048576);留空表示这一项不覆盖、回落到发现值与目录。
119
69
 
120
- 就地编辑写的都是配置:容量与输入类型等落在 `aperture.models` 的对应条目上,目录别名落在 `aperture.modelAliases[id]`,写入按字段合并——界面没提到的字段原样留着(比如 `reasoningEfforts`),留空则表示这一项不覆盖、回落到发现值与目录。容量认 `1M`、`100K` 这种写法(十进制后缀,跟官方「模型」页同一套词汇:`1M` 是 1000000,不是 1048576),存下去的仍是普通 token 数,输入框回写成能原样读回来的最短那个(`384000` → `384K`,而 `1048576` 不是整千,照原样写)。「未服务」的模型不在这一页出现,它们的出路在配置里:给 `models` 里那一条写上 `protocol`,只在原生端点上应答的模型就能在对应路由上发布。
70
+ 就地编辑写下去的都是配置:容量与输入类型落在 `aperture.models` 的对应条目上,目录别名落在 `aperture.modelAliases[id]`,写入按字段合并,界面没提到的字段原样留着(比如 `reasoningEfforts`)。
121
71
 
122
72
  ## 配置
123
73
 
124
- 所有键都写在 profile 补丁文档里那一行的 `config:` 下(用户层),不写的键一律回落下面这些缺省值。`baseUrl` 与 `sync` 能在插件页上就地编辑,`models`、`modelAliases` 里的逐模型参数能在「设置 → 模型」页里就地编辑;其余键只有配置文件这一条路。
74
+ 所有键都写在 profile 补丁文档里那一行的 `config:` 下,不写的键回落下面的缺省值(默认一栏写 `—` 的键没有缺省值,不写就是缺失)。`baseUrl` 与 `sync` 能在插件页上就地编辑,`models`、`modelAliases` 里的逐模型参数能在「设置 → 模型」页里就地编辑;其余键只有配置文件这一条路。
125
75
 
126
76
  | 键 | 默认 | 说明 |
127
77
  | --- | --- | --- |
128
78
  | `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 里的引用名;非空时不再带占位凭据 |
79
+ | `routePrefix` | `aperture` | 三条路由名的共同前缀:路由键是前缀加协议名的小写连字符写法(`aperture-openai-chat-completions`、`aperture-openai-responses`、`aperture-anthropic-messages`),三个选择器名称同样由它推出来,逐字取官方「模型」页给协议用的产品名:`Aperture (OpenAI Chat Completions)`、`Aperture (OpenAI Responses)`、`Aperture (Anthropic Messages)` |
80
+ | `apiKeyEnv` | `—` | 凭据 seam 里的引用名(须匹配 `^[A-Za-z_][A-Za-z0-9_]*$`);不写这一项就按协议带占位凭据。空串不是引用名,别写 |
131
81
  | `headers` | `{}` | 每条请求额外带的头;同名时**归因头**与**占位凭据**仍会按协议补齐 |
132
82
  | `enabledModelIds` | `[]` | 非空时只保留这些 id(`models` 里显式列出的不受限) |
133
83
  | `modelAliases` | `{}` | 网关 id → models.dev id |
@@ -138,94 +88,101 @@ Aperture (OpenAI Chat Completions) 自定义 编辑
138
88
  | `sync` | `true` | `false` = 只探测不注册路由(配置页仍可查看) |
139
89
  | `refreshIntervalMinutes` | `0` | 定时刷新间隔;`0` = 只在启动和配置变化时刷新 |
140
90
 
141
- 容量与推理等级缺失时,按 Aperture 字段 → [models.dev](https://models.dev) → 保守默认值补全(兜底容量 128000、单次请求超时 20s、流式空闲上限 5 分钟是代码里的常量,不是配置项)。`maxTokens` 只有模型自己声明过才会作为**默认输出上限**报给宿主:没人声明时不报,凭空编一个值会让每次请求都按它截断。
91
+ 三个常用例子:
92
+
93
+ ```yaml
94
+ # ~/.dsh/profiles/web/cordis.patch.yml
95
+ - id: aperture
96
+ config:
97
+ baseUrl: https://ai.example.ts.net
98
+ models:
99
+ # 给某个模型更多推理等级(默认只给保守的两档)
100
+ - id: deepseek-v4-pro
101
+ reasoningEfforts: { off: disabled, minimal: minimal, low: low, medium: medium, high: high, max: max }
102
+ # 网关没列出的模型,显式补一条
103
+ - id: gemini-2.5-pro
104
+ api: openai-completions
105
+ modelAliases:
106
+ # 网关改了名,models.dev 上对不上
107
+ deepseek-flash: deepseek/deepseek-v4-flash
108
+ k3: moonshotai/kimi-k3
109
+ ```
110
+
111
+ 容量与推理等级缺失时,按 Aperture 字段 → [models.dev](https://models.dev) → 保守默认值补全(兜底容量 128000、单次请求超时 20s、流式空闲上限 5 分钟是代码里的常量,不是配置项);`maxTokens` 只有模型自己声明过才会作为默认输出上限报给宿主,没人声明时不报。
142
112
 
143
113
  ## 常见问题
144
114
 
145
- **从 git 装的时候,第一次 `add` 失败、说构建脚本被忽略?** 按[安装](#1-装上插件)里 git 那段的 `allowBuilds` 写一行,然后重跑;或者直接用 npm 安装,不需要任何授权。
115
+ ### 从 git 装的时候,第一次 `add` 失败、说构建脚本被忽略?
116
+
117
+ 按[安装](#1-装上插件)里 git 那段的 `allowBuilds` 写一行,然后重跑;或者直接用 npm 安装,不需要任何授权。
118
+
119
+ ### 装的时候警告 `Issues with peer dependencies found`?
146
120
 
147
- **装的时候警告 `Issues with peer dependencies found`?** 预期内:本包依赖的 `@deepseek-ai/cordis`、`@deepseek-ai/schemastery`、`@deepseek-ai/dsh-settings` 都由 DSH 自带并自行解析,不进 profile 的 `node_modules`,pnpm 看不到它们不影响运行。
121
+ 预期内:本包依赖的 `@deepseek-ai/cordis`、`@deepseek-ai/schemastery`、`@deepseek-ai/dsh-settings` 都由 DSH 自带并自行解析,不进 profile 的 `node_modules`,pnpm 看不到它们不影响运行。
148
122
 
149
- **`Failed to resolve dependency: 文件名、目录名或卷标语法不正确。 (os error 123)`?** git 地址用了 `git@github.com:he0119/dsh-aperture.git` 这种 scp 风格——在 Windows 上冒号会被当作盘符,于是被当成**本地路径**。改用 pnpm 认的写法:`github:he0119/dsh-aperture`、`git+https://…` 或 `git+ssh://…`。
123
+ ### `Failed to resolve dependency: 文件名、目录名或卷标语法不正确。 (os error 123)`?
150
124
 
151
- **本机 git 的 HTTPS 不可用(报 schannel / `SEC_E_NO_CREDENTIALS`)?**
125
+ git 地址用了 `git@github.com:he0119/dsh-aperture.git` 这种 scp 风格——在 Windows 上冒号会被当作盘符,于是被当成**本地路径**。改用 pnpm 认的写法:`github:he0119/dsh-aperture`、`git+https://…` 或 `git+ssh://…`。
126
+
127
+ ### 本机 git 的 HTTPS 不可用(报 schannel / `SEC_E_NO_CREDENTIALS`)?
152
128
 
153
129
  ```sh
154
130
  git config --global url."git@github.com:".insteadOf "https://github.com/"
155
131
  ```
156
132
 
157
- **有些模型没出现在选择器里?** 看**插件 → dsh-aperture** 配置页上那句话——它说有几个模型没有路由可服务、都叫什么(本插件的路由卡下面列的是那一条路由真的能服务的模型)。只提供 Gemini 原生 `generateContent` 端点的模型接不进来——本插件可发布 OpenAI Chat Completions、OpenAI Responses 与 Anthropic Messages,不能转换 Gemini 原生协议。走错端点时 Aperture 会明确告诉你该用哪个:
133
+ ### 有些模型没出现在选择器里?
158
134
 
159
- ```
160
- 404 model "gemini-2.5-flash" is available via gemini_generate_content, not openai_chat
161
- 404 model "MiniMax-M3" is available via anthropic_messages, not openai_chat
162
- ```
135
+ 看**插件 → dsh-aperture** 配置页上那句话:有几个模型没有路由可服务、都叫什么(路由卡里列的只是那一条路由真的能服务的模型)。只提供 Gemini 原生 `generateContent` 端点的模型接不进来——本插件只发布 OpenAI Chat Completions、OpenAI Responses 与 Anthropic Messages。接不上时 Aperture 会明确告诉你该用哪个端点,比如 `404 model "gemini-2.5-flash" is available via gemini_generate_content, not openai_chat`。
163
136
 
164
- **想给某个模型更多推理等级?** 默认只给保守的两档(DeepSeek 系 `off/high/max`,其它会推理的模型 `off/high`),自己加:
137
+ ### 想给某个模型更多推理等级?
165
138
 
166
- ```yaml
167
- # ~/.dsh/profiles/web/cordis.patch.yml
168
- - id: aperture
169
- config:
170
- models:
171
- - id: deepseek-v4-pro
172
- reasoningEfforts: { off: disabled, minimal: minimal, low: low, medium: medium, high: high, max: max }
173
- ```
139
+ 默认只给保守的两档(DeepSeek 系 `off/high/max`,其它会推理的模型 `off/high`),要加就在 `models` 里给这一条写 `reasoningEfforts`,例子见[配置](#配置)。
174
140
 
175
- **网关没列出的模型也想接?** 用 `models` 显式补一条即可(比如配置页那句话里报出来的那几个 Gemini 模型,只要你知道它在 OpenAI 兼容端点上确实能用):
141
+ ### 网关没列出的模型也想接?
176
142
 
177
- ```yaml
178
- # ~/.dsh/profiles/web/cordis.patch.yml
179
- - id: aperture
180
- config:
181
- models:
182
- - id: gemini-2.5-pro
183
- api: openai-completions
184
- ```
143
+ 在 `models` 里显式补一条就行(比如插件页那句话里报出来的那几个 Gemini 模型,只要你知道它在 OpenAI 兼容端点上确实能用),例子见[配置](#配置)。
185
144
 
186
- **模型的容量/推理标记没补上?** 网关会改名,models.dev 上可能对不上(实测 `deepseek-flash`、`k3` 那边叫 `deepseek/deepseek-v4-flash`、`moonshotai/kimi-k3`)。显式映射:
145
+ ### 模型的容量/推理标记没补上?
187
146
 
188
- ```yaml
189
- # ~/.dsh/profiles/web/cordis.patch.yml
190
- - id: aperture
191
- config:
192
- modelAliases:
193
- deepseek-flash: deepseek/deepseek-v4-flash
194
- k3: moonshotai/kimi-k3
195
- ```
147
+ 网关会改名,models.dev 上可能对不上(实测 `deepseek-flash`、`k3` 那边叫 `deepseek/deepseek-v4-flash`、`moonshotai/kimi-k3`),用 `modelAliases` 显式映射,例子见[配置](#配置)。
196
148
 
197
- **界面上说 `没注册(路由 aperture-openai-responses 已被另一个适配器注册…)`?** 说明请求的路由键里有一个已经被别人服务了——最常见的原因是**旧版本的本插件**:0.2 及更早只做发现,它会把自己发现的路由写进 `llm-pi-ai.providers`。本插件不替你改别人的配置,照那一行给出的键名手工处理:删掉 `llm-pi-ai` 段里对应的 `providers.<键>`;如果那个路由名是别的插件在用的,就改本插件配置里的 `routePrefix`(三条路由键一起变)。下一个适配器集合变化(改完配置的重载、或者在插件页按那颗「立刻刷新」)就会重新尝试注册,不必重启。
149
+ ### 界面上说 `没注册(路由 aperture-openai-responses 已被另一个适配器注册…)`?
198
150
 
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` 继续服务一份过期的路由(选择器里出现重复模型),升级时一并删掉即可。
151
+ 那个路由键已经被别人服务了,最常见的原因是**旧版本的本插件**(0.2 及更早只做发现,会把自己发现的路由写进 `llm-pi-ai.providers`)。本插件不替你改别人的配置:照那句话给出的键名删掉 `llm-pi-ai` 段里对应的 `providers.<键>`,或者那个名字属于别的插件时改本插件的 `routePrefix`(三条路由键一起变)。下一次适配器集合变化(改完配置的重载、或按「立刻刷新」)会重新尝试注册,不必重启。
200
152
 
201
- **配置里的 `route` 键去哪了?** 它改名成了 `routePrefix`。旧键不报错,但会被 schema 忽略——前缀于是静默回到缺省的 `aperture`。当初把前缀写成了别的名字(`route: my-gateway`)的话,升级后要把它抄到 `routePrefix` 上;只写过缺省值的话,把旧键删掉即可。
153
+ ### 从 0.2 或更早升上来,`llm-pi-ai.providers` 里那几个 `aperture*` 键要不要自己删?
202
154
 
203
- **保存了但没生效?** DSH 的补丁层是叠加的:profile 的补丁文档之上还有 `$DSH_HOME/cordis.patch.yml` 这类更高优先级的层。如果 `aperture` 这一行在那里也被写过,配置页上的保存会落在 profile 的补丁文档里、却被上面那层盖住(这一笔也可能被设置接缝直接拒收,配置页会说没被收下)。把那一行从高优先级的层里删掉,或者直接改那一处。
155
+ 要,而且这次没有哪个键会替你报错:现在的路由键是前缀加协议名(默认 `aperture-openai-chat-completions` / `aperture-openai-responses` / `aperture-anthropic-messages`),与那时写下的 `aperture`、`aperture-responses`、`aperture-anthropic` 都不同名,注册不会撞键。留着只会让 `llm-pi-ai` 继续服务一份过期的路由(选择器里出现重复模型)。
204
156
 
205
- **从 0.2 升上来,我的 `settings.yaml` 去哪了?** 0.1.7 起设置不再有独立文件,而是落在 profile 的补丁文档里。首次启动时 `$DSH_HOME/settings.yaml` 会被改名成 `settings.yaml.imported`,各段按设置命名空间搬进补丁文档——`aperture:` 段原样搬过去,仍能过 schema 的键与值都不变,所以地址与逐模型覆盖都还在。此后被读的只有补丁文档,`settings.yaml.imported` 只是留档,改它没有用;搬不过去的段(值已不合法)也只留在那份留档里,并在日志里说一声。
157
+ ### 配置里的 `route` 键去哪了?
206
158
 
207
- **本部署没有「插件」页 / 没有界面?** 两处界面都只在 Web 界面里有(插件页那一份靠 Typert Remote 端点工作)。headless profile 里插件照常发现、照常注册路由,只是没有可点按的页面。模型在官方「模型」页里也会出现相应的行(只有真的有模型的那几种协议才占一行):那一行自己的编辑器对本插件是只读的(设置段是 `aperture`,不是模型页的通用表单),但本插件在那一行里挂了自己的一块编辑器,所以改模型还是那一页上的事(没有路由可服务的模型不在那一页出现,界面在时由插件页那句话交代);没有界面时改配置。
159
+ 改名叫 `routePrefix` 了。旧键不报错,但会被 schema 忽略——前缀于是静默回到缺省的 `aperture`。写过别的名字(`route: my-gateway`)就把它抄到 `routePrefix` 上,只写过缺省值就删掉旧键。
208
160
 
209
- **需要真密钥而不是占位凭据?** Aperture 靠网络身份(Tailscale)认证,本不需要密钥;插件默认在每条请求上带 `authorization: Bearer dsh-aperture`(Anthropic 路由是 `x-api-key: dsh-aperture`),只是让 pi-ai 愿意把请求发出去,**不是密钥**。真要密钥时把 `apiKeyEnv` 指向凭据 seam 里的记录,占位凭据就不再带。
161
+ ### 保存了但没生效?
210
162
 
211
- **改了 `routePrefix` 之后旧路由还在?** 插件只认自己当前请求的三个键(`<前缀>-openai-chat-completions`、`<前缀>-openai-responses`、`<前缀>-anthropic-messages`),进程退出后旧键就没有服务者了;它不再出现在选择器里,也不需要清理,除非有别的适配器顶上那个键。
163
+ DSH 的补丁层是叠加的:profile 的补丁文档之上还有 `$DSH_HOME/cordis.patch.yml` 这类更高优先级的层。`aperture` 那一行在那里也被写过时,配置页的保存会落在 profile 的补丁文档里、却被上面那层盖住(也可能被设置接缝直接拒收,配置页会说没被收下)。把那一行从高优先级的层里删掉,或者直接改那一处。
164
+
165
+ ### 从 0.2 升上来,我的 `settings.yaml` 去哪了?
166
+
167
+ 0.1.7 起设置不再有独立文件,而是落在 profile 的补丁文档里。首次启动时 `$DSH_HOME/settings.yaml` 会被改名成 `settings.yaml.imported`,各段按设置命名空间搬进补丁文档——`aperture:` 段原样搬过去,仍能过 schema 的键与值都不变,所以地址与逐模型覆盖都还在。此后被读的只有补丁文档,那份留档改了没用;搬不过去的段(值已不合法)也只留在留档里,并在日志里说一声。
168
+
169
+ ### 本部署没有「插件」页 / 没有界面?
170
+
171
+ 两处界面都只在 Web 界面里有。headless profile 里插件照常发现、照常注册路由,只是没有可点按的页面,改配置即可。模型在官方「模型」页里也会有相应的行——那一行自己的编辑器对本插件是只读的(设置段是 `aperture`),能编辑的是本插件挂进去的那一块。
172
+
173
+ ### 需要真密钥而不是占位凭据?
174
+
175
+ 不需要:Aperture 靠网络身份(Tailscale)认证。插件默认在每条请求上带 `authorization: Bearer dsh-aperture`(Anthropic 路由是 `x-api-key: dsh-aperture`),只是让 pi-ai 愿意把请求发出去,**不是密钥**。真要密钥时把 `apiKeyEnv` 指向凭据 seam 里的记录,占位凭据就不再带。
176
+
177
+ ### 改了 `routePrefix` 之后旧路由还在?
178
+
179
+ 插件只认自己当前请求的三个键,进程退出后旧键就没有服务者了;它不再出现在选择器里,也不需要清理,除非有别的适配器顶上那个键。
212
180
 
213
181
  ## 它做了什么
214
182
 
215
- ```
216
- GET {baseUrl}/v1/models
217
- │
218
- ├─ 每个模型:supported_endpoints ──► 分流
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 ──► 不发布(配置页那句话里报出来)
223
- ├─ 容量:Aperture 字段 ─► models.dev ─► 默认值
224
- ├─ 推理:Aperture 字段 ─► models.dev ─► 关闭
225
- └─ 注册成三条 provider 路由(<routePrefix> + 协议名的小写写法)
226
- ```
183
+ 插件只请求网关上那份 `GET {baseUrl}/v1/models` 清单,再按每个模型的 `supported_endpoints` 分流:`/v1/chat/completions` 对到 `openai-completions`、`/v1/responses` 对到 `openai-responses`、`/v1/messages` 对到 `anthropic-messages`,各自挂上同一前缀的三条路由之一;只提供原生 `generateContent` 的模型不发布,由配置页那句话报出来。
227
184
 
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)。
185
+ 三条路由各自只承载一种协议,模型 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)(中文)。
229
186
 
230
187
  ## 开发
231
188
 
package/lib/index.js CHANGED
@@ -684,7 +684,7 @@ const modelConfig = z.object({
684
684
  const Config = z.object({
685
685
  baseUrl: z.string().default(""),
686
686
  routePrefix: z.string().default("aperture"),
687
- apiKeyEnv: z.string().default(""),
687
+ apiKeyEnv: z.string().role("credential-ref"),
688
688
  headers: z.dict(z.string()).default({}),
689
689
  enabledModelIds: z.array(z.string()).default([]),
690
690
  modelAliases: z.dict(z.string()).default({}),
@@ -28,7 +28,7 @@ export interface Config {
28
28
  * Chat Completions)`)。
29
29
  */
30
30
  routePrefix?: string;
31
- /** 按请求解析的凭据引用;留空则改为发布一个占位请求头。 */
31
+ /** 按请求解析的凭据引用;未设置时按协议带占位请求头。 */
32
32
  apiKeyEnv?: string;
33
33
  /** 每条路由的请求都会带上的额外请求头;它们优先于占位凭据。 */
34
34
  headers?: Dict<string>;
@@ -68,7 +68,7 @@ export interface Config {
68
68
  export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
69
69
  baseUrl: z<string, string, "defined">;
70
70
  routePrefix: z<string, string, "defined">;
71
- apiKeyEnv: z<string, string, "defined">;
71
+ apiKeyEnv: z<string, string, "plain">;
72
72
  headers: z<Dict<string, string>, Dict<string, string>, "defined">;
73
73
  enabledModelIds: z<string[], string[], "defined">;
74
74
  modelAliases: z<Dict<string, string>, Dict<string, string>, "defined">;
@@ -101,13 +101,13 @@ export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
101
101
  }>>[], "defined">;
102
102
  modelMetadataUrl: z<string, string, "defined">;
103
103
  images: z<"ignore" | "metadata", "ignore" | "metadata", "defined">;
104
- reasoning: z<"auto" | "off", "auto" | "off", "defined">;
104
+ reasoning: z<"off" | "auto", "off" | "auto", "defined">;
105
105
  sync: z<boolean, boolean, "defined">;
106
106
  refreshIntervalMinutes: z<number, number, "defined">;
107
107
  }>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
108
108
  baseUrl: z<string, string, "defined">;
109
109
  routePrefix: z<string, string, "defined">;
110
- apiKeyEnv: z<string, string, "defined">;
110
+ apiKeyEnv: z<string, string, "plain">;
111
111
  headers: z<Dict<string, string>, Dict<string, string>, "defined">;
112
112
  enabledModelIds: z<string[], string[], "defined">;
113
113
  modelAliases: z<Dict<string, string>, Dict<string, string>, "defined">;
@@ -140,7 +140,7 @@ export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
140
140
  }>>[], "defined">;
141
141
  modelMetadataUrl: z<string, string, "defined">;
142
142
  images: z<"ignore" | "metadata", "ignore" | "metadata", "defined">;
143
- reasoning: z<"auto" | "off", "auto" | "off", "defined">;
143
+ reasoning: z<"off" | "auto", "off" | "auto", "defined">;
144
144
  sync: z<boolean, boolean, "defined">;
145
145
  refreshIntervalMinutes: z<number, number, "defined">;
146
146
  }>>>, "volatile">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aperture",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "自动发现 Aperture 网关上的模型,并加进 DSH 的模型选择器。",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.7.0",