dsh-aperture 0.1.0 → 0.3.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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 uy/sun
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 uy/sun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.en.md CHANGED
@@ -1,63 +1,26 @@
1
1
  # dsh-aperture
2
2
 
3
- Discover the models an [Aperture](https://tailscale.com/kb/1542/aperture) gateway serves, and publish them to DeepSeek Harness as `llm-pi-ai` provider routes — so they simply appear in the model selector.
3
+ Discover the models an [Aperture](https://tailscale.com/kb/1542/aperture) gateway serves, and publish them to DeepSeek Harness as `llm-pi-ai` provider routes — so they simply appear in the model selector. Once installed, one Aperture address is all you configure.
4
4
 
5
- The reference implementation is [he0119/vscode-aperture-for-copilot](https://github.com/he0119/vscode-aperture-for-copilot). The difference is that the extension had to implement a provider from scratch, while DSH already ships `@deepseek-ai/dsh-llm-pi-ai` — an adapter that speaks OpenAI Chat Completions and Anthropic Messages, which is exactly what Aperture exposes. So this plugin **only discovers; it converts no API format**. It translates a discovery result into `llm-pi-ai` provider profiles and lets the existing adapter do the rest.
6
-
7
- ```yaml
8
- # ~/.dsh/settings.yaml — written by the plugin; you do not hand-write this
9
- llm-pi-ai:
10
- providers:
11
- aperture:
12
- api: openai-completions
13
- baseURL: https://ai.example.ts.net/v1
14
- models:
15
- - id: deepseek-flash
16
- name: DeepSeek V4.1 Flash
17
- contextWindow: 1048576
18
- maxTokens: 384000
19
- ```
5
+ ## Install
20
6
 
21
- ## Features
7
+ Requirements: Node ≥ 24, and an Aperture instance you can reach.
22
8
 
23
- - **Zero-configuration discovery.** One `baseUrl` is enough. `GET {baseUrl}/v1/models` needs no key; Aperture authenticates by network identity (Tailscale).
24
- - **Per-model protocol routing.** Each model's `supported_endpoints` decides which route it is published on, instead of publishing models that 404 on every request.
25
- - **Capacity and capability completion.** Aperture's own fields win, [models.dev](https://models.dev) answers what Aperture left out, and a configurable conservative default answers last.
26
- - **Reasoning mapping.** Only levels the upstream actually accepts are offered, with the DeepSeek `thinking` dialect expressed through `compat`.
27
- - **Writes only what it owns.** Writes are path-addressed, so your hand-written providers survive untouched; an unchanged section is not rewritten; a failed discovery never wipes the published catalog.
28
- - **A `/aperture` command** for status, model listing, forced refresh, and route removal.
9
+ ### 1. Add the plugin
29
10
 
30
- ## Install
11
+ From [npm](https://www.npmjs.com/package/dsh-aperture) (recommended):
31
12
 
32
13
  ```sh
33
- # from git (pin the commit, so a later push cannot silently change what runs)
34
- npx @deepseek-ai/dsh plugin --profile web add github:he0119/dsh-aperture#<commit>
35
-
36
- # or from a local checkout
37
- npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
14
+ npx @deepseek-ai/dsh plugin --profile web add dsh-aperture
38
15
  ```
39
16
 
40
- > **The git spec must be one pnpm recognises** (`github:owner/repo`, `git+https://…`, `git+ssh://…`).
41
- > The scp-style `git@github.com:he0119/dsh-aperture.git` is parsed as a **local path** on Windows —
42
- > the colon reads as a drive letter — and fails with
43
- > `Failed to resolve dependency: The filename, directory name, or volume label syntax is incorrect. (os error 123)`.
44
- >
45
- > If git over HTTPS is unusable on this machine — schannel / `SEC_E_NO_CREDENTIALS` — let it fall back to SSH with
46
- > `git config --global url."git@github.com:".insteadOf "https://github.com/"`.
47
-
48
- Before starting, look at the composed result:
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:
49
18
 
50
19
  ```sh
51
- npx @deepseek-ai/dsh --profile web --dump-config # should show a "# == dsh-aperture" layer
20
+ npx @deepseek-ai/dsh plugin --profile web add github:he0119/dsh-aperture#<sha>
52
21
  ```
53
22
 
54
- **Restart DSH afterwards** — bundle changes are not hot-reloaded.
55
-
56
- ### The first install has to authorize the build (or use a prebuilt artifact)
57
-
58
- This is a TypeScript source package: a git install pulls **source**, and a `prepare` script compiles `lib/` during
59
- install. pnpm ≥10 refuses to run a git dependency's build scripts until it is explicitly allowed, so **the first
60
- `add` fails** — dsh then tells you the exact package key, which you write into the profile's `pnpm-workspace.yaml`:
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.
61
24
 
62
25
  ```yaml
63
26
  # ~/.dsh/profiles/web/pnpm-workspace.yaml
@@ -65,251 +28,209 @@ allowBuilds:
65
28
  dsh-aperture: true
66
29
  ```
67
30
 
68
- (The key takes the **map** form with `true`; a list is not accepted.) Re-run the `add` afterwards.
31
+ (The key takes the **map** form with `true`; a list is not accepted.)
69
32
 
70
- Read that authorization as "let this package's code run on your machine at install time, outside any agent sandbox".
71
- Authorize only source you trust, and pin the commit (`github:he0119/dsh-aperture#<sha>`) — a git install pulls code
72
- that can change.
33
+ > That authorization lets this package run code on your machine at install time, outside any agent sandbox. Authorize only source you trust.
73
34
 
74
- If you would rather **not** authorize anything, use a prebuilt artifact, and pnpm never needs to run a script of ours:
35
+ When editing the code locally, install the checkout directory instead (run `npm run build` first):
75
36
 
76
37
  ```sh
77
- pnpm pack # in this repository: dsh-aperture-0.1.0.tgz, with lib/ inside
78
- npx @deepseek-ai/dsh plugin --profile web add ./dsh-aperture-0.1.0.tgz
38
+ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
79
39
  ```
80
40
 
81
- Once published to npm, `dsh plugin add dsh-aperture` works the same way.
82
-
83
- > pnpm may warn `Issues with peer dependencies found` during install. **That is expected**: the
84
- > `@deepseek-ai/cordis`, `@deepseek-ai/schemastery` and `@deepseek-ai/dsh-settings` packages this plugin peers on ship
85
- > with DSH and are resolved by DSH itself (they never enter the profile's `node_modules`), so pnpm not seeing them does
86
- > not affect running the plugin.
87
-
88
- `dsh plugin add` adds the package to the profile and reconciles `dsh.profile.bundles`: any dependency declaring `dsh.bundle.patch` joins the layer stack automatically. **Restart DSH afterwards** — bundle changes are not hot-reloaded.
89
-
90
- Then point it at your instance, either in the user layer:
41
+ ### 2. Point it at your instance
91
42
 
92
43
  ```yaml
93
- # ~/.dsh/settings.yaml (recommended)
94
- aperture:
95
- baseUrl: https://ai.example.ts.net
44
+ # ~/.dsh/profiles/web/cordis.patch.yml
45
+ - id: aperture
46
+ config:
47
+ baseUrl: https://ai.example.ts.net
96
48
  ```
97
49
 
98
- …or in the profile's `cordis.patch.yml` (composition layer). The user layer wins.
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.
99
51
 
100
- After the restart the models appear in the selector under the route `Aperture`. Confirm with `/aperture` — the
101
- command output and the log lines report in Chinese:
102
-
103
- ```
104
- Aperture:https://ai.example.ts.net
105
- 最近一次刷新:配置变更 · 2026-09-22T16:31:02.184Z · 412ms · 成功
106
- 清单:422 个条目
107
- 端点:https://ai.example.ts.net/v1/models 列出了 16 行
108
- 路由 aperture:11 个模型,经由 openai-completions → https://ai.example.ts.net/v1
109
- 路由 aperture-anthropic:1 个模型,经由 anthropic-messages → https://ai.example.ts.net
110
- 未服务:4 个模型(gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.5-pro, gemini-3.1-flash-image-preview)
111
- 设置:向 llm-pi-ai 写入 2 个操作(aperture, aperture-anthropic)
112
- ```
52
+ ### 3. Restart DSH
113
53
 
114
- ## How it works
54
+ Bundle changes are not hot-reloaded. Before starting, you can look at the composed result:
115
55
 
116
- ```
117
- GET {baseUrl}/v1/models
118
- │
119
- ├─ per model: supported_endpoints ──► route
120
- │ /v1/chat/completions ──► route (openai-completions)
121
- │ /v1/messages ──► anthropicRoute (anthropic-messages)
122
- │ native generateContent only ──► not published (reported under 未服务)
123
- │
124
- ├─ capacity: Aperture fields ─► models.dev ─► default
125
- ├─ reasoning: Aperture fields ─► models.dev ─► off
126
- │
127
- └─ llm-pi-ai providers.<route>, written to settings.yaml by revision
56
+ ```sh
57
+ npx @deepseek-ai/dsh --profile web --dump-config # should show a "# == dsh-aperture" layer
128
58
  ```
129
59
 
130
- ### Why two routes
60
+ ### 4. Confirm
131
61
 
132
- Aperture is an endpoint-aware gateway: a given model does not accept every protocol. Measured against a live instance:
62
+ The models appear in the selector under the route `Aperture`. This package's configuration page at **Plugins → dsh-aperture** is that page — the instance address and sync toggle on top, one row per discovered model below.
133
63
 
134
- | Models | `supported_endpoints` | Result |
135
- | --- | --- | --- |
136
- | 11 (DeepSeek / MiMo / Grok / Qwen / LongCat …) | `/v1/chat/completions` | route `aperture` |
137
- | `MiniMax-M3` | `/v1/messages` | route `aperture-anthropic` |
138
- | 4 Gemini models | `/v1beta/models/{model}:generateContent` | not published |
139
-
140
- Using the wrong endpoint fails loudly, and Aperture names the right one:
141
-
142
- ```
143
- 404 model "gemini-2.5-flash" is available via gemini_generate_content, not openai_chat
144
- 404 model "MiniMax-M3" is available via anthropic_messages, not openai_chat
145
64
  ```
65
+ Instance address Overridden Reset to default
66
+ [https://ai.example.ts.net ]
67
+ Where Aperture listens; leave it empty to go dormant and stop discovering models.
146
68
 
147
- `llm-pi-ai` speaks OpenAI-compatible and Anthropic Messages only, so those four Gemini models **cannot** be attached through it. The plugin reports them instead of publishing models that are guaranteed to fail.
148
-
149
- ### The placeholder credential
150
-
151
- `llm-pi-ai` — more precisely the pi-ai SDK beneath it — throws `No API key for provider` when no credential exists at all. Aperture authenticates by network identity and needs none, so the plugin writes a placeholder header:
152
-
153
- - route `aperture` → `authorization: Bearer dsh-aperture`
154
- - route `aperture-anthropic` → `x-api-key: dsh-aperture`
155
-
156
- **It is not a key**; it only makes the adapter willing to send the request, and a live Aperture instance answers a garbage bearer with 200. When a real credential is needed, point `apiKeyEnv` at a credential-seam record and no placeholder is written.
157
-
158
- ### Where each fact comes from
159
-
160
- | Fact | Precedence |
161
- | --- | --- |
162
- | `contextWindow` | Aperture `context_window_tokens` / `max_input_tokens` / `limit.context` → models.dev → `defaultContextWindow` |
163
- | `maxTokens` | Aperture `max_output_tokens` / `limit.output` → models.dev → **nothing** |
164
- | `input` (modalities) | with `images: metadata`: Aperture capability fields → models.dev → `["text"]`; with `images: ignore`: always `["text"]` |
165
- | `reasoning` | Aperture capability fields → models.dev → off |
166
-
167
- An unstated `maxTokens` is deliberately **omitted**: in `llm-pi-ai` it is both the declared output capability and the per-request `max_tokens` cap, so inventing 16384 would truncate every request.
168
-
169
- ### Reasoning levels are conservative
170
-
171
- A level in `reasoningEfforts` is the value sent on the wire. Measured:
172
-
173
- - DeepSeek accepts `minimal/low/medium/high/xhigh/max/none`, returns `reasoning_content` by default, and needs `thinking: {type: disabled}` to suppress it;
174
- - MiMo (`mimo-v2.6-pro`) answers **HTTP 400** for `minimal`, `xhigh`, and `max`.
69
+ Sync automatically Overridden Reset to default ●━
70
+ After each discovery round, write the models into dsh's llm-pi-ai routes. [Save]
175
71
 
176
- So only two levels are offered by default:
72
+ Saved: rediscovered and published.
177
73
 
178
- | Model | `reasoningEfforts` | `compat` |
179
- | --- | --- | --- |
180
- | DeepSeek family (id/name/provider contains `deepseek`) | `{off: disabled, high: high, max: max}` | `{supportsReasoningEffort: true, thinkingFormat: deepseek}` |
181
- | every other reasoning model | `{off: null, high: high}` | `{supportsReasoningEffort: true}` |
182
-
183
- More levels are one configuration entry away:
184
-
185
- ```yaml
186
- aperture:
187
- models:
188
- - id: deepseek-v4-pro
189
- reasoningEfforts:
190
- off: disabled
191
- minimal: minimal
192
- low: low
193
- medium: medium
194
- high: high
195
- max: max
196
- ```
197
-
198
- The Anthropic route declares **no reasoning levels** by default: Anthropic thinking is a different switch (it takes a budget), so `reasoning_effort` would mean nothing there. Opt in explicitly with `thinking: true`.
74
+ Models 18 ⟳ Refresh now
75
+ One model per row; expand a row to edit its overrides, and Save writes only that row. The order comes from discovery, with anything no route can serve last.
199
76
 
200
- ### When a models.dev id does not match
77
+ ● deepseek-v4-flash
78
+ route aperture · protocol openai-completions · context 1,048,576 · output 384,000 · modalities text+image · reasoning on · 1 overridden
79
+ ● gemini-2.5-flash
80
+ route aperture · protocol openai-completions · context 128,000 · modalities text · reasoning off
81
+ ● qwen3-vl-32b unserved
82
+ context 262,144 · modalities text+image · reasoning on
201
83
 
202
- Gateways rename things. In practice `deepseek-flash` and `k3` have no models.dev entry (the catalog calls them `deepseek/deepseek-v4-flash` and `moonshotai/kimi-k3`), and no scoring rule can bridge that without guessing. Bridge it explicitly:
203
-
204
- ```yaml
205
- aperture:
206
- modelAliases:
207
- deepseek-flash: deepseek/deepseek-v4-flash
208
- k3: moonshotai/kimi-k3
84
+ (expand a row and you get that row's override editor: name and protocol in one group, capacity in another,
85
+ modalities beside reasoning, and Save / Clear overrides / Cancel underneath)
209
86
  ```
210
87
 
211
- Only then do those two pick up the catalog's reasoning flag and capacity.
88
+ **The instance address and the sync toggle** are two fields of one official settings form: where a field says "Overridden", a "Reset to default" right beside it drops that key from your settings file (the same two words in the same position as the official plugin-config page), and Save writes only the fields you actually changed. The per-model override editor is covered under [Usage](#usage). Headings and spacing separate the groups, while a model row is a card (a hairline outline with a large radius, coloured only with theme tokens this page really defines), and the only thing you can expand is a model row.
212
89
 
213
- ### Lifecycle and dependencies
90
+ (English labels are shown above; the page itself is bilingual.)
214
91
 
215
- - `settings` is a **hard dependency** (`inject = ['settings']`). Writing into settings *is* this plugin's job, so
216
- without it there is nothing to publish into: the framework holds the plugin at `PENDING`, unloads it if the
217
- provider is replaced, and reloads it afterwards — rather than leaving a loaded instance with nowhere to publish.
218
- - `commands` is deliberately **not** declared. A deployment without the command service should still get discovery,
219
- so it is attached optionally through `ctx.inject(['commands'])`.
220
- - The refresh timer is registered through `ctx.effect`, so it is cleaned up on unload; a configuration change
221
- re-arms it with the new interval.
222
- - **Registering the settings section is what starts the first discovery**: `installSection` calls `setSource` and
223
- then notifies `onChange` at attach, so the first refresh already sees the user layer — one pass, not a
224
- composition-config pass followed by a reconciling one.
225
- - The section is held as a **live thunk, not a snapshot**: editing the `aperture:` section of
226
- `~/.dsh/settings.yaml` reaches the next refresh with no restart and no plugin reload.
92
+ ## Usage
227
93
 
228
- ## Commands
94
+ The interface is at **Plugins → dsh-aperture**: open this plugin in the plugin list; the configuration page hangs off the package, so there is no separate Configure button. The page header's name, icon and description come from the package's `locale/*.json` and `package.json`'s `icon`; the page itself is drawn by the Plugins page. The address, the toggle and the per-model parameters stay drafts until you press Save; models are **one row at a time**, and collapsing a row does not throw its draft away — the "unsaved edits" tag stays visible.
229
95
 
230
- | Command | Effect |
96
+ | Where | Effect |
231
97
  | --- | --- |
232
- | `/aperture` | status of the last refresh (default) |
233
- | `/aperture models` | every model, its route, and the source of each fact |
234
- | `/aperture refresh` | discover and republish now |
235
- | `/aperture remove` | withdraw this plugin's routes from the `llm-pi-ai` section |
98
+ | Configuration page · Instance address | edits `baseUrl` (written through the settings seam; when it says "Overridden", the "Reset to default" beside it falls back to the default) |
99
+ | Configuration page · Sync toggle | edits `sync`: off discovers without writing `llm-pi-ai`, and that round withdraws whatever this plugin had published (only the two keys it owns; every other provider in the section is left alone); carries the same "Overridden / Reset to default" pair |
100
+ | Configuration page · Save | below the form: writes the address and toggle drafts into the settings document; it is revision-fenced, so a form that has drifted from the settings document is refused rather than overwriting someone else's edit; it returns only once that round of re-discovery has landed, so the interface shows the new configuration right away |
101
+ | Configuration page · Models | one row per model, one card per row: a state dot at its head (green: this round wrote it into the routes; grey: this round synced but did not write it; amber: no route can serve it — hovering it, or a screen reader, hears exactly that), then the name with its "unserved / N overridden / unsaved edits" tags on the first line and labelled facts (route, protocol, capacities, modalities, reasoning, alias) on the second, with long names ellipsised and facts wrapping; expanded, it is that row's override editor — display name, alias and protocol as one group of text fields, context window and max output as the "capacity" group, and two modality checkboxes beside a three-way reasoning switch (follow discovery / on / off); a field keeps only one line naming where its value comes from ("Source: Aperture"), while how-to copy ("Leave it empty to use the discovered name") lives behind the "i" next to the label and only takes up room once opened; the "Refresh now" action at its top right discovers and republishes immediately, and the list and every row's status follow that round |
102
+ | Configuration page · Save / Clear overrides / Cancel | write that row only, clear only the fields the backend report says really were overridden, or drop that row's draft; Save likewise waits for a round of re-discovery, so what you see afterwards is the new value |
103
+
104
+ In-place edits are configuration: capacities and modalities land on the matching `aperture.models` entry, the catalog alias lands on `aperture.modelAliases[id]`, and writes merge per field — a field the interface never mentions (say `reasoningEfforts`) survives untouched, while an emptied field drops that override and falls back to discovery and the catalog. Capacities accept the `1M` / `100K` spelling (decimal suffixes, the same vocabulary as the official Models page: `1M` is 1000000, not 1048576); what gets stored is still a plain token count, and the field spells it back in the shortest form that survives a round trip (`384000` → `384K`, while `1048576` is not a whole thousand and stays written out). The protocol field is the only way out for an unserved model: filling it in publishes a model that only answers on its native endpoint under the matching route.
236
105
 
237
106
  ## Configuration
238
107
 
239
- Every key may live in the `aperture:` section of `~/.dsh/settings.yaml` (user layer) or in the profile's `cordis.patch.yml` (composition layer).
108
+ Every key lives under that row's `config:` in the profile patch document (user layer); anything you leave out falls back to the defaults below. `baseUrl`, `sync` and the per-model parameters inside `models` and `modelAliases` can also be edited in place on the configuration page; every other key needs the file.
240
109
 
241
110
  | Key | Default | Meaning |
242
111
  | --- | --- | --- |
243
112
  | `baseUrl` | `''` | Aperture instance root. A trailing `/v1` is tolerated and stripped; empty leaves the plugin dormant |
244
- | `route` | `aperture` | Route key owning OpenAI-compatible models |
245
- | `anthropicRoute` | `aperture-anthropic` | Route key owning Anthropic Messages models |
246
- | `displayName` | `Aperture` | Selector label |
247
- | `anthropicDisplayName` | `Aperture (Anthropic)` | Selector label for the Anthropic route |
113
+ | `route` | `aperture` | Route key owning OpenAI-compatible models; the Anthropic route is this key plus `-anthropic`, and both selector labels derive from it (`aperture` → `Aperture` / `Aperture (Anthropic)`) |
248
114
  | `apiKeyEnv` | `''` | Credential-seam reference; non-empty suppresses the placeholder header |
249
- | `placeholderCredential` | `dsh-aperture` | Placeholder value; `''` writes no placeholder header at all |
250
115
  | `headers` | `{}` | Extra request headers; they **win over** the placeholder |
251
116
  | `enabledModelIds` | `[]` | Non-empty restricts discovery to these ids (explicit `models` entries are exempt) |
252
117
  | `modelAliases` | `{}` | Gateway id → models.dev id |
253
118
  | `models` | `[]` | Per-model overrides and extras: `id`, `name`, `api`, `contextWindow`, `maxTokens`, `input`, `thinking`, `reasoningEfforts` |
254
119
  | `modelMetadataUrl` | `https://models.dev/models.json` | Catalog URL; `''` disables enrichment |
255
- | `defaultContextWindow` | `128000` | Context capacity when nothing sizes a model |
256
120
  | `images` | `ignore` | `metadata` adopts models.dev input modalities (images) |
257
121
  | `reasoning` | `auto` | `off` declares every model non-reasoning |
258
- | `sync` | `true` | `false` discovers without writing (`/aperture` still reports) |
122
+ | `sync` | `true` | `false` discovers without writing (the configuration page still reports) |
259
123
  | `refreshIntervalMinutes` | `0` | Periodic refresh; `0` refreshes only at load and on change |
260
- | `timeoutMs` | `20000` | Per-request timeout for the gateway and the catalog |
261
124
 
262
- `models` both overrides discovered entries (only the fields you state) and adds models the gateway did not list — for instance those four Gemini models, if you know they work on an OpenAI-compatible endpoint after all:
125
+ Missing capacity and reasoning levels are filled in from Aperture's own fields → [models.dev](https://models.dev) → a conservative default (the fallback capacity, 128000, and the 20s per-request timeout are constants in the code, not configuration). An unstated `maxTokens` is deliberately **omitted**: in `llm-pi-ai` it is also the per-request `max_tokens` cap, so inventing a value would truncate every request.
126
+
127
+ ## Troubleshooting
128
+
129
+ **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.
130
+
131
+ **`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.
132
+
133
+ **`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://…`.
134
+
135
+ **git over HTTPS is unusable on this machine (schannel / `SEC_E_NO_CREDENTIALS`)?**
136
+
137
+ ```sh
138
+ git config --global url."git@github.com:".insteadOf "https://github.com/"
139
+ ```
140
+
141
+ **Some models never show up in the selector?** Look at the rows tagged `未服务` (unserved) in the Models section of the configuration page. Models that only offer Gemini's native `generateContent` endpoint cannot be attached — `llm-pi-ai` speaks OpenAI-compatible and Anthropic Messages only. Using the wrong endpoint fails loudly, and Aperture names the right one:
142
+
143
+ ```
144
+ 404 model "gemini-2.5-flash" is available via gemini_generate_content, not openai_chat
145
+ 404 model "MiniMax-M3" is available via anthropic_messages, not openai_chat
146
+ ```
147
+
148
+ **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:
149
+
150
+ ```yaml
151
+ # ~/.dsh/profiles/web/cordis.patch.yml
152
+ - id: aperture
153
+ config:
154
+ models:
155
+ - id: deepseek-v4-pro
156
+ reasoningEfforts:
157
+ off: disabled
158
+ minimal: minimal
159
+ low: low
160
+ medium: medium
161
+ high: high
162
+ max: max
163
+ ```
164
+
165
+ **Want a model the gateway did not list?** Add it explicitly with `models` — for instance those four Gemini models, if you know they work on an OpenAI-compatible endpoint after all:
263
166
 
264
167
  ```yaml
265
- aperture:
266
- models:
267
- - id: gemini-2.5-pro
268
- api: openai-completions
168
+ # ~/.dsh/profiles/web/cordis.patch.yml
169
+ - id: aperture
170
+ config:
171
+ models:
172
+ - id: gemini-2.5-pro
173
+ api: openai-completions
269
174
  ```
270
175
 
271
- ## Write behaviour
176
+ **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:
272
177
 
273
- The plugin touches exactly two keys under `llm-pi-ai.providers` (`route` and `anthropicRoute`), and:
178
+ ```yaml
179
+ # ~/.dsh/profiles/web/cordis.patch.yml
180
+ - id: aperture
181
+ config:
182
+ modelAliases:
183
+ deepseek-flash: deepseek/deepseek-v4-flash
184
+ k3: moonshotai/kimi-k3
185
+ ```
274
186
 
275
- - **writes nothing when nothing changed** — each refresh compares against the resolved section, so there is no rewrite churn and no watcher feedback loop;
276
- - **writes with path ops** — not one field of your other providers is touched;
277
- - **writes nothing after a failed discovery** — a transient gateway outage keeps the catalog that is already serving;
278
- - **writes by revision** — a conflict with another writer (the Models page, another process) re-reads once and retries;
279
- - **removes a route that lost its models** — no empty route pointing at a stale catalog is left behind.
187
+ **The configuration page says `设置:未写入(已处于同步状态)`?** That is the normal steady state: the settings already hold the current catalog.
280
188
 
281
- `设置:未写入(已处于同步状态)` in `/aperture` is the normal steady state.
189
+ **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.
282
190
 
283
- ## Development
191
+ **Upgrading from 0.2 — where did my `settings.yaml` go?** As of 0.1.7 settings no longer live in a file of their own; they live in the profile patch document. On the first start `$DSH_HOME/settings.yaml` is renamed to `settings.yaml.imported` and each section is moved into the patch document under its settings namespace — the `aperture:` section moves as-is, and every key and value that still passes the schema is unchanged, so the address and the per-model overrides are all still there. From then on only the patch document is read, and `settings.yaml.imported` is just an archive; editing it does nothing. A section whose values no longer validate stays in that archive too, with a line in the log saying so.
192
+
193
+ **No Plugins page / no GUI in this deployment?** The configuration page only exists in the Web GUI (it works over Typert Remote endpoints). A headless profile still discovers and still writes, it just has no clickable page. If the deployment has no manageable profile at all, the `settings` service does not exist and the plugin stays `PENDING` on its hard dependency — its only job is writing settings, so with nowhere to write it deliberately does nothing.
194
+
195
+ **Need a real key instead of the placeholder header?** Aperture authenticates by network identity (Tailscale) and needs none; the plugin writes `authorization: Bearer dsh-aperture` / `x-api-key: dsh-aperture` only to make the adapter willing to send the request. It is **not a key**. When a real credential is needed, point `apiKeyEnv` at a credential-seam record and no placeholder is written.
196
+
197
+ **The old route is still there after changing `route`?** The plugin only knows the two keys it currently owns (`route` and `route` + `-anthropic`), not the names it used before, so the old key stays in `llm-pi-ai.providers`. It does no harm and simply stops refreshing; delete the entry by hand to clean it up.
198
+
199
+ ## What it does
284
200
 
285
- ```sh
286
- npm install # if the machine-level npm cache is not writable: npm install --cache ./.npm-cache --ignore-scripts
287
- npm run build # tsc -> lib/
288
- npm run typecheck # includes test/
289
- npm test # offline unit tests (93, no node_modules needed)
290
- npm run test:live # end-to-end: real harness stack + real gateway
291
- npm run inspect # print the generated settings.yaml and its resolutions
201
+ ```
202
+ GET {baseUrl}/v1/models
203
+ │
204
+ ├─ per model: supported_endpoints ──► routing
205
+ │ /v1/chat/completions ──► route (openai-completions)
206
+ │ /v1/messages ──► route + -anthropic (anthropic-messages)
207
+ │ native generateContent only ──► not published (reported under 未服务)
208
+ │
209
+ ├─ capacity: Aperture fields ─► models.dev ─► default
210
+ ├─ reasoning: Aperture fields ─► models.dev ─► off
211
+ │
212
+ └─ llm-pi-ai providers.<route>, written into the profile patch document by revision
292
213
  ```
293
214
 
294
- `npm run test:live` needs a gateway address:
215
+ Writes touch only the two keys under `llm-pi-ai.providers` that this plugin owns: an unchanged section is not rewritten; writes are path-addressed so your hand-written providers survive untouched; a failed discovery never wipes the published catalog; a route that lost its models is removed. Design notes — why two routes, where each fact comes from, lifecycle and dependencies, write behaviour — are in [docs/internals.md](https://github.com/he0119/dsh-aperture/blob/main/docs/internals.md) (Chinese).
216
+
217
+ ## Development
295
218
 
296
219
  ```sh
297
- DSH_APERTURE_LIVE_URL=https://ai.example.ts.net npm run test:live
220
+ npm install
221
+ npm run build # tsc -> lib/
222
+ npm test # unit tests + end-to-end (offline; devDependencies must be installed)
298
223
  ```
299
224
 
300
- It boots the real `dsh-settings-file`, `dsh-llm`, `dsh-llm-pi-ai`, and this plugin, performs a real discovery, and then asserts that the settings file was written, both routes registered, `ctx.llm.listModels()` can see the models, and capacity and reasoning levels match. It is the only test that proves the adapter actually accepts what was written.
301
-
302
- > `lib/` is a build artifact: a git install and `npm publish` both compile it through the `prepare` script.
303
- > Installing from a **local directory** (`link:`) does *not* run `prepare`, so run `npm run build` before
304
- > debugging locally.
225
+ Working on the plugin — build, tests, and a dedicated development instance — is in [docs/development.md](https://github.com/he0119/dsh-aperture/blob/main/docs/development.md) (Chinese); the release process and what the published package contains are in [docs/releasing.md](https://github.com/he0119/dsh-aperture/blob/main/docs/releasing.md) (Chinese).
305
226
 
306
- ## Known boundaries
227
+ ## Acknowledgements
307
228
 
308
- - **No API-format conversion**, by design rather than by omission — and therefore only the two protocols `llm-pi-ai` speaks. Native Gemini endpoints cannot be attached.
309
- - `supported_endpoints` is the only protocol signal. A gateway that reports none is treated as OpenAI-compatible.
310
- - models.dev is best-effort enrichment: if it cannot be fetched, discovery still succeeds.
311
- - The plugin registers no provider directory (`registerConfigurableProviders`) — `llm-pi-ai` already claims that, and a duplicate registration throws.
312
- - **Renaming `route` / `anthropicRoute` leaves the old key behind** in `llm-pi-ai.providers`: the plugin only knows the two keys it currently owns, not the names it used before. The stale route does no harm and simply stops refreshing; delete the entry by hand to clean it up.
229
+ - [he0119/vscode-aperture-for-copilot](https://github.com/he0119/vscode-aperture-for-copilot): the reference implementation this plugin follows for Aperture model discovery.
230
+ - [xiaoyuyu6420/dsh-backup](https://github.com/xiaoyuyu6420/dsh-backup): the reference implementation this plugin follows for the interface wiring — the Remote endpoint shape comes from it, while the way the configuration page is mounted now comes from the Plugins page's slot contract as of 0.1.7.
231
+ - [Aperture](https://tailscale.com/kb/1542/aperture) (Tailscale): the gateway being discovered.
232
+ - [models.dev](https://models.dev): enriches capacity and capabilities Aperture does not declare.
233
+ - `@deepseek-ai/dsh-llm-pi-ai`: this plugin only discovers; the adapter does the protocol work.
313
234
 
314
235
  ## License
315
236