dsh-aperture 0.4.0 → 0.5.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,5 +1,15 @@
1
+ <p align="center">
2
+ <img src="icon.svg" width="88" alt="">
3
+ </p>
4
+
5
+ <div align="center">
6
+
1
7
  # dsh-aperture
2
8
 
9
+ [![](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white)](https://github.com/deepseek-ai/deepseek-harness)
10
+
11
+ </div>
12
+
3
13
  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
14
 
5
15
  ## Install
@@ -8,19 +18,18 @@ Requirements: Node ^22.19.0 or ≥24.0.0 (matching DSH), and an Aperture instanc
8
18
 
9
19
  ### 1. Add the plugin
10
20
 
11
- From [npm](https://www.npmjs.com/package/dsh-aperture) (recommended):
12
-
13
21
  ```sh
22
+ # npm (recommended): the published artifact ships a compiled lib/, so no build script has to be authorized
14
23
  npx @deepseek-ai/dsh plugin --profile web add dsh-aperture
15
- ```
16
24
 
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
-
19
- ```sh
25
+ # git: pulls source, compiled by a prepare script during install; pins a commit
20
26
  npx @deepseek-ai/dsh plugin --profile web add github:he0119/dsh-aperture#<sha>
27
+
28
+ # a local checkout: run pnpm run build first
29
+ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
21
30
  ```
22
31
 
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.
32
+ 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
33
 
25
34
  ```yaml
26
35
  # ~/.dsh/profiles/web/pnpm-workspace.yaml
@@ -28,16 +37,8 @@ allowBuilds:
28
37
  dsh-aperture: true
29
38
  ```
30
39
 
31
- (The key takes the **map** form with `true`; a list is not accepted.)
32
-
33
40
  > That authorization lets this package run code on your machine at install time, outside any agent sandbox. Authorize only source you trust.
34
41
 
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
42
  ### 2. Point it at your instance
42
43
 
43
44
  ```yaml
@@ -47,7 +48,7 @@ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
47
48
  baseUrl: https://ai.example.ts.net
48
49
  ```
49
50
 
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.
51
+ 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
52
 
52
53
  ### 3. Restart DSH
53
54
 
@@ -59,78 +60,33 @@ npx @deepseek-ai/dsh --profile web --dump-config # should show a "# == dsh-ape
59
60
 
60
61
  ### 4. Confirm
61
62
 
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.
63
+ The models appear in the selector under the route `Aperture`. The interface lives in two places:
87
64
 
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
- ```
65
+ - **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.
66
+ - **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.
97
67
 
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.)
101
-
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.
68
+ 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
69
 
104
70
  ## Usage
105
71
 
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.
72
+ 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.
110
73
 
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.
74
+ - **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).
75
+ - **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.
76
+ - **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.
77
+ - **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.
78
+ - **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.
112
79
 
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.
80
+ 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
81
 
125
82
  ## Configuration
126
83
 
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.
84
+ 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
85
 
129
86
  | Key | Default | Meaning |
130
87
  | --- | --- | --- |
131
88
  | `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 |
89
+ | `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)` |
134
90
  | `headers` | `{}` | Extra request headers; on a name collision the **attribution header** and the **placeholder credential** are still filled in per protocol |
135
91
  | `enabledModelIds` | `[]` | Non-empty restricts discovery to these ids (explicit `models` entries are exempt) |
136
92
  | `modelAliases` | `{}` | Gateway id → models.dev id |
@@ -141,102 +97,100 @@ Every key lives under that row's `config:` in the profile patch document (user l
141
97
  | `sync` | `true` | `false` discovers without registering routes (the configuration page still reports) |
142
98
  | `refreshIntervalMinutes` | `0` | Periodic refresh; `0` refreshes only at load and on change |
143
99
 
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.
100
+ Three common examples:
101
+
102
+ ```yaml
103
+ # ~/.dsh/profiles/web/cordis.patch.yml
104
+ - id: aperture
105
+ config:
106
+ models:
107
+ # more reasoning levels for one model (only two conservative ones are offered by default)
108
+ - id: deepseek-v4-pro
109
+ reasoningEfforts: { off: disabled, minimal: minimal, low: low, medium: medium, high: high, max: max }
110
+ # a model the gateway did not list
111
+ - id: gemini-2.5-pro
112
+ api: openai-completions
113
+ modelAliases:
114
+ # the gateway renamed it, so models.dev does not match
115
+ deepseek-flash: deepseek/deepseek-v4-flash
116
+ k3: moonshotai/kimi-k3
117
+ ```
118
+
119
+ 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
120
 
146
121
  ## Troubleshooting
147
122
 
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.
123
+ ### The first `add` from git fails, saying build scripts were ignored?
124
+
125
+ Add the `allowBuilds` line from the git part of step 1, then re-run — or install from npm, which needs no authorization at all.
126
+
127
+ ### `Issues with peer dependencies found` during install?
128
+
129
+ 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.
149
130
 
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.
131
+ ### `Failed to resolve dependency: The filename, directory name, or volume label syntax is incorrect. (os error 123)`?
151
132
 
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://…`.
133
+ 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://…`.
153
134
 
154
- **git over HTTPS is unusable on this machine (schannel / `SEC_E_NO_CREDENTIALS`)?**
135
+ ### git over HTTPS is unusable on this machine (schannel / `SEC_E_NO_CREDENTIALS`)?
155
136
 
156
137
  ```sh
157
138
  git config --global url."git@github.com:".insteadOf "https://github.com/"
158
139
  ```
159
140
 
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:
141
+ ### Some models never show up in the selector?
161
142
 
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
- ```
143
+ 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
144
 
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:
145
+ ### Want more reasoning levels for a model?
168
146
 
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
- ```
147
+ 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
148
 
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:
149
+ ### Want a model the gateway did not list?
185
150
 
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
- ```
151
+ 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
152
 
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:
153
+ ### Capacity or reasoning flags were not filled in?
196
154
 
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
- ```
155
+ 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).
205
156
 
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.)
157
+ ### The interface says `没注册(路由 aperture-openai-responses 已被另一个适配器注册…)`?
207
158
 
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.
159
+ 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.)
209
160
 
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.
161
+ ### Coming from 0.2 or earlier, do I have to delete those `aperture*` keys in `llm-pi-ai.providers` myself?
211
162
 
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.
163
+ 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).
213
164
 
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.
165
+ ### Where did the `route` key go?
215
166
 
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.
167
+ 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.
217
168
 
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.
169
+ ### Saved but not in effect?
219
170
 
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.
171
+ 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.
172
+
173
+ ### Upgrading from 0.2 — where did my `settings.yaml` go?
174
+
175
+ 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.
176
+
177
+ ### No Plugins page / no GUI in this deployment?
178
+
179
+ 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.
180
+
181
+ ### Need a real key instead of the placeholder credential?
182
+
183
+ No — and the plugin has no key setting at all: Aperture authenticates by network identity (Tailscale). Every request carries `authorization: Bearer dsh-aperture` (the Anthropic route sends `x-api-key: dsh-aperture`), only to make pi-ai willing to send the request — this is **not a key**. If a gateway really demands a static token, put one of those two headers in `headers` and the placeholder credential is no longer sent.
184
+
185
+ ### Is the old route still there after changing `routePrefix`?
186
+
187
+ 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
188
 
222
189
  ## What it does
