dsh-neartoken 0.20.0 → 0.21.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 CHANGED
@@ -24,7 +24,7 @@
24
24
  |---|---|
25
25
  | `src/index.ts` | 配置 schema、按凭据现状挂载 provider、装配其余模块 |
26
26
  | `src/host/account.ts` | RFC 8628 形状的设备授权:发起、按 interval 轮询、把 key 写进 credentials |
27
- | `src/host/routes.ts` | 设置页调用的同源路由(状态 / 余额立即刷新 / 授权 / 取消 / 断开 / 模型白名单 / 生图设置) |
27
+ | `src/host/routes.ts` | 设置页与模型选择器调用的同源路由(状态 / 余额立即刷新 / 授权 / 取消 / 断开 / 模型白名单 / 生图设置 / 长连接端点) |
28
28
  | `src/host/whitelist.ts` | 白名单读写在插件自身 Config 的 `enabledModels`(volatile),存 profile patch |
29
29
  | `src/host/pricing.ts` | 拉 `/api/pricing`,展开成 `"<组>::<模型>"` 路由,过滤出能聊的模型 |
30
30
  | `src/host/model-caps.ts` | 一个模型能不能聊、上下文窗口多大、可选的推理等级(只读站点声明,不存模型表) |
@@ -33,6 +33,7 @@
33
33
  | `src/host/protocol-router.ts` | 按模型选上游协议(claude / gemini / gpt / 其余) |
34
34
  | `src/host/session-key.ts` | 从 `GenerateOptions.sessionId` 取会话亲和键,四条 wire 用它让站点把会话粘在同一渠道 |
35
35
  | `src/host/provider-mount.ts` | 路由挂载、撤下、白名单变更时 `replace()` 重播 |
36
+ | `src/host/relay.ts` | 模型接口走哪个域名:站点根或长连接端点,由模型选择器里的开关决定 |
36
37
  | `src/host/topup.ts` | 站点充值面:读 amount 档位与渠道、下单,把 403 `DSH_TOKEN_REQUIRED` 翻成「是否 DSH 密钥」的原因 |
37
38
  | `src/host/images.ts` | 生图:挑通道、发请求、两种响应都读成 bytes |
38
39
  | `src/host/image-tool.ts` | `generate_image` 工具:选模型/分组、把图写进 attachment |
@@ -59,6 +60,8 @@
59
60
 
60
61
  分组路由按同一文档:请求头 `x-neartoken-group` 的值是 `/api/pricing` 的 `group_refs` 给出的 **`#<id>`**(纯 ASCII),分组名只用于展示;某分组没有 ref 时不发该头,按令牌自身分组路由。
61
62
 
63
+ 模型选择器的根菜单里,「分组」下面一行是**长连接端点**开关:打开后所有**模型接口**(`/v1/chat/completions`、`/v1/messages`、`/v1/responses`、`/v1/images/*`、Gemini 的 `/v1beta/*`)改走 `https://direct.neartoken.cc`,站点控制台的 `/api/*`(目录、用量、钱包、充值、设备授权)仍走 `baseURL`。开关写进插件配置的 `directLink`(volatile),点完立刻对下一次请求生效,不需要重启。它只出现在本插件自己的 provider 上。
64
+
62
65
  模型选择器里的分组是**显式选择**:换模型时先保留当前分组;新模型不在该分组时,按分组名上的档位标签(`[低价]` / `[满血]` / `[官key]` 等)就近匹配同一档位的分组,而不是落回站点目录里的第一个分组——那一个往往是倍率最高的。跨模型族(`[低价] DeepSeek` → GPT)也按标签匹配。
63
66
 
64
67
  ## 数据概览(消耗 / Token / 模型堆积)
@@ -105,6 +108,8 @@ https://<site>/dsh/device?user_code=K7QM-3XPD&aff=<code>
105
108
  | 字段 | 默认 | 说明 |
106
109
  |---|---|---|
107
110
  | `baseURL` | `https://neartoken.cc` | 站点根地址,不带尾斜杠 |
111
+ | `directEndpoint` | `https://direct.neartoken.cc` | 长连接端点;模型选择器打开开关后模型接口改走它,`/api/*` 不受影响 |
112
+ | `directLink` | `false` | 长连接端点开关;volatile,模型选择器直接写它 |
108
113
  | `apiKeyEnv` | `NEARTOKEN_API_KEY` | 授权写入、adapter 读取的凭据引用名 |
109
114
  | `catalogTtlMs` | `300000` | `/api/pricing` 目录缓存时长 |
110
115
  | `defaultContextWindow` | `200000` | 没有任何来源能说明某模型上下文窗口时上报的值 |
