dsh-aperture 0.1.0 → 0.2.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
@@ -2,62 +2,29 @@
2
2
 
3
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.
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.
5
+ Once installed, one Aperture address is all you configure.
6
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
- ```
7
+ ## Install
20
8
 
21
- ## Features
9
+ Requirements: Node ≥ 24, and an Aperture instance you can reach.
22
10
 
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.
11
+ ### 1. Add the plugin
29
12
 
30
- ## Install
13
+ From [npm](https://www.npmjs.com/package/dsh-aperture) (recommended):
31
14
 
32
15
  ```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
16
+ npx @deepseek-ai/dsh plugin --profile web add dsh-aperture
38
17
  ```
39
18
 
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/"`.
19
+ The published artifact ships a compiled `lib/`, so no build script has to be authorized.
47
20
 
48
- Before starting, look at the composed result:
21
+ To pin a commit, or to follow unreleased changes, install from git:
49
22
 
50
23
  ```sh
51
- npx @deepseek-ai/dsh --profile web --dump-config # should show a "# == dsh-aperture" layer
24
+ npx @deepseek-ai/dsh plugin --profile web add github:he0119/dsh-aperture#<sha>
52
25
  ```
53
26
 
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`:
27
+ 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
28
 
62
29
  ```yaml
63
30
  # ~/.dsh/profiles/web/pnpm-workspace.yaml
@@ -65,122 +32,148 @@ allowBuilds:
65
32
  dsh-aperture: true
66
33
  ```
67
34
 
68
- (The key takes the **map** form with `true`; a list is not accepted.) Re-run the `add` afterwards.
35
+ (The key takes the **map** form with `true`; a list is not accepted.)
69
36
 
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.
37
+ > That authorization lets this package run code on your machine at install time, outside any agent sandbox. Authorize only source you trust.
73
38
 
74
- If you would rather **not** authorize anything, use a prebuilt artifact, and pnpm never needs to run a script of ours:
39
+ When editing the code locally, install the checkout directory instead (run `npm run build` first):
75
40
 
76
41
  ```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
42
+ npx @deepseek-ai/dsh plugin --profile web add /path/to/dsh-aperture
79
43
  ```
80
44
 
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:
45
+ ### 2. Point it at your instance
91
46
 
92
47
  ```yaml
93
- # ~/.dsh/settings.yaml (recommended)
48
+ # ~/.dsh/settings.yaml
94
49
  aperture:
95
50
  baseUrl: https://ai.example.ts.net
