@tnnevol/dsh-midscene 0.2.1-rc.2.7 → 6.0.6

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/index.js CHANGED
@@ -6,6 +6,100 @@ import { existsSync } from "node:fs";
6
6
  import { readFile, readdir, stat } from "node:fs/promises";
7
7
  import { basename, join } from "node:path";
8
8
  import { fileURLToPath } from "node:url";
9
+ //#region src/contracts/intents.ts
10
+ /**
11
+ * Midscene 的**模型职责**(FNOS-021-02)。
12
+ *
13
+ * 上游把模型策略从「三职责」扩展到「四职责」:默认模型提供全部能力,定位(Locate)、
14
+ * 规划(Planning)、页面理解(Insight)三个职责各自可绑定专用模型,未配置者沿用默认。
15
+ * 插件据此把「一个模型」扩展成「四个可选模型」。
16
+ *
17
+ * **每个职责必须有各自的对外模型名**:桥要靠请求里的 `model` 字段判断这次调用属于哪个
18
+ * 职责——如果四组共用同一个名字,桥无从区分,专用职责配的模型就永远不会被用上,而且
19
+ * **不会报错**(与「家族错了点击偏移」同一类静默失效)。因此专用职责的模型名在固定名
20
+ * 之后带一个职责后缀(`dsh-model@locate`),桥据此路由。
21
+ *
22
+ * 本文件**不含任何 import**:浏览器半侧(设置页)也要用它渲染 Tabs,因此不能拖进
23
+ * `node:crypto`、schemastery 之类宿主依赖。
24
+ *
25
+ * @module dsh-midscene/intents
26
+ */
27
+ /**
28
+ * 桥对外的固定模型名(默认职责)。
29
+ *
30
+ * 做成固定值后,用户可以把 `.env` 写死、不必随模型变化更新它——换模型只改插件设置。
31
+ * 专用职责在它之后追加 `@职责` 后缀(见 {@link intentModelName})。
32
+ */
33
+ const FIXED_MODEL_NAME = "dsh-model";
34
+ /** 四个模型职责。 */
35
+ const MIDSCENE_INTENTS = [
36
+ "default",
37
+ "locate",
38
+ "planning",
39
+ "insight"
40
+ ];
41
+ /**
42
+ * 三个**可选**职责(默认职责始终存在,且是其它职责的回落目标)。
43
+ *
44
+ * 顺序即接入配置里的分组顺序与设置页的 Tab 顺序。
45
+ */
46
+ const DEDICATED_INTENTS = [
47
+ "locate",
48
+ "planning",
49
+ "insight"
50
+ ];
51
+ /** 职责 → 插件配置字段名。 */
52
+ const INTENT_CONFIG_FIELD = {
53
+ default: "model",
54
+ locate: "locateModel",
55
+ planning: "planningModel",
56
+ insight: "insightModel"
57
+ };
58
+ /**
59
+ * 职责 → Midscene 环境变量前缀。
60
+ *
61
+ * 与上游一致:默认职责用 `MIDSCENE_MODEL_*`,定位用 `MIDSCENE_LOCATE_MODEL_*`,规划用
62
+ * `MIDSCENE_PLANNING_MODEL_*`,页面理解用 `MIDSCENE_INSIGHT_MODEL_*`。
63
+ */
64
+ const INTENT_ENV_PREFIX = {
65
+ default: "MIDSCENE_MODEL",
66
+ locate: "MIDSCENE_LOCATE_MODEL",
67
+ planning: "MIDSCENE_PLANNING_MODEL",
68
+ insight: "MIDSCENE_INSIGHT_MODEL"
69
+ };
70
+ /** 职责 → 中文标签(接入配置的分组注释与设置页 Tab 用)。 */
71
+ const INTENT_LABEL_ZH = {
72
+ default: "默认",
73
+ locate: "定位",
74
+ planning: "规划",
75
+ insight: "页面理解"
76
+ };
77
+ /**
78
+ * 拼出某个职责的对外模型名。
79
+ *
80
+ * 默认职责沿用固定名(`dsh-model`),专用职责追加 `@职责` 后缀。
81
+ * @param intent - 职责。
82
+ * @returns 对外模型名。
83
+ */
84
+ function intentModelName(intent) {
85
+ return intent === "default" ? FIXED_MODEL_NAME : `${FIXED_MODEL_NAME}@${intent}`;
86
+ }
87
+ /**
88
+ * 从请求里的模型名解析它属于哪个职责。
89
+ *
90
+ * 认得两种形态:固定名本身(默认职责)与带 `@职责` 后缀的专用名。其它取值(例如用户
91
+ * 直接写了「提供方/模型」)返回 `undefined`,由调用方按显式路由处理。
92
+ * @param raw - 请求里的 `model` 字段。
93
+ * @returns 职责;不是本桥的固定名形态时为 `undefined`。
94
+ */
95
+ function parseIntentModelName(raw) {
96
+ const value = raw.trim();
97
+ if (value === "dsh-model") return "default";
98
+ if (!value.startsWith(`dsh-model@`)) return void 0;
99
+ const suffix = value.slice(10);
100
+ return MIDSCENE_INTENTS.includes(suffix) ? suffix : void 0;
101
+ }
102
+ //#endregion
9
103
  //#region src/contracts/config.ts
10
104
  /**
11
105
  * 插件配置契约(FNOS-013-01、桥接服务行为细则)。
@@ -38,13 +132,6 @@ const BRIDGE_HOST = "127.0.0.1";
38
132
  /** 桥接对外呈现的 OpenAI API 前缀。 */
39
133
  const OPENAI_API_PREFIX = "/v1";
40
134
  /**
41
- * Midscene 侧固定使用的对外模型名。
42
- *
43
- * 桥按这个名字决定「用哪个模型」:优先用插件配置指定的模型,否则跟随 DSH 当前
44
- * 模型选择。做成固定值后,用户可以把 `.env` 写死、不必随模型变化更新它。
45
- */
46
- const FIXED_MODEL_NAME = "dsh-model";
47
- /**
48
135
  * Midscene 接受的协议家族白名单。
49
136
  *
50
137
  * **必须与 Midscene 的校验列表逐字一致**——它对该字段做运行时校验,未知值直接
@@ -52,11 +139,15 @@ const FIXED_MODEL_NAME = "dsh-model";
52
139
  * 技术的:family 决定 Midscene 用哪套提示词模板与坐标解析协议,绑定到具体模型的
53
140
  * 输出格式,无法为未知家族生成请求。
54
141
  *
55
- * 列表取自 Midscene v1.15.0 的运行时错误信息与 `ModelFamily` 类型定义;上游新增
56
- * 家族时需同步本表({@link isKnownFamily} 用于在配置面提前给出可读提示,而不是
57
- * 等运行时才报错)。
142
+ * 列表取自 Midscene v1.16.0 的 `TModelFamily` / `MODEL_FAMILY_VALUES` 与运行时错误
143
+ * 信息;上游新增家族时需同步本表({@link isKnownFamily} 用于在配置面提前给出可读
144
+ * 提示,而不是等运行时才报错)。
145
+ *
146
+ * `jev` 在白名单内但**永不由此插件推导**:它是 TypeSafe 的商业模型(私有 System One
147
+ * 协议),且上游明确它不能作默认模型;插件按用户已有的 DSH 模型推导家族,不会猜出它。
58
148
  */