223
190
 
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
- ```
191
+ 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
192
 
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).
193
+ 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
194
 
241
195
  ## Development
242
196
 
package/README.md CHANGED
@@ -1,6 +1,16 @@
1
+ <p align="center">
2
+ <img src="icon.svg" width="88" alt="">
3
+ </p>
4
+
5
+ <div align="center">
6
+
1
7
  # dsh-aperture
2
8
 
3
- 把 [Aperture](https://tailscale.com/kb/1542/aperture) 网关上的模型自动发现出来,按模型自己在哪个端点上应答,注册成 DeepSeek Harness 里本插件自己的 provider 路由,让它们直接出现在模型选择器里。装好后你只需要填一个 Aperture 地址,其余交给插件。
9
+ [![](https://img.shields.io/badge/powered_by-dsh-4D6BFE?style=flat-square&logo=deepseek&logoColor=white)](https://github.com/deepseek-ai/deepseek-harness)
10
+
11
+ </div>
12
+
13
+ 把 [Aperture](https://tailscale.com/kb/1542/aperture) 网关上的模型自动发现出来,按模型自己在哪个端点上应答,注册成 DeepSeek Harness 里本插件自己的 provider 路由,让它们直接出现在模型选择器里。装好后你只需要填一个 Aperture 地址。
4
14
 
5
15
  ## 安装
6
16
 
@@ -8,19 +18,18 @@
8
18
 
9
19
  ### 1. 装上插件
10
20
 
11
- 从 [npm](https://www.npmjs.com/package/dsh-aperture) 装(推荐):
12
-
13
21
  ```sh
22
+ # npm(推荐):发布产物里带着编译好的 lib/,安装时不需要授权任何构建脚本
14
23
  npx @deepseek-ai/dsh plugin --profile web add dsh-aperture
15
- ```
16
24
 
17
- 发布产物里带着编译好的 `lib/`,安装时不需要授权任何构建脚本。想锁 commit、或跟进未发布的改动,就从 git 装:
18
-
19
- ```sh
25
+ # git:拉下来的是源码,靠 prepare 脚本在安装时编译,可以锁 commit
20
26
  npx @deepseek-ai/dsh plugin --profile web add github:he0119/dsh-aperture#<sha>
27
+
28
+ # 本地仓库:先 pnpm run build
29
+ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
21
30
  ```
22
31
 
23
- git 安装拉下来的是**源码**,靠 `prepare` 脚本在安装时编译。pnpm ≥10 默认拒绝运行 git 依赖的构建脚本,所以**第一次 `add` 会失败**:dsh 会把你需要的包键打印出来,写进 profile 的 `pnpm-workspace.yaml` 后重跑一次即可。
32
+ pnpm ≥10 默认拒绝运行 git 依赖的构建脚本,所以 git 那条**第一次会失败**:dsh 会把要授权的包键打印出来,写进 profile 的 `pnpm-workspace.yaml` 后重跑一次即可(键是**映射**形式,值为 `true`)。
24
33
 
25
34
  ```yaml
26
35
  # ~/.dsh/profiles/web/pnpm-workspace.yaml
@@ -28,16 +37,8 @@ allowBuilds:
28
37
  dsh-aperture: true
29
38
  ```
30
39
 
31
- (键是**映射**形式,值为 `true`;写成列表无效。)
32
-
33
40
  > 这项授权等于允许该包在你机器上、于 agent 沙箱之外执行安装脚本。只对信任的源码授权。
34
41
 
35
- 本地改代码时,直接装仓库目录(先 `pnpm run build`):
36
-
37
- ```sh
38
- npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
39
- ```
40
-
41
42
  ### 2. 填上你的 Aperture 地址
42
43
 
43
44
  ```yaml
@@ -47,7 +48,7 @@ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
47
48
  baseUrl: https://ai.example.ts.net