96
51
  ```
97
52
 
98
- …or in the profile's `cordis.patch.yml` (composition layer). The user layer wins.
53
+ You may put this in the profile's `cordis.patch.yml` (composition layer) instead; the user layer wins.
99
54
 
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:
55
+ After a restart you can also set it in the GUI: the **Aperture** tab under **Settings → Plugins** (alongside "Plugin configuration"). Its "实例地址" field edits the same `aperture.baseUrl`.
102
56
 
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)
57
+ ### 3. Restart DSH
58
+
59
+ Bundle changes are not hot-reloaded. Before starting, you can look at the composed result:
60
+
61
+ ```sh
62
+ npx @deepseek-ai/dsh --profile web --dump-config # should show a "# == dsh-aperture" layer
112
63
  ```
113
64
 
114
- ## How it works
65
+ ### 4. Confirm
66
+
67
+ The models appear in the selector under the route `Aperture`. To see what the last refresh did, look at the **Aperture** tab under **Settings → Plugins**: the status block lays every fact out on its own row, and the models are listed per route underneath.
115
68
 
116
69
  ```
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
70
+ Last refresh
71
+ Trigger 配置变更 Time 2026-09-23 12:32:36
72
+ Took 286ms Result succeeded
73
+ Catalog 422 entries Endpoint https://ai.example.ts.net/v1/models listed 16 rows
74
+ Settings wrote 2 operations to llm-pi-ai (aperture, aperture-anthropic)
75
+
76
+ Models and routes 1 models overridden, the rest inherit discovery and the catalog
77
+ aperture · openai-completions
78
+ → https://ai.example.ts.net/v1 · 11 models
79
+ deepseek-v4-flash DeepSeek V4 Flash overridden [▾ Collapse]
80
+ 1,048,576 context window · 384,000 output · text+image · reasoning
81
+ │ deepseek-v4-flash · aperture · openai-completions
82
+ │ Display name [DeepSeek V4 Flash ] from models.dev
83
+ │ Catalog alias [deepseek/deepseek-v4-flash]
84
+ │ Context [1048576] in effect 1,048,576 · from aperture
85
+ │ Max output [384000] in effect 384,000 · from aperture
86
+ │ Modalities ☑ text ☑ image in effect text+image · from config
87
+ │ Reasoning [follow discovery ▾] in effect on · from models.dev
88
+ │ Protocol [follow discovery ▾] in effect openai-completions
89
+ │ An empty display name, capacity or modality drops that override… [Reset override] [Cancel] [Save]
90
+ gemini-2.5-flash [▸ Edit]
91
+ 128,000 context window · text · no reasoning
92
+ Unserved: no endpoint this plugin can publish
93
+ 4 models
94
+ gemini-2.5-flash-lite [▸ Edit]
95
+ Advertised endpoints: /v1beta/models/gemini-2.5-flash-lite:generateContent
128
96
  ```
129
97
 
130
- ### Why two routes
98
+ Collapsed, each row is just the facts (model id and the values in effect); "Edit" expands the panel, where every source sits next to the field it describes ("in effect 1,048,576 · from aperture"). Each row gets its own Save and Cancel: Save writes that row only, Cancel throws that row's edits away.
131
99
 
132
- Aperture is an endpoint-aware gateway: a given model does not accept every protocol. Measured against a live instance:
100
+ (The tab itself is bilingual; the labels above are its English wording.) Next to it are the buttons that edit the address, refresh now, and withdraw the routes.
133
101
 
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 |
102
+ ## Usage
139
103
 
140
- Using the wrong endpoint fails loudly, and Aperture names the right one:
104
+ The interface is the **Aperture** tab under **Settings → Plugins**: it shows your instance address and what the last refresh did, lists the discovered models per route, and lets you edit the address, toggle `sync`, discover and republish now, withdraw the published routes from the `llm-pi-ai` section, and edit model parameters in place. The address and the toggle stay drafts until you press Save; the save is handed to the host half, which writes through the settings seam, so it is revision-fenced — a form that has drifted from the settings document is refused rather than overwriting someone else's edit. Model parameters work the same way, **one row at a time**: an expanded row edits a draft (the row shows an "unsaved" tag), Save writes that row only, and Cancel drops it. There is no batch edit.
141
105
 
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
- ```
106
+ | Where | Effect |
107
+ | --- | --- |
108
+ | Tab · 状态 | what the last refresh did, what triggered it, and the catalog, endpoint and settings-write results |
109
+ | Tab · 实例地址 | edits `baseUrl` (written through the settings seam, with an "overridden" badge and reset-to-composition) |
110
+ | Tab · 同步开关 | edits `sync`: off discovers without writing `llm-pi-ai` |
111
+ | Tab · 保存 | writes the address and toggle drafts into the settings document |
112
+ | Tab · 立即刷新 | discover and republish now, then show that round's report |
113
+ | Tab · 撤掉已发布的路由 | withdraw this plugin's two routes from the `llm-pi-ai` section |
114
+ | Tab · 模型与路由 | which route every model belongs to, and the values in effect |
115
+ | Tab · 编辑 | expands one model's parameters: display name, catalog alias, capacities, modalities, reasoning, protocol, each source next to the field it describes |
116
+ | Tab · 保存 / 取消 | write that row only, or throw that row's edits away |
117
+ | Tab · 撤销覆盖 | clear only the fields the report says really were overridden, falling back to discovery and the catalog right away |
146
118
 
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.
119
+ 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. 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.
148
120
 
149
- ### The placeholder credential
121
+ > "撤掉已发布的路由" withdraws once: the next refresh republishes according to the current configuration. To make it stick, turn the sync toggle off first (equivalent to `sync: false`).
150
122
 
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:
123
+ ## Configuration
152
124
 
