@dsh-plus/llm-pi 0.1.16 → 0.1.17
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/lib/client.js +4 -3
- package/lib/index.d.ts +2 -2
- package/lib/index.js +34 -34
- package/package.json +32 -30
- package/src/catalog/models-dev.ts +1 -6
- package/src/client/client.ts +1 -1
- package/src/compat.ts +2 -2
- package/src/config.ts +2 -3
- package/src/deepseek-routes.ts +3 -3
- package/src/ns.ts +4 -3
- package/src/profiles.ts +1 -1
- package/src/resolve-dsh.ts +2 -2
- package/src/service.ts +34 -29
package/lib/client.js
CHANGED
|
@@ -385,9 +385,10 @@ ${extra}
|
|
|
385
385
|
//#region src/ns.ts
|
|
386
386
|
/**
|
|
387
387
|
* settings 命名空间字面量(纯常量,零依赖,浏览器半可安全引入)。
|
|
388
|
-
*
|
|
389
|
-
* settings.plugin.item keyed 槽位的
|
|
390
|
-
*
|
|
388
|
+
* 服务端直接以字面量注册(0.1.2-alpha.2 起 dsh-settings 对命名空间做编译期
|
|
389
|
+
* 语法校验,见 config.ts),浏览器半将其作为 settings.plugin.item keyed 槽位的
|
|
390
|
+
* key —— 同一字面量两处共用,防止漂移。
|
|
391
|
+
* 契约:该槽位按「卡片编辑的 settings 命名空间」作 key 分发,
|
|
391
392
|
* 官方配置页只渲染 key 命中 Host 已注册命名空间的卡片。
|
|
392
393
|
* @module llm-pi/ns
|
|
393
394
|
*/
|
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
3
|
//#region src/config.d.ts
|
|
4
|
-
/** settings
|
|
5
|
-
declare const SETTINGS_NS
|
|
4
|
+
/** settings 命名空间(字面量即合法命名空间,0.1.2-alpha.2 起编译期校验;webui 配置卡片与插件运行期读取同一份)。 */
|
|
5
|
+
declare const SETTINGS_NS = "dsh-plus-llm-pi";
|
|
6
6
|
/** 本插件可为手写 route 提供的协议实现(与官方 PROTOCOLS 表一致)。 */
|
|
7
7
|
declare const PROTOCOL_IDS: readonly ["openai-completions", "openai-responses", "anthropic-messages"];
|
|
8
8
|
type ProtocolId = (typeof PROTOCOL_IDS)[number];
|
package/lib/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { deepEqualJson, installSettingsSection, settingsNamespace } from "@deepseek-ai/dsh-settings";
|
|
2
1
|
import z from "@deepseek-ai/schemastery";
|
|
3
2
|
import { dshHomePath } from "@deepseek-ai/dsh-home-paths";
|
|
4
3
|
import { launchEnvironmentOf } from "@deepseek-ai/dsh-launch-environment";
|
|
4
|
+
import { deepEqualJson } from "@deepseek-ai/dsh-util-values";
|
|
5
5
|
import { existsSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { request } from "node:http";
|
|
7
7
|
import { request as request$1 } from "node:https";
|
|
8
8
|
import { dirname, join, resolve } from "node:path";
|
|
9
|
-
import
|
|
9
|
+
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
10
10
|
import { credentialKeyId, credentialKeyScope, credentialRef, isCredentialKeySegment, isCredentialRefName } from "@deepseek-ai/dsh-credentials";
|
|
11
11
|
import { pathToFileURL } from "node:url";
|
|
12
12
|
import * as vendoredAnonId from "@deepseek-ai/dsh-anonymous-user-id";
|
|
@@ -33,8 +33,8 @@ import { homedir } from "node:os";
|
|
|
33
33
|
* - provider/model 均支持 extends 继承(见 inherit.ts)。
|
|
34
34
|
* @module llm-pi/config
|
|
35
35
|
*/
|
|
36
|
-
/** settings
|
|
37
|
-
const SETTINGS_NS =
|
|
36
|
+
/** settings 命名空间(字面量即合法命名空间,0.1.2-alpha.2 起编译期校验;webui 配置卡片与插件运行期读取同一份)。 */
|
|
37
|
+
const SETTINGS_NS = "dsh-plus-llm-pi";
|
|
38
38
|
/** 本插件可为手写 route 提供的协议实现(与官方 PROTOCOLS 表一致)。 */
|
|
39
39
|
const PROTOCOL_IDS = [
|
|
40
40
|
"openai-completions",
|
|
@@ -263,8 +263,6 @@ function registerCatalogApi(ctx, runtime) {
|
|
|
263
263
|
* 视觉等模态须用户在条目上显式声明(防 over-claiming 导致会话重复失败请求)。
|
|
264
264
|
* @module llm-pi/catalog/models-dev
|
|
265
265
|
*/
|
|
266
|
-
/** 仅 https 目标走代理(http 目标直连;代理通常只提供 CONNECT 隧道)。 */
|
|
267
|
-
const { HttpsProxyAgent } = HttpsProxyAgentModule;
|
|
268
266
|
const FETCH_TIMEOUT_MS = 2e4;
|
|
269
267
|
/** 目录文档体上限(api.json 全量约 1-2MB,放宽到 20MB 防未来膨胀)。 */
|
|
270
268
|
const MAX_RESPONSE_BYTES$1 = 20971520;
|
|
@@ -1116,7 +1114,7 @@ function buildDeepseekRoutes(providers, deps) {
|
|
|
1116
1114
|
//#endregion
|
|
1117
1115
|
//#region src/profiles.ts
|
|
1118
1116
|
/**
|
|
1119
|
-
* profile 构建器(0.1.2-alpha.
|
|
1117
|
+
* profile 构建器(0.1.2-alpha.2 复核兼容):插件 Config → 官方 schema 形状的
|
|
1120
1118
|
* 「前置数据源归一化」→ 官方 resolveProfiles(或插件等价兜底)→
|
|
1121
1119
|
* ResolvedPiAiProviderProfile。
|
|
1122
1120
|
*
|
|
@@ -1635,7 +1633,7 @@ function authContextFrom(ctx) {
|
|
|
1635
1633
|
* 两条路径产物都过形状自检(assertKitShape):上游重构导致形状漂移时
|
|
1636
1634
|
* 抛错,由调用方决定回退或放弃注册——绝不让坏套件进入消息链路。
|
|
1637
1635
|
*
|
|
1638
|
-
* 0.1.2-alpha.1
|
|
1636
|
+
* 0.1.2-alpha 线的新面(0.1.2-alpha.2 复核包根仍未导出、仅 src 子路径有):
|
|
1639
1637
|
* - resolveProfiles(config.ts):官方解析链,dev 布局树可经 src 子路径复用;
|
|
1640
1638
|
* - credentialStoreFrom/authContextFrom(auth.ts):PiAiAdapter 必需 auth 注入。
|
|
1641
1639
|
* npm 发布形态(lib/index.js 单 bundle + 无 src/)两者都拿不到:dsh 树优先
|
|
@@ -2068,33 +2066,35 @@ async function startRuntime(ctx, rawConfig) {
|
|
|
2068
2066
|
ensureRegistration();
|
|
2069
2067
|
ensureDeepseek();
|
|
2070
2068
|
ensureDirectory();
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2069
|
+
ctx.inject(["settings"], (settingsCtx) => {
|
|
2070
|
+
settingsCtx.settings.installSection(ctx, SETTINGS_NS, Config, config, {
|
|
2071
|
+
validate: (cfg) => assertServiceable(cfg, deps),
|
|
2072
|
+
setSource: (source) => {
|
|
2073
|
+
current = source;
|
|
2074
|
+
},
|
|
2075
|
+
onChange: () => {
|
|
2076
|
+
try {
|
|
2077
|
+
ensureRegistration();
|
|
2078
|
+
} catch (error) {
|
|
2079
|
+
logger.error("llm-pi: 更新被拒,保留此前注册的 route");
|
|
2080
|
+
logger.error(error);
|
|
2081
|
+
}
|
|
2082
|
+
try {
|
|
2083
|
+
ensureDeepseek();
|
|
2084
|
+
} catch (error) {
|
|
2085
|
+
logger.error("llm-pi: deepseek route 更新失败,保留此前注册");
|
|
2086
|
+
logger.error(error);
|
|
2087
|
+
}
|
|
2088
|
+
try {
|
|
2089
|
+
ensureDirectory();
|
|
2090
|
+
} catch (error) {
|
|
2091
|
+
logger.error("llm-pi: 更新被拒,保留此前的 configurable-provider 目录");
|
|
2092
|
+
logger.error(error);
|
|
2093
|
+
}
|
|
2094
|
+
const cfg = current();
|
|
2095
|
+
modelsDev.reconfigure(cfg.catalogUrl, cfg.catalogRefreshHours, cfg.catalogProxy ?? "");
|
|
2094
2096
|
}
|
|
2095
|
-
|
|
2096
|
-
modelsDev.reconfigure(cfg.catalogUrl, cfg.catalogRefreshHours, cfg.catalogProxy ?? "");
|
|
2097
|
-
}
|
|
2097
|
+
});
|
|
2098
2098
|
});
|
|
2099
2099
|
return {
|
|
2100
2100
|
currentConfig: () => current(),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-plus/llm-pi",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "dsh-plus service+ui plugin: 基于 PiAiAdapter 的自定义 LLM 路由(全量 compat、模型继承、models.dev 目录兜底)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,42 +31,44 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"https-proxy-agent": "^
|
|
35
|
-
"@dsh-plus/shared": "0.1.
|
|
34
|
+
"https-proxy-agent": "^9.1.0",
|
|
35
|
+
"@dsh-plus/shared": "0.1.7"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@deepseek-ai/cordis": "^4.0.1",
|
|
39
|
-
"@deepseek-ai/dsh-anonymous-user-id": "^0.1.2-alpha.
|
|
40
|
-
"@deepseek-ai/dsh-credentials": "^0.1.2-alpha.
|
|
41
|
-
"@deepseek-ai/dsh-home-paths": "^0.1.2-alpha.
|
|
42
|
-
"@deepseek-ai/dsh-host-webserver": "^0.1.2-alpha.
|
|
43
|
-
"@deepseek-ai/dsh-launch-environment": "^0.1.2-alpha.
|
|
44
|
-
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.
|
|
45
|
-
"@deepseek-ai/dsh-llm-deepseek": "^0.1.2-alpha.
|
|
46
|
-
"@deepseek-ai/dsh-llm-pi-ai": "^0.1.2-alpha.
|
|
47
|
-
"@deepseek-ai/dsh-settings": "^0.1.2-alpha.
|
|
39
|
+
"@deepseek-ai/dsh-anonymous-user-id": "^0.1.2-alpha.2",
|
|
40
|
+
"@deepseek-ai/dsh-credentials": "^0.1.2-alpha.2",
|
|
41
|
+
"@deepseek-ai/dsh-home-paths": "^0.1.2-alpha.2",
|
|
42
|
+
"@deepseek-ai/dsh-host-webserver": "^0.1.2-alpha.2",
|
|
43
|
+
"@deepseek-ai/dsh-launch-environment": "^0.1.2-alpha.2",
|
|
44
|
+
"@deepseek-ai/dsh-llm": "^0.1.2-alpha.2",
|
|
45
|
+
"@deepseek-ai/dsh-llm-deepseek": "^0.1.2-alpha.2",
|
|
46
|
+
"@deepseek-ai/dsh-llm-pi-ai": "^0.1.2-alpha.2",
|
|
47
|
+
"@deepseek-ai/dsh-settings": "^0.1.2-alpha.2",
|
|
48
|
+
"@deepseek-ai/dsh-util-values": "^0.1.2-alpha.2",
|
|
48
49
|
"@deepseek-ai/schemastery": "^3.18.1",
|
|
49
50
|
"@earendil-works/pi-ai": "^0.84.2"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@deepseek-ai/cordis": "4.0.
|
|
53
|
-
"@deepseek-ai/dsh-anonymous-user-id": "0.1.2-alpha.
|
|
54
|
-
"@deepseek-ai/dsh-atomic-write": "0.1.2-alpha.
|
|
55
|
-
"@deepseek-ai/dsh-attachment": "0.1.2-alpha.
|
|
56
|
-
"@deepseek-ai/dsh-credentials": "0.1.2-alpha.
|
|
57
|
-
"@deepseek-ai/dsh-home-paths": "0.1.2-alpha.
|
|
58
|
-
"@deepseek-ai/dsh-host-webserver": "0.1.2-alpha.
|
|
59
|
-
"@deepseek-ai/dsh-launch-environment": "0.1.2-alpha.
|
|
60
|
-
"@deepseek-ai/dsh-llm": "0.1.2-alpha.
|
|
61
|
-
"@deepseek-ai/dsh-llm-deepseek": "0.1.2-alpha.
|
|
62
|
-
"@deepseek-ai/dsh-llm-pi-ai": "0.1.2-alpha.
|
|
63
|
-
"@deepseek-ai/dsh-settings": "0.1.2-alpha.
|
|
64
|
-
"@deepseek-ai/dsh-timeout": "0.1.2-alpha.
|
|
65
|
-
"@deepseek-ai/dsh-typert-protocol": "0.1.2-alpha.
|
|
66
|
-
"@deepseek-ai/dsh-util-crypto": "0.1.2-alpha.
|
|
67
|
-
"@deepseek-ai/
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
53
|
+
"@deepseek-ai/cordis": "4.0.2",
|
|
54
|
+
"@deepseek-ai/dsh-anonymous-user-id": "0.1.2-alpha.2",
|
|
55
|
+
"@deepseek-ai/dsh-atomic-write": "0.1.2-alpha.2",
|
|
56
|
+
"@deepseek-ai/dsh-attachment": "0.1.2-alpha.2",
|
|
57
|
+
"@deepseek-ai/dsh-credentials": "0.1.2-alpha.2",
|
|
58
|
+
"@deepseek-ai/dsh-home-paths": "0.1.2-alpha.2",
|
|
59
|
+
"@deepseek-ai/dsh-host-webserver": "0.1.2-alpha.2",
|
|
60
|
+
"@deepseek-ai/dsh-launch-environment": "0.1.2-alpha.2",
|
|
61
|
+
"@deepseek-ai/dsh-llm": "0.1.2-alpha.2",
|
|
62
|
+
"@deepseek-ai/dsh-llm-deepseek": "0.1.2-alpha.2",
|
|
63
|
+
"@deepseek-ai/dsh-llm-pi-ai": "0.1.2-alpha.2",
|
|
64
|
+
"@deepseek-ai/dsh-settings": "0.1.2-alpha.2",
|
|
65
|
+
"@deepseek-ai/dsh-timeout": "0.1.2-alpha.2",
|
|
66
|
+
"@deepseek-ai/dsh-typert-protocol": "0.1.2-alpha.2",
|
|
67
|
+
"@deepseek-ai/dsh-util-crypto": "0.1.2-alpha.2",
|
|
68
|
+
"@deepseek-ai/dsh-util-values": "0.1.2-alpha.2",
|
|
69
|
+
"@deepseek-ai/schemastery": "3.18.2",
|
|
70
|
+
"@earendil-works/pi-ai": "0.84.4",
|
|
71
|
+
"@types/react": "~18.3.31",
|
|
70
72
|
"react": "^18.2.0"
|
|
71
73
|
},
|
|
72
74
|
"publishConfig": {
|
|
@@ -21,15 +21,10 @@ import { request as httpRequest } from 'node:http'
|
|
|
21
21
|
import { request as httpsRequest } from 'node:https'
|
|
22
22
|
import { dirname } from 'node:path'
|
|
23
23
|
|
|
24
|
-
import
|
|
24
|
+
import { HttpsProxyAgent } from 'https-proxy-agent'
|
|
25
25
|
|
|
26
26
|
import type { ModelBase } from './builtin.ts'
|
|
27
27
|
|
|
28
|
-
/** 仅 https 目标走代理(http 目标直连;代理通常只提供 CONNECT 隧道)。 */
|
|
29
|
-
const { HttpsProxyAgent } = HttpsProxyAgentModule as unknown as {
|
|
30
|
-
HttpsProxyAgent: new (proxy: string) => unknown
|
|
31
|
-
}
|
|
32
|
-
|
|
33
28
|
export interface ModelsDevStatus {
|
|
34
29
|
fetchedAt: string | null
|
|
35
30
|
providers: number
|
package/src/client/client.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 类型说明:浏览器半只用到 slots/locale/remote 的很窄一面,
|
|
7
7
|
* scope 与基础控件走 @dsh-plus/shared/client 套件(收编自本插件原实现)。
|
|
8
8
|
* 该插槽为 keyed 槽位:key 必须是卡片编辑的 settings 命名空间
|
|
9
|
-
*
|
|
9
|
+
* (即服务端注册的同一字面量,见 ../ns.ts),
|
|
10
10
|
* 官方配置页按此 key 与 Host 已注册命名空间配对分发。
|
|
11
11
|
* 配置读写经 ctx.remote.settings 直连(0.1.2-alpha.1 起 connection.api.settings
|
|
12
12
|
* 已移除;不复用 settingsScope 服务——非 loopback 页面下它固定 memory 模式无数据,
|
package/src/compat.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 逐协议 compat 门控表与校验(0.1.2-alpha.
|
|
2
|
+
* 逐协议 compat 门控表与校验(0.1.2-alpha.2 复核:官方门控表逐块一致,无需变更)。
|
|
3
3
|
*
|
|
4
|
-
* 适配决策:官方 dsh-llm-pi-ai 0.1.2-alpha.
|
|
4
|
+
* 适配决策:官方 dsh-llm-pi-ai 0.1.2-alpha.2 的 COMPAT_GATES(catalog.ts)
|
|
5
5
|
* 是 compat 可配性的唯一事实源——按协议分型(offer/withhold),withhold 字段
|
|
6
6
|
* (catalog 已为对应厂商设置,如 openRouterRouting/zaiToolStream/
|
|
7
7
|
* sendSessionAffinityHeaders/supportsToolSearch 等)写时拒绝并提示以目录
|
package/src/config.ts
CHANGED
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
* @module llm-pi/config
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import { settingsNamespace } from '@deepseek-ai/dsh-settings'
|
|
13
12
|
import z from '@deepseek-ai/schemastery'
|
|
14
13
|
|
|
15
14
|
import { SETTINGS_NS as NS_LITERAL } from './ns.ts'
|
|
16
15
|
|
|
17
|
-
/** settings
|
|
18
|
-
export const SETTINGS_NS =
|
|
16
|
+
/** settings 命名空间(字面量即合法命名空间,0.1.2-alpha.2 起编译期校验;webui 配置卡片与插件运行期读取同一份)。 */
|
|
17
|
+
export const SETTINGS_NS = NS_LITERAL
|
|
19
18
|
|
|
20
19
|
/** 本插件可为手写 route 提供的协议实现(与官方 PROTOCOLS 表一致)。 */
|
|
21
20
|
export const PROTOCOL_IDS = [
|
package/src/deepseek-routes.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* 请求生效);retryPolicy 是注册期捕获事实,变化时 handle.replace 原地重注册
|
|
12
12
|
* (官方同款模式);route 移除即 dispose 释放路由名。
|
|
13
13
|
*
|
|
14
|
-
* 0.1.2-alpha
|
|
14
|
+
* 0.1.2-alpha 线:DeepSeekAdapterOptions 必需 prepareExtensions(官方接线
|
|
15
15
|
* ctx.get('deepseekLlmApiExtensions'),缺省空实现)与可选 resolveImageAccess。
|
|
16
16
|
* @module llm-pi/deepseek-routes
|
|
17
17
|
*/
|
|
@@ -19,7 +19,7 @@ import type { Context } from '@deepseek-ai/cordis'
|
|
|
19
19
|
import type { CredentialRef } from '@deepseek-ai/dsh-credentials'
|
|
20
20
|
import { launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment'
|
|
21
21
|
import type { AdapterRegistrationHandle } from '@deepseek-ai/dsh-llm'
|
|
22
|
-
import { deepEqualJson } from '@deepseek-ai/dsh-
|
|
22
|
+
import { deepEqualJson } from '@deepseek-ai/dsh-util-values'
|
|
23
23
|
|
|
24
24
|
import type { ResolvedDeepseekRoute } from './profiles-deepseek.ts'
|
|
25
25
|
import type { DshKit } from './resolve-dsh.ts'
|
|
@@ -146,7 +146,7 @@ export class DeepseekRouteRegistrar {
|
|
|
146
146
|
)?.processPathFromHostPath(hostPath),
|
|
147
147
|
ref,
|
|
148
148
|
) as never,
|
|
149
|
-
// 0.1.2-alpha
|
|
149
|
+
// 0.1.2-alpha 线必需:官方扩展注册表(deepseekLlmApiExtensions)缺席时
|
|
150
150
|
// 给空实现(官方接线范式,llm-deepseek/src/index.ts:404-470)。
|
|
151
151
|
prepareExtensions: (request) => {
|
|
152
152
|
const extensions = ctx.get('deepseekLlmApiExtensions') as
|
package/src/ns.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* settings 命名空间字面量(纯常量,零依赖,浏览器半可安全引入)。
|
|
3
|
-
*
|
|
4
|
-
* settings.plugin.item keyed 槽位的
|
|
5
|
-
*
|
|
3
|
+
* 服务端直接以字面量注册(0.1.2-alpha.2 起 dsh-settings 对命名空间做编译期
|
|
4
|
+
* 语法校验,见 config.ts),浏览器半将其作为 settings.plugin.item keyed 槽位的
|
|
5
|
+
* key —— 同一字面量两处共用,防止漂移。
|
|
6
|
+
* 契约:该槽位按「卡片编辑的 settings 命名空间」作 key 分发,
|
|
6
7
|
* 官方配置页只渲染 key 命中 Host 已注册命名空间的卡片。
|
|
7
8
|
* @module llm-pi/ns
|
|
8
9
|
*/
|
package/src/profiles.ts
CHANGED
package/src/resolve-dsh.ts
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* 两条路径产物都过形状自检(assertKitShape):上游重构导致形状漂移时
|
|
13
13
|
* 抛错,由调用方决定回退或放弃注册——绝不让坏套件进入消息链路。
|
|
14
14
|
*
|
|
15
|
-
* 0.1.2-alpha.1
|
|
15
|
+
* 0.1.2-alpha 线的新面(0.1.2-alpha.2 复核包根仍未导出、仅 src 子路径有):
|
|
16
16
|
* - resolveProfiles(config.ts):官方解析链,dev 布局树可经 src 子路径复用;
|
|
17
17
|
* - credentialStoreFrom/authContextFrom(auth.ts):PiAiAdapter 必需 auth 注入。
|
|
18
18
|
* npm 发布形态(lib/index.js 单 bundle + 无 src/)两者都拿不到:dsh 树优先
|
|
@@ -118,7 +118,7 @@ function assertKitShape(kit: DshKit, origin: string): void {
|
|
|
118
118
|
const problems: string[] = []
|
|
119
119
|
if (typeof kit.PiAiAdapter !== 'function') problems.push('PiAiAdapter 不是类')
|
|
120
120
|
else {
|
|
121
|
-
// 0.1.2-alpha.
|
|
121
|
+
// 0.1.2-alpha.2 的 LlmAdapter 抽象面:prepareCall/providerRetryPolicy 为
|
|
122
122
|
// master 适配器必需 override;models.getModels/getModel 语义未变
|
|
123
123
|
// (pi-ai 0.84.2 Models.getModel(provider,id)/getModels(provider),
|
|
124
124
|
// 由同源 adapter 内部消费,本插件不直调)。
|
package/src/service.ts
CHANGED
|
@@ -14,7 +14,8 @@ import type { CredentialRef } from '@deepseek-ai/dsh-credentials'
|
|
|
14
14
|
import { dshHomePath } from '@deepseek-ai/dsh-home-paths'
|
|
15
15
|
import { launchEnvironmentOf } from '@deepseek-ai/dsh-launch-environment'
|
|
16
16
|
import type { ResolvedPiAiProviderProfile } from '@deepseek-ai/dsh-llm-pi-ai'
|
|
17
|
-
import {
|
|
17
|
+
import type {} from '@deepseek-ai/dsh-settings'
|
|
18
|
+
import { deepEqualJson } from '@deepseek-ai/dsh-util-values'
|
|
18
19
|
|
|
19
20
|
import { ModelsDevSource } from './catalog/models-dev.ts'
|
|
20
21
|
import { Config, type LlmPiConfig, SETTINGS_NS } from './config.ts'
|
|
@@ -127,7 +128,7 @@ export async function startRuntime(ctx: Context, rawConfig: LlmPiConfig): Promis
|
|
|
127
128
|
profiles,
|
|
128
129
|
resolveApiKey: makeResolveApiKey(ctx, kit),
|
|
129
130
|
resolveAttachments: () => ctx.get('attachments'),
|
|
130
|
-
// 0.1.2-alpha.
|
|
131
|
+
// 0.1.2-alpha.2 必需(包根仍未导出官方 auth 助手):登录/OAuth 类 provider 与 pi-ai 自有凭据写入的落点。
|
|
131
132
|
// dsh 树 dev 布局(src/auth.ts 存在)时为官方助手,其余形态为内联等价
|
|
132
133
|
// 实现(resolve-dsh.ts 探测,见 auth-inline.ts)。
|
|
133
134
|
auth: {
|
|
@@ -284,33 +285,37 @@ export async function startRuntime(ctx: Context, rawConfig: LlmPiConfig): Promis
|
|
|
284
285
|
ensureDeepseek()
|
|
285
286
|
ensureDirectory()
|
|
286
287
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
288
|
+
// 官方 installSection 范式(0.1.2-alpha.2):settings 在时以行级 config 为
|
|
289
|
+
// base 注册用户层(validate 拒绝坏写入),缺席/detach 时回落行级 config。
|
|
290
|
+
ctx.inject(['settings'], (settingsCtx) => {
|
|
291
|
+
settingsCtx.settings.installSection(ctx, SETTINGS_NS, Config, config, {
|
|
292
|
+
validate: (cfg: LlmPiConfig) => assertServiceable(cfg, deps),
|
|
293
|
+
setSource: (source: () => LlmPiConfig) => {
|
|
294
|
+
current = source
|
|
295
|
+
},
|
|
296
|
+
onChange: () => {
|
|
297
|
+
try {
|
|
298
|
+
ensureRegistration()
|
|
299
|
+
} catch (error) {
|
|
300
|
+
logger.error('llm-pi: 更新被拒,保留此前注册的 route')
|
|
301
|
+
logger.error(error)
|
|
302
|
+
}
|
|
303
|
+
try {
|
|
304
|
+
ensureDeepseek()
|
|
305
|
+
} catch (error) {
|
|
306
|
+
logger.error('llm-pi: deepseek route 更新失败,保留此前注册')
|
|
307
|
+
logger.error(error)
|
|
308
|
+
}
|
|
309
|
+
try {
|
|
310
|
+
ensureDirectory()
|
|
311
|
+
} catch (error) {
|
|
312
|
+
logger.error('llm-pi: 更新被拒,保留此前的 configurable-provider 目录')
|
|
313
|
+
logger.error(error)
|
|
314
|
+
}
|
|
315
|
+
const cfg = current()
|
|
316
|
+
modelsDev.reconfigure(cfg.catalogUrl, cfg.catalogRefreshHours, cfg.catalogProxy ?? '')
|
|
317
|
+
},
|
|
318
|
+
})
|
|
314
319
|
})
|
|
315
320
|
|
|
316
321
|
return {
|