dsh-aperture 0.1.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 -0
- package/README.en.md +316 -0
- package/README.md +303 -0
- package/cordis.patch.yml +48 -0
- package/lib/aperture.d.ts +48 -0
- package/lib/aperture.js +109 -0
- package/lib/catalog.d.ts +37 -0
- package/lib/catalog.js +78 -0
- package/lib/command.d.ts +21 -0
- package/lib/command.js +58 -0
- package/lib/config.d.ts +197 -0
- package/lib/config.js +126 -0
- package/lib/index.d.ts +64 -0
- package/lib/index.js +122 -0
- package/lib/metadata/extract.d.ts +62 -0
- package/lib/metadata/extract.js +235 -0
- package/lib/metadata/modelsdev.d.ts +55 -0
- package/lib/metadata/modelsdev.js +304 -0
- package/lib/metadata/utils.d.ts +29 -0
- package/lib/metadata/utils.js +100 -0
- package/lib/namespaces.d.ts +12 -0
- package/lib/namespaces.js +12 -0
- package/lib/profile.d.ts +70 -0
- package/lib/profile.js +161 -0
- package/lib/registry.d.ts +57 -0
- package/lib/registry.js +246 -0
- package/lib/report.d.ts +16 -0
- package/lib/report.js +89 -0
- package/lib/runtime.d.ts +96 -0
- package/lib/runtime.js +203 -0
- package/lib/sync.d.ts +71 -0
- package/lib/sync.js +190 -0
- package/lib/types.d.ts +118 -0
- package/lib/types.js +10 -0
- package/lib/url.d.ts +37 -0
- package/lib/url.js +67 -0
- package/package.json +71 -0
package/lib/url.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 单个 Aperture 实例的 URL 归一化。
|
|
3
|
+
*
|
|
4
|
+
* 配置里给的是实例根地址——`https://ai.example.ts.net`——本插件与 pi-ai 适配器
|
|
5
|
+
* 访问的每个端点都由它推导出来。结尾的 `/v1` 会被容忍并剥掉,而不是报错:VS Code
|
|
6
|
+
* 那个参考实现用的是相反的习惯,带着这种习惯过来的用户不该撞上 `/v1/v1`。
|
|
7
|
+
*
|
|
8
|
+
* @module dsh-aperture/url
|
|
9
|
+
*/
|
|
10
|
+
/** 去掉 URL 字符串结尾的所有正斜杠。 */
|
|
11
|
+
function stripTrailingSlashes(value) {
|
|
12
|
+
return value.replace(/\/+$/u, '');
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 归一化配置里的实例根地址;若没有一个可用,则报告这一点。
|
|
16
|
+
*
|
|
17
|
+
* 只给主机名时按 HTTPS 假定,查询串与片段被丢弃,结尾的 `/v1`(连同任意多个
|
|
18
|
+
* 结尾斜杠)被去掉,这样调用方永远从实例根地址开始拼路径。
|
|
19
|
+
*
|
|
20
|
+
* @param raw - 原样保留的配置值。
|
|
21
|
+
* @returns 去掉结尾斜杠的归一化根地址;当值为空、或不是绝对的 HTTP(S) URL 时
|
|
22
|
+
* 返回 `undefined`。
|
|
23
|
+
*/
|
|
24
|
+
export function normalizeBaseUrl(raw) {
|
|
25
|
+
const trimmed = raw?.trim();
|
|
26
|
+
if (!trimmed) {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const withScheme = /^[a-z][a-z\d+\-.]*:\/\//iu.test(trimmed) ? trimmed : `https://${trimmed}`;
|
|
30
|
+
let url;
|
|
31
|
+
try {
|
|
32
|
+
url = new URL(withScheme);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
if (url.protocol !== 'http:' && url.protocol !== 'https:') {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
url.hash = '';
|
|
41
|
+
url.search = '';
|
|
42
|
+
const path = stripTrailingSlashes(url.pathname).replace(/\/v1$/u, '');
|
|
43
|
+
url.pathname = path || '/';
|
|
44
|
+
return stripTrailingSlashes(url.toString());
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 列出某个实例所服务模型的端点。
|
|
48
|
+
* @param instanceRoot - 归一化后的实例根地址。
|
|
49
|
+
* @returns 绝对地址的模型清单 URL。
|
|
50
|
+
*/
|
|
51
|
+
export function buildModelsEndpoint(instanceRoot) {
|
|
52
|
+
return `${stripTrailingSlashes(instanceRoot)}/v1/models`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 某种协议下,一条 pi-ai 路由必须携带的 `baseURL`。
|
|
56
|
+
*
|
|
57
|
+
* `openai-completions` 会在路由的 `baseURL` 后面追加 `/chat/completions`,所以它
|
|
58
|
+
* 拿到的是带 `/v1` 的根地址;`anthropic-messages` 走 provider SDK,SDK 自己会追加
|
|
59
|
+
* `/v1/messages`,所以它拿到的是裸的实例根地址。
|
|
60
|
+
* @param instanceRoot - 归一化后的实例根地址。
|
|
61
|
+
* @param protocol - 该路由的协议格式。
|
|
62
|
+
* @returns 该路由的 `baseURL`。
|
|
63
|
+
*/
|
|
64
|
+
export function buildRouteBaseUrl(instanceRoot, protocol) {
|
|
65
|
+
const root = stripTrailingSlashes(instanceRoot);
|
|
66
|
+
return protocol === 'openai-completions' ? `${root}/v1` : root;
|
|
67
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dsh-aperture",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Discover the models an Aperture gateway advertises and publish them to DeepSeek Harness as llm-pi-ai provider routes. 探测 Aperture 网关暴露的模型,并自动写入 DSH 的 llm-pi-ai 设置,使其出现在模型选择器中。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"lib",
|
|
18
|
+
"cordis.patch.yml",
|
|
19
|
+
"README.md",
|
|
20
|
+
"README.en.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc -p tsconfig.json",
|
|
25
|
+
"prepare": "tsc -p tsconfig.json",
|
|
26
|
+
"typecheck": "tsc -p tsconfig.test.json",
|
|
27
|
+
"test": "node --test --test-isolation=none \"test/**/*.test.ts\"",
|
|
28
|
+
"test:live": "node --test --test-isolation=none test/live.test.ts",
|
|
29
|
+
"inspect": "node scripts/inspect-live.mjs"
|
|
30
|
+
},
|
|
31
|
+
"keywords": [
|
|
32
|
+
"dsh",
|
|
33
|
+
"dsh-plugin",
|
|
34
|
+
"deepseek-harness",
|
|
35
|
+
"aperture",
|
|
36
|
+
"tailscale",
|
|
37
|
+
"llm",
|
|
38
|
+
"model-discovery"
|
|
39
|
+
],
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"author": "uy/sun",
|
|
42
|
+
"repository": {
|
|
43
|
+
"type": "git",
|
|
44
|
+
"url": "git+https://github.com/he0119/dsh-aperture.git"
|
|
45
|
+
},
|
|
46
|
+
"engines": {
|
|
47
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
48
|
+
},
|
|
49
|
+
"dsh": {
|
|
50
|
+
"bundle": {
|
|
51
|
+
"patch": "./cordis.patch.yml"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
56
|
+
"@deepseek-ai/dsh-commands": "^0.1.5-rc.2",
|
|
57
|
+
"@deepseek-ai/dsh-settings": "^0.1.5-rc.2",
|
|
58
|
+
"@deepseek-ai/schemastery": "^3.18.2"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@deepseek-ai/cordis": "4.0.2",
|
|
62
|
+
"@deepseek-ai/dsh-commands": "0.1.5-rc.2",
|
|
63
|
+
"@deepseek-ai/dsh-llm": "0.1.5-rc.2",
|
|
64
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.1.5-rc.2",
|
|
65
|
+
"@deepseek-ai/dsh-settings": "0.1.5-rc.2",
|
|
66
|
+
"@deepseek-ai/dsh-settings-file": "^0.1.5-rc.2",
|
|
67
|
+
"@deepseek-ai/schemastery": "3.18.2",
|
|
68
|
+
"@types/node": "^22.20.0",
|
|
69
|
+
"typescript": "^5.9.0"
|
|
70
|
+
}
|
|
71
|
+
}
|