153
- - route `aperture` → `authorization: Bearer dsh-aperture`
154
- - route `aperture-anthropic` → `x-api-key: dsh-aperture`
125
+ Every key may live in the `aperture:` section of `~/.dsh/settings.yaml` (user layer) or in the profile's `cordis.patch.yml` (composition layer). `baseUrl` and `sync` can also be edited on the GUI's Aperture tab, and so can the per-model parameters inside `models` and `modelAliases`; every other key needs the file.
155
126
 
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.
127
+ | Key | Default | Meaning |
128
+ | --- | --- | --- |
129
+ | `baseUrl` | `''` | Aperture instance root. A trailing `/v1` is tolerated and stripped; empty leaves the plugin dormant |
130
+ | `route` | `aperture` | Route key owning OpenAI-compatible models |
131
+ | `anthropicRoute` | `aperture-anthropic` | Route key owning Anthropic Messages models |
132
+ | `displayName` | `Aperture` | Selector label |
133
+ | `anthropicDisplayName` | `Aperture (Anthropic)` | Selector label for the Anthropic route |
134
+ | `apiKeyEnv` | `''` | Credential-seam reference; non-empty suppresses the placeholder header |
135
+ | `placeholderCredential` | `dsh-aperture` | Placeholder value; `''` writes no placeholder header at all |
136
+ | `headers` | `{}` | Extra request headers; they **win over** the placeholder |
137
+ | `enabledModelIds` | `[]` | Non-empty restricts discovery to these ids (explicit `models` entries are exempt) |
138
+ | `modelAliases` | `{}` | Gateway id → models.dev id |
139
+ | `models` | `[]` | Per-model overrides and extras: `id`, `name`, `api`, `contextWindow`, `maxTokens`, `input`, `thinking`, `reasoningEfforts` |
140
+ | `modelMetadataUrl` | `https://models.dev/models.json` | Catalog URL; `''` disables enrichment |
141
+ | `defaultContextWindow` | `128000` | Context capacity when nothing sizes a model |
142
+ | `images` | `ignore` | `metadata` adopts models.dev input modalities (images) |
143
+ | `reasoning` | `auto` | `off` declares every model non-reasoning |
144
+ | `sync` | `true` | `false` discovers without writing (the tab still reports) |
145
+ | `refreshIntervalMinutes` | `0` | Periodic refresh; `0` refreshes only at load and on change |
146
+ | `timeoutMs` | `20000` | Per-request timeout for the gateway and the catalog |
157
147
 
158
- ### Where each fact comes from
148
+ Missing capacity and reasoning levels are filled in from Aperture's own fields → [models.dev](https://models.dev) → a conservative default. 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.
159
149
 
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 |
150
+ ## Troubleshooting
166
151
 
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.
152
+ **The first `add` from git fails, saying build scripts were ignored?**
153
+ Add the `allowBuilds` line from the git part of step 1, then re-run — or install from npm, which needs no authorization at all.
168
154
 
169
- ### Reasoning levels are conservative
155
+ **`Issues with peer dependencies found` during install?**
156
+ 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.
170
157
 
171
- A level in `reasoningEfforts` is the value sent on the wire. Measured:
158
+ **`Failed to resolve dependency: The filename, directory name, or volume label syntax is incorrect. (os error 123)`?**
159
+ 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://…`.
172
160
 
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`.
161
+ **git over HTTPS is unusable on this machine (schannel / `SEC_E_NO_CREDENTIALS`)?**
175
162
 
176
- So only two levels are offered by default:
163
+ ```sh
164
+ git config --global url."git@github.com:".insteadOf "https://github.com/"
165
+ ```
177
166
 
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}` |
167
+ **Some models never show up in the selector?**
168
+ Look at 模型与路由 on the tab (the `未服务` line). 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:
182
169
 
183
- More levels are one configuration entry away:
170
+ ```
171
+ 404 model "gemini-2.5-flash" is available via gemini_generate_content, not openai_chat
172
+ 404 model "MiniMax-M3" is available via anthropic_messages, not openai_chat
173
+ ```
174
+
175
+ **Want more reasoning levels for a model?**
176
+ Only two conservative levels are offered by default (DeepSeek family `off/high/max`, every other reasoning model `off/high`). Add your own:
184
177
 
185
178
  ```yaml
186
179
  aperture:
@@ -195,11 +188,18 @@ aperture:
195
188
  max: max
196
189
  ```
197
190
 
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`.
191
+ **Want a model the gateway did not list?**
192
+ Add it explicitly with `models` — for instance those four Gemini models, if you know they work on an OpenAI-compatible endpoint after all:
199
193
 
200
- ### When a models.dev id does not match
194
+ ```yaml
195
+ aperture:
196
+ models:
197
+ - id: gemini-2.5-pro
198
+ api: openai-completions
199
+ ```
201
200
 
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:
201
+ **Capacity or reasoning flags were not filled in?**
202
+ 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:
203
203
 
204
204
  ```yaml
205
205
  aperture:
@@ -208,108 +208,56 @@ aperture:
208
208
  k3: moonshotai/kimi-k3