package/lib/client.js CHANGED
@@ -44,6 +44,8 @@ window.__ModuleLoader__.load({
44
44
  const MODELS_PATH = "/neartoken/models";
45
45
  /** Read the picture models and the image-generation setting; POST one change to it. */
46
46
  const IMAGES_PATH = "/neartoken/images";
47
+ /** Read the long-connection switch; POST its new state. */
48
+ const LINK_PATH = "/neartoken/link";
47
49
  /** Read the site's top-up offer; POST one order and open its checkout page. */
48
50
  const TOPUP_PATH = "/neartoken/topup";
49
51
  /**
@@ -200,6 +202,20 @@ window.__ModuleLoader__.load({
200
202
  const refusal = await response.json().catch(() => ({ message: `HTTP ${String(response.status)}` }));
201
203
  throw new Error(refusal.message ?? `HTTP ${String(response.status)}`);
202
204
  }
205
+ },
206
+ async link() {
207
+ return await jsonOf(await fetcher(LINK_PATH, { headers: { accept: "application/json" } }));
208
+ },
209
+ async saveLink(direct) {
210
+ const response = await fetcher(LINK_PATH, {
211
+ method: "POST",
212
+ headers: { "content-type": "application/json" },
213
+ body: JSON.stringify({ direct })
214
+ });
215
+ if (!response.ok) {
216
+ const refusal = await response.json().catch(() => ({ message: `HTTP ${String(response.status)}` }));
217
+ throw new Error(refusal.message ?? `HTTP ${String(response.status)}`);
218
+ }
203
219
  }
204
220
  };
205
221
  }
@@ -456,23 +472,23 @@ window.__ModuleLoader__.load({
456
472
  document.head.appendChild(tag);
457
473
  }
458
474
  var group_tags_module_css_default = {
459
- "toneLime": "FotuUq_toneLime",
460
- "tag": "FotuUq_tag",
461
- "toneViolet": "FotuUq_toneViolet",
475
+ "toneOrange": "FotuUq_toneOrange",
476
+ "toneTeal": "FotuUq_toneTeal",
477
+ "ratioChip": "FotuUq_ratioChip",
462
478
  "toneRose": "FotuUq_toneRose",
479
+ "toneIndigo": "FotuUq_toneIndigo",
480
+ "tag": "FotuUq_tag",
463
481
  "toneEmerald": "FotuUq_toneEmerald",
464
- "toneTeal": "FotuUq_toneTeal",
465
- "toneOrange": "FotuUq_toneOrange",
482
+ "toneSky": "FotuUq_toneSky",
466
483
  "ratioBase": "FotuUq_ratioBase",
467
- "toneCyan": "FotuUq_toneCyan",
468
- "toneIndigo": "FotuUq_toneIndigo",
484
+ "ratioPricey": "FotuUq_ratioPricey",
469
485
  "toneAmber": "FotuUq_toneAmber",
470
- "ratioChip": "FotuUq_ratioChip",
486
+ "toneCyan": "FotuUq_toneCyan",
471
487
  "ratioCheap": "FotuUq_ratioCheap",
472
488
  "tonePink": "FotuUq_tonePink",
473
- "toneSky": "FotuUq_toneSky",
489
+ "toneViolet": "FotuUq_toneViolet",
474
490
  "toneFuchsia": "FotuUq_toneFuchsia",
475
- "ratioPricey": "FotuUq_ratioPricey"
491
+ "toneLime": "FotuUq_toneLime"
476
492
  };
477
493
  //#endregion
478
494
  //#region src/client/group-tags.tsx
@@ -517,7 +533,7 @@ window.__ModuleLoader__.load({
517
533
  }
518
534
  //#endregion
519
535
  //#region \0dsh-css:D:\Projects\deepseek-harness\dsh-neartoken\src\client\ModelGroupSelect.module.css.mjs
520
- const css$1 = "._2pt-bW_root{min-width:0;position:relative}._2pt-bW_trigger{border-radius:var(--dsw-radius-sm);min-width:0;max-width:min(360px,45cqw);height:28px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;outline:none;align-items:center;gap:4px;padding:0 4px 0 8px;font-size:13px;font-weight:400;line-height:20px;display:flex}._2pt-bW_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}._2pt-bW_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}._2pt-bW_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}._2pt-bW_triggerLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}._2pt-bW_triggerEffort{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-caption);flex-shrink:1000;overflow:hidden}._2pt-bW_triggerIcon{display:var(--dsh-composer-model-icon-display,none);flex:none}._2pt-bW_chevron{color:var(--dsw-alias-label-caption);flex:none}._2pt-bW_menu{z-index:1100;--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);width:max-content;min-width:min(240px,100vw - 32px);max-width:min(420px,100vw - 32px);max-height:min(360px,100vh - 96px);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex-direction:column;padding:4px;display:flex;position:fixed;overflow:hidden}._2pt-bW_status,._2pt-bW_empty{color:var(--dsw-alias-label-tertiary);padding:8px;font-size:12px;line-height:18px}._2pt-bW_error,._2pt-bW_warning{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:flex-start;gap:6px;margin-bottom:3px;padding:6px 7px;font-size:11px;line-height:16px;display:flex}._2pt-bW_warning{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-state-warn-label)}._2pt-bW_retry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600}._2pt-bW_searchRow{flex-shrink:0;margin:2px 0 3px;position:relative}._2pt-bW_searchRow ._2pt-bW_search{border-radius:var(--dsw-radius-md);background:0 0;border:0 solid #0000;height:auto;padding:5px 7px;display:flex}._2pt-bW_searchRow ._2pt-bW_search input{padding:0;font-size:12px;line-height:normal}._2pt-bW_searchClear{width:24px;height:24px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;display:inline-flex;position:absolute;top:50%;right:4px;transform:translateY(-50%)}._2pt-bW_searchClear:hover,._2pt-bW_searchClear:focus-visible{background:var(--dsw-alias-interactive-bg-hover);outline:none}._2pt-bW_groups{min-height:0;overflow-y:auto}._2pt-bW_option{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:auto;min-width:100%;min-height:34px;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;outline:none;align-items:center;gap:6px;padding:5px 7px;display:flex}._2pt-bW_option:not(._2pt-bW_modelOption):hover:not(:disabled),._2pt-bW_option:focus-visible,._2pt-bW_optionActive:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}._2pt-bW_selected{background:0 0}._2pt-bW_option:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}._2pt-bW_optionCopy{flex-direction:column;flex:1;min-width:0;display:flex}._2pt-bW_modelName{color:inherit;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:400;line-height:18px;overflow:hidden}._2pt-bW_optionTrailing{flex:none;align-items:center;gap:6px;display:flex}._2pt-bW_variantCount{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);border-radius:999px;padding:0 5px;font-size:10px;line-height:16px}._2pt-bW_check{color:var(--dsw-alias-label-primary);flex:0 0 14px;place-items:center;display:grid}._2pt-bW_check svg{width:14px;height:14px}._2pt-bW_cell{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:auto;min-width:100%;height:34px;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border:none;outline:none;align-items:center;gap:6px;padding:0 8px;font-size:13px;line-height:20px;display:flex}._2pt-bW_cell:hover:not(:disabled),._2pt-bW_cell:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}._2pt-bW_cell:disabled{cursor:default}._2pt-bW_cellLabel{white-space:nowrap;flex:none}._2pt-bW_cellValue{text-align:right;min-width:0;color:var(--dsw-alias-label-tertiary);flex:auto;justify-content:flex-end;display:flex;overflow:hidden}._2pt-bW_cellChevron{width:12px;height:12px;color:var(--dsw-alias-menu-icon);flex:none}._2pt-bW_groupInline{align-items:center;gap:4px;min-width:0;display:inline-flex;overflow:hidden}._2pt-bW_groupName{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}._2pt-bW_groupOptionLabel{align-items:center;min-width:0;display:flex;overflow:hidden}._2pt-bW_toast{z-index:1100;border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);max-width:320px;color:var(--dsw-alias-state-error-primary);padding:6px 10px;font-size:11px;line-height:16px;position:absolute;bottom:calc(100% + 6px);right:0}";
536
+ const css$1 = "._2pt-bW_root{min-width:0;position:relative}._2pt-bW_trigger{border-radius:var(--dsw-radius-sm);min-width:0;max-width:min(360px,45cqw);height:28px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;outline:none;align-items:center;gap:4px;padding:0 4px 0 8px;font-size:13px;font-weight:400;line-height:20px;display:flex}._2pt-bW_trigger:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}._2pt-bW_trigger:focus-visible{box-shadow:0 0 0 2px var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary))}._2pt-bW_trigger:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}._2pt-bW_triggerLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}._2pt-bW_triggerEffort{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--dsw-alias-label-caption);flex-shrink:1000;overflow:hidden}._2pt-bW_triggerIcon{display:var(--dsh-composer-model-icon-display,none);flex:none}._2pt-bW_chevron{color:var(--dsw-alias-label-caption);flex:none}._2pt-bW_menu{z-index:1100;--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);width:max-content;min-width:min(240px,100vw - 32px);max-width:min(420px,100vw - 32px);max-height:min(360px,100vh - 96px);box-shadow:var(--dsw-elevation-prominent);color:var(--dsw-alias-label-primary);--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2);--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2);border:0;flex-direction:column;padding:4px;display:flex;position:fixed;overflow:hidden}._2pt-bW_status,._2pt-bW_empty{color:var(--dsw-alias-label-tertiary);padding:8px;font-size:12px;line-height:18px}._2pt-bW_error,._2pt-bW_warning{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);justify-content:space-between;align-items:flex-start;gap:6px;margin-bottom:3px;padding:6px 7px;font-size:11px;line-height:16px;display:flex}._2pt-bW_warning{background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-state-warn-label)}._2pt-bW_retry{color:inherit;font:inherit;cursor:pointer;background:0 0;border:none;flex:none;padding:0;font-weight:600}._2pt-bW_searchRow{flex-shrink:0;margin:2px 0 3px;position:relative}._2pt-bW_searchRow ._2pt-bW_search{border-radius:var(--dsw-radius-md);background:0 0;border:0 solid #0000;height:auto;padding:5px 7px;display:flex}._2pt-bW_searchRow ._2pt-bW_search input{padding:0;font-size:12px;line-height:normal}._2pt-bW_searchClear{width:24px;height:24px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;display:inline-flex;position:absolute;top:50%;right:4px;transform:translateY(-50%)}._2pt-bW_searchClear:hover,._2pt-bW_searchClear:focus-visible{background:var(--dsw-alias-interactive-bg-hover);outline:none}._2pt-bW_groups{min-height:0;overflow-y:auto}._2pt-bW_option{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:auto;min-width:100%;min-height:34px;color:inherit;text-align:left;cursor:pointer;background:0 0;border:none;outline:none;align-items:center;gap:6px;padding:5px 7px;display:flex}._2pt-bW_option:not(._2pt-bW_modelOption):hover:not(:disabled),._2pt-bW_option:focus-visible,._2pt-bW_optionActive:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}._2pt-bW_selected{background:0 0}._2pt-bW_option:disabled{color:var(--dsw-alias-label-dimmed);cursor:default}._2pt-bW_optionCopy{flex-direction:column;flex:1;min-width:0;display:flex}._2pt-bW_modelName{color:inherit;text-overflow:ellipsis;white-space:nowrap;font-size:13px;font-weight:400;line-height:18px;overflow:hidden}._2pt-bW_optionTrailing{flex:none;align-items:center;gap:6px;display:flex}._2pt-bW_variantCount{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-tertiary);border-radius:999px;padding:0 5px;font-size:10px;line-height:16px}._2pt-bW_check{color:var(--dsw-alias-label-primary);flex:0 0 14px;place-items:center;display:grid}._2pt-bW_check svg{width:14px;height:14px}._2pt-bW_cell{box-sizing:border-box;border-radius:var(--dsw-radius-md);width:auto;min-width:100%;height:34px;color:var(--dsw-alias-label-primary);cursor:pointer;text-align:left;background:0 0;border:none;outline:none;align-items:center;gap:6px;padding:0 8px;font-size:13px;line-height:20px;display:flex}._2pt-bW_cell:hover:not(:disabled),._2pt-bW_cell:focus-visible{background:var(--dsw-alias-interactive-bg-hover)}._2pt-bW_cell:disabled{cursor:default}._2pt-bW_cellLabel{white-space:nowrap;flex:none}._2pt-bW_cellValue{text-align:right;min-width:0;color:var(--dsw-alias-label-tertiary);flex:auto;justify-content:flex-end;display:flex;overflow:hidden}._2pt-bW_cellChevron{width:12px;height:12px;color:var(--dsw-alias-menu-icon);flex:none}._2pt-bW_cellSwitch{box-sizing:border-box;width:auto;min-width:100%;height:34px;color:var(--dsw-alias-label-primary);align-items:center;gap:6px;padding:0 8px;font-size:13px;line-height:20px;display:flex}._2pt-bW_linkError{border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);color:var(--dsw-alias-state-error-primary);margin:0 0 3px;padding:6px 7px;font-size:11px;line-height:16px}._2pt-bW_groupInline{align-items:center;gap:4px;min-width:0;display:inline-flex;overflow:hidden}._2pt-bW_groupName{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}._2pt-bW_groupOptionLabel{align-items:center;min-width:0;display:flex;overflow:hidden}._2pt-bW_toast{z-index:1100;border-radius:var(--dsw-radius-md);background:var(--dsw-alias-interactive-bg-hover-danger);max-width:320px;color:var(--dsw-alias-state-error-primary);padding:6px 10px;font-size:11px;line-height:16px;position:absolute;bottom:calc(100% + 6px);right:0}";
521
537
  const tagId$1 = "dsh-neartoken/ModelGroupSelect.module.css";
522
538
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$1) + "]") === null) {
523
539
  const tag = document.createElement("style");
@@ -527,39 +543,41 @@ window.__ModuleLoader__.load({
527
543
  document.head.appendChild(tag);
528
544
  }
529
545
  var ModelGroupSelect_module_css_default = {
530
- "trigger": "_2pt-bW_trigger",
531
- "menu": "_2pt-bW_menu",
532
- "groupInline": "_2pt-bW_groupInline",
533
- "chevron": "_2pt-bW_chevron",
534
- "search": "_2pt-bW_search",
546
+ "cellChevron": "_2pt-bW_cellChevron",
535
547
  "retry": "_2pt-bW_retry",
536
- "status": "_2pt-bW_status",
537
- "warning": "_2pt-bW_warning",
548
+ "cellSwitch": "_2pt-bW_cellSwitch",
549
+ "optionCopy": "_2pt-bW_optionCopy",
550
+ "error": "_2pt-bW_error",
551
+ "option": "_2pt-bW_option",
538
552
  "selected": "_2pt-bW_selected",
539
- "optionTrailing": "_2pt-bW_optionTrailing",
540
- "modelOption": "_2pt-bW_modelOption",
541
553
  "variantCount": "_2pt-bW_variantCount",
542
- "searchClear": "_2pt-bW_searchClear",
543
- "toast": "_2pt-bW_toast",
544
- "empty": "_2pt-bW_empty",
545
554
  "optionActive": "_2pt-bW_optionActive",
546
- "modelName": "_2pt-bW_modelName",
547
- "optionCopy": "_2pt-bW_optionCopy",
555
+ "groupInline": "_2pt-bW_groupInline",
556
+ "triggerIcon": "_2pt-bW_triggerIcon",
557
+ "empty": "_2pt-bW_empty",
558
+ "check": "_2pt-bW_check",
559
+ "chevron": "_2pt-bW_chevron",
560
+ "status": "_2pt-bW_status",
548
561
  "cellValue": "_2pt-bW_cellValue",
549
- "cellLabel": "_2pt-bW_cellLabel",
550
- "groups": "_2pt-bW_groups",
551
- "searchRow": "_2pt-bW_searchRow",
552
- "triggerLabel": "_2pt-bW_triggerLabel",
553
- "cellChevron": "_2pt-bW_cellChevron",
554
- "cell": "_2pt-bW_cell",
562
+ "modelName": "_2pt-bW_modelName",
563
+ "search": "_2pt-bW_search",
555
564
  "root": "_2pt-bW_root",
556
- "check": "_2pt-bW_check",
565
+ "optionTrailing": "_2pt-bW_optionTrailing",
566
+ "modelOption": "_2pt-bW_modelOption",
567
+ "linkError": "_2pt-bW_linkError",
568
+ "groups": "_2pt-bW_groups",
557
569
  "groupName": "_2pt-bW_groupName",
570
+ "menu": "_2pt-bW_menu",
571
+ "toast": "_2pt-bW_toast",
572
+ "triggerLabel": "_2pt-bW_triggerLabel",
558
573
  "groupOptionLabel": "_2pt-bW_groupOptionLabel",
574
+ "warning": "_2pt-bW_warning",
559
575
  "triggerEffort": "_2pt-bW_triggerEffort",
560
- "triggerIcon": "_2pt-bW_triggerIcon",
561
- "option": "_2pt-bW_option",
562
- "error": "_2pt-bW_error"
576
+ "cellLabel": "_2pt-bW_cellLabel",
577
+ "trigger": "_2pt-bW_trigger",
578
+ "searchRow": "_2pt-bW_searchRow",
579
+ "cell": "_2pt-bW_cell",
580
+ "searchClear": "_2pt-bW_searchClear"
563
581
  };
564
582
  //#endregion
565
583
  //#region src/client/ModelGroupSelect.tsx
@@ -612,7 +630,7 @@ window.__ModuleLoader__.load({
612
630
  * @param props - owner share (locked) + injected directory face + the locale seat.
613
631
  * @returns the trigger and, while open, the three-level menu.
614
632
  */
615
- function ModelGroupSelect({ locked, available, directory, load, select, t }) {
633
+ function ModelGroupSelect({ locked, available, directory, load, select, readLink, saveLink, t }) {
616
634
  const state = (0, react.useSyncExternalStore)((fn) => directory.subscribe(fn), () => directory.getSnapshot());
617
635
  const [open, setOpen] = (0, react.useState)(false);
618
636
  const [pane, setPane] = (0, react.useState)("root");
@@ -624,6 +642,12 @@ window.__ModuleLoader__.load({
624
642
  const menuRef = (0, react.useRef)(null);
625
643
  const searchRef = (0, react.useRef)(null);
626
644
  const [menuPos, setMenuPos] = (0, react.useState)(null);
645
+ /** The long-connection switch, once the Host answered; undefined while unread. */
646
+ const [direct, setDirect] = (0, react.useState)(void 0);
647
+ /** Whether a switch write is on the wire. */
648
+ const [linkBusy, setLinkBusy] = (0, react.useState)(false);
649
+ /** Why the last switch write was refused; cleared by the next one. */
650
+ const [linkError, setLinkError] = (0, react.useState)(null);
627
651
  const id = (0, react.useId)();
628
652
  const accountName = t("provider.account");
629
653
  const providers = (0, react.useMemo)(() => state.groups.map((group) => ({
@@ -729,6 +753,24 @@ window.__ModuleLoader__.load({
729
753
  pane,
730
754
  showSearch
731
755
  ]);
756
+ const ownSeat = located !== void 0 && isGroupedProvider(located.provider.id);
757
+ (0, react.useEffect)(() => {
758
+ if (!open || !ownSeat) return;
759
+ let live = true;
760
+ readLink().then((next) => {
761
+ if (live) setDirect(next.direct);
762
+ }, (failure) => {
763
+ if (live) setLinkError(t("link.failed", { message: failure instanceof Error ? failure.message : String(failure) }));
764
+ });
765
+ return () => {
766
+ live = false;
767
+ };
768
+ }, [
769
+ open,
770
+ ownSeat,
771
+ readLink,
772
+ t
773
+ ]);
732
774
  if (!available) return null;
733
775
  const settle = (result) => {
734
776
  if (result === void 0) return;
@@ -783,6 +825,18 @@ window.__ModuleLoader__.load({
783
825
  ...effort === void 0 ? {} : { reasoningEffort: effort }
784
826
  });
785
827
  };
828
+ const toggleDirect = (next) => {
829
+ setDirect(next);
830
+ setLinkBusy(true);
831
+ setLinkError(null);
832
+ saveLink(next).then(() => {
833
+ setLinkBusy(false);
834
+ }, (failure) => {
835
+ setDirect(!next);
836
+ setLinkBusy(false);
837
+ setLinkError(t("link.failed", { message: failure instanceof Error ? failure.message : String(failure) }));
838
+ });
839
+ };
786
840
  const onKeyDown = (event) => {
787
841
  if (event.nativeEvent.isComposing) return;
788
842
  if (event.key === "Escape" && open) {
@@ -891,6 +945,26 @@ window.__ModuleLoader__.load({
891
945
  groupChoices.length > 1 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { className: ModelGroupSelect_module_css_default.cellChevron })
892
946
  ]
893
947
  }),
948
+ ownSeat && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
949
+ className: ModelGroupSelect_module_css_default.cellSwitch,
950
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
951
+ className: ModelGroupSelect_module_css_default.cellLabel,
952
+ children: t("link.label")
953
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
954
+ className: ModelGroupSelect_module_css_default.cellValue,
955
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Switch, {
956
+ checked: direct === true,
957
+ disabled: linkBusy || direct === void 0,
958
+ label: t("link.label"),
959
+ onChange: toggleDirect
960
+ })
961
+ })]
962
+ }),
963
+ linkError === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
964
+ className: ModelGroupSelect_module_css_default.linkError,
965
+ role: "status",
966
+ children: linkError
967
+ }),
894
968
  reasoning !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
895
969
  type: "button",
896
970
  role: "menuitem",
@@ -1164,106 +1238,106 @@ window.__ModuleLoader__.load({
1164
1238
  document.head.appendChild(tag);
1165
1239
  }
1166
1240
  var NearTokenSection_module_css_default = {
1241
+ "tipTitle": "_02HI2q_tipTitle",
1242
+ "badgeOn": "_02HI2q_badgeOn",
1167
1243
  "fact": "_02HI2q_fact",
1168
- "tipGroupName": "_02HI2q_tipGroupName",
1169
- "chevron": "_02HI2q_chevron",
1170
- "segmentOn": "_02HI2q_segmentOn",
1171
- "axisRow": "_02HI2q_axisRow",
1172
- "swatch": "_02HI2q_swatch",
1173
- "series3": "_02HI2q_series3",
1174
- "voucherRow": "_02HI2q_voucherRow",
1175
- "link": "_02HI2q_link",
1176
- "rowMeta": "_02HI2q_rowMeta",
1177
- "gridLine": "_02HI2q_gridLine",
1178
- "axis": "_02HI2q_axis",
1179
- "list": "_02HI2q_list",
1180
- "topupChips": "_02HI2q_topupChips",
1181
- "topupInput": "_02HI2q_topupInput",
1182
- "topupChipActive": "_02HI2q_topupChipActive",
1183
- "count": "_02HI2q_count",
1184
- "title": "_02HI2q_title",
1244
+ "yScale": "_02HI2q_yScale",
1245
+ "actions": "_02HI2q_actions",
1246
+ "metaField": "_02HI2q_metaField",
1247
+ "plot": "_02HI2q_plot",
1248
+ "metaHead": "_02HI2q_metaHead",
1249
+ "intro": "_02HI2q_intro",
1250
+ "refresh": "_02HI2q_refresh",
1251
+ "hit": "_02HI2q_hit",
1252
+ "series5": "_02HI2q_series5",
1185
1253
  "countDot": "_02HI2q_countDot",
1186
- "chevronOpen": "_02HI2q_chevronOpen",
1187
- "plotPanel": "_02HI2q_plotPanel",
1188
- "legendItem": "_02HI2q_legendItem",
1189
- "metaEditor": "_02HI2q_metaEditor",
1190
- "code": "_02HI2q_code",
1191
- "metaIntro": "_02HI2q_metaIntro",
1192
- "voucherEmpty": "_02HI2q_voucherEmpty",
1193
1254
  "cardHead": "_02HI2q_cardHead",
1194
- "buttonSmall": "_02HI2q_buttonSmall",
1195
- "card": "_02HI2q_card",
1196
- "legendName": "_02HI2q_legendName",
1197
- "invite": "_02HI2q_invite",
1255
+ "select": "_02HI2q_select",
1198
1256
  "button": "_02HI2q_button",
1199
- "plot": "_02HI2q_plot",
1200
- "factValue": "_02HI2q_factValue",
1201
- "legend": "_02HI2q_legend",
1202
- "valueRow": "_02HI2q_valueRow",
1203
- "metaHead": "_02HI2q_metaHead",
1204
- "cardToggle": "_02HI2q_cardToggle",
1205
- "badgeOn": "_02HI2q_badgeOn",
1257
+ "chevronOpen": "_02HI2q_chevronOpen",
1258
+ "hint": "_02HI2q_hint",
1259
+ "yTick": "_02HI2q_yTick",
1260
+ "metaHint": "_02HI2q_metaHint",
1261
+ "axisLabel": "_02HI2q_axisLabel",
1206
1262
  "topupBar": "_02HI2q_topupBar",
1207
- "buttonPrimary": "_02HI2q_buttonPrimary",
1208
- "voucherFact": "_02HI2q_voucherFact",
1209
- "metaBtnOn": "_02HI2q_metaBtnOn",
1210
- "intro": "_02HI2q_intro",
1211
- "linkLine": "_02HI2q_linkLine",
1263
+ "facts": "_02HI2q_facts",
1212
1264
  "row": "_02HI2q_row",
1213
- "select": "_02HI2q_select",
1214
- "factLabel": "_02HI2q_factLabel",
1215
- "countPicked": "_02HI2q_countPicked",
1216
- "section": "_02HI2q_section",
1217
- "tally": "_02HI2q_tally",
1218
- "metaField": "_02HI2q_metaField",
1265
+ "buttonSmall": "_02HI2q_buttonSmall",
1266
+ "rowRatio": "_02HI2q_rowRatio",
1267
+ "card": "_02HI2q_card",
1268
+ "voucherEmpty": "_02HI2q_voucherEmpty",
1269
+ "gridBase": "_02HI2q_gridBase",
1270
+ "plotPanel": "_02HI2q_plotPanel",
1219
1271
  "chart": "_02HI2q_chart",
1220
- "axisLabel": "_02HI2q_axisLabel",
1221
- "series2": "_02HI2q_series2",
1222
- "topupChip": "_02HI2q_topupChip",
1272
+ "code": "_02HI2q_code",
1273
+ "countPicked": "_02HI2q_countPicked",
1274
+ "swatch": "_02HI2q_swatch",
1275
+ "count": "_02HI2q_count",
1276
+ "list": "_02HI2q_list",
1277
+ "autosave": "_02HI2q_autosave",
1278
+ "codeRow": "_02HI2q_codeRow",
1223
1279
  "metaBtn": "_02HI2q_metaBtn",
1224
- "metaTitle": "_02HI2q_metaTitle",
1225
- "topup": "_02HI2q_topup",
1226
- "metaLabel": "_02HI2q_metaLabel",
1227
- "name": "_02HI2q_name",
1228
- "metaHint": "_02HI2q_metaHint",
1229
- "tip": "_02HI2q_tip",
1230
- "segmented": "_02HI2q_segmented",
1231
1280
  "segment": "_02HI2q_segment",
1232
- "plotRow": "_02HI2q_plotRow",
1281
+ "rowMeta": "_02HI2q_rowMeta",
1282
+ "topup": "_02HI2q_topup",
1233
1283
  "series4": "_02HI2q_series4",
1234
- "series5": "_02HI2q_series5",
1235
- "handle": "_02HI2q_handle",
1236
- "series1": "_02HI2q_series1",
1284
+ "valueRow": "_02HI2q_valueRow",
1285
+ "form": "_02HI2q_form",
1286
+ "axisRow": "_02HI2q_axisRow",
1287
+ "linkRow": "_02HI2q_linkRow",
1288
+ "factValue": "_02HI2q_factValue",
1289
+ "voucherFact": "_02HI2q_voucherFact",
1290
+ "metaEditor": "_02HI2q_metaEditor",
1291
+ "topupChipActive": "_02HI2q_topupChipActive",
1292
+ "rowName": "_02HI2q_rowName",
1237
1293
  "voucherGroup": "_02HI2q_voucherGroup",
1238
1294
  "metaActions": "_02HI2q_metaActions",
1295
+ "notice": "_02HI2q_notice",
1296
+ "tip": "_02HI2q_tip",
1297
+ "legend": "_02HI2q_legend",
1298
+ "segmentOn": "_02HI2q_segmentOn",
1299
+ "topupChip": "_02HI2q_topupChip",
1300
+ "gridLine": "_02HI2q_gridLine",
1301
+ "axis": "_02HI2q_axis",
1302
+ "handle": "_02HI2q_handle",
1303
+ "series3": "_02HI2q_series3",
1304
+ "section": "_02HI2q_section",
1305
+ "link": "_02HI2q_link",
1306
+ "series2": "_02HI2q_series2",
1239
1307
  "tipGroup": "_02HI2q_tipGroup",
1240
- "yScale": "_02HI2q_yScale",
1241
- "tipRow": "_02HI2q_tipRow",
1242
- "codeRow": "_02HI2q_codeRow",
1243
- "toolbar": "_02HI2q_toolbar",
1308
+ "series0": "_02HI2q_series0",
1244
1309
  "label": "_02HI2q_label",
1245
- "facts": "_02HI2q_facts",
1246
- "tipTitle": "_02HI2q_tipTitle",
1247
- "hit": "_02HI2q_hit",
1248
- "refresh": "_02HI2q_refresh",
1249
- "linkRow": "_02HI2q_linkRow",
1250
- "notice": "_02HI2q_notice",
1251
- "voucherList": "_02HI2q_voucherList",
1252
- "form": "_02HI2q_form",
1310
+ "factLabel": "_02HI2q_factLabel",
1311
+ "topupInput": "_02HI2q_topupInput",
1253
1312
  "search": "_02HI2q_search",
1254
- "rowName": "_02HI2q_rowName",
1255
- "yTick": "_02HI2q_yTick",
1256
- "legendCost": "_02HI2q_legendCost",
1257
- "series0": "_02HI2q_series0",
1258
- "actions": "_02HI2q_actions",
1259
- "rowRatio": "_02HI2q_rowRatio",
1260
- "voucherAmount": "_02HI2q_voucherAmount",
1261
- "metaChecks": "_02HI2q_metaChecks",
1262
- "autosave": "_02HI2q_autosave",
1263
- "gridBase": "_02HI2q_gridBase",
1313
+ "plotRow": "_02HI2q_plotRow",
1314
+ "legendItem": "_02HI2q_legendItem",
1315
+ "buttonPrimary": "_02HI2q_buttonPrimary",
1316
+ "metaTitle": "_02HI2q_metaTitle",
1317
+ "topupChips": "_02HI2q_topupChips",
1318
+ "cardToggle": "_02HI2q_cardToggle",
1319
+ "name": "_02HI2q_name",
1320
+ "toolbar": "_02HI2q_toolbar",
1321
+ "invite": "_02HI2q_invite",
1322
+ "voucherList": "_02HI2q_voucherList",
1264
1323
  "metaInput": "_02HI2q_metaInput",
1324
+ "metaIntro": "_02HI2q_metaIntro",
1325
+ "chevron": "_02HI2q_chevron",
1326
+ "title": "_02HI2q_title",
1327
+ "voucherRow": "_02HI2q_voucherRow",
1328
+ "metaChecks": "_02HI2q_metaChecks",
1329
+ "voucherAmount": "_02HI2q_voucherAmount",
1265
1330
  "metaCheck": "_02HI2q_metaCheck",
1266
- "hint": "_02HI2q_hint",
1331
+ "tipGroupName": "_02HI2q_tipGroupName",
1332
+ "segmented": "_02HI2q_segmented",
1333
+ "tally": "_02HI2q_tally",
1334
+ "legendCost": "_02HI2q_legendCost",
1335
+ "linkLine": "_02HI2q_linkLine",
1336
+ "metaBtnOn": "_02HI2q_metaBtnOn",
1337
+ "series1": "_02HI2q_series1",
1338
+ "tipRow": "_02HI2q_tipRow",
1339
+ "legendName": "_02HI2q_legendName",
1340
+ "metaLabel": "_02HI2q_metaLabel",
1267
1341
  "badge": "_02HI2q_badge"
1268
1342
  };
1269
1343
  //#endregion
@@ -3003,6 +3077,8 @@ window.__ModuleLoader__.load({
3003
3077
  "menu.model": "模型",
3004
3078
  "menu.group": "分组",
3005
3079
  "menu.effort": "推理等级",
3080
+ "link.label": "长连接端点",
3081
+ "link.failed": "端点切换失败:{message}",
3006
3082
  "effort.providerDefault": "Default",
3007
3083
  "status.loading": "正在刷新模型列表…",
3008
3084
  "error.action": "模型操作失败:{message}",
@@ -3140,6 +3216,8 @@ window.__ModuleLoader__.load({
3140
3216
  "menu.model": "Model",
3141
3217
  "menu.group": "Group",
3142
3218
  "menu.effort": "Effort",
3219
+ "link.label": "Long-lived endpoint",
3220
+ "link.failed": "Could not switch the endpoint: {message}",
3143
3221
  "effort.providerDefault": "Default",
3144
3222
  "status.loading": "Refreshing model list…",
3145
3223
  "error.action": "Model operation failed: {message}",
@@ -3316,7 +3394,9 @@ window.__ModuleLoader__.load({
3316
3394
  load: () => {
3317
3395
  if (available) directory.load().catch(() => {});
3318
3396
  },
3319
- select: (selection) => available ? directory.select(selection) : Promise.resolve(void 0)
3397
+ select: (selection) => available ? directory.select(selection) : Promise.resolve(void 0),
3398
+ readLink: () => api.link(),
3399
+ saveLink: (direct) => api.saveLink(direct)
3320
3400
  };
3321
3401
  }
3322
3402
  }, ModelGroupSelect));