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 +21 -21
- package/README.en.md +155 -207
- package/README.md +156 -195
- package/client/aperture.js +1522 -0
- package/cordis.patch.yml +3 -2
- package/lib/index.d.ts +11 -2
- package/lib/index.js +18 -5
- package/lib/panel.d.ts +113 -0
- package/lib/panel.js +271 -0
- package/lib/registry.d.ts +1 -5
- package/lib/registry.js +0 -14
- package/lib/remote.d.ts +79 -0
- package/lib/remote.js +120 -0
- package/lib/report.d.ts +111 -9
- package/lib/report.js +107 -79
- package/lib/runtime.d.ts +4 -9
- package/lib/runtime.js +6 -23
- package/lib/types.d.ts +1 -1
- package/package.json +20 -9
- package/lib/command.d.ts +0 -21
- package/lib/command.js +0 -58
package/README.md
CHANGED
|
@@ -1,62 +1,30 @@
|
|
|
1
1
|
# dsh-aperture
|
|
2
2
|
|
|
3
|
-
把 [Aperture](https://tailscale.com/kb/1542/aperture)
|
|
3
|
+
把 [Aperture](https://tailscale.com/kb/1542/aperture) 网关上的模型自动发现出来,写进 DeepSeek Harness 的 `llm-pi-ai` 设置,让它们直接出现在模型选择器里。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
装好后你只需要填一个 Aperture 地址,其余交给插件。
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
# ~/.dsh/settings.yaml —— 由插件自动写入,不需要手写
|
|
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
|
+
## 安装
|
|
20
8
|
|
|
21
|
-
|
|
9
|
+
前提:Node ≥ 24,以及一个你能访问的 Aperture 实例。
|
|
22
10
|
|
|
23
|
-
|
|
24
|
-
- **按协议自动分流**:读每个模型的 `supported_endpoints`,把它发到它真正应答的那条路由上,而不是让它每条请求都 404。
|
|
25
|
-
- **容量与能力补全**:Aperture 自己的字段优先,缺失时用 [models.dev](https://models.dev) 补全,再缺失时用可配置的保守默认值。
|
|
26
|
-
- **推理等级映射**:只暴露后端实测接受的等级,并按 DeepSeek 的 `thinking` 方言生成 `compat`。
|
|
27
|
-
- **只写自己拥有的键**:写入是路径寻址的,你手写的其它 provider 原样保留;内容没变就不写;探测失败绝不删空已有目录。
|
|
28
|
-
- **`/aperture` 命令**:查看状态、列出模型、强制刷新、撤销路由。
|
|
11
|
+
### 1. 装上插件
|
|
29
12
|
|
|
30
|
-
|
|
13
|
+
从 [npm](https://www.npmjs.com/package/dsh-aperture) 装(推荐):
|
|
31
14
|
|
|
32
15
|
```sh
|
|
33
|
-
|
|
34
|
-
npx @deepseek-ai/dsh plugin --profile web add github:he0119/dsh-aperture#<commit>
|
|
35
|
-
|
|
36
|
-
# 或从本地目录(开发时)
|
|
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
|
-
|
|
41
|
-
> `git@github.com:he0119/dsh-aperture.git` 这种 scp 风格在 Windows 上会被当成**本地路径**解析——冒号被当作盘符——
|
|
42
|
-
> 直接报 `Failed to resolve dependency: 文件名、目录名或卷标语法不正确。 (os error 123)`。
|
|
43
|
-
>
|
|
44
|
-
> 如果本机 git 的 HTTPS 不可用、报 schannel / `SEC_E_NO_CREDENTIALS`,用
|
|
45
|
-
> `git config --global url."git@github.com:".insteadOf "https://github.com/"` 让它改走 SSH。
|
|
19
|
+
发布产物里带着编译好的 `lib/`,安装时不需要授权任何构建脚本。
|
|
46
20
|
|
|
47
|
-
|
|
21
|
+
想锁 commit、或跟进未发布的改动,就从 git 装:
|
|
48
22
|
|
|
49
23
|
```sh
|
|
50
|
-
npx @deepseek-ai/dsh --profile web
|
|
24
|
+
npx @deepseek-ai/dsh plugin --profile web add github:he0119/dsh-aperture#<sha>
|
|
51
25
|
```
|
|
52
26
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
### 第一次安装要放行构建(或者用预构建产物)
|
|
56
|
-
|
|
57
|
-
这是个 TypeScript 源码包,git 安装拉下来的是**源码**,靠 `prepare` 脚本在安装时编译出 `lib/`。
|
|
58
|
-
pnpm ≥10 在得到显式允许前**拒绝运行 git 依赖的构建脚本**,所以**第一次 `add` 会失败**;dsh 会把 pnpm 打印的包键告诉你,
|
|
59
|
-
把它写进 profile 的 `pnpm-workspace.yaml`:
|
|
27
|
+
git 安装拉下来的是**源码**,靠 `prepare` 脚本在安装时编译。pnpm ≥10 默认拒绝运行 git 依赖的构建脚本,所以**第一次 `add` 会失败**:dsh 会把你需要的包键打印出来,写进 profile 的 `pnpm-workspace.yaml` 后重跑一次即可。
|
|
60
28
|
|
|
61
29
|
```yaml
|
|
62
30
|
# ~/.dsh/profiles/web/pnpm-workspace.yaml
|
|
@@ -64,118 +32,148 @@ allowBuilds:
|
|
|
64
32
|
dsh-aperture: true
|
|
65
33
|
```
|
|
66
34
|
|
|
67
|
-
(键是**映射**形式,值为 `true
|
|
35
|
+
(键是**映射**形式,值为 `true`;写成列表无效。)
|
|
68
36
|
|
|
69
|
-
|
|
70
|
-
(`github:he0119/dsh-aperture#<sha>`)——git 安装拉取的是会变的代码。
|
|
37
|
+
> 这项授权等于允许该包在你机器上、于 agent 沙箱之外执行安装脚本。只对信任的源码授权。
|
|
71
38
|
|
|
72
|
-
|
|
39
|
+
本地改代码时,直接装仓库目录(先 `npm run build`):
|
|
73
40
|
|
|
74
41
|
```sh
|
|
75
|
-
|
|
76
|
-
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
|
|
77
43
|
```
|
|
78
44
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
> 安装时 pnpm 可能警告 `Issues with peer dependencies found`。**这是预期的**:本包依赖的
|
|
82
|
-
> `@deepseek-ai/cordis`、`@deepseek-ai/schemastery`、`@deepseek-ai/dsh-settings` 等都是 DSH 自带、
|
|
83
|
-
> 由 DSH 自己解析的包(它们不进 profile 的 `node_modules`),所以 pnpm 看不到它们并不影响运行。
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
然后填上你的 Aperture 地址,二选一:
|
|
45
|
+
### 2. 填上你的 Aperture 地址
|
|
87
46
|
|
|
88
47
|
```yaml
|
|
89
|
-
# ~/.dsh/settings.yaml
|
|
48
|
+
# ~/.dsh/settings.yaml
|
|
90
49
|
aperture:
|
|
91
50
|
baseUrl: https://ai.example.ts.net
|
|
92
51
|
```
|
|
93
52
|
|
|
94
|
-
|
|
53
|
+
也可以写进 profile 的 `cordis.patch.yml`(组合层);用户层覆盖组合层。
|
|
95
54
|
|
|
96
|
-
|
|
55
|
+
重启之后也可以直接在界面里填:**设置 → 插件 → Aperture**(与「插件配置」并列的标签页),页面上的「实例地址」写的就是同一个 `aperture.baseUrl`。
|
|
97
56
|
|
|
57
|
+
### 3. 重启 DSH
|
|
58
|
+
|
|
59
|
+
bundle 变化不会热加载。重启前可以先只看组合结果:
|
|
60
|
+
|
|
61
|
+
```sh
|
|
62
|
+
npx @deepseek-ai/dsh --profile web --dump-config # 应出现 "# == dsh-aperture" 层
|
|
98
63
|
```
|
|
99
|
-
Aperture:https://ai.example.ts.net
|
|
100
|
-
最近一次刷新:配置变更 · 2026-09-22T16:31:02.184Z · 412ms · 成功
|
|
101
|
-
清单:422 个条目
|
|
102
|
-
端点:https://ai.example.ts.net/v1/models 列出了 16 行
|
|
103
|
-
路由 aperture:11 个模型,经由 openai-completions → https://ai.example.ts.net/v1
|
|
104
|
-
路由 aperture-anthropic:1 个模型,经由 anthropic-messages → https://ai.example.ts.net
|
|
105
|
-
未服务:4 个模型(gemini-2.5-flash, gemini-2.5-flash-lite, gemini-2.5-pro, gemini-3.1-flash-image-preview)
|
|
106
|
-
设置:向 llm-pi-ai 写入 2 个操作(aperture, aperture-anthropic)
|
|
107
|
-
```
|
|
108
64
|
|
|
109
|
-
|
|
65
|
+
### 4. 确认
|
|
66
|
+
|
|
67
|
+
模型会出现在选择器里,路由名 `Aperture`。最近一次刷新做了什么,看 **设置 → 插件 → Aperture**:状态段把每一行摆成一项事实,下面按路由列出模型。
|
|
110
68
|
|
|
111
69
|
```
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
70
|
+
最近一次刷新
|
|
71
|
+
触发 配置变更 时间 2026-09-23 12:32:36
|
|
72
|
+
耗时 286ms 结果 成功
|
|
73
|
+
清单 422 个条目 端点 https://ai.example.ts.net/v1/models 列出了 16 行
|
|
74
|
+
设置 向 llm-pi-ai 写入 2 个操作(aperture, aperture-anthropic)
|
|
75
|
+
|
|
76
|
+
模型与路由 已覆盖 1 个模型,其余沿用发现值与清单
|
|
77
|
+
aperture · openai-completions
|
|
78
|
+
→ https://ai.example.ts.net/v1 · 11 个模型
|
|
79
|
+
deepseek-v4-flash DeepSeek V4 Flash 已覆盖 [▾ 收起]
|
|
80
|
+
1,048,576 上下文窗口 · 384,000 输出 · 文本+图像 · 推理
|
|
81
|
+
│ deepseek-v4-flash · aperture · openai-completions
|
|
82
|
+
│ 显示名 [DeepSeek V4 Flash ] 来自 models.dev
|
|
83
|
+
│ 清单别名 [deepseek/deepseek-v4-flash]
|
|
84
|
+
│ 上下文 [1048576] 生效 1,048,576 · 来自 aperture
|
|
85
|
+
│ 最大输出 [384000] 生效 384,000 · 来自 aperture
|
|
86
|
+
│ 输入模态 ☑文本 ☑图像 生效 文本+图像 · 来自 配置
|
|
87
|
+
│ 推理 [跟随发现 ▾] 生效 开 · 来自 models.dev
|
|
88
|
+
│ 协议 [跟随发现 ▾] 生效 openai-completions
|
|
89
|
+
│ 显示名、容量与模态留空表示这一项不覆盖…… [撤销覆盖] [取消] [保存]
|
|
90
|
+
gemini-2.5-flash [▸ 编辑]
|
|
91
|
+
128,000 上下文窗口 · 文本 · 无推理
|
|
92
|
+
未服务:没有本插件可发布的端点
|
|
93
|
+
4 个模型
|
|
94
|
+
gemini-2.5-flash-lite [▸ 编辑]
|
|
95
|
+
通告的端点:/v1beta/models/gemini-2.5-flash-lite:generateContent
|
|
123
96
|
```
|
|
124
97
|
|
|
125
|
-
|
|
98
|
+
收起时每一行只是一条事实(模型 id 与生效的取值);点「编辑」展开面板,每条来源就写在它描述的那个字段旁边(「生效 1,048,576 · 来自 aperture」)。一行一套「保存 / 取消」,按「保存」只写这一行,「取消」把这一行的改动整个丢掉。
|
|
126
99
|
|
|
127
|
-
|
|
100
|
+
旁边就是改地址、立刻刷新与撤下路由的按钮。
|
|
128
101
|
|
|
129
|
-
|
|
130
|
-
| --- | --- | --- |
|
|
131
|
-
| 11 个(DeepSeek / MiMo / Grok / Qwen / LongCat …) | `/v1/chat/completions` | 走 `aperture` |
|
|
132
|
-
| `MiniMax-M3` | `/v1/messages` | 走 `aperture-anthropic` |
|
|
133
|
-
| 4 个 Gemini | `/v1beta/models/{model}:generateContent` | 不发布 |
|
|
102
|
+
## 使用
|
|
134
103
|
|
|
135
|
-
|
|
104
|
+
界面在 **设置 → 插件 → Aperture**:一个标签页,写着你当前的实例地址与最近一次刷新做了什么,下面按路由列出发现的模型,可以改地址、开关「同步到 llm-pi-ai」、按一下立刻重新发现、按一下把已经发布的路由从 `llm-pi-ai` 段撤下来,也可以就地为单个模型改参数。地址与开关在按下「保存」之前只是草稿;保存交给宿主半边写进设置接缝,因此有版本设栅——表单已经与设置文档脱节时会拒绝写入,而不是覆盖别处的改动。模型参数同理,而且**按行来**:展开的那一行改的是草稿,行上出现「待保存」,按「保存」才写,也只写这一行;「取消」把这一行的改动丢掉。
|
|
136
105
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
106
|
+
| 位置 | 作用 |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| 标签页 · 状态 | 最近一次刷新做了什么、它是被什么触发的,以及清单、端点与设置写入的结果 |
|
|
109
|
+
| 标签页 · 实例地址 | 改 `baseUrl`(写入设置接缝,带「已覆盖」标记与撤销回继承) |
|
|
110
|
+
| 标签页 · 同步开关 | 改 `sync`:关掉就只探测、不写 `llm-pi-ai` |
|
|
111
|
+
| 标签页 · 保存 | 把地址与开关的草稿写进设置文档 |
|
|
112
|
+
| 标签页 · 立即刷新 | 立刻重新发现并发布,并把这一轮的报告摆出来 |
|
|
113
|
+
| 标签页 · 撤掉已发布的路由 | 把本插件的两条路由从 `llm-pi-ai` 段撤下来 |
|
|
114
|
+
| 标签页 · 模型与路由 | 每个模型所在的路由,以及它生效的取值 |
|
|
115
|
+
| 标签页 · 编辑 | 展开一个模型的参数:显示名、清单别名、容量、模态、推理、协议,每条事实来自哪里就写在对应字段旁边 |
|
|
116
|
+
| 标签页 · 保存 / 取消 | 只写这一行,或者把这一行的改动整个丢掉 |
|
|
117
|
+
| 标签页 · 撤销覆盖 | 只清掉报告里写着确实被覆盖过的那几项,随即回落到发现值与清单 |
|
|
141
118
|
|
|
142
|
-
`
|
|
119
|
+
就地编辑写的都是配置:容量与模态等落在 `aperture.models` 的对应条目上,清单别名落在 `aperture.modelAliases[id]`,写入按字段合并——界面没提到的字段原样留着(比如 `reasoningEfforts`),留空则表示这一项不覆盖、回落到发现值与清单。协议那一项是「未服务」模型唯一的出路:填上它就能让只在原生端点上应答的模型在对应路由上发布。
|
|
143
120
|
|
|
144
|
-
|
|
121
|
+
> 「撤掉已发布的路由」只撤这一次:下一次刷新会按当前配置重新发布。要让撤下长期生效,先把同步开关关掉(等价于 `sync: false`)。
|
|
145
122
|
|
|
146
|
-
|
|
123
|
+
## 配置
|
|
147
124
|
|
|
148
|
-
|
|
149
|
-
- `aperture-anthropic` 路由 → `x-api-key: dsh-aperture`
|
|
125
|
+
所有键都可写在 `~/.dsh/settings.yaml` 的 `aperture:` 段(用户层),或 profile 的 `cordis.patch.yml`(组合层)。`baseUrl` 与 `sync` 也可以在界面上的 Aperture 标签页里改,`models` 与 `modelAliases` 里的逐模型参数同样可以在那里就地编辑;其余键只有配置文件这一条路。
|
|
150
126
|
|
|
151
|
-
|
|
127
|
+
| 键 | 默认 | 说明 |
|
|
128
|
+
| --- | --- | --- |
|
|
129
|
+
| `baseUrl` | `''` | Aperture 实例地址。末尾 `/v1` 会被容忍并去掉;空值表示休眠(不探测、不写入) |
|
|
130
|
+
| `route` | `aperture` | OpenAI 兼容模型的路由名 |
|
|
131
|
+
| `anthropicRoute` | `aperture-anthropic` | Anthropic Messages 模型的路由名 |
|
|
132
|
+
| `displayName` | `Aperture` | 选择器里的名字 |
|
|
133
|
+
| `anthropicDisplayName` | `Aperture (Anthropic)` | 同上,Anthropic 路由 |
|
|
134
|
+
| `apiKeyEnv` | `''` | 凭据 seam 里的引用名;非空时不再写占位头 |
|
|
135
|
+
| `placeholderCredential` | `dsh-aperture` | 占位凭据的值;设成 `''` 就完全不写占位头 |
|
|
136
|
+
| `headers` | `{}` | 每条请求额外带的头,**优先于**占位头 |
|
|
137
|
+
| `enabledModelIds` | `[]` | 非空时只保留这些 id(`models` 里显式列出的不受限) |
|
|
138
|
+
| `modelAliases` | `{}` | 网关 id → models.dev id |
|
|
139
|
+
| `models` | `[]` | 逐模型覆盖或补充:`id`、`name`、`api`、`contextWindow`、`maxTokens`、`input`、`thinking`、`reasoningEfforts` |
|
|
140
|
+
| `modelMetadataUrl` | `https://models.dev/models.json` | 目录地址;设成 `''` 关闭补全 |
|
|
141
|
+
| `defaultContextWindow` | `128000` | 谁都没说容量时的上下文 |
|
|
142
|
+
| `images` | `ignore` | `metadata` = 采用 models.dev 的输入模态(图片) |
|
|
143
|
+
| `reasoning` | `auto` | `off` = 所有模型都当不会推理 |
|
|
144
|
+
| `sync` | `true` | `false` = 只探测不写设置(标签页仍可查看) |
|
|
145
|
+
| `refreshIntervalMinutes` | `0` | 定时刷新间隔;`0` = 只在启动和配置变化时刷新 |
|
|
146
|
+
| `timeoutMs` | `20000` | 网关与目录的单次请求超时 |
|
|
152
147
|
|
|
153
|
-
|
|
148
|
+
容量与推理档位缺失时,按 Aperture 字段 → [models.dev](https://models.dev) → 保守默认值补全;`maxTokens` 没人声明时**故意不写**(在 `llm-pi-ai` 里它同时是每次请求的 `max_tokens` 上限,凭空编一个值会把请求截断)。
|
|
154
149
|
|
|
155
|
-
|
|
156
|
-
| --- | --- |
|
|
157
|
-
| `contextWindow` | Aperture `context_window_tokens` / `max_input_tokens` / `limit.context` → models.dev → `defaultContextWindow` |
|
|
158
|
-
| `maxTokens` | Aperture `max_output_tokens` / `limit.output` → models.dev → **不写** |
|
|
159
|
-
| `input`(多模态) | `images: metadata` 时取 Aperture 能力字段 → models.dev → `["text"]`;`images: ignore` 时恒为 `["text"]` |
|
|
160
|
-
| `reasoning` | Aperture 能力字段 → models.dev → 关闭 |
|
|
150
|
+
## 常见问题
|
|
161
151
|
|
|
162
|
-
|
|
152
|
+
**从 git 装的时候,第一次 `add` 失败、说构建脚本被忽略?**
|
|
153
|
+
按[安装](#1-装上插件)里 git 那段的 `allowBuilds` 写一行,然后重跑;或者直接用 npm 安装,不需要任何授权。
|
|
163
154
|
|
|
164
|
-
|
|
155
|
+
**装的时候警告 `Issues with peer dependencies found`?**
|
|
156
|
+
预期内。本包依赖的 `@deepseek-ai/cordis`、`@deepseek-ai/schemastery`、`@deepseek-ai/dsh-settings` 都由 DSH 自带并自行解析,不进 profile 的 `node_modules`,pnpm 看不到它们不影响运行。
|
|
165
157
|
|
|
166
|
-
|
|
158
|
+
**`Failed to resolve dependency: 文件名、目录名或卷标语法不正确。 (os error 123)`?**
|
|
159
|
+
git 地址用了 `git@github.com:he0119/dsh-aperture.git` 这种 scp 风格——在 Windows 上冒号会被当作盘符,于是被当成**本地路径**。改用 pnpm 认的写法:`github:he0119/dsh-aperture`、`git+https://…` 或 `git+ssh://…`。
|
|
167
160
|
|
|
168
|
-
|
|
169
|
-
- MiMo(`mimo-v2.6-pro`)对 `minimal`/`xhigh`/`max` 直接 **HTTP 400**。
|
|
161
|
+
**本机 git 的 HTTPS 不可用(报 schannel / `SEC_E_NO_CREDENTIALS`)?**
|
|
170
162
|
|
|
171
|
-
|
|
163
|
+
```sh
|
|
164
|
+
git config --global url."git@github.com:".insteadOf "https://github.com/"
|
|
165
|
+
```
|
|
172
166
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
| DeepSeek 系(id/name/provider 含 `deepseek`) | `{off: disabled, high: high, max: max}` | `{supportsReasoningEffort: true, thinkingFormat: deepseek}` |
|
|
176
|
-
| 其它会推理的模型 | `{off: null, high: high}` | `{supportsReasoningEffort: true}` |
|
|
167
|
+
**有些模型没出现在选择器里?**
|
|
168
|
+
看标签页上的「模型与路由」(「未服务」那一行)。只提供 Gemini 原生 `generateContent` 端点的模型接不进来——`llm-pi-ai` 只讲 OpenAI 兼容和 Anthropic Messages 两种协议。走错端点时 Aperture 会明确告诉你该用哪个:
|
|
177
169
|
|
|
178
|
-
|
|
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
|
+
**想给某个模型更多推理档位?**
|
|
176
|
+
默认只给保守的两档(DeepSeek 系 `off/high/max`,其它会推理的模型 `off/high`),自己加:
|
|
179
177
|
|
|
180
178
|
```yaml
|
|
181
179
|
aperture:
|
|
@@ -190,11 +188,18 @@ aperture:
|
|
|
190
188
|
max: max
|
|
191
189
|
```
|
|
192
190
|
|
|
193
|
-
|
|
191
|
+
**网关没列出的模型也想接?**
|
|
192
|
+
用 `models` 显式补一条即可(比如标签页里「未服务」的那几个 Gemini 模型,只要你知道它在 OpenAI 兼容端点上确实能用):
|
|
194
193
|
|
|
195
|
-
|
|
194
|
+
```yaml
|
|
195
|
+
aperture:
|
|
196
|
+
models:
|
|
197
|
+
- id: gemini-2.5-pro
|
|
198
|
+
api: openai-completions
|
|
199
|
+
```
|
|
196
200
|
|
|
197
|
-
|
|
201
|
+
**模型的容量/推理标记没补上?**
|
|
202
|
+
网关会改名,models.dev 上可能对不上(实测 `deepseek-flash`、`k3` 那边叫 `deepseek/deepseek-v4-flash`、`moonshotai/kimi-k3`)。显式映射:
|
|
198
203
|
|
|
199
204
|
```yaml
|
|
200
205
|
aperture:
|
|
@@ -203,100 +208,56 @@ aperture:
|
|
|
203
208
|
k3: moonshotai/kimi-k3
|
|
204
209
|
```
|
|
205
210
|
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
### 生命周期与依赖
|
|
209
|
-
|
|
210
|
-
- `settings` 是**硬依赖**(`inject = ['settings']`)。本插件的职责就是往设置里写,没有它发布对象都不存在,所以宁可让框架把插件挂在 `PENDING`,provider 被替换时自动卸载、恢复后重新加载,而不是留着一个无处发布的实例。
|
|
211
|
-
- `commands` **不声明**。没有命令服务的部署也该照常获得发现能力,所以它走 `ctx.inject(['commands'])` 可选挂载。
|
|
212
|
-
- 定时刷新用 `ctx.effect` 注册,卸载自动清理;配置变更会按新值重新计算间隔。
|
|
213
|
-
- **注册配置段本身就是第一次发现的触发器**:`installSection` 挂载时先 `setSource` 再通知 `onChange`,所以首次刷新看到的就是叠加了用户层的配置,不需要为了对齐两份配置再刷一遍。
|
|
214
|
-
- 配置段是**活引用**(thunk)而不是快照:改 `~/.dsh/settings.yaml` 里的 `aperture:` 段,下一次刷新立刻用新值,不必重启、也不必重载插件。
|
|
215
|
-
|
|
216
|
-
## 命令
|
|
217
|
-
|
|
218
|
-
| 命令 | 作用 |
|
|
219
|
-
| --- | --- |
|
|
220
|
-
| `/aperture` | 上一次刷新的状态(默认) |
|
|
221
|
-
| `/aperture models` | 列出每个模型、它的路由,以及每条事实的来源 |
|
|
222
|
-
| `/aperture refresh` | 立刻重新发现并发布 |
|
|
223
|
-
| `/aperture remove` | 把本插件的路由从 `llm-pi-ai` 段里撤掉 |
|
|
224
|
-
|
|
225
|
-
## 配置
|
|
211
|
+
**标签页上说 `设置:未写入(已处于同步状态)`?**
|
|
212
|
+
正常状态,表示设置里已经是最新内容。
|
|
226
213
|
|
|
227
|
-
|
|
214
|
+
**需要真密钥而不是占位头?**
|
|
215
|
+
Aperture 靠网络身份(Tailscale)认证,本不需要密钥;插件默认写入 `authorization: Bearer dsh-aperture` / `x-api-key: dsh-aperture`,只是让适配器愿意发请求,**不是密钥**。真要密钥时把 `apiKeyEnv` 指向凭据 seam 里的记录,占位头就不会写入。
|
|
228
216
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
| `baseUrl` | `''` | Aperture 实例地址。末尾 `/v1` 会被容忍并去掉;空值表示休眠(不探测、不写入) |
|
|
232
|
-
| `route` | `aperture` | OpenAI 兼容模型的路由名 |
|
|
233
|
-
| `anthropicRoute` | `aperture-anthropic` | Anthropic Messages 模型的路由名 |
|
|
234
|
-
| `displayName` | `Aperture` | 选择器里的名字 |
|
|
235
|
-
| `anthropicDisplayName` | `Aperture (Anthropic)` | 同上,Anthropic 路由 |
|
|
236
|
-
| `apiKeyEnv` | `''` | 凭据 seam 里的引用名;非空时不再写占位头 |
|
|
237
|
-
| `placeholderCredential` | `dsh-aperture` | 占位凭据的值;设成 `''` 就完全不写占位头 |
|
|
238
|
-
| `headers` | `{}` | 每条请求额外带的头,**优先于**占位头 |
|
|
239
|
-
| `enabledModelIds` | `[]` | 非空时只保留这些 id(`models` 里显式列出的不受限) |
|
|
240
|
-
| `modelAliases` | `{}` | 网关 id → models.dev id |
|
|
241
|
-
| `models` | `[]` | 逐模型覆盖或补充:`id`、`name`、`api`、`contextWindow`、`maxTokens`、`input`、`thinking`、`reasoningEfforts` |
|
|
242
|
-
| `modelMetadataUrl` | `https://models.dev/models.json` | 目录地址;设成 `''` 关闭补全 |
|
|
243
|
-
| `defaultContextWindow` | `128000` | 谁都没说容量时的上下文 |
|
|
244
|
-
| `images` | `ignore` | `metadata` = 采用 models.dev 的输入模态(图片) |
|
|
245
|
-
| `reasoning` | `auto` | `off` = 所有模型都当不会推理 |
|
|
246
|
-
| `sync` | `true` | `false` = 只探测不写设置(`/aperture` 仍可查看) |
|
|
247
|
-
| `refreshIntervalMinutes` | `0` | 定时刷新间隔;`0` = 只在启动和配置变化时刷新 |
|
|
248
|
-
| `timeoutMs` | `20000` | 网关与目录的单次请求超时 |
|
|
217
|
+
**改了 `route` / `anthropicRoute` 之后旧路由还在?**
|
|
218
|
+
插件只认自己当前拥有的两个键,不知道历史上用过哪些名字,所以旧键会留在 `llm-pi-ai.providers` 里。它不报错、只是不再刷新;要清理就手动删掉那一行。
|
|
249
219
|
|
|
250
|
-
|
|
220
|
+
## 它做了什么
|
|
251
221
|
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
222
|
+
```
|
|
223
|
+
GET {baseUrl}/v1/models
|
|
224
|
+
│
|
|
225
|
+
├─ 每个模型:supported_endpoints ──► 分流
|
|
226
|
+
│ /v1/chat/completions ──► route (openai-completions)
|
|
227
|
+
│ /v1/messages ──► anthropicRoute (anthropic-messages)
|
|
228
|
+
│ 只有原生 generateContent ──► 不发布(列进「未服务」)
|
|
229
|
+
│
|
|
230
|
+
├─ 容量:Aperture 字段 ─► models.dev ─► 默认值
|
|
231
|
+
├─ 推理:Aperture 字段 ─► models.dev ─► 关闭
|
|
232
|
+
│
|
|
233
|
+
└─ 生成 llm-pi-ai 的 providers.<route>,按 revision 写入 settings.yaml
|
|
257
234
|
```
|
|
258
235
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
插件只碰 `llm-pi-ai.providers` 下的两个键(`route` / `anthropicRoute`),并且:
|
|
262
|
-
|
|
263
|
-
- **内容相同就不写**——每次刷新都对比解析后的段,避免无意义的重写和文件监听回环;
|
|
264
|
-
- **用路径操作写**——你的其它 provider 一个字段都不会动;
|
|
265
|
-
- **探测失败就不写**——网关临时不可达时保留已经生效的目录,而不是清空;
|
|
266
|
-
- **带 revision 写**——与其它写入者(比如模型页)冲突时重读一次再写;
|
|
267
|
-
- **路由没模型了就删掉**——避免留下指向旧目录的空路由。
|
|
236
|
+
写入只碰 `llm-pi-ai.providers` 下属于本插件的两个键:内容没变就不写;用路径操作写,你手写的其它 provider 原样保留;探测失败绝不删空已有目录;路由没模型了就删掉。
|
|
268
237
|
|
|
269
|
-
|
|
238
|
+
实现细节(两条路由的取舍、容量与推理的来源优先级、生命周期与依赖、写入行为)见 [docs/internals.md](https://github.com/he0119/dsh-aperture/blob/main/docs/internals.md)。
|
|
270
239
|
|
|
271
240
|
## 开发
|
|
272
241
|
|
|
273
242
|
```sh
|
|
274
243
|
npm install # 若机器级 npm 缓存不可写:npm install --cache ./.npm-cache --ignore-scripts
|
|
275
244
|
npm run build # tsc -> lib/
|
|
276
|
-
npm run typecheck # 含 test
|
|
277
|
-
npm test #
|
|
278
|
-
npm run test:live # 端到端:真实 DSH 栈 + 真实网关
|
|
245
|
+
npm run typecheck # 含 test/,并用 node --check 解析浏览器半边
|
|
246
|
+
npm test # 单元测试(119 个,离线运行;需要已安装的 devDependencies)
|
|
279
247
|
npm run inspect # 打印真实生成的 settings.yaml 与解析结果
|
|
280
|
-
```
|
|
281
248
|
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
```sh
|
|
285
|
-
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 # 端到端:真实 DSH 栈 + 真实网关
|
|
286
250
|
```
|
|
287
251
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
> `lib/` 是构建产物:git 安装与 `npm publish` 都由 `prepare` 脚本现场编译。
|
|
291
|
-
> 而从本地目录安装(`link:`)不会跑 `prepare`,所以本地调试前先 `npm run build`。
|
|
252
|
+
发布流程与产物构成见 [docs/releasing.md](https://github.com/he0119/dsh-aperture/blob/main/docs/releasing.md)。
|
|
292
253
|
|
|
293
|
-
##
|
|
254
|
+
## 致谢
|
|
294
255
|
|
|
295
|
-
-
|
|
296
|
-
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
-
|
|
256
|
+
- [he0119/vscode-aperture-for-copilot](https://github.com/he0119/vscode-aperture-for-copilot):本插件的参考实现,Aperture 模型发现的做法来自这个 VS Code 扩展。
|
|
257
|
+
- [xiaoyuyu6420/dsh-backup](https://github.com/xiaoyuyu6420/dsh-backup):界面接线的参考实现,设置标签页的注册方式与 Remote 端点的形状都来自这个插件。
|
|
258
|
+
- [Aperture](https://tailscale.com/kb/1542/aperture)(Tailscale):提供被发现的网关。
|
|
259
|
+
- [models.dev](https://models.dev):为 Aperture 未声明的容量与能力做补全。
|
|
260
|
+
- `@deepseek-ai/dsh-llm-pi-ai`:本插件只做发现,协议对接交给它。
|
|
300
261
|
|
|
301
262
|
## License
|
|
302
263
|
|