48
49
  ```
49
50
 
50
- 这一层(profile 的补丁文档,即用户层)就是本插件的设置命名空间 `aperture`。补丁层是**整行替换**而不是深合并——这一行的 `config` 会整个取代本包自带 `cordis.patch.yml`(组合层)那一行的,而组合层只声明这一行、不写 `config`,所以你写几项就只有几项;每个键的缺省值都在 schema 里,不写的键回落缺省值。也可以直接在界面里填:**插件**页里点开本插件,配置页上第一个格子「实例地址」写的就是同一个 `aperture.baseUrl`,保存后落在同一个文件里。
51
+ 这一行就是本插件的设置命名空间 `aperture`。补丁层是**整行替换**而不是深合并:你写几项就只有几项,没写的键回落 schema 里的缺省值。也可以直接在界面里填:**插件**页里点开本插件,「实例地址」写的就是同一个 `aperture.baseUrl`,保存后落在同一个文件里。
51
52
 
52
53
  ### 3. 重启 DSH
53
54
 
@@ -59,75 +60,33 @@ npx @deepseek-ai/dsh --profile web --dump-config # 应出现 "# == dsh-apertur
59
60
 
60
61
  ### 4. 确认
61
62
 
62
- 模型会出现在选择器里,路由名 `Aperture`。设置分在两处:**插件 → dsh-aperture** 那个包的配置页上是实例地址、注册开关与「立刻刷新」,模型目录在官方**设置 → 模型**页里本插件的路由卡上。
63
+ 模型出现在选择器里,路由名 `Aperture`。界面分两处:
63
64
 
64
- ```
65
- (插件 → dsh-aperture)
66
- 实例地址 已覆盖 恢复默认
67
- [https://ai.example.ts.net ]
68
- 填 Aperture 的地址;留空即休眠,不再发现模型。
65
+ - **插件 → dsh-aperture**:实例地址、注册开关与「立刻刷新」。设置挂在插件这个包上,因此没有单独的「配置」按钮。
66
+ - **设置 → 模型**:本插件的每一条路由是那一页上的一行,行里一块**默认收着**的模型目录——点开就是这条路由能服务的模型,以及逐模型的覆盖编辑器(显示名称、目录别名、协议、容量、输入类型、推理)。没有路由可服务的模型不占座位,由插件页那句话交代:几个、叫什么、去哪儿给它们写协议。
69
67
 
70
- 自动同步 已覆盖 恢复默认 ●━
71
- 每轮发现之后,把这批模型注册成 dsh 里本插件自己的 provider 路由。 [保存]
72
-
73
- 已保存:已重新发现并发布。
74
-
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
- 一行一个模型;展开改这一行的覆盖,「保存」只写这一行。顺序来自发现顺序。
87
-
88
- ● deepseek-v4-flash
89
- 上下文 1,048,576 · 输出 384,000 · 输入类型 文本+图像 · 推理 开 · 已覆盖 1 项
90
-
91
- (点开一行就是这一行的覆盖编辑器:名称与协议一组、容量一组,输入类型与推理各占一行,下面是「保存 / 清空覆盖 / 取消」。
92
- 同一张卡里每一行都是同一条路由,卡片头已经写着它,行内不再重复「路由 / 协议」)
93
-
94
- + 添加模型提供商
95
- ```
96
-
97
- **地址与注册开关**是同一份官方设置表单里的两个字段:写着「已覆盖」时,右边那颗「恢复默认」把它从设置文件里删掉(与官方「插件配置」页同一对词、同一个位置),按「保存」只发真的改动过的那一项。分组靠标题与间距分开,模型那一行则是一张卡(发丝描边加大圆角,颜色只用本页真的定义过的主题 token),能点开的只有模型行。
98
-
99
- **模型目录挂在官方「模型」页本插件那几行的扩展位上**(页主自己叫 Extension slots):本插件注册的每一条路由就是那一页上的一行,那一行里挂一块,只画**那一条路由**的模型——能列在那一页上的模型因此一定真的有路由。没有路由可服务的模型(配置里手写的、目录里没有的那些)不在那一页占座位,它们由配置页一句话交代:几个、叫什么,以及去哪儿给它们写协议。这一块**默认收着**:折叠头(自己画的一行,上面一条细线)左边是标题与模型数目,右边常驻一枚箭头,点一下才摊开这一块——那一页的每一行都有这一块,摊开一次是十几行,收着才不喧宾夺主。同一张卡里每一行都是同一条路由,卡片头已经写着它,行内因此不再重复「路由 / 协议」。
68
+ 界面怎么排、每条限制的来历,见 [docs/internals.md](https://github.com/he0119/dsh-aperture/blob/main/docs/internals.md)。
100
69
 
101
70
  ## 使用
102
71
 
103
- 界面分两处,各管各的:
72
+ 地址、开关与逐模型参数在按下「保存」之前都只是草稿;模型那部分**按行来**,收起一行不算放弃。
104
73
 
105
- - **插件 → dsh-aperture**:在插件列表里点开本插件,设置页挂在包上,所以没有单独的「配置」按钮。页头的名字、图标与那句描述来自本包的 `locale/*.json` 与 `package.json` 的 `icon`,页面本身由插件页画出。这一页只有实例地址与注册开关两项。
106
- - **设置 → 模型**:本插件的模型目录挂在官方那一页上——每条路由的行里一块(那一行自己的模型);没有路由可服务的模型不在这一页出现,它们由插件页那句话交代。那个座位的名字由页主自己声明,本插件只往里注册内容。
74
+ - **插件页 · 实例地址与注册开关**:保存只发真的改动过的那一项,并按版本设栅挡住已经与设置文档脱节的表单;写着「已覆盖」的键旁边那颗「恢复默认」把它从设置文件里删掉(与官方「插件配置」页同一对词、同一个位置)。
75
+ - **插件页 · 立刻刷新**:不写设置,直接重跑一轮发现与注册,成功或失败的原因贴在同一页上。
76
+ - **插件页 · 注册开关**:关掉就只探测、不注册——那一轮会把本插件已经注册出去的三条路由撤下来,别处注册的同名路由不受影响。
77
+ - **模型页 · 保存 / 清空覆盖 / 取消**:只写这一行;或者只清掉后台报告里确实覆盖过的那几项;或者丢掉这一行的草稿。「保存」等一轮重新发现落地才返回,所以按完看到的就是新值。
78
+ - **容量写法**:认 `1M`、`100K`(十进制后缀,`1M` 是 1000000,不是 1048576);留空表示这一项不覆盖、回落到发现值与目录。
107
79
 
108
- 地址、开关与逐模型参数在按下「保存」之前都只是草稿;模型那部分**按行来**,收起一行不算放弃,行上的「有未保存的改动」标签会一直挂着。
109
-
110
- | 位置 | 作用 |
111
- | --- | --- |
112
- | 插件页 · 实例地址 | 改 `baseUrl`(写入设置接缝;写着「已覆盖」时旁边那颗「恢复默认」把它放回缺省值) |
113
- | 插件页 · 注册开关 | 改 `sync`:关掉就只探测、不注册——那一轮刷新会把本插件已经注册出去的三条路由撤下来,别处注册的同名路由不受影响;同样带「已覆盖 / 恢复默认」这一对 |
114
- | 插件页 · 保存 | 表单下方,把地址与开关的草稿写进设置文档;有版本设栅,表单已经与设置文档脱节时会拒绝写入,而不是覆盖别处的改动;写完等这一轮重新发现落地才返回,界面随即显示新配置 |
115
- | 插件页 · 立刻刷新 | 保存按钮旁边那一颗:不写设置,直接重跑一轮发现与注册,结果(成功,或者失败的原因)贴在同一页上,「这一轮哪里不对」那句话跟着变新 |
116
- | 模型页 · 路由卡里的模型 | 一行一个模型,一行一张卡:行首一颗状态点(绿=这一轮注册上了路由,灰=这一轮注册过而它没注册上,鼠标停在上面或读屏都能听到这句话),第一行是名字与「已覆盖 N 项 / 有未保存的改动」几枚标签,第二行是带标签的事实(容量、输入类型、推理、别名;路由与协议同卡每一行都一样,卡片头已经写着,行内不再重复),长名字省略、事实随宽度换行;点开就是这一行的覆盖编辑器——显示名称、目录别名、API 协议三个输入框一组,「容量」一组(上下文窗口、最大输出 token 数),输入类型两个勾选框与推理一个三段开关(跟随发现 / 开 / 关)各占一行;字段下面只留一句来源(「来源:Aperture」),「留空即用发现到的名字」这类怎么做的话在标签旁边那颗「i」里,点开才占位置 |
117
- | 模型页 · 保存 / 清空覆盖 / 取消 | 只写这一行,或者只清掉后台报告里确实被覆盖过的那几项,或者把这一行的草稿整个丢掉;「保存」同样等一轮重新发现落地,所以按完看到的就是新值 |
118
- | 插件页 · 未服务的模型 | 报告里没有路由可服务的模型有几个、叫什么(最多报五个名字,多的写「等 N 个」):给它们写上 `models[].protocol` 就有路由,接不进来的删掉即可;一条路由都没注册时改说这一句 |
119
-
120
- 就地编辑写的都是配置:容量与输入类型等落在 `aperture.models` 的对应条目上,目录别名落在 `aperture.modelAliases[id]`,写入按字段合并——界面没提到的字段原样留着(比如 `reasoningEfforts`),留空则表示这一项不覆盖、回落到发现值与目录。容量认 `1M`、`100K` 这种写法(十进制后缀,跟官方「模型」页同一套词汇:`1M` 是 1000000,不是 1048576),存下去的仍是普通 token 数,输入框回写成能原样读回来的最短那个(`384000` → `384K`,而 `1048576` 不是整千,照原样写)。「未服务」的模型不在这一页出现,它们的出路在配置里:给 `models` 里那一条写上 `protocol`,只在原生端点上应答的模型就能在对应路由上发布。
80
+ 就地编辑写下去的都是配置:容量与输入类型落在 `aperture.models` 的对应条目上,目录别名落在 `aperture.modelAliases[id]`,写入按字段合并,界面没提到的字段原样留着(比如 `reasoningEfforts`)。
121
81
 
122
82
  ## 配置
123
83
 
124
- 所有键都写在 profile 补丁文档里那一行的 `config:` 下(用户层),不写的键一律回落下面这些缺省值。`baseUrl` 与 `sync` 能在插件页上就地编辑,`models`、`modelAliases` 里的逐模型参数能在「设置 → 模型」页里就地编辑;其余键只有配置文件这一条路。
84
+ 所有键都写在 profile 补丁文档里那一行的 `config:` 下,不写的键回落下面的缺省值(默认一栏写 `—` 的键没有缺省值,不写就是缺失)。`baseUrl` 与 `sync` 能在插件页上就地编辑,`models`、`modelAliases` 里的逐模型参数能在「设置 → 模型」页里就地编辑;其余键只有配置文件这一条路。
125
85
 
126
86
  | 键 | 默认 | 说明 |
127
87
  | --- | --- | --- |
128
88
  | `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 里的引用名;非空时不再带占位凭据 |
89
+ | `routePrefix` | `aperture` | 三条路由名的共同前缀:路由键是前缀加协议名的小写连字符写法(`aperture-openai-chat-completions`、`aperture-openai-responses`、`aperture-anthropic-messages`),三个选择器名称同样由它推出来,逐字取官方「模型」页给协议用的产品名:`Aperture (OpenAI Chat Completions)`、`Aperture (OpenAI Responses)`、`Aperture (Anthropic Messages)` |
131
90
  | `headers` | `{}` | 每条请求额外带的头;同名时**归因头**与**占位凭据**仍会按协议补齐 |
132
91
  | `enabledModelIds` | `[]` | 非空时只保留这些 id(`models` 里显式列出的不受限) |
133
92
  | `modelAliases` | `{}` | 网关 id → models.dev id |
@@ -138,94 +97,101 @@ Aperture (OpenAI Chat Completions) 自定义 编辑
138
97
  | `sync` | `true` | `false` = 只探测不注册路由(配置页仍可查看) |
139
98
  | `refreshIntervalMinutes` | `0` | 定时刷新间隔;`0` = 只在启动和配置变化时刷新 |
140
99
 
141
- 容量与推理等级缺失时,按 Aperture 字段 → [models.dev](https://models.dev) → 保守默认值补全(兜底容量 128000、单次请求超时 20s、流式空闲上限 5 分钟是代码里的常量,不是配置项)。`maxTokens` 只有模型自己声明过才会作为**默认输出上限**报给宿主:没人声明时不报,凭空编一个值会让每次请求都按它截断。
100
+ 三个常用例子:
101
+
102
+ ```yaml
103
+ # ~/.dsh/profiles/web/cordis.patch.yml
104
+ - id: aperture
105
+ config:
106
+ baseUrl: https://ai.example.ts.net
107
+ models:
108
+ # 给某个模型更多推理等级(默认只给保守的两档)
109
+ - id: deepseek-v4-pro
110
+ reasoningEfforts: { off: disabled, minimal: minimal, low: low, medium: medium, high: high, max: max }
111
+ # 网关没列出的模型,显式补一条
112
+ - id: gemini-2.5-pro
113
+ api: openai-completions
114
+ modelAliases:
115
+ # 网关改了名,models.dev 上对不上
116
+ deepseek-flash: deepseek/deepseek-v4-flash
117
+ k3: moonshotai/kimi-k3
118
+ ```
119
+
120
+ 容量与推理等级缺失时,按 Aperture 字段 → [models.dev](https://models.dev) → 保守默认值补全(兜底容量 128000、单次请求超时 20s、流式空闲上限 5 分钟是代码里的常量,不是配置项);`maxTokens` 只有模型自己声明过才会作为默认输出上限报给宿主,没人声明时不报。
142
121
 
143
122
  ## 常见问题
144
123
 
145
- **从 git 装的时候,第一次 `add` 失败、说构建脚本被忽略?** 按[安装](#1-装上插件)里 git 那段的 `allowBuilds` 写一行,然后重跑;或者直接用 npm 安装,不需要任何授权。
124
+ ### 从 git 装的时候,第一次 `add` 失败、说构建脚本被忽略?
125
+
126
+ 按[安装](#1-装上插件)里 git 那段的 `allowBuilds` 写一行,然后重跑;或者直接用 npm 安装,不需要任何授权。
127
+
128
+ ### 装的时候警告 `Issues with peer dependencies found`?
129
+
130
+ 预期内:本包依赖的 `@deepseek-ai/cordis`、`@deepseek-ai/schemastery`、`@deepseek-ai/dsh-settings` 都由 DSH 自带并自行解析,不进 profile 的 `node_modules`,pnpm 看不到它们不影响运行。
146
131
 
147
- **装的时候警告 `Issues with peer dependencies found`?** 预期内:本包依赖的 `@deepseek-ai/cordis`、`@deepseek-ai/schemastery`、`@deepseek-ai/dsh-settings` 都由 DSH 自带并自行解析,不进 profile 的 `node_modules`,pnpm 看不到它们不影响运行。
132
+ ### `Failed to resolve dependency: 文件名、目录名或卷标语法不正确。 (os error 123)`?
148
133
 
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://…`。
134
+ git 地址用了 `git@github.com:he0119/dsh-aperture.git` 这种 scp 风格——在 Windows 上冒号会被当作盘符,于是被当成**本地路径**。改用 pnpm 认的写法:`github:he0119/dsh-aperture`、`git+https://…` 或 `git+ssh://…`。
150
135
 
151
- **本机 git 的 HTTPS 不可用(报 schannel / `SEC_E_NO_CREDENTIALS`)?**
136
+ ### 本机 git 的 HTTPS 不可用(报 schannel / `SEC_E_NO_CREDENTIALS`)?
152
137
 
153
138
  ```sh
154
139
  git config --global url."git@github.com:".insteadOf "https://github.com/"
155
140
  ```
156
141
 
157
- **有些模型没出现在选择器里?** 看**插件 → dsh-aperture** 配置页上那句话——它说有几个模型没有路由可服务、都叫什么(本插件的路由卡下面列的是那一条路由真的能服务的模型)。只提供 Gemini 原生 `generateContent` 端点的模型接不进来——本插件可发布 OpenAI Chat Completions、OpenAI Responses 与 Anthropic Messages,不能转换 Gemini 原生协议。走错端点时 Aperture 会明确告诉你该用哪个:
142
+ ### 有些模型没出现在选择器里?
158
143
 
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
- ```
144
+ 看**插件 → 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
145
 
164
- **想给某个模型更多推理等级?** 默认只给保守的两档(DeepSeek 系 `off/high/max`,其它会推理的模型 `off/high`),自己加:
146
+ ### 想给某个模型更多推理等级?
165
147
 
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
- ```
148
+ 默认只给保守的两档(DeepSeek 系 `off/high/max`,其它会推理的模型 `off/high`),要加就在 `models` 里给这一条写 `reasoningEfforts`,例子见[配置](#配置)。
174
149
 
175
- **网关没列出的模型也想接?** 用 `models` 显式补一条即可(比如配置页那句话里报出来的那几个 Gemini 模型,只要你知道它在 OpenAI 兼容端点上确实能用):
150
+ ### 网关没列出的模型也想接?
176
151
 
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
- ```
152
+ 在 `models` 里显式补一条就行(比如插件页那句话里报出来的那几个 Gemini 模型,只要你知道它在 OpenAI 兼容端点上确实能用),例子见[配置](#配置)。
185
153
 
186
- **模型的容量/推理标记没补上?** 网关会改名,models.dev 上可能对不上(实测 `deepseek-flash`、`k3` 那边叫 `deepseek/deepseek-v4-flash`、`moonshotai/kimi-k3`)。显式映射:
154
+ ### 模型的容量/推理标记没补上?
187
155
 
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
- ```
156
+ 网关会改名,models.dev 上可能对不上(实测 `deepseek-flash`、`k3` 那边叫 `deepseek/deepseek-v4-flash`、`moonshotai/kimi-k3`),用 `modelAliases` 显式映射,例子见[配置](#配置)。
196
157
 
197
- **界面上说 `没注册(路由 aperture-openai-responses 已被另一个适配器注册…)`?** 说明请求的路由键里有一个已经被别人服务了——最常见的原因是**旧版本的本插件**:0.2 及更早只做发现,它会把自己发现的路由写进 `llm-pi-ai.providers`。本插件不替你改别人的配置,照那一行给出的键名手工处理:删掉 `llm-pi-ai` 段里对应的 `providers.<键>`;如果那个路由名是别的插件在用的,就改本插件配置里的 `routePrefix`(三条路由键一起变)。下一个适配器集合变化(改完配置的重载、或者在插件页按那颗「立刻刷新」)就会重新尝试注册,不必重启。
158
+ ### 界面上说 `没注册(路由 aperture-openai-responses 已被另一个适配器注册…)`?
198
159
 
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` 继续服务一份过期的路由(选择器里出现重复模型),升级时一并删掉即可。
160
+ 那个路由键已经被别人服务了,最常见的原因是**旧版本的本插件**(0.2 及更早只做发现,会把自己发现的路由写进 `llm-pi-ai.providers`)。本插件不替你改别人的配置:照那句话给出的键名删掉 `llm-pi-ai` 段里对应的 `providers.<键>`,或者那个名字属于别的插件时改本插件的 `routePrefix`(三条路由键一起变)。下一次适配器集合变化(改完配置的重载、或按「立刻刷新」)会重新尝试注册,不必重启。
200
161
 
201
- **配置里的 `route` 键去哪了?** 它改名成了 `routePrefix`。旧键不报错,但会被 schema 忽略——前缀于是静默回到缺省的 `aperture`。当初把前缀写成了别的名字(`route: my-gateway`)的话,升级后要把它抄到 `routePrefix` 上;只写过缺省值的话,把旧键删掉即可。
162
+ ### 从 0.2 或更早升上来,`llm-pi-ai.providers` 里那几个 `aperture*` 键要不要自己删?
202
163
 
203
- **保存了但没生效?** DSH 的补丁层是叠加的:profile 的补丁文档之上还有 `$DSH_HOME/cordis.patch.yml` 这类更高优先级的层。如果 `aperture` 这一行在那里也被写过,配置页上的保存会落在 profile 的补丁文档里、却被上面那层盖住(这一笔也可能被设置接缝直接拒收,配置页会说没被收下)。把那一行从高优先级的层里删掉,或者直接改那一处。
164
+ 要,而且这次没有哪个键会替你报错:现在的路由键是前缀加协议名(默认 `aperture-openai-chat-completions` / `aperture-openai-responses` / `aperture-anthropic-messages`),与那时写下的 `aperture`、`aperture-responses`、`aperture-anthropic` 都不同名,注册不会撞键。留着只会让 `llm-pi-ai` 继续服务一份过期的路由(选择器里出现重复模型)。
204
165
 
205
- **从 0.2 升上来,我的 `settings.yaml` 去哪了?** 0.1.7 起设置不再有独立文件,而是落在 profile 的补丁文档里。首次启动时 `$DSH_HOME/settings.yaml` 会被改名成 `settings.yaml.imported`,各段按设置命名空间搬进补丁文档——`aperture:` 段原样搬过去,仍能过 schema 的键与值都不变,所以地址与逐模型覆盖都还在。此后被读的只有补丁文档,`settings.yaml.imported` 只是留档,改它没有用;搬不过去的段(值已不合法)也只留在那份留档里,并在日志里说一声。
166
+ ### 配置里的 `route` 键去哪了?
206
167
 
207
- **本部署没有「插件」页 / 没有界面?** 两处界面都只在 Web 界面里有(插件页那一份靠 Typert Remote 端点工作)。headless profile 里插件照常发现、照常注册路由,只是没有可点按的页面。模型在官方「模型」页里也会出现相应的行(只有真的有模型的那几种协议才占一行):那一行自己的编辑器对本插件是只读的(设置段是 `aperture`,不是模型页的通用表单),但本插件在那一行里挂了自己的一块编辑器,所以改模型还是那一页上的事(没有路由可服务的模型不在那一页出现,界面在时由插件页那句话交代);没有界面时改配置。
168
+ 改名叫 `routePrefix` 了。旧键不报错,但会被 schema 忽略——前缀于是静默回到缺省的 `aperture`。写过别的名字(`route: my-gateway`)就把它抄到 `routePrefix` 上,只写过缺省值就删掉旧键。
208
169
 
209
- **需要真密钥而不是占位凭据?** Aperture 靠网络身份(Tailscale)认证,本不需要密钥;插件默认在每条请求上带 `authorization: Bearer dsh-aperture`(Anthropic 路由是 `x-api-key: dsh-aperture`),只是让 pi-ai 愿意把请求发出去,**不是密钥**。真要密钥时把 `apiKeyEnv` 指向凭据 seam 里的记录,占位凭据就不再带。
170
+ ### 保存了但没生效?
210
171
 
211
- **改了 `routePrefix` 之后旧路由还在?** 插件只认自己当前请求的三个键(`<前缀>-openai-chat-completions`、`<前缀>-openai-responses`、`<前缀>-anthropic-messages`),进程退出后旧键就没有服务者了;它不再出现在选择器里,也不需要清理,除非有别的适配器顶上那个键。
172
+ DSH 的补丁层是叠加的:profile 的补丁文档之上还有 `$DSH_HOME/cordis.patch.yml` 这类更高优先级的层。`aperture` 那一行在那里也被写过时,配置页的保存会落在 profile 的补丁文档里、却被上面那层盖住(也可能被设置接缝直接拒收,配置页会说没被收下)。把那一行从高优先级的层里删掉,或者直接改那一处。
173
+
174
+ ### 从 0.2 升上来,我的 `settings.yaml` 去哪了?
175
+
176
+ 0.1.7 起设置不再有独立文件,而是落在 profile 的补丁文档里。首次启动时 `$DSH_HOME/settings.yaml` 会被改名成 `settings.yaml.imported`,各段按设置命名空间搬进补丁文档——`aperture:` 段原样搬过去,仍能过 schema 的键与值都不变,所以地址与逐模型覆盖都还在。此后被读的只有补丁文档,那份留档改了没用;搬不过去的段(值已不合法)也只留在留档里,并在日志里说一声。
177
+
178
+ ### 本部署没有「插件」页 / 没有界面?
179
+
180
+ 两处界面都只在 Web 界面里有。headless profile 里插件照常发现、照常注册路由,只是没有可点按的页面,改配置即可。模型在官方「模型」页里也会有相应的行——那一行自己的编辑器对本插件是只读的(设置段是 `aperture`),能编辑的是本插件挂进去的那一块。
181
+
182
+ ### 需要真密钥而不是占位凭据?
183
+
184
+ 不需要,插件也不提供密钥配置:Aperture 靠网络身份(Tailscale)认证。每条请求按协议带 `authorization: Bearer dsh-aperture`(Anthropic 路由是 `x-api-key: dsh-aperture`),只是让 pi-ai 愿意把请求发出去,**不是密钥**。网关若真的要求静态令牌,用 `headers` 写死这两个头之一,占位凭据就不再带。
185
+
186
+ ### 改了 `routePrefix` 之后旧路由还在?
187
+
188
+ 插件只认自己当前请求的三个键,进程退出后旧键就没有服务者了;它不再出现在选择器里,也不需要清理,除非有别的适配器顶上那个键。
212
189
 
213
190
  ## 它做了什么
214
191
 
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
- ```
192
+ 插件只请求网关上那份 `GET {baseUrl}/v1/models` 清单,再按每个模型的 `supported_endpoints` 分流:`/v1/chat/completions` 对到 `openai-completions`、`/v1/responses` 对到 `openai-responses`、`/v1/messages` 对到 `anthropic-messages`,各自挂上同一前缀的三条路由之一;只提供原生 `generateContent` 的模型不发布,由配置页那句话报出来。
227
193
 
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)。
194
+ 三条路由各自只承载一种协议,模型 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
195
 
230
196
  ## 开发
231
197
 
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import z from "@deepseek-ai/schemastery";
2
- import { CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, IMAGE_OFFLOAD_REQUIRED_CODE, LlmAdapter, LlmError, QUOTA_EXCEEDED_CODE, ReasoningEffortId, ToolCallId, assertUsableApiKey, attributionHeaders, contentHasImage, isContextWindowExceededError, isQuotaExceededError, offloadedImageText, projectOffloadedImages, requestImageHandleText, requiredImageOffload } from "@deepseek-ai/dsh-llm";
3
- import { credentialRef } from "@deepseek-ai/dsh-credentials";
2
+ import { CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, IMAGE_OFFLOAD_REQUIRED_CODE, LlmAdapter, LlmError, QUOTA_EXCEEDED_CODE, ReasoningEffortId, ToolCallId, attributionHeaders, contentHasImage, isContextWindowExceededError, isQuotaExceededError, offloadedImageText, projectOffloadedImages, requestImageHandleText, requiredImageOffload } from "@deepseek-ai/dsh-llm";
4
3
  import { idleWatchdog, timeoutOf } from "@deepseek-ai/dsh-timeout";
4
+ import { normalizeContext } from "@earendil-works/pi-ai";
5
5
  import { requestImageDimensions } from "@deepseek-ai/dsh-attachment";
6
6
  import { anthropicMessagesApi } from "@earendil-works/pi-ai/api/anthropic-messages.lazy";
7
7
  import { openAICompletionsApi } from "@earendil-works/pi-ai/api/openai-completions.lazy";
@@ -684,7 +684,6 @@ 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(""),
688
687
  headers: z.dict(z.string()).default({}),
689
688
  enabledModelIds: z.array(z.string()).default([]),
690
689
  modelAliases: z.dict(z.string()).default({}),
@@ -733,13 +732,11 @@ function resolveConfig(config) {
733
732
  assertEfforts(id, model.reasoningEfforts);
734
733
  if (model.protocol !== void 0 && model.protocol !== "openai-completions" && model.protocol !== "openai-responses" && model.protocol !== "anthropic-messages") throw new Error(`models["${id}"].protocol "${model.protocol}" 无法服务;请使用 openai-completions、openai-responses 或 anthropic-messages`);
735
734
  }
736
- const apiKeyEnv = (config.apiKeyEnv ?? "").trim();
737
735
  return {
738
736
  instanceRoot,
739
737
  rawBaseUrl,
740
738
  routePrefix,
741
739
  routes: resolveRoutes(routePrefix),
742
- apiKeyEnv: apiKeyEnv.length === 0 ? void 0 : apiKeyEnv,
743
740
  headers: config.headers ?? {},
744
741
  enabledModelIds: config.enabledModelIds ?? [],
745
742
  modelAliases: config.modelAliases ?? {},
@@ -1275,7 +1272,7 @@ function isDeepSeekFamily(model) {
1275
1272
  * 传输。
1276
1273
  *
1277
1274
  * 两件网关事实塑造了本模块:pi-ai 的 OpenAI 兼容路径在既无凭据、又无非空 `authorization`
1278
- * 头时拒绝派发,所以没有配 `apiKeyEnv` 的路由会带上一个占位头;pi-ai 的 `Model.maxTokens`
1275
+ * 头时拒绝派发,所以每条路由都按协议带上一个占位头;pi-ai 的 `Model.maxTokens`
1279
1276
  * 是必填的,而没有谁声明过输出上限的模型不该被钉上一个凭空的数字,因此缺省值只作为
1280
1277
  * pi-ai 侧的请求上限,同时**不**作为本插件向宿主声明的默认值(见 `defaultMaxTokens`)。
1281
1278
  *
@@ -1314,15 +1311,14 @@ function buildProviderRoute(route, models, options) {
1314
1311
  protocol: route.protocol,
1315
1312
  baseURL: buildRouteBaseUrl(options.instanceRoot, route.protocol),
1316
1313
  ...headers === void 0 ? {} : { headers },
1317
- ...options.apiKeyEnv === void 0 ? {} : { apiKeyEnv: options.apiKeyEnv },
1318
1314
  models: models.map((model) => buildModelEntry(model, route.protocol, options))
1319
1315
  };
1320
1316
  }
1321
1317
  /**
1322
1318
  * 一条路由发送的头。
1323
1319
  *
1324
- * 已配置的 `apiKeyEnv` 完全取代占位头——此后由凭据接缝提供。插件自身配置里的部署头在两种
1325
- * 情况下都优先于占位头,需要真实静态令牌的网关正是借此拿到它。
1320
+ * 部署配置里的头(`headers`)优先于占位头:需要真实静态令牌的网关正是借此拿到它;没有配
1321
+ * 这类头时,按协议带一个占位凭据,让 pi-ai 愿意把请求发出去。
1326
1322
  *
1327
1323
  * @param protocol - 该路由的协议。
1328
1324
  * @param options - 配置。
@@ -1330,10 +1326,10 @@ function buildProviderRoute(route, models, options) {
1330
1326
  */
1331
1327
  function routeHeaders(protocol, options) {
1332
1328
  const headers = {};
1333
- if (!(options.apiKeyEnv !== void 0 || Object.keys(options.headers).some((name) => {
1329
+ if (!Object.keys(options.headers).some((name) => {
1334
1330
  const lower = name.toLowerCase();
1335
1331
  return lower === "authorization" || lower === "x-api-key" || lower === "cf-aig-authorization";
1336
- }))) {
1332
+ })) {
1337
1333
  if (protocol === "anthropic-messages") headers["x-api-key"] = DEFAULT_PLACEHOLDER_CREDENTIAL;
1338
1334
  else headers.authorization = `Bearer ${DEFAULT_PLACEHOLDER_CREDENTIAL}`;
1339
1335
  }
@@ -1525,7 +1521,6 @@ var ApertureRuntime = class {
1525
1521
  const plan = planRoutes(registry.models, {
1526
1522
  instanceRoot: config.instanceRoot,
1527
1523
  routes: config.routes,
1528
- ...config.apiKeyEnv === void 0 ? {} : { apiKeyEnv: config.apiKeyEnv },
1529
1524
  headers: config.headers,
1530
1525
  configured: config.models
1531
1526
  });
@@ -1912,13 +1907,14 @@ function isNonEmptyString(value) {
1912
1907
  /**
1913
1908
  * 一张图片在请求里的目标版本。
1914
1909
  *
1915
- * 与 `dsh-llm-pi-ai` 自己的默认值一致:4 Mi 像素的上限(等价于 2048×2048)与 1 MiB 的
1916
- * 单张编码字节上限。网关不通过任何接口声明它接受什么,而这两个数字是当前发布物里已经被
1917
- * 验证过的那一组。
1910
+ * 4 Mi 像素的上限(等价于 2048×2048)与 1 MiB 的单张编码字节硬上限,是 0.2.0 那版发布物上
1911
+ * 验证过的一组。`dsh-llm-pi-ai` 现在按请求预算给每张图分 0.75 MiB(20 MiB 预算、20 份),
1912
+ * 本插件沿用自己一直用的 1 MiB 单张上限;软目标与硬上限同值,缩尺寸仍由编码器按质量阶梯
1913
+ * 先试,超过 1 MiB 才继续缩。
1918
1914
  */
1919
1915
  const REQUEST_IMAGE_POLICY = {
1920
1916
  maxPixels: 4194304,
1921
- maxBytes: 1048576
1917
+ maxImageBytes: 1048576
1922
1918
  };
1923
1919
  /** 一次请求里图片累积后的 base64 字节上限;超过就要求上层先卸载最旧的几张。 */
1924
1920
  const MAX_REQUEST_IMAGE_BYTES = 20971520;
@@ -2085,7 +2081,8 @@ async function prepareRequestImages(messages, images) {
2085
2081
  function requestImageTarget(ref) {
2086
2082
  return {
2087
2083
  ...requestImageDimensions(ref.width, ref.height, REQUEST_IMAGE_POLICY.maxPixels),
2088
- maxBytes: REQUEST_IMAGE_POLICY.maxBytes
2084
+ maxImageBytes: REQUEST_IMAGE_POLICY.maxImageBytes,
2085
+ imageTargetBytes: REQUEST_IMAGE_POLICY.maxImageBytes
2089
2086
  };
2090
2087
  }
2091
2088
  /**
@@ -2663,7 +2660,6 @@ var ApertureAdapter = class extends LlmAdapter {
2663
2660
  const { route, model, pi } = entry;
2664
2661
  const effort = options.reasoningEffort;
2665
2662
  if (effort !== void 0 && !supportedEfforts(pi).includes(effort)) throw new LlmError(`dsh-aperture: 模型 "${options.model}" 不支持推理档位 "${effort}"`, "UNSUPPORTED_REASONING_EFFORT");
2666
- const apiKey = await this.deps.resolveApiKey(options.provider, route.provider);
2667
2663
  const consumer = new AbortController();
2668
2664
  const upstream = options.signal === void 0 ? consumer.signal : AbortSignal.any([options.signal, consumer.signal]);
2669
2665
  const watchdog = idleWatchdog(upstream, STREAM_IDLE_TIMEOUT_MS, IDLE_TIMEOUT_CODE);
@@ -2679,8 +2675,7 @@ var ApertureAdapter = class extends LlmAdapter {
2679
2675
  attachments,
2680
2676
  signal: watchdog.signal
2681
2677
  }, (reason) => this.deps.logger.debug(`dsh-aperture: 路由 "${options.provider}" 模型 "${options.model}" 的历史降级:${reason}`));
2682
- const iterator = toStreamChunks(protocolApi(route.provider.protocol).streamSimple(pi, context, {
2683
- ...apiKey === void 0 ? {} : { apiKey },
2678
+ const iterator = toStreamChunks(protocolApi(route.provider.protocol).streamSimple(pi, normalizeContext(context), {
2684
2679
  headers: requestHeaders(route.provider.headers),
2685
2680
  ...options.temperature === void 0 ? {} : { temperature: options.temperature },
2686
2681
  ...options.maxTokens === void 0 ? {} : { maxTokens: options.maxTokens },
@@ -2749,20 +2744,6 @@ function requestHeaders(configured) {
2749
2744
  //#endregion
2750
2745
  //#region src/provider.ts
2751
2746
  /**
2752
- * 注册阶段:把一代路由交给宿主的 LLM 接缝。
2753
- *
2754
- * 本模块**不写任何配置**。更早的版本把自己的路由写进另一个插件的配置段,现在这条能力整块拿掉:
2755
- * 配置只由用户与官方界面写,本插件只读。代价是遗留写入不会自动消失——它正好占着本插件要用的
2756
- * 路由键,于是注册被拒。这时本模块不去替用户清理,而是把「哪个键挡住了、去哪删」写进报告,
2757
- * 界面上直接可读;用户删掉之后下一次 `llm/adapters-updated` 就会把注册补上。
2758
- *
2759
- * 注册本身只有两条性质需要照顾:首次注册用 `registerAdapter`(空数组会被拒),之后用句柄的
2760
- * `replace`,于是刷新不会让请求观察到「路由消失」的空档;注册失败不会把整轮刷新判为失败——
2761
- * 发现与报告仍然有结果,用户看到的是「哪条路由没上去、为什么」。
2762
- *
2763
- * @module dsh-aperture/provider
2764
- */
2765
- /**
2766
2747
  * 本插件的 provider 身份。
2767
2748
  *
2768
2749
  * 一个实例跨代复用同一个适配器对象,只替换它的路由集合。
@@ -2783,7 +2764,6 @@ var ApertureProvider = class {
2783
2764
  this.deps = deps;
2784
2765
  this.adapter = new ApertureAdapter({
2785
2766
  routes: () => this.routes,
2786
- resolveApiKey: (provider, profile) => this.resolveApiKey(provider, profile),
2787
2767
  attachments: () => this.deps.attachments(),
2788
2768
  logger: this.deps.logger
2789
2769
  });
@@ -2880,20 +2860,6 @@ var ApertureProvider = class {
2880
2860
  conflictReason(blocked) {
2881
2861
  return `路由 ${blocked.join("、")} 已被另一个适配器注册;本插件不写配置,请手工处理:旧版本曾把本插件的路由写进 llm-pi-ai.providers,删掉那里的 ${blocked.join(" / ")} 键即可;若那个路由名是别的插件在用的,请把本插件配置里的 routePrefix 改成另一个名字(三条路由键一起变)。`;
2882
2862
  }
2883
- /**
2884
- * 解析一条路由的凭据。
2885
- *
2886
- * 配置了 `apiKeyEnv` 就**必须**解析出可用的值:那是一个明确的声明,悄悄退回占位凭据会让
2887
- * 一次配错了密钥的部署看起来像一次网关拒绝。
2888
- */
2889
- async resolveApiKey(provider, route) {
2890
- const ref = route.apiKeyEnv;
2891
- if (ref === void 0) return void 0;
2892
- const credentials = this.deps.credentials();
2893
- const resolved = credentials === void 0 ? process.env[ref] : (await credentials.resolve(credentialRef(ref)))?.value;
2894
- if (resolved !== void 0 && resolved.length > 0) return assertUsableApiKey(resolved, "dsh-aperture", ref);
2895
- throw new LlmError(`dsh-aperture: 路由 "${provider}" 的 apiKeyEnv 指向 ${ref},但它没有值;请通过凭据服务存入 ${ref}(模型页可写入),或在启动环境里导出它`, "MISSING_CREDENTIAL");
2896
- }
2897
2863
  };
2898
2864
  //#endregion
2899
2865
  //#region src/relay.ts
@@ -3060,7 +3026,6 @@ function apply(ctx, config) {
3060
3026
  const readConfig = memoizedConfig(() => configValue(config));
3061
3027
  const provider = new ApertureProvider({
3062
3028
  llm: ctx.llm,
3063
- credentials: () => ctx.get("credentials"),
3064
3029
  attachments: () => ctx.get("attachments"),
3065
3030
  logger
3066
3031
  });
@@ -1,4 +1,4 @@
1
- import { PlannedRoute, ProviderRoute } from "../plan.js";
1
+ import { PlannedRoute } from "../plan.js";
2
2
  import { RuntimeLogger } from "../runtime.js";
3
3
  import { GenerateOptions, LlmAdapter, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, PreparedAdapterCall, StreamChunk } from "@deepseek-ai/dsh-llm";
4
4
  import { AttachmentStore } from "@deepseek-ai/dsh-attachment";
@@ -7,8 +7,6 @@ import { AttachmentStore } from "@deepseek-ai/dsh-attachment";
7
7
  export interface AdapterDeps {
8
8
  /** 当前这一代要服务的路由;换一份新数组就是新一代。 */
9
9
  readonly routes: () => readonly PlannedRoute[];
10
- /** 解析一条路由的凭据;未配置 `apiKeyEnv` 时返回 `undefined`(该路由用占位凭据)。 */
11
- readonly resolveApiKey: (provider: string, route: ProviderRoute) => Promise<string | undefined>;
12
10
  /** 附件服务;没有它的部署里图片不可转换。 */
13
11
  readonly attachments: () => AttachmentStore | undefined;
14
12
  /** 诊断。 */
@@ -28,8 +28,6 @@ export interface Config {
28
28
  * Chat Completions)`)。
29
29
  */
30
30
  routePrefix?: string;
31
- /** 按请求解析的凭据引用;留空则改为发布一个占位请求头。 */
32
- apiKeyEnv?: string;
33
31
  /** 每条路由的请求都会带上的额外请求头;它们优先于占位凭据。 */
34
32
  headers?: Dict<string>;
35
33
  /** 非空时,只发现这些模型 id。 */
@@ -68,7 +66,6 @@ export interface Config {
68
66
  export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
69
67
  baseUrl: z<string, string, "defined">;
70
68
  routePrefix: z<string, string, "defined">;
71
- apiKeyEnv: z<string, string, "defined">;
72
69
  headers: z<Dict<string, string>, Dict<string, string>, "defined">;
73
70
  enabledModelIds: z<string[], string[], "defined">;
74
71
  modelAliases: z<Dict<string, string>, Dict<string, string>, "defined">;
@@ -107,7 +104,6 @@ export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
107
104
  }>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
108
105
  baseUrl: z<string, string, "defined">;
109
106
  routePrefix: z<string, string, "defined">;
110
- apiKeyEnv: z<string, string, "defined">;
111
107
  headers: z<Dict<string, string>, Dict<string, string>, "defined">;
112
108
  enabledModelIds: z<string[], string[], "defined">;
113
109
  modelAliases: z<Dict<string, string>, Dict<string, string>, "defined">;
@@ -178,8 +174,6 @@ export interface ResolvedConfig {
178
174
  readonly routePrefix: string;
179
175
  /** 这一代的三条路由(短名、协议、注册键、显示名),顺序固定。 */
180
176
  readonly routes: readonly ResolvedRoute[];
181
- /** 凭据引用;未配置时为 `undefined`。 */
182
- readonly apiKeyEnv: string | undefined;
183
177
  readonly headers: Readonly<Record<string, string>>;
184
178
  readonly enabledModelIds: readonly string[];
185
179
  readonly modelAliases: Readonly<Record<string, string>>;
@@ -44,8 +44,6 @@ export interface ProviderRoute {
44
44
  readonly baseURL: string;
45
45
  /** 每条请求带上的头;没有时为缺失。 */
46
46
  readonly headers?: Readonly<Record<string, string>>;
47
- /** 该路由解析凭据用的引用;没有时以占位凭据发出。 */
48
- readonly apiKeyEnv?: string;
49
47
  /** 该路由承载的模型。 */
50
48
  readonly models: readonly ProviderModel[];
51
49
  }
@@ -60,8 +58,6 @@ export interface RoutePlanOptions {
60
58
  * 不可能与发出去的东西对不上。
61
59
  */
62
60
  readonly routes: readonly ResolvedRoute[];
63
- /** 凭据引用;部署配置了才有。 */
64
- readonly apiKeyEnv?: string;
65
61
  /** 额外的路由头;它们优先于占位头。 */
66
62
  readonly headers: Readonly<Record<string, string>>;
67
63
  /** 已配置的逐模型覆盖项,用于查询显式的推理档位。 */
@@ -2,7 +2,6 @@ import { RoutePlan } from "./plan.js";
2
2
  import { RuntimeLogger } from "./runtime.js";
3
3
  import { LlmRuntime } from "@deepseek-ai/dsh-llm";
4
4
  import { AttachmentStore } from "@deepseek-ai/dsh-attachment";
5
- import { CredentialProvider } from "@deepseek-ai/dsh-credentials";
6
5
  //#region src/provider.d.ts
7
6
  /** 一次发布的结果。 */
8
7
  export interface PublishOutcome {
@@ -15,8 +14,6 @@ export interface PublishOutcome {
15
14
  export interface ProviderDeps {
16
15
  /** LLM 服务。 */
17
16
  readonly llm: LlmRuntime;
18
- /** 凭据服务;未挂载时为缺失。 */
19
- readonly credentials: () => CredentialProvider | undefined;
20
17
  /** 附件服务;没有它的部署里图片不可转换。 */
21
18
  readonly attachments: () => AttachmentStore | undefined;
22
19
  /** 诊断。 */
@@ -73,12 +70,5 @@ export declare class ApertureProvider {
73
70
  private registerDirectory;
74
71
  /** 给用户看的冲突说明:点名被占用的键,并说清要手工做什么。 */
75
72
  private conflictReason;
76
- /**
77
- * 解析一条路由的凭据。
78
- *
79
- * 配置了 `apiKeyEnv` 就**必须**解析出可用的值:那是一个明确的声明,悄悄退回占位凭据会让
80
- * 一次配错了密钥的部署看起来像一次网关拒绝。
81
- */
82
- private resolveApiKey;
83
73
  }
84
74
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-aperture",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "自动发现 Aperture 网关上的模型,并加进 DSH 的模型选择器。",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.7.0",
@@ -57,7 +57,7 @@
57
57
  },
58
58
  "engines": {
59
59
  "node": "^22.19.0 || >=24.0.0",
60
- "dsh": "^0.1.7-rc.1 || ^0.2.0-rc.1"
60
+ "dsh": "^0.2.3-alpha.2"
61
61
  },
62
62
  "dsh": {
63
63
  "bundle": {
@@ -77,49 +77,47 @@
77
77
  }
78
78
  },
79
79
  "peerDependencies": {
80
- "@deepseek-ai/cordis": "^4.0.4",
81
- "@deepseek-ai/cordis-plugin-loader": "^1.0.5",
82
- "@deepseek-ai/dsh-attachment": "^0.1.7-rc.1 || ^0.2.0-rc.1",
83
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.7-rc.1 || ^0.2.0-rc.1",
84
- "@deepseek-ai/dsh-client-ui-settings-models": "^0.1.7-rc.1 || ^0.2.0-rc.1",
85
- "@deepseek-ai/dsh-credentials": "^0.1.7-rc.1 || ^0.2.0-rc.1",
86
- "@deepseek-ai/dsh-llm": "^0.1.7-rc.1 || ^0.2.0-rc.1",
87
- "@deepseek-ai/dsh-settings": "^0.1.7-rc.1 || ^0.2.0-rc.1",
88
- "@deepseek-ai/dsh-timeout": "^0.1.7-rc.1 || ^0.2.0-rc.1",
89
- "@deepseek-ai/dsh-typert-protocol": "^0.1.7-rc.1 || ^0.2.0-rc.1",
90
- "@deepseek-ai/schemastery": "^3.18.4"
80
+ "@deepseek-ai/cordis": "^4.2.0-alpha.1",
81
+ "@deepseek-ai/cordis-plugin-loader": "^1.2.0-alpha.1",
82
+ "@deepseek-ai/dsh-attachment": "^0.2.3-alpha.2",
83
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.2.3-alpha.2",
84
+ "@deepseek-ai/dsh-client-ui-settings-models": "^0.2.3-alpha.2",
85
+ "@deepseek-ai/dsh-llm": "^0.2.3-alpha.2",
86
+ "@deepseek-ai/dsh-settings": "^0.2.3-alpha.2",
87
+ "@deepseek-ai/dsh-timeout": "^0.2.3-alpha.2",
88
+ "@deepseek-ai/dsh-typert-protocol": "^0.2.3-alpha.2",
89
+ "@deepseek-ai/schemastery": "^3.20.0-alpha.1"
91
90
  },
92
91
  "devDependencies": {
93
- "@deepseek-ai/cordis": "4.0.4",
94
- "@deepseek-ai/cordis-plugin-loader": "1.0.5",
95
- "@deepseek-ai/cosmokit": "1.8.5",
96
- "@deepseek-ai/dsh-api-gateway": "0.2.0-rc.1",
97
- "@deepseek-ai/dsh-api-remotes": "0.2.0-rc.1",
98
- "@deepseek-ai/dsh-app-boot": "0.2.0-rc.1",
99
- "@deepseek-ai/dsh-attachment": "0.2.0-rc.1",
100
- "@deepseek-ai/dsh-client-locale": "0.2.0-rc.1",
101
- "@deepseek-ai/dsh-client-store": "0.2.0-rc.1",
102
- "@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.0-rc.1",
103
- "@deepseek-ai/dsh-client-ui-primitives": "0.2.0-rc.1",
104
- "@deepseek-ai/dsh-client-ui-renderer": "0.2.0-rc.1",
105
- "@deepseek-ai/dsh-client-ui-settings": "0.2.0-rc.1",
106
- "@deepseek-ai/dsh-client-ui-settings-models": "0.2.0-rc.1",
107
- "@deepseek-ai/dsh-client-ui-slots": "0.2.0-rc.1",
108
- "@deepseek-ai/dsh-config-editor": "0.2.0-rc.1",
109
- "@deepseek-ai/dsh-credentials": "0.2.0-rc.1",
110
- "@deepseek-ai/dsh-llm": "0.2.0-rc.1",
111
- "@deepseek-ai/dsh-llm-pi-ai": "0.2.0-rc.1",
112
- "@deepseek-ai/dsh-settings": "0.2.0-rc.1",
113
- "@deepseek-ai/dsh-timeout": "0.2.0-rc.1",
114
- "@deepseek-ai/dsh-typert-protocol": "0.2.0-rc.1",
115
- "@deepseek-ai/dsh-typert-registry": "0.2.0-rc.1",
116
- "@deepseek-ai/schemastery": "3.18.4",
92
+ "@deepseek-ai/cordis": "4.2.0-alpha.1",
93
+ "@deepseek-ai/cordis-plugin-loader": "1.2.0-alpha.1",
94
+ "@deepseek-ai/cosmokit": "1.10.0-alpha.1",
95
+ "@deepseek-ai/dsh-api-gateway": "0.2.3-alpha.2",
96
+ "@deepseek-ai/dsh-api-remotes": "0.2.3-alpha.2",
97
+ "@deepseek-ai/dsh-app-boot": "0.2.3-alpha.2",
98
+ "@deepseek-ai/dsh-attachment": "0.2.3-alpha.2",
99
+ "@deepseek-ai/dsh-client-locale": "0.2.3-alpha.2",
100
+ "@deepseek-ai/dsh-client-store": "0.2.3-alpha.2",
101
+ "@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.3-alpha.2",
102
+ "@deepseek-ai/dsh-client-ui-primitives": "0.2.3-alpha.2",
103
+ "@deepseek-ai/dsh-client-ui-renderer": "0.2.3-alpha.2",
104
+ "@deepseek-ai/dsh-client-ui-settings": "0.2.3-alpha.2",
105
+ "@deepseek-ai/dsh-client-ui-settings-models": "0.2.3-alpha.2",
106
+ "@deepseek-ai/dsh-client-ui-slots": "0.2.3-alpha.2",
107
+ "@deepseek-ai/dsh-config-editor": "0.2.3-alpha.2",
108
+ "@deepseek-ai/dsh-llm": "0.2.3-alpha.2",
109
+ "@deepseek-ai/dsh-llm-pi-ai": "0.2.3-alpha.2",
110
+ "@deepseek-ai/dsh-settings": "0.2.3-alpha.2",
111
+ "@deepseek-ai/dsh-timeout": "0.2.3-alpha.2",
112
+ "@deepseek-ai/dsh-typert-protocol": "0.2.3-alpha.2",
113
+ "@deepseek-ai/dsh-typert-registry": "0.2.3-alpha.2",
114
+ "@deepseek-ai/schemastery": "3.20.0-alpha.1",
117
115
  "@types/node": "^22.20.0",
118
116
  "@types/react": "^18.3.12",
119
117
  "tsdown": "^0.23.0",
120
118
  "typescript": "^5.9.0"
121
119
  },
122
120
  "dependencies": {
123
- "@earendil-works/pi-ai": "^0.85.1"
121
+ "@earendil-works/pi-ai": "^1.0.2"
124
122
  }
125
123
  }