@tnnevol/dsh-midscene 0.2.1-rc.2.2 → 6.0.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.md +26 -7
- package/compatibility.json +1 -1
- package/lib/client.js +3812 -2192
- package/lib/index.d.ts +239 -22
- package/lib/index.js +565 -91
- package/lib/style.css +1 -1
- package/locale/zh.json +1 -1
- package/package.json +29 -28
- package/skills/SOURCE.md +7 -6
- package/skills/dsh-midscene/SKILL.md +57 -8
- package/skills/midscenejs/GENERATION.md +25 -5
- package/skills/midscenejs/SKILL.md +10 -4
- package/skills/midscenejs/references/midscene-test/configuration.md +42 -0
- package/skills/midscenejs/references/midscene-test/github-actions.md +138 -0
- package/skills/midscenejs/references/midscene-test/use.md +64 -14
- package/skills/midscenejs/references/model-config.md +85 -19
package/lib/index.d.ts
CHANGED
|
@@ -1,8 +1,76 @@
|
|
|
1
1
|
import z from "@deepseek-ai/schemastery";
|
|
2
2
|
import { Context } from "@deepseek-ai/cordis";
|
|
3
|
-
import { FinishReason, LlmModelInfo, LlmRuntime, RequestMessage, StreamChunk, ToolSchema } from "@deepseek-ai/dsh-llm";
|
|
3
|
+
import { FinishReason, LlmModelInfo, LlmRuntime, ReasoningEffortId, RequestMessage, StreamChunk, ToolSchema } from "@deepseek-ai/dsh-llm";
|
|
4
4
|
import { AttachmentStore, ImageMediaType } from "@deepseek-ai/dsh-attachment";
|
|
5
5
|
import { SkillCandidate, SkillProvider, SkillRegistry } from "@deepseek-ai/dsh-skill";
|
|
6
|
+
//#region src/contracts/intents.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Midscene 的**模型职责**(FNOS-021-02)。
|
|
9
|
+
*
|
|
10
|
+
* 上游把模型策略从「三职责」扩展到「四职责」:默认模型提供全部能力,定位(Locate)、
|
|
11
|
+
* 规划(Planning)、页面理解(Insight)三个职责各自可绑定专用模型,未配置者沿用默认。
|
|
12
|
+
* 插件据此把「一个模型」扩展成「四个可选模型」。
|
|
13
|
+
*
|
|
14
|
+
* **每个职责必须有各自的对外模型名**:桥要靠请求里的 `model` 字段判断这次调用属于哪个
|
|
15
|
+
* 职责——如果四组共用同一个名字,桥无从区分,专用职责配的模型就永远不会被用上,而且
|
|
16
|
+
* **不会报错**(与「家族错了点击偏移」同一类静默失效)。因此专用职责的模型名在固定名
|
|
17
|
+
* 之后带一个职责后缀(`dsh-model@locate`),桥据此路由。
|
|
18
|
+
*
|
|
19
|
+
* 本文件**不含任何 import**:浏览器半侧(设置页)也要用它渲染 Tabs,因此不能拖进
|
|
20
|
+
* `node:crypto`、schemastery 之类宿主依赖。
|
|
21
|
+
*
|
|
22
|
+
* @module dsh-midscene/intents
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* 桥对外的固定模型名(默认职责)。
|
|
26
|
+
*
|
|
27
|
+
* 做成固定值后,用户可以把 `.env` 写死、不必随模型变化更新它——换模型只改插件设置。
|
|
28
|
+
* 专用职责在它之后追加 `@职责` 后缀(见 {@link intentModelName})。
|
|
29
|
+
*/
|
|
30
|
+
declare const FIXED_MODEL_NAME = "dsh-model";
|
|
31
|
+
/** 四个模型职责。 */
|
|
32
|
+
declare const MIDSCENE_INTENTS: readonly ["default", "locate", "planning", "insight"];
|
|
33
|
+
/** 模型职责。 */
|
|
34
|
+
type MidsceneIntent = (typeof MIDSCENE_INTENTS)[number];
|
|
35
|
+
/**
|
|
36
|
+
* 三个**可选**职责(默认职责始终存在,且是其它职责的回落目标)。
|
|
37
|
+
*
|
|
38
|
+
* 顺序即接入配置里的分组顺序与设置页的 Tab 顺序。
|
|
39
|
+
*/
|
|
40
|
+
declare const DEDICATED_INTENTS: readonly ["locate", "planning", "insight"];
|
|
41
|
+
/** 可选职责。 */
|
|
42
|
+
type DedicatedIntent = (typeof DEDICATED_INTENTS)[number];
|
|
43
|
+
/** 插件配置里承载各职责模型的字段名。 */
|
|
44
|
+
type IntentConfigField = 'model' | 'locateModel' | 'planningModel' | 'insightModel';
|
|
45
|
+
/** 职责 → 插件配置字段名。 */
|
|
46
|
+
declare const INTENT_CONFIG_FIELD: Record<MidsceneIntent, IntentConfigField>;
|
|
47
|
+
/**
|
|
48
|
+
* 职责 → Midscene 环境变量前缀。
|
|
49
|
+
*
|
|
50
|
+
* 与上游一致:默认职责用 `MIDSCENE_MODEL_*`,定位用 `MIDSCENE_LOCATE_MODEL_*`,规划用
|
|
51
|
+
* `MIDSCENE_PLANNING_MODEL_*`,页面理解用 `MIDSCENE_INSIGHT_MODEL_*`。
|
|
52
|
+
*/
|
|
53
|
+
declare const INTENT_ENV_PREFIX: Record<MidsceneIntent, string>;
|
|
54
|
+
/** 职责 → 中文标签(接入配置的分组注释与设置页 Tab 用)。 */
|
|
55
|
+
declare const INTENT_LABEL_ZH: Record<MidsceneIntent, string>;
|
|
56
|
+
/**
|
|
57
|
+
* 拼出某个职责的对外模型名。
|
|
58
|
+
*
|
|
59
|
+
* 默认职责沿用固定名(`dsh-model`),专用职责追加 `@职责` 后缀。
|
|
60
|
+
* @param intent - 职责。
|
|
61
|
+
* @returns 对外模型名。
|
|
62
|
+
*/
|
|
63
|
+
declare function intentModelName(intent: MidsceneIntent): string;
|
|
64
|
+
/**
|
|
65
|
+
* 从请求里的模型名解析它属于哪个职责。
|
|
66
|
+
*
|
|
67
|
+
* 认得两种形态:固定名本身(默认职责)与带 `@职责` 后缀的专用名。其它取值(例如用户
|
|
68
|
+
* 直接写了「提供方/模型」)返回 `undefined`,由调用方按显式路由处理。
|
|
69
|
+
* @param raw - 请求里的 `model` 字段。
|
|
70
|
+
* @returns 职责;不是本桥的固定名形态时为 `undefined`。
|
|
71
|
+
*/
|
|
72
|
+
declare function parseIntentModelName(raw: string): MidsceneIntent | undefined;
|
|
73
|
+
//#endregion
|
|
6
74
|
//#region src/contracts/config.d.ts
|
|
7
75
|
/**
|
|
8
76
|
* 桥接服务的首选端口。
|
|
@@ -20,13 +88,6 @@ declare const DEFAULT_BRIDGE_PORT = 8787;
|
|
|
20
88
|
declare const BRIDGE_HOST = "127.0.0.1";
|
|
21
89
|
/** 桥接对外呈现的 OpenAI API 前缀。 */
|
|
22
90
|
declare const OPENAI_API_PREFIX = "/v1";
|
|
23
|
-
/**
|
|
24
|
-
* Midscene 侧固定使用的对外模型名。
|
|
25
|
-
*
|
|
26
|
-
* 桥按这个名字决定「用哪个模型」:优先用插件配置指定的模型,否则跟随 DSH 当前
|
|
27
|
-
* 模型选择。做成固定值后,用户可以把 `.env` 写死、不必随模型变化更新它。
|
|
28
|
-
*/
|
|
29
|
-
declare const FIXED_MODEL_NAME = "dsh-model";
|
|
30
91
|
/**
|
|
31
92
|
* Midscene 接受的协议家族白名单。
|
|
32
93
|
*
|
|
@@ -35,11 +96,14 @@ declare const FIXED_MODEL_NAME = "dsh-model";
|
|
|
35
96
|
* 技术的:family 决定 Midscene 用哪套提示词模板与坐标解析协议,绑定到具体模型的
|
|
36
97
|
* 输出格式,无法为未知家族生成请求。
|
|
37
98
|
*
|
|
38
|
-
* 列表取自 Midscene v1.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
99
|
+
* 列表取自 Midscene v1.16.0 的 `TModelFamily` / `MODEL_FAMILY_VALUES` 与运行时错误
|
|
100
|
+
* 信息;上游新增家族时需同步本表({@link isKnownFamily} 用于在配置面提前给出可读
|
|
101
|
+
* 提示,而不是等运行时才报错)。
|
|
102
|
+
*
|
|
103
|
+
* `jev` 在白名单内但**永不由此插件推导**:它是 TypeSafe 的商业模型(私有 System One
|
|
104
|
+
* 协议),且上游明确它不能作默认模型;插件按用户已有的 DSH 模型推导家族,不会猜出它。
|
|
41
105
|
*/
|
|
42
|
-
declare const MIDSCENE_FAMILIES: readonly ["doubao-vision", "doubao-seed", "gemini", "qwen2.5-vl", "qwen3-vl", "qwen3", "qwen3.5", "qwen3.6", "vlm-ui-tars", "vlm-ui-tars-doubao", "vlm-ui-tars-doubao-1.5", "glm-v", "auto-glm", "auto-glm-multilingual", "gpt-5", "gpt-6", "deepseek", "kimi", "kimi3", "xiaomi-mimo"];
|
|
106
|
+
declare const MIDSCENE_FAMILIES: readonly ["jev", "doubao-vision", "doubao-seed", "gemini", "qwen2.5-vl", "qwen3-vl", "qwen3", "qwen3.5", "qwen3.6", "vlm-ui-tars", "vlm-ui-tars-doubao", "vlm-ui-tars-doubao-1.5", "glm-v", "auto-glm", "auto-glm-multilingual", "gpt-5", "gpt-6", "deepseek", "kimi", "kimi3", "xiaomi-mimo"];
|
|
43
107
|
/** 协议家族取值。 */
|
|
44
108
|
type MidsceneFamily = (typeof MIDSCENE_FAMILIES)[number];
|
|
45
109
|
/**
|
|
@@ -76,25 +140,46 @@ declare function isKnownFamily(value: string): value is MidsceneFamily;
|
|
|
76
140
|
*/
|
|
77
141
|
declare function generateApiKey(): string;
|
|
78
142
|
/**
|
|
79
|
-
*
|
|
143
|
+
* 接入配置里一个**专用职责**的变量组。
|
|
80
144
|
*
|
|
81
|
-
*
|
|
145
|
+
* 只在该职责单独指定了模型时才出现——上游对「未配置专用模型」的职责会自动沿用默认
|
|
146
|
+
* 模型,因此插件不写这组变量即可,无需自己实现回落逻辑。
|
|
147
|
+
*/
|
|
148
|
+
interface DedicatedEnvSlot {
|
|
149
|
+
/** 职责。 */
|
|
150
|
+
readonly intent: DedicatedIntent;
|
|
151
|
+
/** 该职责自己的协议家族(按该职责的模型推导,不沿用默认家族的取值)。 */
|
|
152
|
+
readonly family: string;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* 生成 Midscene 侧的接入配置。
|
|
156
|
+
*
|
|
157
|
+
* **默认职责固定四行**(基址、密钥、模型名、家族),因此用户可以把 `.env` 写死:换模型
|
|
82
158
|
* 只需改插件设置,不必动这个文件。`MIDSCENE_MODEL_NAME` 固定为 {@link FIXED_MODEL_NAME},
|
|
83
159
|
* 由桥决定实际用哪个模型。
|
|
84
160
|
*
|
|
161
|
+
* **专用职责只在用户为它指定了模型后才追加一组变量**({@link DedicatedEnvSlot})。没配的
|
|
162
|
+
* 职责不写——上游自己回落到默认模型,于是「全部留空」时输出与升级前逐字符一致。
|
|
163
|
+
*
|
|
85
164
|
* **`port` 必须传桥实际监听的端口**(`BridgeServer.port`),不是配置里的首选端口:
|
|
86
165
|
* 端口被占用而自动跳号时,配置字段与实际情况可能不一致,`.env` 里写错端口会让
|
|
87
166
|
* Midscene 直接连不上。
|
|
88
|
-
*
|
|
167
|
+
*
|
|
168
|
+
* 头部注释额外声明**协议**(Chat Completions):本桥只提供这一种协议,用户照上游文档
|
|
169
|
+
* 自行改成 Responses 协议会打错路径。声明为注释而不是多写一个环境变量,是为了不改变
|
|
170
|
+
* 既有四行的取值(已按旧格式写入 `.env` 的用户不受影响)。
|
|
171
|
+
* @param config - 桥接配置中与接入文件相关的项。
|
|
89
172
|
* @param config.port - 桥**实际**监听的端口。
|
|
90
173
|
* @param config.apiKey - 桥接入密钥。
|
|
91
|
-
* @param config.family -
|
|
174
|
+
* @param config.family - 默认职责的协议家族。
|
|
175
|
+
* @param config.dedicated - 专用职责的变量组(可选;未配置的职责不出现在这里)。
|
|
92
176
|
* @returns `.env` 文本。
|
|
93
177
|
*/
|
|
94
178
|
declare function renderEnvFile(config: {
|
|
95
179
|
readonly port: number;
|
|
96
180
|
readonly apiKey: string;
|
|
97
181
|
readonly family: string;
|
|
182
|
+
readonly dedicated?: readonly DedicatedEnvSlot[];
|
|
98
183
|
}): string;
|
|
99
184
|
/** 配置字段的推导类型(`z.object` 的泛型参数)。 */
|
|
100
185
|
interface BridgeConfigShape {
|
|
@@ -102,17 +187,22 @@ interface BridgeConfigShape {
|
|
|
102
187
|
apiKey: z<NoInfer<string>, NoInfer<string>, 'volatile-defined'>;
|
|
103
188
|
family: z<NoInfer<string>, NoInfer<string>, 'volatile-defined'>;
|
|
104
189
|
model: z<NoInfer<string>, NoInfer<string>, 'volatile-defined'>;
|
|
190
|
+
locateModel: z<NoInfer<string>, NoInfer<string>, 'volatile-defined'>;
|
|
191
|
+
planningModel: z<NoInfer<string>, NoInfer<string>, 'volatile-defined'>;
|
|
192
|
+
insightModel: z<NoInfer<string>, NoInfer<string>, 'volatile-defined'>;
|
|
105
193
|
requestTimeoutMs: z<NoInfer<number>, NoInfer<number>, 'volatile-defined'>;
|
|
106
194
|
logRequests: z<NoInfer<boolean>, NoInfer<boolean>, 'volatile-defined'>;
|
|
107
195
|
}
|
|
108
196
|
/**
|
|
109
197
|
* 桥接服务配置。
|
|
110
198
|
*
|
|
111
|
-
* `model`
|
|
199
|
+
* `model` 是**默认职责**的模型:为空时桥跟随 DSH 当前模型选择(需具备识图能力);
|
|
200
|
+
* 指定时用它。三个专用职责(`locateModel` / `planningModel` / `insightModel`)留空时
|
|
201
|
+
* 沿用默认职责——与上游「未配置专用模型的职责使用默认模型」一致。
|
|
112
202
|
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
203
|
+
* **为什么每个职责只让选一个、不选列表**:Midscene 的协议家族在启动期从 `.env` 读取,
|
|
204
|
+
* 而一个职责只有一个家族——多选里若混入不同系列的模型,回退到备用模型时家族仍是最初
|
|
205
|
+
* 那个,反而制造静默错位。既然任何时刻只可能有一个模型生效,界面就如实只让选一个。
|
|
116
206
|
*/
|
|
117
207
|
declare const Config: z<Schemastery.ObjectS<NoInfer<BridgeConfigShape>>, Schemastery.ObjectT<NoInfer<BridgeConfigShape>>, 'plain'>;
|
|
118
208
|
/** 解析后的桥接服务配置。 */
|
|
@@ -129,8 +219,14 @@ interface BridgeConfig {
|
|
|
129
219
|
readonly apiKey: string;
|
|
130
220
|
/** Midscene 协议家族。 */
|
|
131
221
|
readonly family: string;
|
|
132
|
-
/**
|
|
222
|
+
/** 默认职责的模型;空表示跟随 DSH 当前模型选择。 */
|
|
133
223
|
readonly model: string;
|
|
224
|
+
/** 定位职责的模型;空表示沿用默认职责。 */
|
|
225
|
+
readonly locateModel: string;
|
|
226
|
+
/** 规划职责的模型;空表示沿用默认职责。 */
|
|
227
|
+
readonly planningModel: string;
|
|
228
|
+
/** 页面理解职责的模型;空表示沿用默认职责。 */
|
|
229
|
+
readonly insightModel: string;
|
|
134
230
|
/** 单次模型请求超时(毫秒);0 表示不超时。 */
|
|
135
231
|
readonly requestTimeoutMs: number;
|
|
136
232
|
/** 是否记录请求摘要日志。 */
|
|
@@ -225,6 +321,119 @@ interface SessionModelReader {
|
|
|
225
321
|
* @returns 决策结果;目录为空时为 `undefined`。
|
|
226
322
|
*/
|
|
227
323
|
declare function chooseModel(snapshot: ModelCatalogSnapshot, configured: string, session: SessionModelReader): ModelChoice | undefined;
|
|
324
|
+
/**
|
|
325
|
+
* 按职责决策模型所需的配置面(只取与模型选择有关的字段)。
|
|
326
|
+
*
|
|
327
|
+
* 与完整的 {@link BridgeConfig} 解耦,使这个纯函数可以在单测里直接构造。
|
|
328
|
+
*/
|
|
329
|
+
interface IntentModelConfig {
|
|
330
|
+
/** 默认职责配置的模型。 */
|
|
331
|
+
readonly model: string;
|
|
332
|
+
/** 定位职责配置的模型。 */
|
|
333
|
+
readonly locateModel: string;
|
|
334
|
+
/** 规划职责配置的模型。 */
|
|
335
|
+
readonly planningModel: string;
|
|
336
|
+
/** 页面理解职责配置的模型。 */
|
|
337
|
+
readonly insightModel: string;
|
|
338
|
+
/** 目录为空时家族回落用的值。 */
|
|
339
|
+
readonly family: string;
|
|
340
|
+
}
|
|
341
|
+
/** 某个职责的模型决策结果。 */
|
|
342
|
+
interface IntentModelChoice {
|
|
343
|
+
/** 职责。 */
|
|
344
|
+
readonly intent: MidsceneIntent;
|
|
345
|
+
/** 该职责实际会使用的模型标识;目录为空时为 `undefined`。 */
|
|
346
|
+
readonly modelId: string | undefined;
|
|
347
|
+
/** 该职责使用的协议家族(按它自己的模型推导)。 */
|
|
348
|
+
readonly family: string;
|
|
349
|
+
/** 该职责是否单独指定了模型(`false` 表示沿用默认职责)。 */
|
|
350
|
+
readonly dedicated: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* 该职责的模型来源:
|
|
353
|
+
* - `configured`:用户为该职责显式指定了模型;
|
|
354
|
+
* - `session`:跟随 DSH 当前会话模型(仅默认职责可能出现);
|
|
355
|
+
* - `fallback`:兜底挑的识图模型(仅默认职责可能出现);
|
|
356
|
+
* - `inherited`:沿用默认职责的结果。
|
|
357
|
+
*/
|
|
358
|
+
readonly source: 'configured' | 'session' | 'fallback' | 'inherited';
|
|
359
|
+
/** 配置了但目录中不存在的模型(供界面如实提示,不静默改选)。 */
|
|
360
|
+
readonly skippedConfigured: readonly string[];
|
|
361
|
+
}
|
|
362
|
+
/**
|
|
363
|
+
* 按**每个职责自己的模型**分别决策(FNOS-021-02)。
|
|
364
|
+
*
|
|
365
|
+
* 与 {@link chooseModel} 的差别在两处,都源于上游的职责语义:
|
|
366
|
+
*
|
|
367
|
+
* 1. **家族按职责分别推导**:上游对专用职责的家族是独立变量(`MIDSCENE_LOCATE_MODEL_FAMILY`
|
|
368
|
+
* 等),且专用模型**不逐字段继承**默认模型。若沿用「按默认模型推导一次」,用户把定位
|
|
369
|
+
* 模型换成另一个系列时家族会停在默认模型那一套——正是需求禁止的「静默失准」。
|
|
370
|
+
* 2. **未配置专用模型时回落默认职责**:不是回落会话模型。默认职责已经按
|
|
371
|
+
* 「插件配置 → 会话模型 → 识图兜底」决策完毕,专用职责未配置就该跟着它的结果走。
|
|
372
|
+
*
|
|
373
|
+
* 专用职责配了但**目录里没有**该模型(提供方被卸载或模型改名)时,同样回落默认职责并
|
|
374
|
+
* 如实登记(`skippedConfigured`),界面据此提示、配置保留用户的选择。
|
|
375
|
+
* @param snapshot - 目录快照。
|
|
376
|
+
* @param config - 各职责配置的模型。
|
|
377
|
+
* @param session - DSH 当前模型选择的读取面。
|
|
378
|
+
* @returns 每个职责的决策结果。
|
|
379
|
+
*/
|
|
380
|
+
declare function resolveIntentModels(snapshot: ModelCatalogSnapshot, config: IntentModelConfig, session: SessionModelReader): Record<MidsceneIntent, IntentModelChoice>;
|
|
381
|
+
//#endregion
|
|
382
|
+
//#region src/host/reasoning.d.ts
|
|
383
|
+
/** 从请求体解析出的思考意图。 */
|
|
384
|
+
type ThinkingIntent =
|
|
385
|
+
/** Midscene 想关闭原生思考(默认行为)。 */
|
|
386
|
+
{
|
|
387
|
+
readonly kind: 'disabled';
|
|
388
|
+
} |
|
|
389
|
+
/** Midscene 想开启原生思考但没指定档位。 */
|
|
390
|
+
{
|
|
391
|
+
readonly kind: 'enabled';
|
|
392
|
+
} |
|
|
393
|
+
/** Midscene 指定了具体档位(如 `medium`)。 */
|
|
394
|
+
{
|
|
395
|
+
readonly kind: 'effort';
|
|
396
|
+
readonly value: string;
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* 从 OpenAI 兼容请求体解析 Midscene 的思考意图。
|
|
400
|
+
*
|
|
401
|
+
* 按**明确的开关字段优先**的顺序判断(Midscene 每个家族只发其中一套,顺序主要用于
|
|
402
|
+
* 同一请求里出现多个字段时的一致性):
|
|
403
|
+
* 1. `thinking.type`:`disabled` → 关;`enabled` → 开(若同时带 `reasoning_effort` 则用该档位);
|
|
404
|
+
* 2. `enable_thinking`:`false` → 关;`true` → 开;
|
|
405
|
+
* 3. `reasoning_effort`:`none`/`minimal` → 关;其它 → 该档位;
|
|
406
|
+
* 4. `extra_body.google.thinking_config.thinking_level`:同上。
|
|
407
|
+
* @param body - 已解析的请求体。
|
|
408
|
+
* @returns 思考意图;请求里没有任何相关字段时为 `undefined`(与升级前一致,不动)。
|
|
409
|
+
*/
|
|
410
|
+
declare function parseThinkingIntent(body: Record<string, unknown>): ThinkingIntent | undefined;
|
|
411
|
+
/**
|
|
412
|
+
* 在宿主披露的档位里挑出与意图匹配的那一个。
|
|
413
|
+
*
|
|
414
|
+
* **只返回宿主确实提供的 id**,绝不自行拼字符串——拼错的档位会在发起请求前被
|
|
415
|
+
* `UNSUPPORTED_REASONING_EFFORT` 拦下,等于把一个本来能用的请求打成失败。
|
|
416
|
+
* @param intent - 思考意图。
|
|
417
|
+
* @param efforts - 宿主 `resolveModelInfo` 给出的可选档位(按由弱到强排序)。
|
|
418
|
+
* @returns 命中的档位 id;无可表达档位时为 `undefined`(调用方据此不传)。
|
|
419
|
+
*/
|
|
420
|
+
declare function pickReasoningEffort(intent: ThinkingIntent, efforts: readonly {
|
|
421
|
+
readonly id: string;
|
|
422
|
+
readonly name: string;
|
|
423
|
+
}[]): string | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* 解析一次请求最终要传给宿主的思考档位。
|
|
426
|
+
*
|
|
427
|
+
* 任何一步失败(请求里没有思考字段、宿主不披露档位、`resolveModelInfo` 报错或超时)都
|
|
428
|
+
* 降级为 `undefined`——**请求照常发出**,思考行为退回宿主默认(与升级前一致)。
|
|
429
|
+
* @param llm - 宿主模型层(只用到 `resolveModelInfo`)。
|
|
430
|
+
* @param provider - 提供方路由键。
|
|
431
|
+
* @param model - 模型 id。
|
|
432
|
+
* @param body - 已解析的请求体。
|
|
433
|
+
* @param signal - 可选中止信号。
|
|
434
|
+
* @returns 宿主档位 id;不应传时为 `undefined`。
|
|
435
|
+
*/
|
|
436
|
+
declare function resolveReasoningEffort(llm: Pick<LlmRuntime, 'resolveModelInfo'>, provider: string, model: string, body: Record<string, unknown>, signal?: AbortSignal): Promise<ReasoningEffortId | undefined>;
|
|
228
437
|
//#endregion
|
|
229
438
|
//#region src/contracts/model-name.d.ts
|
|
230
439
|
/**
|
|
@@ -524,6 +733,14 @@ declare class BridgeServer {
|
|
|
524
733
|
* @returns 模型标识;目录为空时 `undefined`。
|
|
525
734
|
*/
|
|
526
735
|
resolveModel(): Promise<string | undefined>;
|
|
736
|
+
/**
|
|
737
|
+
* 每个职责的模型决策结果。
|
|
738
|
+
*
|
|
739
|
+
* 供设置页展示「各职责当前实际使用哪个模型」与生成接入配置。设置页与桥共用同一套
|
|
740
|
+
* 决策函数,因此界面显示的与真实调用的必然一致。
|
|
741
|
+
* @returns 每个职责的决策结果。
|
|
742
|
+
*/
|
|
743
|
+
resolveSlots(): Promise<Record<MidsceneIntent, IntentModelChoice>>;
|
|
527
744
|
/**
|
|
528
745
|
* 启动服务。
|
|
529
746
|
*
|
|
@@ -607,4 +824,4 @@ declare const inject: string[];
|
|
|
607
824
|
*/
|
|
608
825
|
declare function apply(ctx: Context, rawConfig?: BridgeConfig): void;
|
|
609
826
|
//#endregion
|
|
610
|
-
export { BRIDGE_HOST, type BridgeConfig, type BridgeDeps, BridgePortExhaustedError, BridgeServer, CatalogCache, Config, DEFAULT_BRIDGE_PORT, DEFAULT_FAMILY, FIXED_MODEL_NAME, GENERIC_FAMILY, MIDSCENE_FAMILIES, type MidsceneFamily, type ModelCatalogSnapshot, type ModelChoice, OPENAI_API_PREFIX, type OpenAiModelEntry, RequestConversionError, type ResolvedModel, SKILL_PROVIDER_NAME, type SessionModelReader, aggregateStream, apply, buildCatalog, bundledSkillsDir, chooseModel, convertMessages, convertTools, createBundledSkillProvider, formatModelName, generateApiKey, inject, isKnownFamily, listBundledSkills, makeChunk, modelSupportsImage, name, parseDataUri, registerBundledSkills, renderEnvFile, resolveModelName, sseLine, toFinishReason, toOpenAiError, toOpenAiModel };
|
|
827
|
+
export { BRIDGE_HOST, type BridgeConfig, type BridgeDeps, BridgePortExhaustedError, BridgeServer, CatalogCache, Config, DEDICATED_INTENTS, DEFAULT_BRIDGE_PORT, DEFAULT_FAMILY, type DedicatedEnvSlot, type DedicatedIntent, FIXED_MODEL_NAME, GENERIC_FAMILY, INTENT_CONFIG_FIELD, INTENT_ENV_PREFIX, INTENT_LABEL_ZH, type IntentConfigField, type IntentModelChoice, type IntentModelConfig, MIDSCENE_FAMILIES, MIDSCENE_INTENTS, type MidsceneFamily, type MidsceneIntent, type ModelCatalogSnapshot, type ModelChoice, OPENAI_API_PREFIX, type OpenAiModelEntry, RequestConversionError, type ResolvedModel, SKILL_PROVIDER_NAME, type SessionModelReader, type ThinkingIntent, aggregateStream, apply, buildCatalog, bundledSkillsDir, chooseModel, convertMessages, convertTools, createBundledSkillProvider, formatModelName, generateApiKey, inject, intentModelName, isKnownFamily, listBundledSkills, makeChunk, modelSupportsImage, name, parseDataUri, parseIntentModelName, parseThinkingIntent, pickReasoningEffort, registerBundledSkills, renderEnvFile, resolveIntentModels, resolveModelName, resolveReasoningEffort, sseLine, toFinishReason, toOpenAiError, toOpenAiModel };
|