59
149
  const MIDSCENE_FAMILIES = [
150
+ "jev",
60
151
  "doubao-vision",
61
152
  "doubao-seed",
62
153
  "gemini",
@@ -130,45 +221,67 @@ function volatileValue(value) {
130
221
  return typeof read === "function" ? read.call(value) : value;
131
222
  }
132
223
  /**
133
- * 生成 Midscene 侧固定四行的接入配置。
224
+ * 生成 Midscene 侧的接入配置。
134
225
  *
135
- * 四行都是固定值(基址、密钥、模型名、家族),因此用户可以把 `.env` 写死:换模型
226
+ * **默认职责固定四行**(基址、密钥、模型名、家族),因此用户可以把 `.env` 写死:换模型
136
227
  * 只需改插件设置,不必动这个文件。`MIDSCENE_MODEL_NAME` 固定为 {@link FIXED_MODEL_NAME},
137
228
  * 由桥决定实际用哪个模型。
138
229
  *
230
+ * **专用职责只在用户为它指定了模型后才追加一组变量**({@link DedicatedEnvSlot})。没配的
231
+ * 职责不写——上游自己回落到默认模型,于是「全部留空」时输出与升级前逐字符一致。
232
+ *
139
233
  * **`port` 必须传桥实际监听的端口**(`BridgeServer.port`),不是配置里的首选端口:
140
234
  * 端口被占用而自动跳号时,配置字段与实际情况可能不一致,`.env` 里写错端口会让
141
235
  * Midscene 直接连不上。
142
- * @param config - 桥接配置中与接入文件相关的三项。
236
+ *
237
+ * 头部注释额外声明**协议**(Chat Completions):本桥只提供这一种协议,用户照上游文档
238
+ * 自行改成 Responses 协议会打错路径。声明为注释而不是多写一个环境变量,是为了不改变
239
+ * 既有四行的取值(已按旧格式写入 `.env` 的用户不受影响)。
240
+ * @param config - 桥接配置中与接入文件相关的项。
143
241
  * @param config.port - 桥**实际**监听的端口。
144
242
  * @param config.apiKey - 桥接入密钥。
145
- * @param config.family - Midscene 协议家族。
243
+ * @param config.family - 默认职责的协议家族。
244
+ * @param config.dedicated - 专用职责的变量组(可选;未配置的职责不出现在这里)。
146
245
  * @returns `.env` 文本。
147
246
  */
148
247
  function renderEnvFile(config) {
149
- return [
248
+ const baseUrl = `http://${BRIDGE_HOST}:${config.port}/v1`;
249
+ const lines = [
150
250
  "# DSH Midscene Bridge 接入配置:四行都是固定值,换模型请改插件设置而非本文件。",
151
- `MIDSCENE_MODEL_BASE_URL="http://${BRIDGE_HOST}:${config.port}/v1"`,
152
- `MIDSCENE_MODEL_API_KEY="${config.apiKey}"`,
153
- `MIDSCENE_MODEL_NAME="${FIXED_MODEL_NAME}"`,
154
- `MIDSCENE_MODEL_FAMILY="${config.family}"`,
155
- ""
156
- ].join("\n");
251
+ "# 协议:OpenAI Chat Completions(openai-chat)——本桥只提供这一种协议。",
252
+ `${INTENT_ENV_PREFIX.default}_BASE_URL="${baseUrl}"`,
253
+ `${INTENT_ENV_PREFIX.default}_API_KEY="${config.apiKey}"`,
254
+ `${INTENT_ENV_PREFIX.default}_NAME="${FIXED_MODEL_NAME}"`,
255
+ `${INTENT_ENV_PREFIX.default}_FAMILY="${config.family}"`
256
+ ];
257
+ for (const intent of DEDICATED_INTENTS) {
258
+ const slot = config.dedicated?.find((entry) => entry.intent === intent);
259
+ if (slot === void 0) continue;
260
+ const prefix = INTENT_ENV_PREFIX[intent];
261
+ lines.push(`# 以下为「${INTENT_LABEL_ZH[intent]}」职责单独指定的模型;不配置则沿用上面的默认模型。`, `${prefix}_BASE_URL="${baseUrl}"`, `${prefix}_API_KEY="${config.apiKey}"`, `${prefix}_NAME="${intentModelName(intent)}"`, `${prefix}_FAMILY="${slot.family}"`, `${prefix}_STREAM_MODE="non-stream"`);
262
+ }
263
+ lines.push("");
264
+ return lines.join("\n");
157
265
  }
158
266
  /**
159
267
  * 桥接服务配置。
160
268
  *
161
- * `model` 为空(默认)时桥跟随 DSH 当前模型选择(需具备识图能力);指定时用它。
269
+ * `model` 是**默认职责**的模型:为空时桥跟随 DSH 当前模型选择(需具备识图能力);
270
+ * 指定时用它。三个专用职责(`locateModel` / `planningModel` / `insightModel`)留空时
271
+ * 沿用默认职责——与上游「未配置专用模型的职责使用默认模型」一致。
162
272
  *
163
- * **为什么是单个而不是列表**:Midscene 的协议家族在启动期从 `.env` 读取,而家族只
164
- * 有一个——多选里若混入不同系列的模型,回退到备用模型时家族仍是最初那个,反而制造
165
- * 静默错位。既然任何时刻只可能有一个模型生效,界面就如实只让选一个。
273
+ * **为什么每个职责只让选一个、不选列表**:Midscene 的协议家族在启动期从 `.env` 读取,
274
+ * 而一个职责只有一个家族——多选里若混入不同系列的模型,回退到备用模型时家族仍是最初
275
+ * 那个,反而制造静默错位。既然任何时刻只可能有一个模型生效,界面就如实只让选一个。
166
276
  */
167
277
  const Config = z.object({
168
278
  port: z.natural().default(DEFAULT_BRIDGE_PORT).volatile().description(`首选监听端口(默认 ${DEFAULT_BRIDGE_PORT})。被占用时自动向上尝试最多 20 个端口,并把实际端口写回本字段;实际端口以插件设置页或 /v1/midscene-env 为准`),
169
279
  apiKey: z.string().default("").role("secret").volatile().description("桥接接入密钥(安装时自动生成)。Midscene 的 .env 用它;可在设置页重新随机生成或自定义"),
170
280
  family: z.string().default(GENERIC_FAMILY).volatile().description("Midscene 协议家族(**自动维护**,无需手工设置):桥按实际使用的模型推导。识别得出家族就用该家族,识别不出但能识图的模型用通用家族。它只影响 Midscene 的提示词模板与坐标解析协议"),
171
- model: z.string().default("").volatile().description("指定用于 Midscene 测试的模型(「提供方/模型」形式)。留空则跟随 DSH 当前模型选择(需具备识图能力)"),
281
+ model: z.string().default("").volatile().description("**默认职责**用于 Midscene 的模型(「提供方/模型」形式)。留空则跟随 DSH 当前模型选择(需具备识图能力)。其余三个职责留空时沿用默认职责"),
282
+ locateModel: z.string().default("").volatile().description("**定位职责**(元素定位、deepLocate)单独指定的模型(「提供方/模型」形式)。留空则沿用默认职责"),
283
+ planningModel: z.string().default("").volatile().description("**规划职责**(多步骤规划与分支判断)单独指定的模型(「提供方/模型」形式)。留空则沿用默认职责"),
284
+ insightModel: z.string().default("").volatile().description("**页面理解职责**(断言、数据提取、aiQuery)单独指定的模型(「提供方/模型」形式)。留空则沿用默认职责"),
172
285
  requestTimeoutMs: z.natural().default(3e5).volatile().description("单次模型请求的超时毫秒数;0 表示不超时"),
173
286
  logRequests: z.boolean().default(true).volatile().description("是否在宿主日志记录每次请求的一行摘要(不含消息内容与图片数据)")
174
287
  });
@@ -197,6 +310,15 @@ function liveConfig(raw) {
197
310
  get model() {
198
311
  return read("model") ?? "";
199
312
  },
313
+ get locateModel() {
314
+ return read("locateModel") ?? "";
315
+ },
316
+ get planningModel() {
317
+ return read("planningModel") ?? "";
318
+ },
319
+ get insightModel() {
320
+ return read("insightModel") ?? "";
321
+ },
200
322
  get requestTimeoutMs() {
201
323
  return read("requestTimeoutMs");
202
324
  },
@@ -239,8 +361,14 @@ const MIDSCENE_SETTINGS_UPDATE_PATH = "/plugins/dsh-midscene-plugin/settings/upd
239
361
  * @module dsh-midscene/model-family
240
362
  */
241
363
  /**
242
- * 映射规则表。**顺序有意义**:先匹配到的胜出,因此更具体的规则必须排在更宽泛的前面
243
- * (例如 `kimi-k3` 必须排在 `kimi` 之前,否则 K3 会被判成旧家族)。
364
+ * 映射规则表。**顺序有意义**:先匹配到的胜出,因此更具体的规则必须排在更宽泛的前面。
365
+ *
366
+ * 三组顺序是硬约束(历史上都排错过,症状是「不报错但点位偏移几十像素」):
367
+ * - `kimi3` 排在 `kimi` 之前——否则 K3 会被判成旧家族;
368
+ * - `auto-glm` 排在 `glm-v` 之前——否则 `autoglm-phone` 这类 AutoGLM 会被宽泛的
369
+ * `glm` 规则先命中,判成智谱 GLM 视觉家族(上游把两者视为不同适配器);
370
+ * - `vlm-ui-tars-*` 排在 `doubao-*` 之前——否则 `doubao-1.5-ui-tars` 会被宽泛的
371
+ * `doubao` 规则先命中,判成豆包旧视觉系列而不是 UI-TARS 1.5。
244
372
  */
245
373
  const FAMILY_RULES = [
246
374
  {
@@ -268,6 +396,21 @@ const FAMILY_RULES = [
268
396
  pattern: /gemini/u,
269
397
  reason: "Google Gemini(坐标顺序为 yx,与其他家族相反)"
270
398
  },
399
+ {
400
+ family: "vlm-ui-tars-doubao-1.5",
401
+ pattern: /ui[-_.]?tars.*1\.5|1\.5.*ui[-_.]?tars/u,
402
+ reason: "UI-TARS 1.5(豆包)"
403
+ },
404
+ {
405
+ family: "vlm-ui-tars-doubao",
406
+ pattern: /ui[-_.]?tars.*doubao/u,
407
+ reason: "UI-TARS(豆包)"
408
+ },
409
+ {
410
+ family: "vlm-ui-tars",
411
+ pattern: /ui[-_.]?tars/u,
412
+ reason: "UI-TARS 原生系列"
413
+ },
271
414
  {
272
415
  family: "doubao-seed",
273
416
  pattern: /doubao[-_.]?seed|seed[-_.]?\d/u,
@@ -308,6 +451,11 @@ const FAMILY_RULES = [
308
451
  pattern: /deepseek/u,
309
452
  reason: "DeepSeek 视觉系列(坐标形状为 point)"
310
453
  },
454
+ {
455
+ family: "auto-glm",
456
+ pattern: /auto[-_.]?glm/u,
457
+ reason: "AutoGLM 系列"
458
+ },
311
459
  {
312
460
  family: "glm-v",
313
461
  pattern: /glm/u,
@@ -317,26 +465,6 @@ const FAMILY_RULES = [
317
465
  family: "xiaomi-mimo",
318
466
  pattern: /mimo/u,
319
467
  reason: "小米 MiMo"
320
- },
321
- {
322
- family: "vlm-ui-tars-doubao-1.5",
323
- pattern: /ui[-_.]?tars.*1\.5|1\.5.*ui[-_.]?tars/u,
324
- reason: "UI-TARS 1.5(豆包)"
325
- },
326
- {
327
- family: "vlm-ui-tars-doubao",
328
- pattern: /ui[-_.]?tars.*doubao/u,
329
- reason: "UI-TARS(豆包)"
330
- },
331
- {
332
- family: "vlm-ui-tars",
333
- pattern: /ui[-_.]?tars/u,
334
- reason: "UI-TARS 原生系列"
335
- },
336
- {
337
- family: "auto-glm",
338
- pattern: /auto[-_.]?glm/u,
339
- reason: "AutoGLM 系列"
340
468
  }
341
469
  ];
342
470
  /**
@@ -453,9 +581,40 @@ function readJsonBody$1(request) {
453
581
  });
454
582
  }
455
583
  /**
584
+ * 组装各职责的状态。
585
+ *
586
+ * 每个职责都给出两件事:**用户选了什么**(`configuredModel`)与**实际会用哪个**
587
+ * (`resolvedModel`)。两者不一致时——例如选了一个已被卸载的模型——界面能立刻看出来,
588
+ * 而不是等 Midscene 跑起来才失败。
589
+ *
590
+ * 专用职责未单独指定模型时沿用默认职责的结果(与上游「未配置专用模型的职责使用默认
591
+ * 模型」一致),此时 `dedicated` 为 `false`,界面据此显示「沿用默认」。
592
+ * @param deps - 端点依赖。
593
+ * @param config - 当前配置。
594
+ * @returns 各职责状态(顺序即 Tab 顺序)。
595
+ */
596
+ async function buildIntentSlots(deps, config) {
597
+ const choices = deps.resolveSlots === void 0 ? void 0 : await deps.resolveSlots().catch(() => void 0);
598
+ const defaultModel = choices?.default.modelId ?? (deps.resolveModel === void 0 ? void 0 : await deps.resolveModel());
599
+ const defaultFamily = choices?.default.family ?? resolveFamily(defaultModel ?? config.family).family;
600
+ return MIDSCENE_INTENTS.map((intent) => {
601
+ const choice = choices?.[intent];
602
+ const configured = config[INTENT_CONFIG_FIELD[intent]] ?? "";
603
+ const modelId = intent === "default" ? defaultModel : choice?.modelId ?? defaultModel;
604
+ const family = intent === "default" ? defaultFamily : choice?.family ?? defaultFamily;
605
+ return {
606
+ intent,
607
+ configuredModel: configured,
608
+ ...modelId === void 0 ? {} : { resolvedModel: modelId },
609
+ family,
610
+ dedicated: choice?.dedicated ?? false
611
+ };
612
+ });
613
+ }
614
+ /**
456
615
  * 组装状态快照。
457
616
  *
458
- * 包含界面需要的全部事实:当前密钥、家族与可选值、指定模型、固定模型名与桥地址、
617
+ * 包含界面需要的全部事实:当前密钥、家族与可选值、各职责的模型、固定模型名与桥地址、
459
618
  * 以及一份可直接复制的 `.env` 文本。让界面只依赖这一个响应,避免多处读取产生不一致。
460
619
  * @param deps - 端点依赖。
461
620
  * @returns 状态快照。
@@ -464,12 +623,20 @@ async function statusSnapshotForTest(deps) {
464
623
  const config = deps.readConfig();
465
624
  const apiKey = config.apiKey.length > 0 ? config.apiKey : generateApiKey();
466
625
  const available = await deps.listModels().catch(() => []);
467
- const chosen = deps.resolveModel === void 0 ? void 0 : await deps.resolveModel();
468
- const family = chosen === void 0 ? {
626
+ const slots = await buildIntentSlots(deps, config);
627
+ const defaultSlot = slots.find((slot) => slot.intent === "default");
628
+ const family = defaultSlot?.resolvedModel === void 0 ? {
469
629
  family: config.family,
470
630
  exact: false,
471
631
  reason: "尚未选择测试模型"
472
- } : resolveFamily(chosen);
632
+ } : resolveFamily(defaultSlot.resolvedModel);
633
+ const dedicated = DEDICATED_INTENTS.flatMap((intent) => {
634
+ const slot = slots.find((entry) => entry.intent === intent);
635
+ return slot === void 0 || !slot.dedicated ? [] : [{
636
+ intent,
637
+ family: slot.family
638
+ }];
639
+ });
473
640
  return {
474
641
  availableModels: available.filter((model) => model.vision === true).map((model) => ({
475
642
  id: model.id,
@@ -481,30 +648,37 @@ async function statusSnapshotForTest(deps) {
481
648
  family: family.family,
482
649
  familyReason: family.reason,
483
650
  model: config.model,
651
+ slots,
484
652
  fixedModelName: FIXED_MODEL_NAME,
485
653
  baseUrl: `http://${BRIDGE_HOST}:${config.port}/v1`,
486
654
  envFile: renderEnvFile({
487
655
  port: config.port,
488
656
  apiKey,
489
- family: family.family
657
+ family: family.family,
658
+ dedicated
490
659
  })
491
660
  };
492
661
  }
493
662
  /**
494
663
  * 校验并归一化一次配置写入请求。
495
664
  *
496
- * 只接受**单个模型**:协议家族由桥按实际使用的模型自动推导(`resolveFamily`),不是用户
665
+ * 只接受**每个职责一个模型**:协议家族由桥按实际使用的模型自动推导(`resolveFamily`),不是用户
497
666
  * 配置项——把它暴露给用户既要求他们理解 Midscene 的内部协议,又必然产生「家族与模型不
498
667
  * 匹配」的静默错位。若请求里带了 `family`,这里直接忽略(老版本界面或脚本可能仍会发送),
499
668
  * 由桥在生成接入配置时按真实模型覆盖。
500
669
  *
501
- * 空串是合法值,表示「未指定,跟随 DSH 当前会话模型」。
670
+ * 空串是合法值,表示「未指定,跟随 DSH 当前会话模型」(默认职责)或「沿用默认职责」
671
+ * (三个专用职责)。
502
672
  * @param input - 写入请求体。
503
673
  * @returns 归一化后的补丁(只含出现过的字段)。
504
674
  */
505
675
  function normalizePatchForTest(input) {
506
676
  const patch = {};
507
- if (typeof input.model === "string") patch.model = input.model.trim();
677
+ for (const intent of MIDSCENE_INTENTS) {
678
+ const field = INTENT_CONFIG_FIELD[intent];
679
+ const value = input[field];
680
+ if (typeof value === "string") patch[field] = value.trim();
681
+ }
508
682
  return patch;
509
683
  }
510
684
  /**
@@ -736,6 +910,73 @@ function chooseModel(snapshot, configured, session) {
736
910
  skippedConfigured
737
911
  };
738
912
  }
913
+ /**
914
+ * 按**每个职责自己的模型**分别决策(FNOS-021-02)。
915
+ *
916
+ * 与 {@link chooseModel} 的差别在两处,都源于上游的职责语义:
917
+ *
918
+ * 1. **家族按职责分别推导**:上游对专用职责的家族是独立变量(`MIDSCENE_LOCATE_MODEL_FAMILY`
919
+ * 等),且专用模型**不逐字段继承**默认模型。若沿用「按默认模型推导一次」,用户把定位
920
+ * 模型换成另一个系列时家族会停在默认模型那一套——正是需求禁止的「静默失准」。
921
+ * 2. **未配置专用模型时回落默认职责**:不是回落会话模型。默认职责已经按
922
+ * 「插件配置 → 会话模型 → 识图兜底」决策完毕,专用职责未配置就该跟着它的结果走。
923
+ *
924
+ * 专用职责配了但**目录里没有**该模型(提供方被卸载或模型改名)时,同样回落默认职责并
925
+ * 如实登记(`skippedConfigured`),界面据此提示、配置保留用户的选择。
926
+ * @param snapshot - 目录快照。
927
+ * @param config - 各职责配置的模型。
928
+ * @param session - DSH 当前模型选择的读取面。
929
+ * @returns 每个职责的决策结果。
930
+ */
931
+ function resolveIntentModels(snapshot, config, session) {
932
+ const defaultChoice = chooseModel(snapshot, config.model, session);
933
+ const defaultModelId = defaultChoice?.entry.id;
934
+ const defaultFamily = resolveFamily(defaultModelId ?? config.family).family;
935
+ const slots = {};
936
+ slots.default = {
937
+ intent: "default",
938
+ modelId: defaultModelId,
939
+ family: defaultFamily,
940
+ dedicated: false,
941
+ source: defaultChoice?.source ?? "fallback",
942
+ skippedConfigured: defaultChoice?.skippedConfigured ?? []
943
+ };
944
+ for (const intent of DEDICATED_INTENTS) {
945
+ const configured = (config[INTENT_CONFIG_FIELD[intent]] ?? "").trim();
946
+ if (configured === "") {
947
+ slots[intent] = {
948
+ intent,
949
+ modelId: defaultModelId,
950
+ family: defaultFamily,
951
+ dedicated: false,
952
+ source: "inherited",
953
+ skippedConfigured: []
954
+ };
955
+ continue;
956
+ }
957
+ const entry = snapshot.entries.find((candidate) => candidate.id === configured);
958
+ if (entry === void 0) {
959
+ slots[intent] = {
960
+ intent,
961
+ modelId: defaultModelId,
962
+ family: defaultFamily,
963
+ dedicated: false,
964
+ source: "inherited",
965
+ skippedConfigured: [configured]
966
+ };
967
+ continue;
968
+ }
969
+ slots[intent] = {
970
+ intent,
971
+ modelId: entry.id,
972
+ family: resolveFamily(entry.id).family,
973
+ dedicated: true,
974
+ source: "configured",
975
+ skippedConfigured: []
976
+ };
977
+ }
978
+ return slots;
979
+ }
739
980
  //#endregion
740
981
  //#region src/host/convert.ts
741
982
  /** 桥接受的图片媒体类型(与宿主附件服务一致)。 */
@@ -956,6 +1197,135 @@ function convertTools(raw) {
956
1197
  return tools.length === 0 ? void 0 : tools;
957
1198
  }
958
1199
  //#endregion
1200
+ //#region src/host/reasoning.ts
1201
+ /** 表示「关闭 / 不做推理」的档位 id 或名字(统一小写比较)。 */
1202
+ const OFF_EFFORT_TOKENS = [
1203
+ "off",
1204
+ "none",
1205
+ "disabled"
1206
+ ];
1207
+ /**
1208
+ * 表示「最低档推理」的档位 id 或名字。
1209
+ *
1210
+ * 它不等于「关闭」,但它是宿主能表达的最接近关闭的取值(Gemini 自己的 `minimal`
1211
+ * 就是这个语义)。只在找不到真正的关闭档位时作为退路。
1212
+ */
1213
+ const MINIMAL_EFFORT_TOKENS = ["minimal"];
1214
+ /**
1215
+ * 把未知值收窄成普通对象。
1216
+ * @param value - 待判定值。
1217
+ * @returns 对象或 `undefined`。
1218
+ */
1219
+ function asRecord(value) {
1220
+ return typeof value === "object" && value !== null && !Array.isArray(value) ? value : void 0;
1221
+ }
1222
+ /**
1223
+ * 取一个非空字符串(去掉首尾空白)。
1224
+ * @param value - 待判定值。
1225
+ * @returns 非空字符串或 `undefined`。
1226
+ */
1227
+ function nonEmptyString(value) {
1228
+ if (typeof value !== "string") return void 0;
1229
+ const trimmed = value.trim();
1230
+ return trimmed === "" ? void 0 : trimmed;
1231
+ }
1232
+ /**
1233
+ * 判断一个档位取值是否在给定词表里。
1234
+ * @param value - 档位 id 或名字(已小写)。
1235
+ * @param tokens - 词表。
1236
+ * @returns 是否命中。
1237
+ */
1238
+ function matchesToken(value, tokens) {
1239
+ return tokens.includes(value);
1240
+ }
1241
+ /**
1242
+ * 把一个「档位值」字符串转成意图。
1243
+ *
1244
+ * `none` / `minimal` 这类取值本身就是「不做推理」的写法,因此归到 `disabled`。
1245
+ * @param value - 档位取值。
1246
+ * @returns 思考意图。
1247
+ */
1248
+ function intentFromEffortValue(value) {
1249
+ const normalized = value.toLowerCase();
1250
+ if (matchesToken(normalized, OFF_EFFORT_TOKENS) || matchesToken(normalized, MINIMAL_EFFORT_TOKENS)) return { kind: "disabled" };
1251
+ return {
1252
+ kind: "effort",
1253
+ value: normalized
1254
+ };
1255
+ }
1256
+ /**
1257
+ * 从 OpenAI 兼容请求体解析 Midscene 的思考意图。
1258
+ *
1259
+ * 按**明确的开关字段优先**的顺序判断(Midscene 每个家族只发其中一套,顺序主要用于
1260
+ * 同一请求里出现多个字段时的一致性):
1261
+ * 1. `thinking.type`:`disabled` → 关;`enabled` → 开(若同时带 `reasoning_effort` 则用该档位);
1262
+ * 2. `enable_thinking`:`false` → 关;`true` → 开;
1263
+ * 3. `reasoning_effort`:`none`/`minimal` → 关;其它 → 该档位;
1264
+ * 4. `extra_body.google.thinking_config.thinking_level`:同上。
1265
+ * @param body - 已解析的请求体。
1266
+ * @returns 思考意图;请求里没有任何相关字段时为 `undefined`(与升级前一致,不动)。
1267
+ */
1268
+ function parseThinkingIntent(body) {
1269
+ const reasoningEffort = nonEmptyString(body.reasoning_effort);
1270
+ const thinkingType = nonEmptyString(asRecord(body.thinking)?.type)?.toLowerCase();
1271
+ if (thinkingType === "disabled") return { kind: "disabled" };
1272
+ if (thinkingType === "enabled") return reasoningEffort === void 0 ? { kind: "enabled" } : intentFromEffortValue(reasoningEffort);
1273
+ if (body.enable_thinking === false) return { kind: "disabled" };
1274
+ if (body.enable_thinking === true) return { kind: "enabled" };
1275
+ if (reasoningEffort !== void 0) return intentFromEffortValue(reasoningEffort);
1276
+ const thinkingLevel = nonEmptyString(asRecord(asRecord(asRecord(body.extra_body)?.google)?.thinking_config)?.thinking_level);
1277
+ if (thinkingLevel !== void 0) return intentFromEffortValue(thinkingLevel);
1278
+ }
1279
+ /**
1280
+ * 在宿主披露的档位里挑出与意图匹配的那一个。
1281
+ *
1282
+ * **只返回宿主确实提供的 id**,绝不自行拼字符串——拼错的档位会在发起请求前被
1283
+ * `UNSUPPORTED_REASONING_EFFORT` 拦下,等于把一个本来能用的请求打成失败。
1284
+ * @param intent - 思考意图。
1285
+ * @param efforts - 宿主 `resolveModelInfo` 给出的可选档位(按由弱到强排序)。
1286
+ * @returns 命中的档位 id;无可表达档位时为 `undefined`(调用方据此不传)。
1287
+ */
1288
+ function pickReasoningEffort(intent, efforts) {
1289
+ if (efforts.length === 0) return void 0;
1290
+ const has = (effort, tokens) => matchesToken(effort.id.toLowerCase(), tokens) || matchesToken(effort.name.toLowerCase(), tokens);
1291
+ switch (intent.kind) {
1292
+ case "disabled": {
1293
+ const off = efforts.find((effort) => has(effort, OFF_EFFORT_TOKENS));
1294
+ if (off !== void 0) return off.id;
1295
+ return efforts.find((effort) => has(effort, MINIMAL_EFFORT_TOKENS))?.id;
1296
+ }
1297
+ case "enabled": return efforts.find((effort) => !has(effort, OFF_EFFORT_TOKENS) && !has(effort, MINIMAL_EFFORT_TOKENS))?.id;
1298
+ case "effort": {
1299
+ const wanted = intent.value.toLowerCase();
1300
+ return efforts.find((effort) => effort.id.toLowerCase() === wanted || effort.name.toLowerCase() === wanted)?.id;
1301
+ }
1302
+ }
1303
+ }
1304
+ /**
1305
+ * 解析一次请求最终要传给宿主的思考档位。
1306
+ *
1307
+ * 任何一步失败(请求里没有思考字段、宿主不披露档位、`resolveModelInfo` 报错或超时)都
1308
+ * 降级为 `undefined`——**请求照常发出**,思考行为退回宿主默认(与升级前一致)。
1309
+ * @param llm - 宿主模型层(只用到 `resolveModelInfo`)。
1310
+ * @param provider - 提供方路由键。
1311
+ * @param model - 模型 id。
1312
+ * @param body - 已解析的请求体。
1313
+ * @param signal - 可选中止信号。
1314
+ * @returns 宿主档位 id;不应传时为 `undefined`。
1315
+ */
1316
+ async function resolveReasoningEffort(llm, provider, model, body, signal) {
1317
+ const intent = parseThinkingIntent(body);
1318
+ if (intent === void 0) return void 0;
1319
+ let efforts;
1320
+ try {
1321
+ efforts = (await llm.resolveModelInfo(provider, model, signal)).reasoning?.efforts ?? [];
1322
+ } catch {
1323
+ return;
1324
+ }
1325
+ const picked = pickReasoningEffort(intent, efforts);
1326
+ return picked === void 0 ? void 0 : picked;
1327
+ }
1328
+ //#endregion
959
1329
  //#region src/host/stream.ts
960
1330
  /** harness 的 `finish` 原因 → OpenAI 的 `finish_reason`。 */
961
1331
  const FINISH_REASONS = {
@@ -1217,6 +1587,17 @@ var CatalogCache = class {
1217
1587
  /** 读取请求体(上限 32 MiB:图片数据 URI 会显著放大 JSON 体积)。 */
1218
1588
  const MAX_BODY_BYTES = 33554432;
1219
1589
  /**
1590
+ * 协议误配时的可读指引。
1591
+ *
1592
+ * 用户照上游文档自行把协议改成 Responses(或把 Jev 当默认模型)时,请求会打到本桥
1593
+ * 不提供的路径上。没有指引时用户只看到一个无上下文的 404,只能自己猜。**保留 404 状态
1594
+ * 码**(那确实是「本桥没有这个端点」),但补上原因与做法。
1595
+ */
1596
+ const PROTOCOL_GUIDANCE = {
1597
+ [`/v1/responses`]: "本桥只提供 OpenAI Chat Completions 协议(/v1/chat/completions)。请把 MIDSCENE_MODEL_PROTOCOL 保持为默认值 openai-chat:DSH 已在宿主内把各提供方的上游协议归一(Codex 的 Responses、CodeBuddy 的私有形态都由各自适配器处理),因此单用 Chat Completions 即可触达 DSH 里已配置的全部模型。",
1598
+ [`/v1/systemone`]: "Jev 使用 TypeSafe 的私有 System One 协议,不经本桥(它也不是 OpenAI 协议)。请在插件设置页的「默认」职责选一个通用模型作为默认模型,并重新拉取接入配置。"
1599
+ };
1600
+ /**
1220
1601
  * 读取并解析 JSON 请求体。
1221
1602
  * @param request - 入站请求。
1222
1603
  * @returns 解析结果。
@@ -1347,6 +1728,31 @@ var BridgeServer = class {
1347
1728
  return chooseModel(await this.catalog.get(), this.deps.config.model, this.deps.sessionModel)?.entry.id;
1348
1729
  }
1349
1730
  /**
1731
+ * 每个职责的模型决策结果。
1732
+ *
1733
+ * 供设置页展示「各职责当前实际使用哪个模型」与生成接入配置。设置页与桥共用同一套
1734
+ * 决策函数,因此界面显示的与真实调用的必然一致。
1735
+ * @returns 每个职责的决策结果。
1736
+ */
1737
+ async resolveSlots() {
1738
+ const snapshot = await this.catalog.get();
1739
+ return this.#slots(snapshot);
1740
+ }
1741
+ /**
1742
+ * 按职责决策模型(内部实现)。
1743
+ * @param snapshot - 目录快照。
1744
+ * @returns 每个职责的决策结果。
1745
+ */
1746
+ #slots(snapshot) {
1747
+ return resolveIntentModels(snapshot, {
1748
+ model: this.deps.config.model,
1749
+ locateModel: this.deps.config.locateModel,
1750
+ planningModel: this.deps.config.planningModel,
1751
+ insightModel: this.deps.config.insightModel,
1752
+ family: this.deps.config.family
1753
+ }, this.deps.sessionModel);
1754
+ }
1755
+ /**
1350
1756
  * 启动服务。
1351
1757
  *
1352
1758
  * 端口被占用时**自动向上尝试**下一个端口(最多 {@link PORT_SCAN_LIMIT} 个),
@@ -1480,15 +1886,22 @@ var BridgeServer = class {
1480
1886
  }
1481
1887
  if (request.method === "GET" && path === `/v1/health`) {
1482
1888
  const snapshot = await this.catalog.get();
1483
- const healthChoice = chooseModel(snapshot, this.deps.config.model, this.deps.sessionModel);
1889
+ const slots = this.#slots(snapshot);
1484
1890
  sendJson(response, 200, {
1485
1891
  status: "ok",
1486
1892
  host: BRIDGE_HOST,
1487
1893
  port: this.port,
1488
1894
  fixedModelName: FIXED_MODEL_NAME,
1489
- family: resolveFamily(healthChoice?.entry.id ?? this.deps.config.family).family,
1490
- resolvedModel: healthChoice?.entry.id,
1895
+ family: slots.default.family,
1896
+ resolvedModel: slots.default.modelId,
1491
1897
  configuredModel: this.deps.config.model,
1898
+ slots: Object.fromEntries(Object.entries(slots).map(([intent, slot]) => [intent, {
1899
+ model: slot.modelId,
1900
+ family: slot.family,
1901
+ dedicated: slot.dedicated,
1902
+ source: slot.source,
1903
+ ...slot.skippedConfigured.length === 0 ? {} : { skippedConfigured: slot.skippedConfigured }
1904
+ }])),
1492
1905
  providers: snapshot.providers,
1493
1906
  models: snapshot.entries.length,
1494
1907
  attachments: this.deps.attachments !== void 0
@@ -1497,25 +1910,48 @@ var BridgeServer = class {
1497
1910
  }
1498
1911
  if (request.method === "GET" && path === `/v1/midscene-env`) {
1499
1912
  const snapshot = await this.catalog.get();
1500
- const choice = chooseModel(snapshot, this.deps.config.model, this.deps.sessionModel);
1501
- const family = resolveFamily(choice?.entry.id ?? this.deps.config.family).family;
1913
+ const slots = this.#slots(snapshot);
1914
+ const defaultSlot = slots.default;
1915
+ const dedicated = DEDICATED_INTENTS.filter((intent) => slots[intent].dedicated).map((intent) => ({
1916
+ intent,
1917
+ family: slots[intent].family
1918
+ }));
1919
+ const baseUrl = `http://${BRIDGE_HOST}:${this.port}/v1`;
1502
1920
  sendJson(response, 200, {
1503
1921
  content: renderEnvFile({
1504
- ...this.deps.config,
1505
1922
  port: this.port,
1506
- family
1923
+ apiKey: this.deps.config.apiKey,
1924
+ family: defaultSlot.family,
1925
+ dedicated
1507
1926
  }),
1508
1927
  variables: {
1509
- MIDSCENE_MODEL_BASE_URL: `http://${BRIDGE_HOST}:${this.port}/v1`,
1510
- MIDSCENE_MODEL_API_KEY: this.deps.config.apiKey,
1511
- MIDSCENE_MODEL_NAME: FIXED_MODEL_NAME,
1512
- MIDSCENE_MODEL_FAMILY: family
1928
+ [`${INTENT_ENV_PREFIX.default}_BASE_URL`]: baseUrl,
1929
+ [`${INTENT_ENV_PREFIX.default}_API_KEY`]: this.deps.config.apiKey,
1930
+ [`${INTENT_ENV_PREFIX.default}_NAME`]: FIXED_MODEL_NAME,
1931
+ [`${INTENT_ENV_PREFIX.default}_FAMILY`]: defaultSlot.family,
1932
+ ...Object.fromEntries(dedicated.flatMap((slot) => {
1933
+ const prefix = INTENT_ENV_PREFIX[slot.intent];
1934
+ return [
1935
+ [`${prefix}_BASE_URL`, baseUrl],
1936
+ [`${prefix}_API_KEY`, this.deps.config.apiKey],
1937
+ [`${prefix}_NAME`, intentModelName(slot.intent)],
1938
+ [`${prefix}_FAMILY`, slot.family],
1939
+ [`${prefix}_STREAM_MODE`, "non-stream"]
1940
+ ];
1941
+ }))
1513
1942
  },
1514
- ...choice === void 0 ? {} : {
1515
- resolvedModel: choice.entry.id,
1516
- resolvedFrom: choice.source
1943
+ ...defaultSlot.modelId === void 0 ? {} : {
1944
+ resolvedModel: defaultSlot.modelId,
1945
+ resolvedFrom: defaultSlot.source
1517
1946
  },
1518
- ...choice === void 0 || choice.skippedConfigured.length === 0 ? {} : { skippedConfigured: choice.skippedConfigured },
1947
+ ...defaultSlot.skippedConfigured.length === 0 ? {} : { skippedConfigured: defaultSlot.skippedConfigured },
1948
+ resolvedSlots: Object.fromEntries(Object.entries(slots).map(([intent, slot]) => [intent, {
1949
+ model: slot.modelId,
1950
+ family: slot.family,
1951
+ dedicated: slot.dedicated,
1952
+ source: slot.source,
1953
+ ...slot.skippedConfigured.length === 0 ? {} : { skippedConfigured: slot.skippedConfigured }
1954
+ }])),
1519
1955
  availableModels: snapshot.entries.filter((entry) => entry.vision === true).map((entry) => entry.id)
1520
1956
  });
1521
1957
  return;
@@ -1525,7 +1961,7 @@ var BridgeServer = class {
1525
1961
  return;
1526
1962
  }
1527
1963
  sendJson(response, 404, { error: {
1528
- message: `unknown endpoint ${path}; available: /v1/models, /v1/chat/completions, /v1/midscene-env, /v1/health`,
1964
+ message: PROTOCOL_GUIDANCE[path] ?? `unknown endpoint ${path}; available: /v1/models, /v1/chat/completions, /v1/midscene-env, /v1/health`,
1529
1965
  type: "invalid_request_error",
1530
1966
  code: null
1531
1967
  } });
@@ -1542,11 +1978,12 @@ var BridgeServer = class {
1542
1978
  const body = await readJsonBody(request);
1543
1979
  const rawModel = typeof body.model === "string" ? body.model : "";
1544
1980
  const snapshot = await this.catalog.get();
1545
- if (rawModel === "dsh-model") {
1546
- const choice = chooseModel(snapshot, this.deps.config.model, this.deps.sessionModel);
1547
- if (choice === void 0) throw new RequestConversionError("no model is available in DSH; configure a provider in DSH first", 400, "invalid_request_error");
1548
- const attribution = choice.entry.id;
1549
- await this.#runCompletion(body, attribution, choice.entry.vision === true, response);
1981
+ const intent = parseIntentModelName(rawModel);
1982
+ if (intent !== void 0) {
1983
+ const slot = this.#slots(snapshot)[intent];
1984
+ if (slot.modelId === void 0) throw new RequestConversionError("no model is available in DSH; configure a provider in DSH first", 400, "invalid_request_error");
1985
+ const known = snapshot.entries.find((entry) => entry.id === slot.modelId);
1986
+ await this.#runCompletion(body, slot.modelId, known === void 0 ? true : known.vision === true, response);
1550
1987
  return;
1551
1988
  }
1552
1989
  const resolved = resolveModelName(rawModel, snapshot.providers, "");
@@ -1582,6 +2019,7 @@ var BridgeServer = class {
1582
2019
  sendError(response, new RequestConversionError("messages produced no content", 400, "invalid_request_error"), attribution);
1583
2020
  return;
1584
2021
  }
2022
+ const reasoningEffort = await resolveReasoningEffort(this.deps.llm, provider, model, body);
1585
2023
  const options = {
1586
2024
  provider,
1587
2025
  model,
@@ -1593,7 +2031,8 @@ var BridgeServer = class {
1593
2031
  ...(() => {
1594
2032
  const tools = convertTools(body.tools);
1595
2033
  return tools === void 0 ? {} : { tools };
1596
- })()
2034
+ })(),
2035
+ ...reasoningEffort === void 0 ? {} : { reasoningEffort }
1597
2036
  };
1598
2037
  const wantsStream = body.stream === true;
1599
2038
  const id = `chatcmpl-${Math.random().toString(36).slice(2, 12)}`;
@@ -1743,10 +2182,16 @@ const BRIDGE_PRELUDE = `> **本环境说明(由 DSH Midscene 插件注入,
1743
2182
  > 模型与 key 示例仅作背景知识;实际使用哪个模型由桥决定。
1744
2183
  > - 需要浏览器桥接模式时同样走桥:Midscene 侧的模型配置始终是上面这四行。
1745
2184
  > - **浏览器交互用用户的主 Chrome**:走扩展桥接(\`--bridge\` / \`AgentOverChromeBridge\`),
1746
- > 复用用户真实浏览器的登录态,而不是另起一个干净 profile。用户只需**一次性**把上面四行
1747
- > 粘进 **Midscene 扩展的侧边栏设置**(扩展的 Playground 靠它接上 DSH 的模型)。
1748
- > **要主动把这一步讲给用户** —— 少了它扩展用不上 DSH 的模型,用户就会被引向申请第三方
1749
- > key,而那正是本插件要消除的成本。不要反过来让用户「先配好模型再来」。
2185
+ > 复用用户真实浏览器的登录态,而不是另起一个干净 profile。
2186
+ > - **桥接模式下扩展不需要配模型。** 推理发生在**跑脚本的这一侧**(Node/CLI),扩展只当
2187
+ > 「眼睛和手」:截图、点击、输入。判据可实测:不给扩展任何模型配置也能跑通;反向验证——
2188
+ > 去掉 CLI 侧的 \`MIDSCENE_MODEL_NAME\` 会直接报 \`Model configuration is incomplete: model
2189
+ > name (MIDSCENE_MODEL_NAME) is required\`,报错点在 CLI 侧,说明配置属于这一侧。
2190
+ > 所以**不要**让用户去配扩展,也不要把「扩展里没填模型」当成连不上的原因:能否连上只取决于
2191
+ > 扩展装没装、首次连接有没有点过 **Allow**。
2192
+ > - **唯一需要配扩展的情况**是让用户用**扩展自带的 Playground**(在扩展侧边栏里手写自然语言
2193
+ > 指令、由扩展自己驱动页面)。那是另一条链路,那时才把上面四行粘进侧边栏设置。用本插件做
2194
+ > 桥接自动化时**不要**主动要求这一步。
1750
2195
  >
1751
2196
  > **静默操作(不打断用户)**:用 Bridge 模式驱动用户浏览器时,不要切走用户正在看的页面。
1752
2197
  > 静默是**一步**——由 \`connectCurrentTab\` 的 \`activateTab: false\` 完成,它会直接连上浏览器的
@@ -2004,6 +2449,15 @@ function apply(ctx, rawConfig = Config({})) {
2004
2449
  get model() {
2005
2450
  return live.model;
2006
2451
  },
2452
+ get locateModel() {
2453
+ return live.locateModel;
2454
+ },
2455
+ get planningModel() {
2456
+ return live.planningModel;
2457
+ },
2458
+ get insightModel() {
2459
+ return live.insightModel;
2460
+ },
2007
2461
  get requestTimeoutMs() {
2008
2462
  return live.requestTimeoutMs;
2009
2463
  },
@@ -2064,6 +2518,7 @@ function apply(ctx, rawConfig = Config({})) {
2064
2518
  }));
2065
2519
  },
2066
2520
  resolveModel: async () => await bridge.resolveModel(),
2521
+ resolveSlots: async () => await bridge.resolveSlots(),
2067
2522
  update: async (patch) => {
2068
2523
  await settings.update(MIDSCENE_SETTINGS_NAMESPACE, patch);
2069
2524
  },
@@ -2083,4 +2538,4 @@ function apply(ctx, rawConfig = Config({})) {
2083
2538
  }, "dsh-midscene: bundled skills");
2084
2539
  }
2085
2540
  //#endregion
2086
- export { BRIDGE_HOST, BridgePortExhaustedError, BridgeServer, CatalogCache, Config, DEFAULT_BRIDGE_PORT, DEFAULT_FAMILY, FIXED_MODEL_NAME, GENERIC_FAMILY, MIDSCENE_FAMILIES, OPENAI_API_PREFIX, RequestConversionError, SKILL_PROVIDER_NAME, aggregateStream, apply, buildCatalog, bundledSkillsDir, chooseModel, convertMessages, convertTools, createBundledSkillProvider, formatModelName, generateApiKey, inject, isKnownFamily, listBundledSkills, makeChunk, modelSupportsImage, name, parseDataUri, registerBundledSkills, renderEnvFile, resolveModelName, sseLine, toFinishReason, toOpenAiError, toOpenAiModel };
2541
+ export { BRIDGE_HOST, BridgePortExhaustedError, BridgeServer, CatalogCache, Config, DEDICATED_INTENTS, DEFAULT_BRIDGE_PORT, DEFAULT_FAMILY, FIXED_MODEL_NAME, GENERIC_FAMILY, INTENT_CONFIG_FIELD, INTENT_ENV_PREFIX, INTENT_LABEL_ZH, MIDSCENE_FAMILIES, MIDSCENE_INTENTS, OPENAI_API_PREFIX, RequestConversionError, SKILL_PROVIDER_NAME, 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 };