dsh-aperture 0.2.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/README.en.md +93 -120
- package/README.md +83 -121
- package/client/aperture.js +1175 -1131
- package/cordis.patch.yml +33 -44
- package/icon.svg +125 -0
- package/lib/aperture.d.ts +6 -8
- package/lib/aperture.js +6 -8
- package/lib/catalog.d.ts +0 -2
- package/lib/catalog.js +0 -4
- package/lib/config.d.ts +106 -89
- package/lib/config.js +79 -37
- package/lib/index.d.ts +28 -31
- package/lib/index.js +46 -52
- package/lib/metadata/extract.d.ts +7 -13
- package/lib/metadata/extract.js +7 -25
- package/lib/metadata/modelsdev.d.ts +9 -11
- package/lib/metadata/modelsdev.js +21 -23
- package/lib/metadata/utils.d.ts +0 -2
- package/lib/metadata/utils.js +0 -14
- package/lib/panel.d.ts +29 -56
- package/lib/panel.js +83 -91
- package/lib/profile.d.ts +5 -13
- package/lib/profile.js +25 -28
- package/lib/registry.d.ts +10 -15
- package/lib/registry.js +23 -21
- package/lib/remote.d.ts +14 -29
- package/lib/remote.js +13 -37
- package/lib/report.d.ts +24 -19
- package/lib/report.js +21 -29
- package/lib/runtime.d.ts +18 -12
- package/lib/runtime.js +40 -32
- package/lib/sync.d.ts +12 -25
- package/lib/sync.js +41 -55
- package/lib/types.d.ts +3 -5
- package/lib/types.js +3 -3
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +24 -16
- package/lib/namespaces.d.ts +0 -12
- package/lib/namespaces.js +0 -12
package/lib/sync.js
CHANGED
|
@@ -1,25 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 写入阶段:把方案发布到 `llm-pi-ai` 配置段。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* 别的东西,就必须重新实现一套协议格式,而本插件之所以存在,正是因为不必如此。
|
|
4
|
+
* 该配置段属于另一个插件(`@deepseek-ai/dsh-llm-pi-ai`),而设置接缝不做归属检查,因此
|
|
5
|
+
* 写入它是被允许的,也是被认可的机制而非变通:宿主把 pi-ai 适配器组合为休眠状态,并声明
|
|
6
|
+
* 「哪些 provider 运行由用户的设置文档决定」。
|
|
8
7
|
*
|
|
9
|
-
*
|
|
8
|
+
* 三条性质使这一写入可以安全重复:没有变化时是空操作(比较对象是**已解析的**配置段,因此
|
|
9
|
+
* 部署自身的组合层不算漂移);只写入本插件拥有的路由键,且用路径寻址的 op,配置段里其他
|
|
10
|
+
* provider 原样保留;绝不在发现失败后运行——瞬时网络错误下删除可用模型比什么都不做更糟。
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
|
|
12
|
+
* @module dsh-aperture/sync
|
|
13
|
+
*/
|
|
14
|
+
/** pi-ai 适配器注册的设置命名空间,也是本插件写入的那一个。 */
|
|
15
|
+
export const PI_AI_NAMESPACE = 'llm-pi-ai';
|
|
16
|
+
/**
|
|
17
|
+
* 找一个 entry 的 descriptor。
|
|
13
18
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
19
|
+
* 设置接缝没有「按命名空间取值」这种读法:`describe()` 是唯一入口,它按 Loader 里的 entry
|
|
20
|
+
* 逐个报告(`ns` 就是 entry id)。目标 entry 不存在时(比如 pi-ai 适配器没挂载)读不到。
|
|
16
21
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
22
|
+
* @param settings - 设置服务。
|
|
23
|
+
* @param ns - 目标 entry id。
|
|
24
|
+
* @returns 该 entry 的 descriptor;没有这个 entry 时为 `undefined`。
|
|
25
|
+
*/
|
|
26
|
+
function sectionDescriptor(settings, ns) {
|
|
27
|
+
try {
|
|
28
|
+
return settings.describe().find((descriptor) => descriptor.ns === ns);
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
// describe() 会为每个 entry 跑一遍解析,某个 entry 自己坏掉时它会抛。这里把「读不到」
|
|
32
|
+
// 与「不存在」一视同仁:调用方拿到 undefined,照常得出「未注册」的结论。
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 读一个 entry 的生效值。
|
|
19
38
|
*
|
|
20
|
-
* @
|
|
39
|
+
* @param settings - 设置服务。
|
|
40
|
+
* @param ns - 目标 entry id。
|
|
41
|
+
* @returns 该 entry 的生效值(深冻结快照);没有这个 entry 时为 `undefined`。
|
|
21
42
|
*/
|
|
22
|
-
|
|
43
|
+
function sectionValue(settings, ns) {
|
|
44
|
+
return sectionDescriptor(settings, ns)?.value;
|
|
45
|
+
}
|
|
23
46
|
/**
|
|
24
47
|
* 计算使某个配置段与方案一致的路径 op。
|
|
25
48
|
*
|
|
@@ -62,7 +85,7 @@ export function planSync(current, routes, ownedRoutes) {
|
|
|
62
85
|
* @returns 发生了什么;未写入任何内容时包含原因。
|
|
63
86
|
*/
|
|
64
87
|
export async function applySync(settings, routes, ownedRoutes) {
|
|
65
|
-
const current = settings
|
|
88
|
+
const current = sectionValue(settings, PI_AI_NAMESPACE);
|
|
66
89
|
if (current === undefined) {
|
|
67
90
|
return {
|
|
68
91
|
applied: false,
|
|
@@ -88,7 +111,7 @@ export async function applySync(settings, routes, ownedRoutes) {
|
|
|
88
111
|
if (!isConflict(error)) {
|
|
89
112
|
throw error;
|
|
90
113
|
}
|
|
91
|
-
const retryOps = planSync(settings
|
|
114
|
+
const retryOps = planSync(sectionValue(settings, PI_AI_NAMESPACE), routes, ownedRoutes);
|
|
92
115
|
if (retryOps.length === 0) {
|
|
93
116
|
return { applied: false, ops: 0, routes: routes.map((route) => route.provider), reason: '已处于同步状态' };
|
|
94
117
|
}
|
|
@@ -96,38 +119,6 @@ export async function applySync(settings, routes, ownedRoutes) {
|
|
|
96
119
|
}
|
|
97
120
|
return { applied: true, ops: ops.length, routes: routes.map((route) => route.provider) };
|
|
98
121
|
}
|
|
99
|
-
/**
|
|
100
|
-
* 从配置段中撤出本插件拥有的每条路由。
|
|
101
|
-
* @param settings - 设置服务。
|
|
102
|
-
* @param ownedRoutes - 要移除的路由键。
|
|
103
|
-
* @returns 发生了什么。
|
|
104
|
-
*/
|
|
105
|
-
export async function clearRoutes(settings, ownedRoutes) {
|
|
106
|
-
const current = settings.get(PI_AI_NAMESPACE);
|
|
107
|
-
if (current === undefined) {
|
|
108
|
-
return {
|
|
109
|
-
applied: false,
|
|
110
|
-
ops: 0,
|
|
111
|
-
routes: [],
|
|
112
|
-
reason: `设置命名空间 "${PI_AI_NAMESPACE}" 未注册`,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
const providers = readProviders(current);
|
|
116
|
-
if (providers === undefined) {
|
|
117
|
-
return { applied: false, ops: 0, routes: [], reason: `"${PI_AI_NAMESPACE}" 配置段不是 provider 字典` };
|
|
118
|
-
}
|
|
119
|
-
const ops = [];
|
|
120
|
-
for (const provider of ownedRoutes) {
|
|
121
|
-
if (provider in providers) {
|
|
122
|
-
ops.push({ op: 'unset', path: ['providers', provider] });
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
if (ops.length === 0) {
|
|
126
|
-
return { applied: false, ops: 0, routes: [], reason: '没有需要移除的路由' };
|
|
127
|
-
}
|
|
128
|
-
await settings.mutate(PI_AI_NAMESPACE, ops, currentRevision(settings));
|
|
129
|
-
return { applied: true, ops: ops.length, routes: [] };
|
|
130
|
-
}
|
|
131
122
|
/** 从已解析的配置段值中读出 provider 字典。 */
|
|
132
123
|
function readProviders(current) {
|
|
133
124
|
if (current === null || typeof current !== 'object') {
|
|
@@ -145,12 +136,7 @@ function readProviders(current) {
|
|
|
145
136
|
}
|
|
146
137
|
/** pi-ai 配置段的当前版本号;provider 未暴露时为空。 */
|
|
147
138
|
function currentRevision(settings) {
|
|
148
|
-
|
|
149
|
-
return settings.describe().find((descriptor) => descriptor.ns === PI_AI_NAMESPACE)?.revision;
|
|
150
|
-
}
|
|
151
|
-
catch {
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
139
|
+
return sectionDescriptor(settings, PI_AI_NAMESPACE)?.revision;
|
|
154
140
|
}
|
|
155
141
|
/** 判断某个可抛出对象是否为设置接缝的陈旧版本号冲突。 */
|
|
156
142
|
function isConflict(error) {
|
|
@@ -159,8 +145,8 @@ function isConflict(error) {
|
|
|
159
145
|
/**
|
|
160
146
|
* 结构化 JSON 相等性。
|
|
161
147
|
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
148
|
+
* 之所以自己写而不导入,是因为这里比较的值恰好都是 JSON:本插件生成的 profile,以及设置
|
|
149
|
+
* 接缝从文档里解析回来的 profile。键顺序不属于这种同一性,因此被归一化掉。
|
|
164
150
|
*
|
|
165
151
|
* @param left - 一个 JSON 值。
|
|
166
152
|
* @param right - 另一个。
|
package/lib/types.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Aperture 发现流水线的共享词汇表。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 该流水线是一条纯函数链——端点响应进,provider profile 出——因此每个阶段都在这里
|
|
5
|
+
* 命名自己的类型,而不去碰 Cordis 或设置的接缝:只有 `src/index.ts` 和 `src/sync.ts`
|
|
6
|
+
* 会接触服务。
|
|
7
7
|
*
|
|
8
8
|
* @module dsh-aperture/types
|
|
9
9
|
*/
|
|
@@ -90,8 +90,6 @@ export interface BuildOptions {
|
|
|
90
90
|
* 的服务为 `k3`,任何评分规则都无法在不猜测的情况下弥合这一差异。
|
|
91
91
|
*/
|
|
92
92
|
readonly modelAliases: Readonly<Record<string, string>>;
|
|
93
|
-
/** 没有任何来源设定容量的模型的兜底上下文容量。 */
|
|
94
|
-
readonly defaultContextWindow: number;
|
|
95
93
|
/** 是否采纳 models.dev 的输入模态(图像)。 */
|
|
96
94
|
readonly images: 'ignore' | 'metadata';
|
|
97
95
|
/** `auto` 映射推理能力;`off` 把每个模型都声明为非推理。 */
|
package/lib/types.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Aperture 发现流水线的共享词汇表。
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* 该流水线是一条纯函数链——端点响应进,provider profile 出——因此每个阶段都在这里
|
|
5
|
+
* 命名自己的类型,而不去碰 Cordis 或设置的接缝:只有 `src/index.ts` 和 `src/sync.ts`
|
|
6
|
+
* 会接触服务。
|
|
7
7
|
*
|
|
8
8
|
* @module dsh-aperture/types
|
|
9
9
|
*/
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-aperture",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "自动发现 Aperture 网关上的模型,并加进 DSH 的模型选择器。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
8
|
+
"icon": "./icon.svg",
|
|
8
9
|
"exports": {
|
|
9
10
|
".": {
|
|
10
11
|
"types": "./lib/index.d.ts",
|
|
11
12
|
"default": "./lib/index.js"
|
|
12
13
|
},
|
|
13
14
|
"./client": "./client/aperture.js",
|
|
15
|
+
"./locale/*.json": "./locale/*.json",
|
|
14
16
|
"./package.json": "./package.json",
|
|
15
17
|
"./cordis.patch.yml": "./cordis.patch.yml"
|
|
16
18
|
},
|
|
17
19
|
"files": [
|
|
18
20
|
"lib",
|
|
19
21
|
"client",
|
|
22
|
+
"locale/*.json",
|
|
23
|
+
"icon.svg",
|
|
20
24
|
"cordis.patch.yml",
|
|
21
25
|
"README.md",
|
|
22
26
|
"README.en.md",
|
|
@@ -56,26 +60,30 @@
|
|
|
56
60
|
"platform": "web",
|
|
57
61
|
"inject": [
|
|
58
62
|
"@deepseek-ai/dsh-client-locale",
|
|
59
|
-
"@deepseek-ai/dsh-client-
|
|
60
|
-
"@deepseek-ai/dsh-client-ui-settings"
|
|
63
|
+
"@deepseek-ai/dsh-client-ui-primitives",
|
|
64
|
+
"@deepseek-ai/dsh-client-ui-settings",
|
|
65
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager"
|
|
61
66
|
]
|
|
62
67
|
}
|
|
63
68
|
},
|
|
64
69
|
"peerDependencies": {
|
|
65
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
66
|
-
"@deepseek-ai/
|
|
67
|
-
"@deepseek-ai/dsh-
|
|
68
|
-
"@deepseek-ai/
|
|
70
|
+
"@deepseek-ai/cordis": "^4.0.4",
|
|
71
|
+
"@deepseek-ai/cordis-plugin-loader": "^1.0.5",
|
|
72
|
+
"@deepseek-ai/dsh-settings": "^0.1.7-rc.1",
|
|
73
|
+
"@deepseek-ai/dsh-typert-protocol": "^0.1.7-rc.1",
|
|
74
|
+
"@deepseek-ai/schemastery": "^3.18.4"
|
|
69
75
|
},
|
|
70
76
|
"devDependencies": {
|
|
71
|
-
"@deepseek-ai/cordis": "4.0.
|
|
72
|
-
"@deepseek-ai/
|
|
73
|
-
"@deepseek-ai/dsh-
|
|
74
|
-
"@deepseek-ai/dsh-
|
|
75
|
-
"@deepseek-ai/dsh-
|
|
76
|
-
"@deepseek-ai/dsh-
|
|
77
|
-
"@deepseek-ai/dsh-
|
|
78
|
-
"@deepseek-ai/
|
|
77
|
+
"@deepseek-ai/cordis": "4.0.4",
|
|
78
|
+
"@deepseek-ai/cordis-plugin-loader": "1.0.5",
|
|
79
|
+
"@deepseek-ai/dsh-app-boot": "0.1.7-rc.1",
|
|
80
|
+
"@deepseek-ai/dsh-config-editor": "0.1.7-rc.1",
|
|
81
|
+
"@deepseek-ai/dsh-llm": "0.1.7-rc.1",
|
|
82
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.1.7-rc.1",
|
|
83
|
+
"@deepseek-ai/dsh-settings": "0.1.7-rc.1",
|
|
84
|
+
"@deepseek-ai/dsh-typert-protocol": "0.1.7-rc.1",
|
|
85
|
+
"@deepseek-ai/dsh-typert-registry": "0.1.7-rc.1",
|
|
86
|
+
"@deepseek-ai/schemastery": "3.18.4",
|
|
79
87
|
"@types/node": "^22.20.0",
|
|
80
88
|
"typescript": "^5.9.0"
|
|
81
89
|
}
|
package/lib/namespaces.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 本插件夹在中间的两个设置命名空间。
|
|
3
|
-
*
|
|
4
|
-
* 从 `config.ts` 里分出来,是为了让发布路径不依赖配置 schema——也让这条纯函数
|
|
5
|
-
* 流水线能在不加载 schema 库的情况下被测试。
|
|
6
|
-
*
|
|
7
|
-
* @module dsh-aperture/namespaces
|
|
8
|
-
*/
|
|
9
|
-
/** 本插件拥有、并可通过它配置的设置命名空间。 */
|
|
10
|
-
export declare const APERTURE_NAMESPACE = "aperture";
|
|
11
|
-
/** pi-ai 适配器注册的设置命名空间,也是本插件写入的那一个。 */
|
|
12
|
-
export declare const PI_AI_NAMESPACE = "llm-pi-ai";
|
package/lib/namespaces.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 本插件夹在中间的两个设置命名空间。
|
|
3
|
-
*
|
|
4
|
-
* 从 `config.ts` 里分出来,是为了让发布路径不依赖配置 schema——也让这条纯函数
|
|
5
|
-
* 流水线能在不加载 schema 库的情况下被测试。
|
|
6
|
-
*
|
|
7
|
-
* @module dsh-aperture/namespaces
|
|
8
|
-
*/
|
|
9
|
-
/** 本插件拥有、并可通过它配置的设置命名空间。 */
|
|
10
|
-
export const APERTURE_NAMESPACE = 'aperture';
|
|
11
|
-
/** pi-ai 适配器注册的设置命名空间,也是本插件写入的那一个。 */
|
|
12
|
-
export const PI_AI_NAMESPACE = 'llm-pi-ai';
|