dsh-aperture 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +11 -2
- package/README.md +11 -2
- package/lib/index.js +15 -50
- package/lib/types/adapter/index.d.ts +1 -3
- package/lib/types/config.d.ts +2 -8
- package/lib/types/plan.d.ts +0 -4
- package/lib/types/provider.d.ts +0 -10
- package/package.json +36 -38
package/README.en.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="icon.svg" width="88" alt="">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
|
|
1
7
|
# dsh-aperture
|
|
2
8
|
|
|
9
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
3
13
|
Discover the models an [Aperture](https://tailscale.com/kb/1542/aperture) gateway serves and, by the endpoint each one answers on, register them as this plugin's own provider routes in DeepSeek Harness — so they simply appear in the model selector. Once installed, one Aperture address is all you configure.
|
|
4
14
|
|
|
5
15
|
## Install
|
|
@@ -77,7 +87,6 @@ Every key lives under that row's `config:` in the profile patch document; anythi
|
|
|
77
87
|
| --- | --- | --- |
|
|
78
88
|
| `baseUrl` | `''` | Aperture instance root. A trailing `/v1` is tolerated and stripped; empty leaves the plugin dormant (no discovery, no registration) |
|
|
79
89
|
| `routePrefix` | `aperture` | Common prefix of the three route names: a route key is the prefix plus its protocol name in lowercase with dashes (`aperture-openai-chat-completions`, `aperture-openai-responses`, `aperture-anthropic-messages`), and the three selector labels come from the same prefix, spelling out the official Models page's product names for the protocols word for word: `Aperture (OpenAI Chat Completions)`, `Aperture (OpenAI Responses)`, `Aperture (Anthropic Messages)` |
|
|
80
|
-
| `apiKeyEnv` | `—` | Credential-seam reference (must match `^[A-Za-z_][A-Za-z0-9_]*$`); leave the key out to keep sending the placeholder credential. An empty string is not a reference — do not write one |
|
|
81
90
|
| `headers` | `{}` | Extra request headers; on a name collision the **attribution header** and the **placeholder credential** are still filled in per protocol |
|
|
82
91
|
| `enabledModelIds` | `[]` | Non-empty restricts discovery to these ids (explicit `models` entries are exempt) |
|
|
83
92
|
| `modelAliases` | `{}` | Gateway id → models.dev id |
|
|
@@ -171,7 +180,7 @@ Both interfaces only exist in the Web GUI. A headless profile still discovers an
|
|
|
171
180
|
|
|
172
181
|
### Need a real key instead of the placeholder credential?
|
|
173
182
|
|
|
174
|
-
No: Aperture authenticates by network identity (Tailscale).
|
|
183
|
+
No — and the plugin has no key setting at all: Aperture authenticates by network identity (Tailscale). Every request carries `authorization: Bearer dsh-aperture` (the Anthropic route sends `x-api-key: dsh-aperture`), only to make pi-ai willing to send the request — this is **not a key**. If a gateway really demands a static token, put one of those two headers in `headers` and the placeholder credential is no longer sent.
|
|
175
184
|
|
|
176
185
|
### Is the old route still there after changing `routePrefix`?
|
|
177
186
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="icon.svg" width="88" alt="">
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<div align="center">
|
|
6
|
+
|
|
1
7
|
# dsh-aperture
|
|
2
8
|
|
|
9
|
+
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
3
13
|
把 [Aperture](https://tailscale.com/kb/1542/aperture) 网关上的模型自动发现出来,按模型自己在哪个端点上应答,注册成 DeepSeek Harness 里本插件自己的 provider 路由,让它们直接出现在模型选择器里。装好后你只需要填一个 Aperture 地址。
|
|
4
14
|
|
|
5
15
|
## 安装
|
|
@@ -77,7 +87,6 @@ npx @deepseek-ai/dsh --profile web --dump-config # 应出现 "# == dsh-apertur
|
|
|
77
87
|
| --- | --- | --- |
|
|
78
88
|
| `baseUrl` | `''` | Aperture 实例地址。末尾 `/v1` 会被容忍并去掉;空值表示休眠(不探测、不注册) |
|
|
79
89
|
| `routePrefix` | `aperture` | 三条路由名的共同前缀:路由键是前缀加协议名的小写连字符写法(`aperture-openai-chat-completions`、`aperture-openai-responses`、`aperture-anthropic-messages`),三个选择器名称同样由它推出来,逐字取官方「模型」页给协议用的产品名:`Aperture (OpenAI Chat Completions)`、`Aperture (OpenAI Responses)`、`Aperture (Anthropic Messages)` |
|
|
80
|
-
| `apiKeyEnv` | `—` | 凭据 seam 里的引用名(须匹配 `^[A-Za-z_][A-Za-z0-9_]*$`);不写这一项就按协议带占位凭据。空串不是引用名,别写 |
|
|
81
90
|
| `headers` | `{}` | 每条请求额外带的头;同名时**归因头**与**占位凭据**仍会按协议补齐 |
|
|
82
91
|
| `enabledModelIds` | `[]` | 非空时只保留这些 id(`models` 里显式列出的不受限) |
|
|
83
92
|
| `modelAliases` | `{}` | 网关 id → models.dev id |
|
|
@@ -172,7 +181,7 @@ DSH 的补丁层是叠加的:profile 的补丁文档之上还有 `$DSH_HOME/co
|
|
|
172
181
|
|
|
173
182
|
### 需要真密钥而不是占位凭据?
|
|
174
183
|
|
|
175
|
-
|
|
184
|
+
不需要,插件也不提供密钥配置:Aperture 靠网络身份(Tailscale)认证。每条请求按协议带 `authorization: Bearer dsh-aperture`(Anthropic 路由是 `x-api-key: dsh-aperture`),只是让 pi-ai 愿意把请求发出去,**不是密钥**。网关若真的要求静态令牌,用 `headers` 写死这两个头之一,占位凭据就不再带。
|
|
176
185
|
|
|
177
186
|
### 改了 `routePrefix` 之后旧路由还在?
|
|
178
187
|
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
|
-
import { CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, IMAGE_OFFLOAD_REQUIRED_CODE, LlmAdapter, LlmError, QUOTA_EXCEEDED_CODE, ReasoningEffortId, ToolCallId,
|
|
3
|
-
import { credentialRef } from "@deepseek-ai/dsh-credentials";
|
|
2
|
+
import { CONTEXT_WINDOW_EXCEEDED_CODE, EMPTY_RESPONSE_CODE, IMAGE_OFFLOAD_REQUIRED_CODE, LlmAdapter, LlmError, QUOTA_EXCEEDED_CODE, ReasoningEffortId, ToolCallId, attributionHeaders, contentHasImage, isContextWindowExceededError, isQuotaExceededError, offloadedImageText, projectOffloadedImages, requestImageHandleText, requiredImageOffload } from "@deepseek-ai/dsh-llm";
|
|
4
3
|
import { idleWatchdog, timeoutOf } from "@deepseek-ai/dsh-timeout";
|
|
4
|
+
import { normalizeContext } from "@earendil-works/pi-ai";
|
|
5
5
|
import { requestImageDimensions } from "@deepseek-ai/dsh-attachment";
|
|
6
6
|
import { anthropicMessagesApi } from "@earendil-works/pi-ai/api/anthropic-messages.lazy";
|
|
7
7
|
import { openAICompletionsApi } from "@earendil-works/pi-ai/api/openai-completions.lazy";
|
|
@@ -684,7 +684,6 @@ const modelConfig = z.object({
|
|
|
684
684
|
const Config = z.object({
|
|
685
685
|
baseUrl: z.string().default(""),
|
|
686
686
|
routePrefix: z.string().default("aperture"),
|
|
687
|
-
apiKeyEnv: z.string().role("credential-ref"),
|
|
688
687
|
headers: z.dict(z.string()).default({}),
|
|
689
688
|
enabledModelIds: z.array(z.string()).default([]),
|
|
690
689
|
modelAliases: z.dict(z.string()).default({}),
|
|
@@ -733,13 +732,11 @@ function resolveConfig(config) {
|
|
|
733
732
|
assertEfforts(id, model.reasoningEfforts);
|
|
734
733
|
if (model.protocol !== void 0 && model.protocol !== "openai-completions" && model.protocol !== "openai-responses" && model.protocol !== "anthropic-messages") throw new Error(`models["${id}"].protocol "${model.protocol}" 无法服务;请使用 openai-completions、openai-responses 或 anthropic-messages`);
|
|
735
734
|
}
|
|
736
|
-
const apiKeyEnv = (config.apiKeyEnv ?? "").trim();
|
|
737
735
|
return {
|
|
738
736
|
instanceRoot,
|
|
739
737
|
rawBaseUrl,
|
|
740
738
|
routePrefix,
|
|
741
739
|
routes: resolveRoutes(routePrefix),
|
|
742
|
-
apiKeyEnv: apiKeyEnv.length === 0 ? void 0 : apiKeyEnv,
|
|
743
740
|
headers: config.headers ?? {},
|
|
744
741
|
enabledModelIds: config.enabledModelIds ?? [],
|
|
745
742
|
modelAliases: config.modelAliases ?? {},
|
|
@@ -1275,7 +1272,7 @@ function isDeepSeekFamily(model) {
|
|
|
1275
1272
|
* 传输。
|
|
1276
1273
|
*
|
|
1277
1274
|
* 两件网关事实塑造了本模块:pi-ai 的 OpenAI 兼容路径在既无凭据、又无非空 `authorization`
|
|
1278
|
-
*
|
|
1275
|
+
* 头时拒绝派发,所以每条路由都按协议带上一个占位头;pi-ai 的 `Model.maxTokens`
|
|
1279
1276
|
* 是必填的,而没有谁声明过输出上限的模型不该被钉上一个凭空的数字,因此缺省值只作为
|
|
1280
1277
|
* pi-ai 侧的请求上限,同时**不**作为本插件向宿主声明的默认值(见 `defaultMaxTokens`)。
|
|
1281
1278
|
*
|
|
@@ -1314,15 +1311,14 @@ function buildProviderRoute(route, models, options) {
|
|
|
1314
1311
|
protocol: route.protocol,
|
|
1315
1312
|
baseURL: buildRouteBaseUrl(options.instanceRoot, route.protocol),
|
|
1316
1313
|
...headers === void 0 ? {} : { headers },
|
|
1317
|
-
...options.apiKeyEnv === void 0 ? {} : { apiKeyEnv: options.apiKeyEnv },
|
|
1318
1314
|
models: models.map((model) => buildModelEntry(model, route.protocol, options))
|
|
1319
1315
|
};
|
|
1320
1316
|
}
|
|
1321
1317
|
/**
|
|
1322
1318
|
* 一条路由发送的头。
|
|
1323
1319
|
*
|
|
1324
|
-
*
|
|
1325
|
-
*
|
|
1320
|
+
* 部署配置里的头(`headers`)优先于占位头:需要真实静态令牌的网关正是借此拿到它;没有配
|
|
1321
|
+
* 这类头时,按协议带一个占位凭据,让 pi-ai 愿意把请求发出去。
|
|
1326
1322
|
*
|
|
1327
1323
|
* @param protocol - 该路由的协议。
|
|
1328
1324
|
* @param options - 配置。
|
|
@@ -1330,10 +1326,10 @@ function buildProviderRoute(route, models, options) {
|
|
|
1330
1326
|
*/
|
|
1331
1327
|
function routeHeaders(protocol, options) {
|
|
1332
1328
|
const headers = {};
|
|
1333
|
-
if (!
|
|
1329
|
+
if (!Object.keys(options.headers).some((name) => {
|
|
1334
1330
|
const lower = name.toLowerCase();
|
|
1335
1331
|
return lower === "authorization" || lower === "x-api-key" || lower === "cf-aig-authorization";
|
|
1336
|
-
}))
|
|
1332
|
+
})) {
|
|
1337
1333
|
if (protocol === "anthropic-messages") headers["x-api-key"] = DEFAULT_PLACEHOLDER_CREDENTIAL;
|
|
1338
1334
|
else headers.authorization = `Bearer ${DEFAULT_PLACEHOLDER_CREDENTIAL}`;
|
|
1339
1335
|
}
|
|
@@ -1525,7 +1521,6 @@ var ApertureRuntime = class {
|
|
|
1525
1521
|
const plan = planRoutes(registry.models, {
|
|
1526
1522
|
instanceRoot: config.instanceRoot,
|
|
1527
1523
|
routes: config.routes,
|
|
1528
|
-
...config.apiKeyEnv === void 0 ? {} : { apiKeyEnv: config.apiKeyEnv },
|
|
1529
1524
|
headers: config.headers,
|
|
1530
1525
|
configured: config.models
|
|
1531
1526
|
});
|
|
@@ -1912,13 +1907,14 @@ function isNonEmptyString(value) {
|
|
|
1912
1907
|
/**
|
|
1913
1908
|
* 一张图片在请求里的目标版本。
|
|
1914
1909
|
*
|
|
1915
|
-
*
|
|
1916
|
-
*
|
|
1917
|
-
*
|
|
1910
|
+
* 4 Mi 像素的上限(等价于 2048×2048)与 1 MiB 的单张编码字节硬上限,是 0.2.0 那版发布物上
|
|
1911
|
+
* 验证过的一组。`dsh-llm-pi-ai` 现在按请求预算给每张图分 0.75 MiB(20 MiB 预算、20 份),
|
|
1912
|
+
* 本插件沿用自己一直用的 1 MiB 单张上限;软目标与硬上限同值,缩尺寸仍由编码器按质量阶梯
|
|
1913
|
+
* 先试,超过 1 MiB 才继续缩。
|
|
1918
1914
|
*/
|
|
1919
1915
|
const REQUEST_IMAGE_POLICY = {
|
|
1920
1916
|
maxPixels: 4194304,
|
|
1921
|
-
|
|
1917
|
+
maxImageBytes: 1048576
|
|
1922
1918
|
};
|
|
1923
1919
|
/** 一次请求里图片累积后的 base64 字节上限;超过就要求上层先卸载最旧的几张。 */
|
|
1924
1920
|
const MAX_REQUEST_IMAGE_BYTES = 20971520;
|
|
@@ -2085,7 +2081,8 @@ async function prepareRequestImages(messages, images) {
|
|
|
2085
2081
|
function requestImageTarget(ref) {
|
|
2086
2082
|
return {
|
|
2087
2083
|
...requestImageDimensions(ref.width, ref.height, REQUEST_IMAGE_POLICY.maxPixels),
|
|
2088
|
-
|
|
2084
|
+
maxImageBytes: REQUEST_IMAGE_POLICY.maxImageBytes,
|
|
2085
|
+
imageTargetBytes: REQUEST_IMAGE_POLICY.maxImageBytes
|
|
2089
2086
|
};
|
|
2090
2087
|
}
|
|
2091
2088
|
/**
|
|
@@ -2663,7 +2660,6 @@ var ApertureAdapter = class extends LlmAdapter {
|
|
|
2663
2660
|
const { route, model, pi } = entry;
|
|
2664
2661
|
const effort = options.reasoningEffort;
|
|
2665
2662
|
if (effort !== void 0 && !supportedEfforts(pi).includes(effort)) throw new LlmError(`dsh-aperture: 模型 "${options.model}" 不支持推理档位 "${effort}"`, "UNSUPPORTED_REASONING_EFFORT");
|
|
2666
|
-
const apiKey = await this.deps.resolveApiKey(options.provider, route.provider);
|
|
2667
2663
|
const consumer = new AbortController();
|
|
2668
2664
|
const upstream = options.signal === void 0 ? consumer.signal : AbortSignal.any([options.signal, consumer.signal]);
|
|
2669
2665
|
const watchdog = idleWatchdog(upstream, STREAM_IDLE_TIMEOUT_MS, IDLE_TIMEOUT_CODE);
|
|
@@ -2679,8 +2675,7 @@ var ApertureAdapter = class extends LlmAdapter {
|
|
|
2679
2675
|
attachments,
|
|
2680
2676
|
signal: watchdog.signal
|
|
2681
2677
|
}, (reason) => this.deps.logger.debug(`dsh-aperture: 路由 "${options.provider}" 模型 "${options.model}" 的历史降级:${reason}`));
|
|
2682
|
-
const iterator = toStreamChunks(protocolApi(route.provider.protocol).streamSimple(pi, context, {
|
|
2683
|
-
...apiKey === void 0 ? {} : { apiKey },
|
|
2678
|
+
const iterator = toStreamChunks(protocolApi(route.provider.protocol).streamSimple(pi, normalizeContext(context), {
|
|
2684
2679
|
headers: requestHeaders(route.provider.headers),
|
|
2685
2680
|
...options.temperature === void 0 ? {} : { temperature: options.temperature },
|
|
2686
2681
|
...options.maxTokens === void 0 ? {} : { maxTokens: options.maxTokens },
|
|
@@ -2749,20 +2744,6 @@ function requestHeaders(configured) {
|
|
|
2749
2744
|
//#endregion
|
|
2750
2745
|
//#region src/provider.ts
|
|
2751
2746
|
/**
|
|
2752
|
-
* 注册阶段:把一代路由交给宿主的 LLM 接缝。
|
|
2753
|
-
*
|
|
2754
|
-
* 本模块**不写任何配置**。更早的版本把自己的路由写进另一个插件的配置段,现在这条能力整块拿掉:
|
|
2755
|
-
* 配置只由用户与官方界面写,本插件只读。代价是遗留写入不会自动消失——它正好占着本插件要用的
|
|
2756
|
-
* 路由键,于是注册被拒。这时本模块不去替用户清理,而是把「哪个键挡住了、去哪删」写进报告,
|
|
2757
|
-
* 界面上直接可读;用户删掉之后下一次 `llm/adapters-updated` 就会把注册补上。
|
|
2758
|
-
*
|
|
2759
|
-
* 注册本身只有两条性质需要照顾:首次注册用 `registerAdapter`(空数组会被拒),之后用句柄的
|
|
2760
|
-
* `replace`,于是刷新不会让请求观察到「路由消失」的空档;注册失败不会把整轮刷新判为失败——
|
|
2761
|
-
* 发现与报告仍然有结果,用户看到的是「哪条路由没上去、为什么」。
|
|
2762
|
-
*
|
|
2763
|
-
* @module dsh-aperture/provider
|
|
2764
|
-
*/
|
|
2765
|
-
/**
|
|
2766
2747
|
* 本插件的 provider 身份。
|
|
2767
2748
|
*
|
|
2768
2749
|
* 一个实例跨代复用同一个适配器对象,只替换它的路由集合。
|
|
@@ -2783,7 +2764,6 @@ var ApertureProvider = class {
|
|
|
2783
2764
|
this.deps = deps;
|
|
2784
2765
|
this.adapter = new ApertureAdapter({
|
|
2785
2766
|
routes: () => this.routes,
|
|
2786
|
-
resolveApiKey: (provider, profile) => this.resolveApiKey(provider, profile),
|
|
2787
2767
|
attachments: () => this.deps.attachments(),
|
|
2788
2768
|
logger: this.deps.logger
|
|
2789
2769
|
});
|
|
@@ -2880,20 +2860,6 @@ var ApertureProvider = class {
|
|
|
2880
2860
|
conflictReason(blocked) {
|
|
2881
2861
|
return `路由 ${blocked.join("、")} 已被另一个适配器注册;本插件不写配置,请手工处理:旧版本曾把本插件的路由写进 llm-pi-ai.providers,删掉那里的 ${blocked.join(" / ")} 键即可;若那个路由名是别的插件在用的,请把本插件配置里的 routePrefix 改成另一个名字(三条路由键一起变)。`;
|
|
2882
2862
|
}
|
|
2883
|
-
/**
|
|
2884
|
-
* 解析一条路由的凭据。
|
|
2885
|
-
*
|
|
2886
|
-
* 配置了 `apiKeyEnv` 就**必须**解析出可用的值:那是一个明确的声明,悄悄退回占位凭据会让
|
|
2887
|
-
* 一次配错了密钥的部署看起来像一次网关拒绝。
|
|
2888
|
-
*/
|
|
2889
|
-
async resolveApiKey(provider, route) {
|
|
2890
|
-
const ref = route.apiKeyEnv;
|
|
2891
|
-
if (ref === void 0) return void 0;
|
|
2892
|
-
const credentials = this.deps.credentials();
|
|
2893
|
-
const resolved = credentials === void 0 ? process.env[ref] : (await credentials.resolve(credentialRef(ref)))?.value;
|
|
2894
|
-
if (resolved !== void 0 && resolved.length > 0) return assertUsableApiKey(resolved, "dsh-aperture", ref);
|
|
2895
|
-
throw new LlmError(`dsh-aperture: 路由 "${provider}" 的 apiKeyEnv 指向 ${ref},但它没有值;请通过凭据服务存入 ${ref}(模型页可写入),或在启动环境里导出它`, "MISSING_CREDENTIAL");
|
|
2896
|
-
}
|
|
2897
2863
|
};
|
|
2898
2864
|
//#endregion
|
|
2899
2865
|
//#region src/relay.ts
|
|
@@ -3060,7 +3026,6 @@ function apply(ctx, config) {
|
|
|
3060
3026
|
const readConfig = memoizedConfig(() => configValue(config));
|
|
3061
3027
|
const provider = new ApertureProvider({
|
|
3062
3028
|
llm: ctx.llm,
|
|
3063
|
-
credentials: () => ctx.get("credentials"),
|
|
3064
3029
|
attachments: () => ctx.get("attachments"),
|
|
3065
3030
|
logger
|
|
3066
3031
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlannedRoute
|
|
1
|
+
import { PlannedRoute } from "../plan.js";
|
|
2
2
|
import { RuntimeLogger } from "../runtime.js";
|
|
3
3
|
import { GenerateOptions, LlmAdapter, LlmModelInfo, LlmProviderInfo, LlmResolvedModelInfo, PreparedAdapterCall, StreamChunk } from "@deepseek-ai/dsh-llm";
|
|
4
4
|
import { AttachmentStore } from "@deepseek-ai/dsh-attachment";
|
|
@@ -7,8 +7,6 @@ import { AttachmentStore } from "@deepseek-ai/dsh-attachment";
|
|
|
7
7
|
export interface AdapterDeps {
|
|
8
8
|
/** 当前这一代要服务的路由;换一份新数组就是新一代。 */
|
|
9
9
|
readonly routes: () => readonly PlannedRoute[];
|
|
10
|
-
/** 解析一条路由的凭据;未配置 `apiKeyEnv` 时返回 `undefined`(该路由用占位凭据)。 */
|
|
11
|
-
readonly resolveApiKey: (provider: string, route: ProviderRoute) => Promise<string | undefined>;
|
|
12
10
|
/** 附件服务;没有它的部署里图片不可转换。 */
|
|
13
11
|
readonly attachments: () => AttachmentStore | undefined;
|
|
14
12
|
/** 诊断。 */
|
package/lib/types/config.d.ts
CHANGED
|
@@ -28,8 +28,6 @@ export interface Config {
|
|
|
28
28
|
* Chat Completions)`)。
|
|
29
29
|
*/
|
|
30
30
|
routePrefix?: string;
|
|
31
|
-
/** 按请求解析的凭据引用;未设置时按协议带占位请求头。 */
|
|
32
|
-
apiKeyEnv?: string;
|
|
33
31
|
/** 每条路由的请求都会带上的额外请求头;它们优先于占位凭据。 */
|
|
34
32
|
headers?: Dict<string>;
|
|
35
33
|
/** 非空时,只发现这些模型 id。 */
|
|
@@ -68,7 +66,6 @@ export interface Config {
|
|
|
68
66
|
export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
|
|
69
67
|
baseUrl: z<string, string, "defined">;
|
|
70
68
|
routePrefix: z<string, string, "defined">;
|
|
71
|
-
apiKeyEnv: z<string, string, "plain">;
|
|
72
69
|
headers: z<Dict<string, string>, Dict<string, string>, "defined">;
|
|
73
70
|
enabledModelIds: z<string[], string[], "defined">;
|
|
74
71
|
modelAliases: z<Dict<string, string>, Dict<string, string>, "defined">;
|
|
@@ -101,13 +98,12 @@ export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
|
|
|
101
98
|
}>>[], "defined">;
|
|
102
99
|
modelMetadataUrl: z<string, string, "defined">;
|
|
103
100
|
images: z<"ignore" | "metadata", "ignore" | "metadata", "defined">;
|
|
104
|
-
reasoning: z<"
|
|
101
|
+
reasoning: z<"auto" | "off", "auto" | "off", "defined">;
|
|
105
102
|
sync: z<boolean, boolean, "defined">;
|
|
106
103
|
refreshIntervalMinutes: z<number, number, "defined">;
|
|
107
104
|
}>>>, NoInfer<Schemastery.ObjectT<NoInfer<{
|
|
108
105
|
baseUrl: z<string, string, "defined">;
|
|
109
106
|
routePrefix: z<string, string, "defined">;
|
|
110
|
-
apiKeyEnv: z<string, string, "plain">;
|
|
111
107
|
headers: z<Dict<string, string>, Dict<string, string>, "defined">;
|
|
112
108
|
enabledModelIds: z<string[], string[], "defined">;
|
|
113
109
|
modelAliases: z<Dict<string, string>, Dict<string, string>, "defined">;
|
|
@@ -140,7 +136,7 @@ export declare const Config: z<NoInfer<Schemastery.ObjectS<NoInfer<{
|
|
|
140
136
|
}>>[], "defined">;
|
|
141
137
|
modelMetadataUrl: z<string, string, "defined">;
|
|
142
138
|
images: z<"ignore" | "metadata", "ignore" | "metadata", "defined">;
|
|
143
|
-
reasoning: z<"
|
|
139
|
+
reasoning: z<"auto" | "off", "auto" | "off", "defined">;
|
|
144
140
|
sync: z<boolean, boolean, "defined">;
|
|
145
141
|
refreshIntervalMinutes: z<number, number, "defined">;
|
|
146
142
|
}>>>, "volatile">;
|
|
@@ -178,8 +174,6 @@ export interface ResolvedConfig {
|
|
|
178
174
|
readonly routePrefix: string;
|
|
179
175
|
/** 这一代的三条路由(短名、协议、注册键、显示名),顺序固定。 */
|
|
180
176
|
readonly routes: readonly ResolvedRoute[];
|
|
181
|
-
/** 凭据引用;未配置时为 `undefined`。 */
|
|
182
|
-
readonly apiKeyEnv: string | undefined;
|
|
183
177
|
readonly headers: Readonly<Record<string, string>>;
|
|
184
178
|
readonly enabledModelIds: readonly string[];
|
|
185
179
|
readonly modelAliases: Readonly<Record<string, string>>;
|
package/lib/types/plan.d.ts
CHANGED
|
@@ -44,8 +44,6 @@ export interface ProviderRoute {
|
|
|
44
44
|
readonly baseURL: string;
|
|
45
45
|
/** 每条请求带上的头;没有时为缺失。 */
|
|
46
46
|
readonly headers?: Readonly<Record<string, string>>;
|
|
47
|
-
/** 该路由解析凭据用的引用;没有时以占位凭据发出。 */
|
|
48
|
-
readonly apiKeyEnv?: string;
|
|
49
47
|
/** 该路由承载的模型。 */
|
|
50
48
|
readonly models: readonly ProviderModel[];
|
|
51
49
|
}
|
|
@@ -60,8 +58,6 @@ export interface RoutePlanOptions {
|
|
|
60
58
|
* 不可能与发出去的东西对不上。
|
|
61
59
|
*/
|
|
62
60
|
readonly routes: readonly ResolvedRoute[];
|
|
63
|
-
/** 凭据引用;部署配置了才有。 */
|
|
64
|
-
readonly apiKeyEnv?: string;
|
|
65
61
|
/** 额外的路由头;它们优先于占位头。 */
|
|
66
62
|
readonly headers: Readonly<Record<string, string>>;
|
|
67
63
|
/** 已配置的逐模型覆盖项,用于查询显式的推理档位。 */
|
package/lib/types/provider.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { RoutePlan } from "./plan.js";
|
|
|
2
2
|
import { RuntimeLogger } from "./runtime.js";
|
|
3
3
|
import { LlmRuntime } from "@deepseek-ai/dsh-llm";
|
|
4
4
|
import { AttachmentStore } from "@deepseek-ai/dsh-attachment";
|
|
5
|
-
import { CredentialProvider } from "@deepseek-ai/dsh-credentials";
|
|
6
5
|
//#region src/provider.d.ts
|
|
7
6
|
/** 一次发布的结果。 */
|
|
8
7
|
export interface PublishOutcome {
|
|
@@ -15,8 +14,6 @@ export interface PublishOutcome {
|
|
|
15
14
|
export interface ProviderDeps {
|
|
16
15
|
/** LLM 服务。 */
|
|
17
16
|
readonly llm: LlmRuntime;
|
|
18
|
-
/** 凭据服务;未挂载时为缺失。 */
|
|
19
|
-
readonly credentials: () => CredentialProvider | undefined;
|
|
20
17
|
/** 附件服务;没有它的部署里图片不可转换。 */
|
|
21
18
|
readonly attachments: () => AttachmentStore | undefined;
|
|
22
19
|
/** 诊断。 */
|
|
@@ -73,12 +70,5 @@ export declare class ApertureProvider {
|
|
|
73
70
|
private registerDirectory;
|
|
74
71
|
/** 给用户看的冲突说明:点名被占用的键,并说清要手工做什么。 */
|
|
75
72
|
private conflictReason;
|
|
76
|
-
/**
|
|
77
|
-
* 解析一条路由的凭据。
|
|
78
|
-
*
|
|
79
|
-
* 配置了 `apiKeyEnv` 就**必须**解析出可用的值:那是一个明确的声明,悄悄退回占位凭据会让
|
|
80
|
-
* 一次配错了密钥的部署看起来像一次网关拒绝。
|
|
81
|
-
*/
|
|
82
|
-
private resolveApiKey;
|
|
83
73
|
}
|
|
84
74
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-aperture",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "自动发现 Aperture 网关上的模型,并加进 DSH 的模型选择器。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@11.7.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": "^22.19.0 || >=24.0.0",
|
|
60
|
-
"dsh": "^0.
|
|
60
|
+
"dsh": "^0.2.3-alpha.2"
|
|
61
61
|
},
|
|
62
62
|
"dsh": {
|
|
63
63
|
"bundle": {
|
|
@@ -77,49 +77,47 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"peerDependencies": {
|
|
80
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
81
|
-
"@deepseek-ai/cordis-plugin-loader": "^1.0.
|
|
82
|
-
"@deepseek-ai/dsh-attachment": "^0.
|
|
83
|
-
"@deepseek-ai/dsh-client-ui-primitives": "^0.
|
|
84
|
-
"@deepseek-ai/dsh-client-ui-settings-models": "^0.
|
|
85
|
-
"@deepseek-ai/dsh-
|
|
86
|
-
"@deepseek-ai/dsh-
|
|
87
|
-
"@deepseek-ai/dsh-
|
|
88
|
-
"@deepseek-ai/dsh-
|
|
89
|
-
"@deepseek-ai/
|
|
90
|
-
"@deepseek-ai/schemastery": "^3.18.4"
|
|
80
|
+
"@deepseek-ai/cordis": "^4.2.0-alpha.1",
|
|
81
|
+
"@deepseek-ai/cordis-plugin-loader": "^1.2.0-alpha.1",
|
|
82
|
+
"@deepseek-ai/dsh-attachment": "^0.2.3-alpha.2",
|
|
83
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.2.3-alpha.2",
|
|
84
|
+
"@deepseek-ai/dsh-client-ui-settings-models": "^0.2.3-alpha.2",
|
|
85
|
+
"@deepseek-ai/dsh-llm": "^0.2.3-alpha.2",
|
|
86
|
+
"@deepseek-ai/dsh-settings": "^0.2.3-alpha.2",
|
|
87
|
+
"@deepseek-ai/dsh-timeout": "^0.2.3-alpha.2",
|
|
88
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.2.3-alpha.2",
|
|
89
|
+
"@deepseek-ai/schemastery": "^3.20.0-alpha.1"
|
|
91
90
|
},
|
|
92
91
|
"devDependencies": {
|
|
93
|
-
"@deepseek-ai/cordis": "4.0.
|
|
94
|
-
"@deepseek-ai/cordis-plugin-loader": "1.0.
|
|
95
|
-
"@deepseek-ai/cosmokit": "1.
|
|
96
|
-
"@deepseek-ai/dsh-api-gateway": "0.2.
|
|
97
|
-
"@deepseek-ai/dsh-api-remotes": "0.2.
|
|
98
|
-
"@deepseek-ai/dsh-app-boot": "0.2.
|
|
99
|
-
"@deepseek-ai/dsh-attachment": "0.2.
|
|
100
|
-
"@deepseek-ai/dsh-client-locale": "0.2.
|
|
101
|
-
"@deepseek-ai/dsh-client-store": "0.2.
|
|
102
|
-
"@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.
|
|
103
|
-
"@deepseek-ai/dsh-client-ui-primitives": "0.2.
|
|
104
|
-
"@deepseek-ai/dsh-client-ui-renderer": "0.2.
|
|
105
|
-
"@deepseek-ai/dsh-client-ui-settings": "0.2.
|
|
106
|
-
"@deepseek-ai/dsh-client-ui-settings-models": "0.2.
|
|
107
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.
|
|
108
|
-
"@deepseek-ai/dsh-config-editor": "0.2.
|
|
109
|
-
"@deepseek-ai/dsh-
|
|
110
|
-
"@deepseek-ai/dsh-llm": "0.2.
|
|
111
|
-
"@deepseek-ai/dsh-
|
|
112
|
-
"@deepseek-ai/dsh-
|
|
113
|
-
"@deepseek-ai/dsh-
|
|
114
|
-
"@deepseek-ai/dsh-typert-
|
|
115
|
-
"@deepseek-ai/
|
|
116
|
-
"@deepseek-ai/schemastery": "3.18.4",
|
|
92
|
+
"@deepseek-ai/cordis": "4.2.0-alpha.1",
|
|
93
|
+
"@deepseek-ai/cordis-plugin-loader": "1.2.0-alpha.1",
|
|
94
|
+
"@deepseek-ai/cosmokit": "1.10.0-alpha.1",
|
|
95
|
+
"@deepseek-ai/dsh-api-gateway": "0.2.3-alpha.2",
|
|
96
|
+
"@deepseek-ai/dsh-api-remotes": "0.2.3-alpha.2",
|
|
97
|
+
"@deepseek-ai/dsh-app-boot": "0.2.3-alpha.2",
|
|
98
|
+
"@deepseek-ai/dsh-attachment": "0.2.3-alpha.2",
|
|
99
|
+
"@deepseek-ai/dsh-client-locale": "0.2.3-alpha.2",
|
|
100
|
+
"@deepseek-ai/dsh-client-store": "0.2.3-alpha.2",
|
|
101
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager": "0.2.3-alpha.2",
|
|
102
|
+
"@deepseek-ai/dsh-client-ui-primitives": "0.2.3-alpha.2",
|
|
103
|
+
"@deepseek-ai/dsh-client-ui-renderer": "0.2.3-alpha.2",
|
|
104
|
+
"@deepseek-ai/dsh-client-ui-settings": "0.2.3-alpha.2",
|
|
105
|
+
"@deepseek-ai/dsh-client-ui-settings-models": "0.2.3-alpha.2",
|
|
106
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.3-alpha.2",
|
|
107
|
+
"@deepseek-ai/dsh-config-editor": "0.2.3-alpha.2",
|
|
108
|
+
"@deepseek-ai/dsh-llm": "0.2.3-alpha.2",
|
|
109
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.2.3-alpha.2",
|
|
110
|
+
"@deepseek-ai/dsh-settings": "0.2.3-alpha.2",
|
|
111
|
+
"@deepseek-ai/dsh-timeout": "0.2.3-alpha.2",
|
|
112
|
+
"@deepseek-ai/dsh-typert-protocol": "0.2.3-alpha.2",
|
|
113
|
+
"@deepseek-ai/dsh-typert-registry": "0.2.3-alpha.2",
|
|
114
|
+
"@deepseek-ai/schemastery": "3.20.0-alpha.1",
|
|
117
115
|
"@types/node": "^22.20.0",
|
|
118
116
|
"@types/react": "^18.3.12",
|
|
119
117
|
"tsdown": "^0.23.0",
|
|
120
118
|
"typescript": "^5.9.0"
|
|
121
119
|
},
|
|
122
120
|
"dependencies": {
|
|
123
|
-
"@earendil-works/pi-ai": "^0.
|
|
121
|
+
"@earendil-works/pi-ai": "^1.0.2"
|
|
124
122
|
}
|
|
125
123
|
}
|