209
209
  ```
210
210
 
211
- Only then do those two pick up the catalog's reasoning flag and capacity.
212
-
213
- ### Lifecycle and dependencies
211
+ **The tab says `设置:未写入(已处于同步状态)`?**
212
+ That is the normal steady state: the settings already hold the current catalog.
214
213
 
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.
227
-
228
- ## Commands
229
-
230
- | Command | Effect |
231
- | --- | --- |
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 |
214
+ **Need a real key instead of the placeholder header?**
215
+ 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.
236
216
 
237
- ## Configuration
217
+ **The old route is still there after changing `route` / `anthropicRoute`?**
218
+ The plugin only knows the two keys it currently owns, 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.
238
219
 
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).
220
+ ## What it does
240
221
 
241
- | Key | Default | Meaning |
242
- | --- | --- | --- |
243
- | `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 |
248
- | `apiKeyEnv` | `''` | Credential-seam reference; non-empty suppresses the placeholder header |
249
- | `placeholderCredential` | `dsh-aperture` | Placeholder value; `''` writes no placeholder header at all |
250
- | `headers` | `{}` | Extra request headers; they **win over** the placeholder |
251
- | `enabledModelIds` | `[]` | Non-empty restricts discovery to these ids (explicit `models` entries are exempt) |
252
- | `modelAliases` | `{}` | Gateway id → models.dev id |
253
- | `models` | `[]` | Per-model overrides and extras: `id`, `name`, `api`, `contextWindow`, `maxTokens`, `input`, `thinking`, `reasoningEfforts` |
254
- | `modelMetadataUrl` | `https://models.dev/models.json` | Catalog URL; `''` disables enrichment |
255
- | `defaultContextWindow` | `128000` | Context capacity when nothing sizes a model |
256
- | `images` | `ignore` | `metadata` adopts models.dev input modalities (images) |
257
- | `reasoning` | `auto` | `off` declares every model non-reasoning |
258
- | `sync` | `true` | `false` discovers without writing (`/aperture` still reports) |
259
- | `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
-
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:
263
-
264
- ```yaml
265
- aperture:
266
- models:
267
- - id: gemini-2.5-pro
268
- api: openai-completions
222
+ ```
223
+ GET {baseUrl}/v1/models
224
+ │
225
+ ├─ per model: supported_endpoints ──► routing
226
+ │ /v1/chat/completions ──► route (openai-completions)
227
+ │ /v1/messages ──► anthropicRoute (anthropic-messages)
228
+ │ native generateContent only ──► not published (reported under 未服务)
229
+ │
230
+ ├─ capacity: Aperture fields ─► models.dev ─► default
231
+ ├─ reasoning: Aperture fields ─► models.dev ─► off
232
+ │
233
+ └─ llm-pi-ai providers.<route>, written to settings.yaml by revision
269
234
  ```
270
235
 
271
- ## Write behaviour
272
-
273
- The plugin touches exactly two keys under `llm-pi-ai.providers` (`route` and `anthropicRoute`), and:
274
-
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.
236
+ 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.
280
237
 
281
- `设置:未写入(已处于同步状态)` in `/aperture` is the normal steady state.
238
+ 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).
282
239
 
283
240
  ## Development
284
241
 
285
242
  ```sh
286
243
  npm install # if the machine-level npm cache is not writable: npm install --cache ./.npm-cache --ignore-scripts
287
244
  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
245
+ npm run typecheck # includes test/, and parses the browser half with node --check
246
+ npm test # offline unit tests (119; devDependencies must be installed)
291
247
  npm run inspect # print the generated settings.yaml and its resolutions
292
- ```
293
248
 
294
- `npm run test:live` needs a gateway address:
295
-
296
- ```sh
297
- DSH_APERTURE_LIVE_URL=https://ai.example.ts.net npm run test:live
249
+ DSH_APERTURE_LIVE_URL=https://ai.example.ts.net npm run test:live # end-to-end: real harness stack + real gateway
298
250
  ```
299
251
 
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.
252
+ 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
253
 
306
- ## Known boundaries
254
+ ## Acknowledgements
307
255
 
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.
256
+ - [he0119/vscode-aperture-for-copilot](https://github.com/he0119/vscode-aperture-for-copilot): the reference implementation this plugin follows for Aperture model discovery.
257
+ - [xiaoyuyu6420/dsh-backup](https://github.com/xiaoyuyu6420/dsh-backup): the reference implementation this plugin follows for the interface wiring — the settings-tab registration and the Remote endpoint shape both come from it.
258
+ - [Aperture](https://tailscale.com/kb/1542/aperture) (Tailscale): the gateway being discovered.
259
+ - [models.dev](https://models.dev): enriches capacity and capabilities Aperture does not declare.
260
+ - `@deepseek-ai/dsh-llm-pi-ai`: this plugin only discovers; the adapter does the protocol work.
313
261
 
314
262
  ## License
315
263