dsh-aperture 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +69 -46
- package/README.md +66 -43
- package/lib/client.js +481 -273
- package/lib/client.js.map +1 -1
- package/lib/index.js +1373 -342
- package/lib/types/adapter/context.d.ts +24 -0
- package/lib/types/adapter/index.d.ts +52 -0
- package/lib/types/adapter/replay.d.ts +66 -0
- package/lib/types/adapter/route.d.ts +45 -0
- package/lib/types/adapter/stream.d.ts +24 -0
- package/lib/types/config.d.ts +44 -32
- package/lib/types/index.d.ts +14 -13
- package/lib/types/panel.d.ts +1 -1
- package/lib/types/plan.d.ts +95 -0
- package/lib/types/provider.d.ts +84 -0
- package/lib/types/report.d.ts +11 -11
- package/lib/types/routes.d.ts +35 -0
- package/lib/types/runtime.d.ts +23 -6
- package/lib/types/types.d.ts +15 -5
- package/package.json +15 -2
- package/lib/types/profile.d.ts +0 -55
- package/lib/types/sync.d.ts +0 -47
package/lib/client.js
CHANGED
|
@@ -89,7 +89,7 @@ window.__ModuleLoader__.load({
|
|
|
89
89
|
*/
|
|
90
90
|
const EDITABLE_KEYS = Object.freeze([
|
|
91
91
|
"name",
|
|
92
|
-
"
|
|
92
|
+
"protocol",
|
|
93
93
|
"contextWindow",
|
|
94
94
|
"maxTokens",
|
|
95
95
|
"input",
|
|
@@ -114,7 +114,7 @@ window.__ModuleLoader__.load({
|
|
|
114
114
|
text: model.input.includes("text"),
|
|
115
115
|
image: model.input.includes("image"),
|
|
116
116
|
reasoning: declaredIn(model, "thinking") ? model.reasoning ? "on" : "off" : "auto",
|
|
117
|
-
|
|
117
|
+
protocol: declaredIn(model, "protocol") ? model.protocol ?? "" : ""
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
@@ -152,7 +152,7 @@ window.__ModuleLoader__.load({
|
|
|
152
152
|
else if (value === void 0) patch[field] = null;
|
|
153
153
|
else if (value !== parseCapacity(initial[field])) patch[field] = value;
|
|
154
154
|
}
|
|
155
|
-
if (draft.
|
|
155
|
+
if (draft.protocol !== initial.protocol) patch.protocol = draft.protocol === "" ? null : draft.protocol;
|
|
156
156
|
if (draft.reasoning !== initial.reasoning) patch.thinking = draft.reasoning === "auto" ? null : draft.reasoning === "on";
|
|
157
157
|
const wanted = [draft.text ? "text" : void 0, draft.image ? "image" : void 0].filter((item) => item !== void 0);
|
|
158
158
|
const before = [initial.text ? "text" : void 0, initial.image ? "image" : void 0].filter((item) => item !== void 0);
|
|
@@ -190,7 +190,7 @@ window.__ModuleLoader__.load({
|
|
|
190
190
|
/** 覆盖键在界面上的名字;界面不编辑的键(`reasoningEfforts`)另给一个词条。 */
|
|
191
191
|
const OVERRIDE_NAMES = {
|
|
192
192
|
name: "editName",
|
|
193
|
-
|
|
193
|
+
protocol: "editProtocol",
|
|
194
194
|
contextWindow: "editContextWindow",
|
|
195
195
|
maxTokens: "editMaxTokens",
|
|
196
196
|
input: "editInput",
|
|
@@ -220,13 +220,13 @@ window.__ModuleLoader__.load({
|
|
|
220
220
|
addressHint: "填 Aperture 的地址;留空即休眠,不再发现模型。",
|
|
221
221
|
addressPlaceholder: "http://127.0.0.1:54117",
|
|
222
222
|
syncLabel: "自动同步",
|
|
223
|
-
syncHint: "
|
|
223
|
+
syncHint: "每轮发现之后,把这批模型注册成 dsh 里本插件自己的 provider 路由。",
|
|
224
224
|
overridden: "已覆盖",
|
|
225
225
|
overriddenCount: "已覆盖 {count} 项",
|
|
226
226
|
resetField: "恢复默认",
|
|
227
227
|
invalidField: "要填不小于 1 的整数,或留空",
|
|
228
228
|
refresh: "立刻刷新",
|
|
229
|
-
refreshHint: "
|
|
229
|
+
refreshHint: "立刻重新发现并注册一次,模型目录与每一行的状态都按这一轮刷新。",
|
|
230
230
|
refreshing: "刷新中…",
|
|
231
231
|
loading: "读取中…",
|
|
232
232
|
configRefused: "设置已被别处改过,这次改动没有写入:刷新页面后再改一遍。",
|
|
@@ -234,23 +234,27 @@ window.__ModuleLoader__.load({
|
|
|
234
234
|
noChanges: "没有改动,因此没有写入。",
|
|
235
235
|
invalidNumber: "{field} 只能填不小于 1 的整数。",
|
|
236
236
|
dormantHint: "还没有实例地址:填上并保存之后才会去发现模型。",
|
|
237
|
-
catalogUnavailable: "
|
|
238
|
-
|
|
237
|
+
catalogUnavailable: "目录不可用({reason})",
|
|
238
|
+
registerSkipped: "没注册({reason})",
|
|
239
239
|
modelsTitle: "模型",
|
|
240
|
-
modelsHint: "
|
|
240
|
+
modelsHint: "一行一个模型;展开改这一行的覆盖,「保存」只写这一行。顺序来自发现顺序。",
|
|
241
|
+
unservedHint: "另有 {count} 个模型没有路由可服务({ids}):在配置里给它们写上 models[].protocol 就有路由;接不进来的删掉即可。",
|
|
242
|
+
noRoutesHint: "这一轮没有注册任何路由:选择器里不会出现本插件的模型。打开「自动同步」并保存,或按「立刻刷新」再试一次。",
|
|
243
|
+
moreModels: "等 {count} 个",
|
|
241
244
|
modelsCount: "{count} 个",
|
|
242
245
|
noModels: "还没有发现任何模型。",
|
|
246
|
+
modelsElsewhere: "模型目录与逐模型覆盖在「设置 → 模型」页里本插件的路由卡上:点开那一行,模型就列在下面。",
|
|
243
247
|
unservedTag: "未服务",
|
|
244
248
|
dirtyTag: "有未保存的改动",
|
|
245
249
|
statusUnserved: "没有路由能服务这个模型",
|
|
246
|
-
statusUnknown: "
|
|
247
|
-
statusPublished: "
|
|
248
|
-
statusNotPublished: "
|
|
250
|
+
statusUnknown: "这一轮没有注册,是否可用看不出来",
|
|
251
|
+
statusPublished: "已注册为 dsh 的路由",
|
|
252
|
+
statusNotPublished: "还没注册成 dsh 的路由",
|
|
249
253
|
factContextWindow: "上下文 {count}",
|
|
250
254
|
factMaxTokens: "输出 {count}",
|
|
251
255
|
factRoute: "路由 {route}",
|
|
252
256
|
factProtocol: "协议 {protocol}",
|
|
253
|
-
factInput: "
|
|
257
|
+
factInput: "输入类型 {value}",
|
|
254
258
|
factReasoning: "推理 {value}",
|
|
255
259
|
factAlias: "别名 {alias}",
|
|
256
260
|
factEndpoints: "网关通告的端点:",
|
|
@@ -265,18 +269,21 @@ window.__ModuleLoader__.load({
|
|
|
265
269
|
sourceModelsDev: "models.dev",
|
|
266
270
|
sourceConfig: "配置",
|
|
267
271
|
sourceDefault: "默认值",
|
|
268
|
-
editName: "
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
272
|
+
editName: "显示名称",
|
|
273
|
+
editProtocol: "API 协议",
|
|
274
|
+
protocolOpenAiCompletions: "OpenAI Chat Completions",
|
|
275
|
+
protocolOpenAiResponses: "OpenAI Responses",
|
|
276
|
+
protocolAnthropicMessages: "Anthropic Messages",
|
|
277
|
+
editContextWindow: "上下文窗口",
|
|
278
|
+
editMaxTokens: "最大输出 token 数",
|
|
279
|
+
editInput: "输入类型",
|
|
273
280
|
editReasoning: "推理",
|
|
274
|
-
editAlias: "
|
|
281
|
+
editAlias: "目录别名",
|
|
275
282
|
editNameHint: "留空即用发现到的名字。",
|
|
276
|
-
|
|
283
|
+
editProtocolHint: "未服务的模型只有这里能救:填上协议它才有路由;留空即用网关通告的协议。",
|
|
277
284
|
editCapacityHint: "可以写 1M、384K;留空即用发现到的容量。",
|
|
278
|
-
editAliasHint: "
|
|
279
|
-
editInputHint: "
|
|
285
|
+
editAliasHint: "在 models.dev 目录里查这个模型时用的名字。",
|
|
286
|
+
editInputHint: "这里能覆盖报告说它接收的输入类型。",
|
|
280
287
|
editReasoningHint: "「跟随发现」就是这一项不写。",
|
|
281
288
|
fieldHelp: "{field}的说明",
|
|
282
289
|
editGroupIdentity: "名称与协议",
|
|
@@ -287,7 +294,7 @@ window.__ModuleLoader__.load({
|
|
|
287
294
|
saveRow: "保存",
|
|
288
295
|
clearOverrides: "清空覆盖",
|
|
289
296
|
cancelRow: "取消",
|
|
290
|
-
keyReasoningEfforts: "
|
|
297
|
+
keyReasoningEfforts: "推理等级",
|
|
291
298
|
listSeparator: "、"
|
|
292
299
|
};
|
|
293
300
|
const en = {
|
|
@@ -300,13 +307,13 @@ window.__ModuleLoader__.load({
|
|
|
300
307
|
addressHint: "Where Aperture listens; leave it empty to go dormant and stop discovering models.",
|
|
301
308
|
addressPlaceholder: "http://127.0.0.1:54117",
|
|
302
309
|
syncLabel: "Sync automatically",
|
|
303
|
-
syncHint: "After each discovery round,
|
|
310
|
+
syncHint: "After each discovery round, register these models as this plugin’s own provider routes in dsh.",
|
|
304
311
|
overridden: "overridden",
|
|
305
312
|
overriddenCount: "{count} overridden",
|
|
306
313
|
resetField: "Reset to default",
|
|
307
314
|
invalidField: "Enter an integer of at least 1, or leave it empty",
|
|
308
315
|
refresh: "Refresh now",
|
|
309
|
-
refreshHint: "Discover and
|
|
316
|
+
refreshHint: "Discover and register once; the list and every row’s status follow this round.",
|
|
310
317
|
refreshing: "Refreshing…",
|
|
311
318
|
loading: "Loading…",
|
|
312
319
|
configRefused: "These settings changed elsewhere, so this edit was not written. Reload the page and try again.",
|
|
@@ -315,22 +322,26 @@ window.__ModuleLoader__.load({
|
|
|
315
322
|
invalidNumber: "{field} takes an integer of at least 1.",
|
|
316
323
|
dormantHint: "No instance address yet: models are discovered once you set and save one.",
|
|
317
324
|
catalogUnavailable: "catalog unavailable ({reason})",
|
|
318
|
-
|
|
325
|
+
registerSkipped: "not registered ({reason})",
|
|
319
326
|
modelsTitle: "Models",
|
|
320
|
-
modelsHint: "One model per row; expand a row to edit its overrides, and Save writes only that row. The order comes from discovery
|
|
321
|
-
|
|
327
|
+
modelsHint: "One model per row; expand a row to edit its overrides, and Save writes only that row. The order comes from discovery.",
|
|
328
|
+
unservedHint: "{count} more models have no route to serve them ({ids}): give them a models[].protocol in the config and the next round registers them; anything that cannot be served can simply be deleted.",
|
|
329
|
+
noRoutesHint: "This round registered no routes at all, so no Aperture models will show up in the selector. Turn on Auto sync and save, or press Refresh now to try again.",
|
|
330
|
+
moreModels: "and {count} more",
|
|
331
|
+
modelsCount: "{count}",
|
|
322
332
|
noModels: "No models discovered yet.",
|
|
333
|
+
modelsElsewhere: "The model list and its per-model overrides live on the Settings → Models page, in this plugin’s route cards: open that row and the models are listed below it.",
|
|
323
334
|
unservedTag: "unserved",
|
|
324
335
|
dirtyTag: "unsaved edits",
|
|
325
336
|
statusUnserved: "No route can serve this model",
|
|
326
|
-
statusUnknown: "This round
|
|
327
|
-
statusPublished: "
|
|
328
|
-
statusNotPublished: "Not
|
|
337
|
+
statusUnknown: "This round registered nothing, so whether the route is live is unknown",
|
|
338
|
+
statusPublished: "Registered as a dsh route",
|
|
339
|
+
statusNotPublished: "Not registered as a dsh route yet",
|
|
329
340
|
factContextWindow: "{count} context",
|
|
330
341
|
factMaxTokens: "output {count}",
|
|
331
342
|
factRoute: "route {route}",
|
|
332
343
|
factProtocol: "protocol {protocol}",
|
|
333
|
-
factInput: "
|
|
344
|
+
factInput: "input types {value}",
|
|
334
345
|
factReasoning: "reasoning {value}",
|
|
335
346
|
factAlias: "alias {alias}",
|
|
336
347
|
factEndpoints: "Endpoints the gateway advertises:",
|
|
@@ -346,17 +357,20 @@ window.__ModuleLoader__.load({
|
|
|
346
357
|
sourceConfig: "config",
|
|
347
358
|
sourceDefault: "default",
|
|
348
359
|
editName: "Display name",
|
|
349
|
-
|
|
360
|
+
editProtocol: "API protocol",
|
|
361
|
+
protocolOpenAiCompletions: "OpenAI Chat Completions",
|
|
362
|
+
protocolOpenAiResponses: "OpenAI Responses",
|
|
363
|
+
protocolAnthropicMessages: "Anthropic Messages",
|
|
350
364
|
editContextWindow: "Context window",
|
|
351
|
-
editMaxTokens: "Max output",
|
|
352
|
-
editInput: "
|
|
365
|
+
editMaxTokens: "Max output tokens",
|
|
366
|
+
editInput: "Input types",
|
|
353
367
|
editReasoning: "Reasoning",
|
|
354
368
|
editAlias: "Catalog alias",
|
|
355
369
|
editNameHint: "Leave it empty to use the discovered name.",
|
|
356
|
-
|
|
370
|
+
editProtocolHint: "The only way an unserved model gets a route is a protocol here; leave it empty to use the advertised one.",
|
|
357
371
|
editCapacityHint: "Write 1M or 384K; leave it empty to use the discovered capacity.",
|
|
358
|
-
editAliasHint: "The
|
|
359
|
-
editInputHint: "This overrides the
|
|
372
|
+
editAliasHint: "The name looked up in the models.dev catalog for this model.",
|
|
373
|
+
editInputHint: "This overrides the input types the report says it accepts.",
|
|
360
374
|
editReasoningHint: "“Follow discovery” leaves this key unwritten.",
|
|
361
375
|
fieldHelp: "About {field}",
|
|
362
376
|
editGroupIdentity: "Name and protocol",
|
|
@@ -367,7 +381,7 @@ window.__ModuleLoader__.load({
|
|
|
367
381
|
saveRow: "Save",
|
|
368
382
|
clearOverrides: "Clear overrides",
|
|
369
383
|
cancelRow: "Cancel",
|
|
370
|
-
keyReasoningEfforts: "reasoning
|
|
384
|
+
keyReasoningEfforts: "reasoning effort levels",
|
|
371
385
|
listSeparator: ", "
|
|
372
386
|
};
|
|
373
387
|
/** 内置中文兜底按普通字典读(`t` 缺席时用它,键集由下面的 `LocaleNamespaceMap` 声明)。 */
|
|
@@ -407,6 +421,26 @@ window.__ModuleLoader__.load({
|
|
|
407
421
|
default: "sourceDefault"
|
|
408
422
|
};
|
|
409
423
|
/**
|
|
424
|
+
* 协议下拉的选项:显示官方「模型」页给这三个协议的产品名,存的值仍是 schema 标识符。
|
|
425
|
+
*
|
|
426
|
+
* 那一页自己就是这么分工的(`protocolOpenAiCompletions` → `openai-completions`),这里跟它一致:
|
|
427
|
+
* 界面上用产品名,写进配置的是标识符,于是选择器里的路由名与这个下拉里的名字是同一套词。
|
|
428
|
+
*/
|
|
429
|
+
const PROTOCOLS = [
|
|
430
|
+
{
|
|
431
|
+
value: "openai-completions",
|
|
432
|
+
label: "protocolOpenAiCompletions"
|
|
433
|
+
},
|
|
434
|
+
{
|
|
435
|
+
value: "openai-responses",
|
|
436
|
+
label: "protocolOpenAiResponses"
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
value: "anthropic-messages",
|
|
440
|
+
label: "protocolAnthropicMessages"
|
|
441
|
+
}
|
|
442
|
+
];
|
|
443
|
+
/**
|
|
410
444
|
* 一行模型的覆盖编辑器。
|
|
411
445
|
*
|
|
412
446
|
* @param {object} props - 这一行的草稿、字典与几个动作。
|
|
@@ -464,57 +498,46 @@ window.__ModuleLoader__.load({
|
|
|
464
498
|
children: [
|
|
465
499
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
466
500
|
className: "dap-selectLabel",
|
|
467
|
-
htmlFor: `dap-${model.id}-
|
|
468
|
-
children: t("
|
|
501
|
+
htmlFor: `dap-${model.id}-protocol`,
|
|
502
|
+
children: t("editProtocol")
|
|
469
503
|
}),
|
|
470
|
-
declaredIn(model, "
|
|
504
|
+
declaredIn(model, "protocol") ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
|
471
505
|
tone: "info",
|
|
472
506
|
children: t("overridden")
|
|
473
507
|
}) : null,
|
|
474
|
-
declaredIn(model, "
|
|
508
|
+
declaredIn(model, "protocol") ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
475
509
|
variant: "ghost",
|
|
476
510
|
size: "sm",
|
|
477
|
-
onClick: () => onStage({
|
|
511
|
+
onClick: () => onStage({ protocol: "" }),
|
|
478
512
|
disabled,
|
|
479
513
|
children: t("resetField")
|
|
480
514
|
}) : null
|
|
481
515
|
]
|
|
482
516
|
}),
|
|
483
517
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
484
|
-
id: `dap-${model.id}-
|
|
518
|
+
id: `dap-${model.id}-protocol`,
|
|
485
519
|
className: "dap-select",
|
|
486
|
-
value: draft.
|
|
520
|
+
value: draft.protocol,
|
|
487
521
|
disabled,
|
|
488
|
-
"aria-describedby": `dap-${model.id}-
|
|
489
|
-
onChange: (event) => onStage({
|
|
490
|
-
children: [
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
children: "openai-completions"
|
|
498
|
-
}),
|
|
499
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
500
|
-
value: "openai-responses",
|
|
501
|
-
children: "openai-responses"
|
|
502
|
-
}),
|
|
503
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
504
|
-
value: "anthropic-messages",
|
|
505
|
-
children: "anthropic-messages"
|
|
506
|
-
})
|
|
507
|
-
]
|
|
522
|
+
"aria-describedby": `dap-${model.id}-protocol-help dap-${model.id}-protocol-source`,
|
|
523
|
+
onChange: (event) => onStage({ protocol: event.target.value }),
|
|
524
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
525
|
+
value: "",
|
|
526
|
+
children: t("reasoningFollow")
|
|
527
|
+
}), PROTOCOLS.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
528
|
+
value: option.value,
|
|
529
|
+
children: t(option.label)
|
|
530
|
+
}, option.value))]
|
|
508
531
|
}),
|
|
509
532
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
510
|
-
id: `dap-${model.id}-
|
|
533
|
+
id: `dap-${model.id}-protocol-help`,
|
|
511
534
|
className: "dap-hint",
|
|
512
|
-
children: t("
|
|
535
|
+
children: t("editProtocolHint")
|
|
513
536
|
}),
|
|
514
537
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
515
|
-
id: `dap-${model.id}-
|
|
538
|
+
id: `dap-${model.id}-protocol-source`,
|
|
516
539
|
className: "dap-hint",
|
|
517
|
-
children: sourceOf(declaredIn(model, "
|
|
540
|
+
children: sourceOf(declaredIn(model, "protocol") ? "config" : "aperture")
|
|
518
541
|
})
|
|
519
542
|
]
|
|
520
543
|
})
|
|
@@ -590,74 +613,73 @@ window.__ModuleLoader__.load({
|
|
|
590
613
|
})]
|
|
591
614
|
}),
|
|
592
615
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
593
|
-
className: "dap-
|
|
594
|
-
children: [
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
})]
|
|
616
|
+
className: "dap-editGroup",
|
|
617
|
+
children: [
|
|
618
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
619
|
+
className: "dap-editGroupTitle",
|
|
620
|
+
children: t("editInput")
|
|
621
|
+
}),
|
|
622
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
623
|
+
className: "dap-control",
|
|
624
|
+
children: [
|
|
625
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
626
|
+
checked: draft.text,
|
|
627
|
+
onChange: (next) => onStage({ text: next }),
|
|
628
|
+
label: t("modalityText"),
|
|
629
|
+
disabled
|
|
630
|
+
}),
|
|
631
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Checkbox, {
|
|
632
|
+
checked: draft.image,
|
|
633
|
+
onChange: (next) => onStage({ image: next }),
|
|
634
|
+
label: t("modalityImage"),
|
|
635
|
+
disabled
|
|
636
|
+
}),
|
|
637
|
+
overrides.includes("input") ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Tag, {
|
|
638
|
+
tone: "neutral",
|
|
639
|
+
children: t("overridden")
|
|
640
|
+
}) : null
|
|
641
|
+
]
|
|
642
|
+
}),
|
|
643
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
644
|
+
className: "dap-hint",
|
|
645
|
+
children: sourceOf(model.provenance.input)
|
|
646
|
+
})
|
|
647
|
+
]
|
|
648
|
+
}),
|
|
649
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
650
|
+
className: "dap-editGroup",
|
|
651
|
+
children: [
|
|
652
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
653
|
+
className: "dap-editGroupTitle",
|
|
654
|
+
children: t("editReasoning")
|
|
655
|
+
}),
|
|
656
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.SegmentedControl, {
|
|
657
|
+
id: `dap-${model.id}-reasoning`,
|
|
658
|
+
className: "dap-controlStart",
|
|
659
|
+
label: t("editReasoning"),
|
|
660
|
+
value: draft.reasoning,
|
|
661
|
+
options: [
|
|
662
|
+
{
|
|
663
|
+
value: "auto",
|
|
664
|
+
label: t("reasoningFollow")
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
value: "on",
|
|
668
|
+
label: t("reasoningOn")
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
value: "off",
|
|
672
|
+
label: t("reasoningOff")
|
|
673
|
+
}
|
|
674
|
+
],
|
|
675
|
+
onChange: (next) => onStage({ reasoning: next }),
|
|
676
|
+
disabled
|
|
677
|
+
}),
|
|
678
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
679
|
+
className: "dap-hint",
|
|
680
|
+
children: sourceOf(model.provenance.reasoning)
|
|
681
|
+
})
|
|
682
|
+
]
|
|
661
683
|
}),
|
|
662
684
|
model.endpoints.length === 0 ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
663
685
|
className: "dap-endpoints",
|
|
@@ -721,26 +743,26 @@ window.__ModuleLoader__.load({
|
|
|
721
743
|
* @module dsh-aperture/client/ModelRow
|
|
722
744
|
*/
|
|
723
745
|
/**
|
|
724
|
-
*
|
|
746
|
+
* 这一行的状态点:绿是注册上去了、灰是没注册上去、黄是根本没有路由能服务它。
|
|
725
747
|
*
|
|
726
748
|
* 点旁边那句 `title` 就是它的说法——官方 `StateDot` 自己是 `aria-hidden`,说给谁听得由这里给。
|
|
727
|
-
*
|
|
749
|
+
* 那一轮没走到注册(`registeredRoutes` 缺失)时不装作「没注册上去」:报告里根本没有这一项。
|
|
728
750
|
*
|
|
729
751
|
* @param {object} model - 报告里的这一行。
|
|
730
|
-
* @param {readonly string[]|undefined}
|
|
752
|
+
* @param {readonly string[]|undefined} registeredRoutes - 最近一轮注册出去的路由名。
|
|
731
753
|
* @param {Function} t - 字典。
|
|
732
754
|
* @returns {object} 点的状态与它的说法。
|
|
733
755
|
*/
|
|
734
|
-
function publishState(model,
|
|
756
|
+
function publishState(model, registeredRoutes, t) {
|
|
735
757
|
if (model.route === void 0) return {
|
|
736
758
|
state: "warning",
|
|
737
759
|
title: t("statusUnserved")
|
|
738
760
|
};
|
|
739
|
-
if (
|
|
761
|
+
if (registeredRoutes === void 0) return {
|
|
740
762
|
state: "idle",
|
|
741
763
|
title: t("statusUnknown")
|
|
742
764
|
};
|
|
743
|
-
return
|
|
765
|
+
return registeredRoutes.includes(model.route) ? {
|
|
744
766
|
state: "done",
|
|
745
767
|
title: t("statusPublished")
|
|
746
768
|
} : {
|
|
@@ -753,12 +775,13 @@ window.__ModuleLoader__.load({
|
|
|
753
775
|
*
|
|
754
776
|
* @param {object} model - 报告里的这一行。
|
|
755
777
|
* @param {Function} t - 字典。
|
|
778
|
+
* @param {boolean} hideRoute - 跳过路由与协议这两项(同卡每一行都一样时是重复信息)。
|
|
756
779
|
* @returns {string[]} 事实。
|
|
757
780
|
*/
|
|
758
|
-
function factItems(model, t) {
|
|
781
|
+
function factItems(model, t, hideRoute) {
|
|
759
782
|
const facts = [];
|
|
760
|
-
if (model.route !== void 0) facts.push(t("factRoute", { route: model.route }));
|
|
761
|
-
if (model.protocol !== void 0) facts.push(t("factProtocol", { protocol: model.protocol }));
|
|
783
|
+
if (!hideRoute && model.route !== void 0) facts.push(t("factRoute", { route: model.route }));
|
|
784
|
+
if (!hideRoute && model.protocol !== void 0) facts.push(t("factProtocol", { protocol: model.protocol }));
|
|
762
785
|
if (model.contextWindow !== void 0) facts.push(t("factContextWindow", { count: formatCount(model.contextWindow) }));
|
|
763
786
|
if (model.maxTokens !== void 0) facts.push(t("factMaxTokens", { count: formatCount(model.maxTokens) }));
|
|
764
787
|
facts.push(t("factInput", { value: model.input.length === 0 ? t("modalityNone") : model.input.map((item) => t(item === "image" ? "modalityImage" : "modalityText")).join("+") }));
|
|
@@ -773,9 +796,9 @@ window.__ModuleLoader__.load({
|
|
|
773
796
|
* @returns {object} 这一行的内容(`li` 由列表那一层画)。
|
|
774
797
|
*/
|
|
775
798
|
function ModelRow(props) {
|
|
776
|
-
const { model, draft, open, busy,
|
|
799
|
+
const { model, draft, open, busy, registeredRoutes, hideRouteFacts, t, onToggle, onStage, onCancel, onSave, onClear } = props;
|
|
777
800
|
const overrides = model.overrideKeys ?? [];
|
|
778
|
-
const status = publishState(model,
|
|
801
|
+
const status = publishState(model, registeredRoutes, t);
|
|
779
802
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
780
803
|
type: "button",
|
|
781
804
|
className: "dap-cardHead",
|
|
@@ -821,7 +844,7 @@ window.__ModuleLoader__.load({
|
|
|
821
844
|
]
|
|
822
845
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
823
846
|
className: "dap-factRow",
|
|
824
|
-
children: factItems(model, t).map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
847
|
+
children: factItems(model, t, hideRouteFacts === true).map((item, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
825
848
|
className: "dap-factItem",
|
|
826
849
|
children: item
|
|
827
850
|
}, `${model.id}-fact-${String(index)}`))
|
|
@@ -845,42 +868,73 @@ window.__ModuleLoader__.load({
|
|
|
845
868
|
}) : null] });
|
|
846
869
|
}
|
|
847
870
|
//#endregion
|
|
848
|
-
//#region src/client/
|
|
871
|
+
//#region src/client/shared.ts
|
|
872
|
+
/** 一个错误的人话形式。 */
|
|
873
|
+
function textOf(error) {
|
|
874
|
+
return error instanceof Error ? error.message : String(error);
|
|
875
|
+
}
|
|
849
876
|
/**
|
|
850
|
-
*
|
|
877
|
+
* 这一轮哪里不对:清单读不到、或者这一轮没注册上。
|
|
878
|
+
*
|
|
879
|
+
* 这些话原本只写在报告事实表里;报告那一块删掉之后,清单挂了的时候用户看到的就只是「还没有发现
|
|
880
|
+
* 任何模型」,没有任何理由。刷新整个失败(`ok: false`)不在这里说:那句话由 `run()` 贴到提示语
|
|
881
|
+
* 上,比这里更显眼。两个组件都用它——它说的是整个插件的事,两处都该看得到。
|
|
882
|
+
*
|
|
883
|
+
* @param {object} current - 最近一次报告。
|
|
884
|
+
* @param {Function} t - 字典。
|
|
885
|
+
* @returns {string|null} 要说的话,没问题时为 `null`。
|
|
886
|
+
*/
|
|
887
|
+
function roundProblem(current, t) {
|
|
888
|
+
const refresh = current === null ? void 0 : current.refresh;
|
|
889
|
+
if (refresh === void 0) return null;
|
|
890
|
+
if (!refresh.catalog.available) return t("catalogUnavailable", { reason: refresh.catalog.reason ?? "—" });
|
|
891
|
+
if (refresh.publish?.reason !== void 0) return t("registerSkipped", { reason: refresh.publish.reason });
|
|
892
|
+
return null;
|
|
893
|
+
}
|
|
894
|
+
//#endregion
|
|
895
|
+
//#region src/client/ApertureModels.tsx
|
|
896
|
+
/**
|
|
897
|
+
* 模型清单与逐模型编辑器:挂在官方「模型」页的卡片扩展位 `settings.models.provider-card` 上,
|
|
898
|
+
* 本插件的配置页只留实例地址与注册开关。
|
|
899
|
+
*
|
|
900
|
+
* 座位按 `settingsNs` 派发(页主自己的 README 叫 Extension slots),因此本插件注册的每一行路由
|
|
901
|
+
* 都会得到这一块;组件从递进来的目录行认出自己管哪一条路由,只画那一条路由的模型——**能列在这一页
|
|
902
|
+
* 上的模型一定有路由**,没有路由可服务的那些不在这一页出现(它们的去处见
|
|
903
|
+
* [AperturePanel.tsx](./AperturePanel.tsx) 里那句提示)。
|
|
904
|
+
*
|
|
905
|
+
* 不放在本插件的配置页里:模型本来就在那一页上列着(provider 目录那几行就是本插件的路由),在模型
|
|
906
|
+
* 旁边编辑模型比「先去插件页、再回来选模型」少一次往返。
|
|
907
|
+
*
|
|
908
|
+
* 页面只交内容,控件用官方原语,**没有卡片**。报告、提示语与每行的草稿、展开状态是这一块的局部
|
|
909
|
+
* 状态;动作在这里按行绑好,然后整份递给只画不记的 [ModelRow.tsx](./ModelRow.tsx)(展开之后是
|
|
910
|
+
* [ModelEditor.tsx](./ModelEditor.tsx))。草稿与补丁的换算——哪一项改过、该发什么出去——在
|
|
911
|
+
* [draft.ts](./draft.ts) 里,行与编辑器问的是同一个答案。
|
|
851
912
|
*
|
|
852
|
-
*
|
|
853
|
-
*
|
|
854
|
-
*
|
|
913
|
+
* **这一块默认收着**:卡片座位在官方「模型」页里是**每一行都渲染**的(页主的派发不带「这一行展开
|
|
914
|
+
* 了吗」这个事实),摊开一次是十几行的清单,收着才不喧宾夺主——标题与模型数目在折叠头上仍然一眼
|
|
915
|
+
* 能看到。页主自己的编辑器(点「编辑」才出现的那一块)与这一块互不影响。
|
|
855
916
|
*
|
|
856
|
-
*
|
|
857
|
-
*
|
|
858
|
-
*
|
|
859
|
-
*
|
|
917
|
+
* 折叠头自己画,不走官方 `DisclosureRow`:那是聊天里 24px 高、没有内边距也没有背景反馈的紧凑流式
|
|
918
|
+
* 行,箭头还要 hover 才出现;摆在设置卡里就成了浮在中间的一条细线。这里按官方「模型」页自己那条
|
|
919
|
+
* 折叠行的语言画(`border-l2` 上一条细线、`label-secondary` 在 hover 时提到 `label-primary`),
|
|
920
|
+
* 箭头常驻在最右、数目跟在标题后面。
|
|
860
921
|
*
|
|
861
922
|
* **effect 的依赖里刻意不放注入面**:`inject` 面由渲染器每次渲染重新组装,把它的身份放进依赖会
|
|
862
923
|
* 让 effect 每渲染一次就重跑一次。因此报告用一个自增计数器当重读信号(依赖里只有那个数),注入
|
|
863
924
|
* 面里的函数只在事件处理里调用,拿到的永远是当轮的那份。
|
|
864
925
|
*
|
|
865
|
-
* @module dsh-aperture/client/
|
|
926
|
+
* @module dsh-aperture/client/ApertureModels
|
|
866
927
|
*/
|
|
867
|
-
/** 一个错误的人话形式。 */
|
|
868
|
-
function textOf(error) {
|
|
869
|
-
return error instanceof Error ? error.message : String(error);
|
|
870
|
-
}
|
|
871
928
|
/**
|
|
872
|
-
*
|
|
929
|
+
* 模型清单与逐模型覆盖:一行一个模型,展开改这一行的覆盖。
|
|
873
930
|
*
|
|
874
|
-
*
|
|
875
|
-
*
|
|
876
|
-
*
|
|
877
|
-
* @param {object} props - 注入面:`useApertureCard`、`panel`(报告端点)、`save` / `edit` /
|
|
878
|
-
* `resetField` / `discard` / `failed`(设置表单)与 `t`(字典,注册时声明了 `locale`)。
|
|
879
|
-
* @returns {object} 页面元素。
|
|
931
|
+
* @param {object} props - 注入面:`panel`(报告与按行写入)与 `t`(字典,注册时声明了
|
|
932
|
+
* `locale`)。
|
|
933
|
+
* @returns {object} 这一块元素。
|
|
880
934
|
*/
|
|
881
|
-
function
|
|
935
|
+
function ApertureModels(props) {
|
|
882
936
|
const t = typeof props.t === "function" ? props.t : (key, params) => interpolate(zhDict[key] ?? key, params);
|
|
883
|
-
const
|
|
937
|
+
const [open, setOpen] = react.useState(false);
|
|
884
938
|
const [report, setReport] = react.useState(null);
|
|
885
939
|
const [banner, setBanner] = react.useState(null);
|
|
886
940
|
const [busy, setBusy] = react.useState("");
|
|
@@ -930,26 +984,6 @@ window.__ModuleLoader__.load({
|
|
|
930
984
|
}
|
|
931
985
|
})();
|
|
932
986
|
};
|
|
933
|
-
/**
|
|
934
|
-
* 保存设置里那两个字段,然后等一轮重新发现落地再说话。
|
|
935
|
-
*
|
|
936
|
-
* 写入走官方表单模型的 `save()`:它自带 `revision` 围栏(期间别处改过就拒绝,而不是覆盖别人的
|
|
937
|
-
* 改动)并从宿主接受的那份重新播种,因此写完不重读设置——投影会自己变新。报告里的模型事实
|
|
938
|
-
* 与状态点来自最近一次刷新,写完必须等一轮,否则就是「保存了却没变」。设置变更自己也会唤起同一轮
|
|
939
|
-
* 刷新(单飞判定按配置版本合并),因此这里通常并进那一轮。
|
|
940
|
-
*/
|
|
941
|
-
const saveSettings = () => run("save", async () => {
|
|
942
|
-
await props.save();
|
|
943
|
-
if (props.failed()) return {
|
|
944
|
-
ok: false,
|
|
945
|
-
summary: t("configRefused")
|
|
946
|
-
};
|
|
947
|
-
const round = await props.panel.refresh();
|
|
948
|
-
return {
|
|
949
|
-
ok: round.ok,
|
|
950
|
-
summary: t("savedResult", { result: round.summary })
|
|
951
|
-
};
|
|
952
|
-
}, () => setRevision((value) => value + 1));
|
|
953
987
|
/** 一个模型此刻的草稿;没改过就是生效值本身。 */
|
|
954
988
|
const draftOf = (model) => drafts[model.id] ?? initialOf(model);
|
|
955
989
|
/** 改这一行的几个字段;用函数式更新,同一个 tick 里连着改几项也不会互相覆盖。 */
|
|
@@ -1042,27 +1076,221 @@ window.__ModuleLoader__.load({
|
|
|
1042
1076
|
setRevision((value) => value + 1);
|
|
1043
1077
|
});
|
|
1044
1078
|
};
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
*
|
|
1079
|
+
/**
|
|
1080
|
+
* 这一块画哪一条路由的模型。
|
|
1081
|
+
*
|
|
1082
|
+
* 只有卡片座位:座位递来的目录行就是这一块管的那条路由,报告里的模型按 `route` 归属它。拿不到
|
|
1083
|
+
* 目录行(座位没递 `provider`)就什么都不画——**没有路由可服务的模型不该在这一页出现**,它们由
|
|
1084
|
+
* 配置页那句话交代。
|
|
1048
1085
|
*/
|
|
1049
|
-
const
|
|
1086
|
+
const cardRoute = props.provider?.provider;
|
|
1087
|
+
const models = (report?.models ?? []).filter((model) => model.route === cardRoute);
|
|
1088
|
+
const dormant = props.useApertureCard((snapshot) => snapshot.available && snapshot.baseUrl.text === "");
|
|
1089
|
+
const problem = roundProblem(report, t);
|
|
1090
|
+
if (cardRoute === void 0) return null;
|
|
1091
|
+
const title = t("modelsTitle");
|
|
1092
|
+
/** 折叠内容的 id:同一页上每一条路由各有一块,按座位取才唯一。 */
|
|
1093
|
+
const bodyId = `dap-models-body-${cardRoute ?? "footer"}`;
|
|
1094
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1095
|
+
"data-dsh-aperture": "",
|
|
1096
|
+
children: [
|
|
1097
|
+
banner === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1098
|
+
className: "dap-banner",
|
|
1099
|
+
"data-ok": banner.ok ? "true" : "false",
|
|
1100
|
+
role: "status",
|
|
1101
|
+
"aria-live": "polite",
|
|
1102
|
+
children: banner.text
|
|
1103
|
+
}),
|
|
1104
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
1105
|
+
className: "dap-models",
|
|
1106
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1107
|
+
type: "button",
|
|
1108
|
+
className: "dap-modelsToggle",
|
|
1109
|
+
"aria-expanded": open ? "true" : "false",
|
|
1110
|
+
"aria-controls": bodyId,
|
|
1111
|
+
onClick: () => setOpen((value) => !value),
|
|
1112
|
+
children: [
|
|
1113
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1114
|
+
className: "dap-modelsTitle",
|
|
1115
|
+
children: title
|
|
1116
|
+
}),
|
|
1117
|
+
report === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1118
|
+
className: "dap-count",
|
|
1119
|
+
children: t("modelsCount", { count: models.length })
|
|
1120
|
+
}),
|
|
1121
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1122
|
+
className: "dap-chevron",
|
|
1123
|
+
"data-open": open ? "true" : "false",
|
|
1124
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronRightOutlineRegular, { size: 14 })
|
|
1125
|
+
})
|
|
1126
|
+
]
|
|
1127
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1128
|
+
className: "dap-modelsBody",
|
|
1129
|
+
id: bodyId,
|
|
1130
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1131
|
+
className: "dap-hint",
|
|
1132
|
+
children: t("modelsHint")
|
|
1133
|
+
}), report === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1134
|
+
className: "dap-hint",
|
|
1135
|
+
children: t("loading")
|
|
1136
|
+
}) : models.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1137
|
+
className: "dap-empty",
|
|
1138
|
+
children: dormant ? t("dormantHint") : t("noModels")
|
|
1139
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
1140
|
+
className: "dap-rows",
|
|
1141
|
+
children: models.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
1142
|
+
className: "dap-card",
|
|
1143
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelRow, {
|
|
1144
|
+
model,
|
|
1145
|
+
draft: draftOf(model),
|
|
1146
|
+
open: opened[model.id] === true,
|
|
1147
|
+
busy,
|
|
1148
|
+
registeredRoutes: report === null ? void 0 : report.refresh?.publish?.routes,
|
|
1149
|
+
hideRouteFacts: true,
|
|
1150
|
+
t,
|
|
1151
|
+
onToggle: () => toggleRow(model),
|
|
1152
|
+
onStage: (changes) => stage(model, changes),
|
|
1153
|
+
onCancel: () => cancelRow(model),
|
|
1154
|
+
onSave: () => submitRow(model),
|
|
1155
|
+
onClear: () => clearOverrides(model)
|
|
1156
|
+
})
|
|
1157
|
+
}, model.id))
|
|
1158
|
+
})]
|
|
1159
|
+
}) : null]
|
|
1160
|
+
}),
|
|
1161
|
+
problem === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1162
|
+
className: "dap-warnNote",
|
|
1163
|
+
children: problem
|
|
1164
|
+
})
|
|
1165
|
+
]
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
//#endregion
|
|
1169
|
+
//#region src/client/AperturePanel.tsx
|
|
1170
|
+
/**
|
|
1171
|
+
* 配置页:插件列表里本插件那个包页上的设置页——实例地址、注册开关、「立刻刷新」,这一轮哪里不对,
|
|
1172
|
+
* 以及**哪些模型没有路由可服务**。
|
|
1173
|
+
*
|
|
1174
|
+
* **模型的清单与逐模型覆盖不在这一页**:它们在官方「模型」页本插件那几行路由卡里,见
|
|
1175
|
+
* [ApertureModels.tsx](./ApertureModels.tsx)。模型本来就列在那一页里(provider 目录那几行就是本
|
|
1176
|
+
* 插件的路由),在模型旁边改模型比「先去插件页、再回来找模型」少一次往返。
|
|
1177
|
+
*
|
|
1178
|
+
* 没有路由可服务的模型在那一页上**没有座位**:那一页只列真的有路由的模型,这些模型于是改由这一页
|
|
1179
|
+
* 一句话交代——有几个、叫什么,以及去哪儿给它们写协议。报告因此不只用来讲「这一轮哪里不对」,还要
|
|
1180
|
+
* 数出这一群人;数量为零时这句话不出现。
|
|
1181
|
+
*
|
|
1182
|
+
* **effect 的依赖里刻意不放注入面**:`inject` 面由渲染器每次渲染重新组装,把它的身份放进依赖会
|
|
1183
|
+
* 让 effect 每渲染一次就重跑一次。因此报告用一个自增计数器当重读信号(依赖里只有那个数),注入
|
|
1184
|
+
* 面里的函数只在事件处理里调用,拿到的永远是当轮的那份。
|
|
1185
|
+
*
|
|
1186
|
+
* @module dsh-aperture/client/AperturePanel
|
|
1187
|
+
*/
|
|
1188
|
+
/**
|
|
1189
|
+
* 配置页:实例地址、注册开关与「立刻刷新」。
|
|
1190
|
+
*
|
|
1191
|
+
* 报告仍然要读:模型的清单在另一页上,但「这一轮哪里不对」与「立刻刷新」都在这一页上——地址填完
|
|
1192
|
+
* 按保存之后,用户唯一会盯着看的就是这里。
|
|
1193
|
+
*
|
|
1194
|
+
* @param {object} props - 注入面:`useApertureCard`、`panel`(报告端点)、`save` / `edit` /
|
|
1195
|
+
* `resetField` / `discard` / `failed`(设置表单)与 `t`(字典,注册时声明了 `locale`)。
|
|
1196
|
+
* @returns {object} 页面元素。
|
|
1197
|
+
*/
|
|
1198
|
+
function AperturePanel(props) {
|
|
1199
|
+
const t = typeof props.t === "function" ? props.t : (key, params) => interpolate(zhDict[key] ?? key, params);
|
|
1200
|
+
const state = props.useApertureCard((snapshot) => snapshot);
|
|
1201
|
+
const [report, setReport] = react.useState(null);
|
|
1202
|
+
const [banner, setBanner] = react.useState(null);
|
|
1203
|
+
const [busy, setBusy] = react.useState("");
|
|
1204
|
+
const [revision, setRevision] = react.useState(0);
|
|
1205
|
+
react.useEffect(() => {
|
|
1206
|
+
let cancelled = false;
|
|
1207
|
+
props.panel.status().then((next) => {
|
|
1208
|
+
if (!cancelled) setReport(next);
|
|
1209
|
+
}, (error) => {
|
|
1210
|
+
if (!cancelled) setBanner({
|
|
1211
|
+
ok: false,
|
|
1212
|
+
text: textOf(error)
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1215
|
+
return () => {
|
|
1216
|
+
cancelled = true;
|
|
1217
|
+
};
|
|
1218
|
+
}, [revision]);
|
|
1050
1219
|
/**
|
|
1051
|
-
*
|
|
1220
|
+
* 跑一个动作:期间禁用控件,结束后把结果贴出来。
|
|
1052
1221
|
*
|
|
1053
|
-
*
|
|
1054
|
-
*
|
|
1055
|
-
* 那句话由 `run()` 贴到提示语上,比这里更显眼。正常的一轮(同步关着 / 同步成功)什么都不说。
|
|
1222
|
+
* @param {string} key - 正在跑的动作名(用来禁用控件与换按钮文案)。
|
|
1223
|
+
* @param {Function} action - 要跑的动作。
|
|
1056
1224
|
*/
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1225
|
+
const run = (key, action) => {
|
|
1226
|
+
setBusy(key);
|
|
1227
|
+
setBanner(null);
|
|
1228
|
+
(async () => {
|
|
1229
|
+
try {
|
|
1230
|
+
const result = await action();
|
|
1231
|
+
setBanner({
|
|
1232
|
+
ok: result.ok,
|
|
1233
|
+
text: result.summary
|
|
1234
|
+
});
|
|
1235
|
+
} catch (error) {
|
|
1236
|
+
setBanner({
|
|
1237
|
+
ok: false,
|
|
1238
|
+
text: textOf(error)
|
|
1239
|
+
});
|
|
1240
|
+
} finally {
|
|
1241
|
+
setBusy("");
|
|
1242
|
+
}
|
|
1243
|
+
})();
|
|
1063
1244
|
};
|
|
1245
|
+
/**
|
|
1246
|
+
* 保存设置里那两个字段,然后等一轮重新发现落地再说话。
|
|
1247
|
+
*
|
|
1248
|
+
* 写入走官方表单模型的 `save()`:它自带 `revision` 围栏(期间别处改过就拒绝,而不是覆盖别人的
|
|
1249
|
+
* 改动)并从宿主接受的那份重新播种,因此写完不重读设置——投影会自己变新。报告里的模型事实
|
|
1250
|
+
* 来自最近一次刷新,写完必须等一轮,否则就是「保存了却没变」。设置变更自己也会唤起同一轮刷新
|
|
1251
|
+
* (单飞判定按配置版本合并),因此这里通常并进那一轮。
|
|
1252
|
+
*/
|
|
1253
|
+
const saveSettings = () => run("save", async () => {
|
|
1254
|
+
await props.save();
|
|
1255
|
+
if (props.failed()) return {
|
|
1256
|
+
ok: false,
|
|
1257
|
+
summary: t("configRefused")
|
|
1258
|
+
};
|
|
1259
|
+
const round = await props.panel.refresh();
|
|
1260
|
+
return {
|
|
1261
|
+
ok: round.ok,
|
|
1262
|
+
summary: t("savedResult", { result: round.summary })
|
|
1263
|
+
};
|
|
1264
|
+
});
|
|
1265
|
+
/**
|
|
1266
|
+
* 立刻重新发现并注册一次,不写设置。
|
|
1267
|
+
*
|
|
1268
|
+
* 这一颗按钮只在这一页上:重新发现是「去哪儿发现」这件事的一部分,而模型的清单在另一页上看,
|
|
1269
|
+
* 那边按一下只能刷新一块清单,说不清这一轮到底发生了什么。
|
|
1270
|
+
*/
|
|
1271
|
+
const refreshNow = () => run("refresh", async () => {
|
|
1272
|
+
const round = await props.panel.refresh();
|
|
1273
|
+
setRevision((value) => value + 1);
|
|
1274
|
+
return round;
|
|
1275
|
+
});
|
|
1064
1276
|
const controlsDisabled = !state.available || !state.writable;
|
|
1065
|
-
const problem = roundProblem(report);
|
|
1277
|
+
const problem = roundProblem(report, t);
|
|
1278
|
+
/**
|
|
1279
|
+
* 没有路由可服务的模型:几个、叫什么。
|
|
1280
|
+
*
|
|
1281
|
+
* 名字最多报五个,多的用「等 N 个」收住——这一页是提示,不是清单;那些模型没有编辑器入口,改的
|
|
1282
|
+
* 地方是配置里的 `models[].protocol`。
|
|
1283
|
+
*/
|
|
1284
|
+
const routes = report?.routes ?? [];
|
|
1285
|
+
const unserved = (report?.models ?? []).filter((model) => model.route === void 0);
|
|
1286
|
+
const named = unserved.slice(0, 5).map((model) => model.id);
|
|
1287
|
+
const rest = unserved.length - named.length;
|
|
1288
|
+
const unservedNote = unserved.length === 0 || routes.length === 0 ? null : t("unservedHint", {
|
|
1289
|
+
count: unserved.length,
|
|
1290
|
+
ids: rest > 0 ? `${named.join(t("listSeparator"))} ${t("moreModels", { count: rest })}` : named.join(t("listSeparator"))
|
|
1291
|
+
});
|
|
1292
|
+
/** 一条路由都没注册时那句:注册失败的原因由 `problem` 说,这里只管「什么都没注册」这件事。 */
|
|
1293
|
+
const noRoutesNote = report !== null && routes.length === 0 && problem === null ? t("noRoutesHint") : null;
|
|
1066
1294
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1067
1295
|
"data-dsh-aperture": "",
|
|
1068
1296
|
children: [
|
|
@@ -1123,6 +1351,29 @@ window.__ModuleLoader__.load({
|
|
|
1123
1351
|
})]
|
|
1124
1352
|
})]
|
|
1125
1353
|
}),
|
|
1354
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1355
|
+
className: "dap-actions",
|
|
1356
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1357
|
+
className: "dap-actionsNote",
|
|
1358
|
+
children: t("modelsElsewhere")
|
|
1359
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1360
|
+
variant: "ghost",
|
|
1361
|
+
size: "sm",
|
|
1362
|
+
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { size: 14 }),
|
|
1363
|
+
onClick: refreshNow,
|
|
1364
|
+
disabled: busy !== "",
|
|
1365
|
+
title: t("refreshHint"),
|
|
1366
|
+
children: busy === "refresh" ? t("refreshing") : t("refresh")
|
|
1367
|
+
})]
|
|
1368
|
+
}),
|
|
1369
|
+
unservedNote === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1370
|
+
className: "dap-hint",
|
|
1371
|
+
children: unservedNote
|
|
1372
|
+
}),
|
|
1373
|
+
noRoutesNote === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1374
|
+
className: "dap-hint",
|
|
1375
|
+
children: noRoutesNote
|
|
1376
|
+
}),
|
|
1126
1377
|
banner === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1127
1378
|
className: "dap-banner",
|
|
1128
1379
|
"data-ok": banner.ok ? "true" : "false",
|
|
@@ -1130,64 +1381,9 @@ window.__ModuleLoader__.load({
|
|
|
1130
1381
|
"aria-live": "polite",
|
|
1131
1382
|
children: banner.text
|
|
1132
1383
|
}),
|
|
1133
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1134
|
-
className: "dap-
|
|
1135
|
-
children:
|
|
1136
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1137
|
-
className: "dap-groupHead",
|
|
1138
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
1139
|
-
className: "dap-titleWrap",
|
|
1140
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
1141
|
-
className: "dap-groupTitle",
|
|
1142
|
-
children: t("modelsTitle")
|
|
1143
|
-
}), report === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1144
|
-
className: "dap-count",
|
|
1145
|
-
children: t("modelsCount", { count: report.models.length })
|
|
1146
|
-
})]
|
|
1147
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
1148
|
-
variant: "ghost",
|
|
1149
|
-
size: "sm",
|
|
1150
|
-
icon: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconRefreshOutlineRegular, { size: 14 }),
|
|
1151
|
-
onClick: refreshReport,
|
|
1152
|
-
disabled: busy !== "",
|
|
1153
|
-
title: t("refreshHint"),
|
|
1154
|
-
children: busy === "refresh" ? t("refreshing") : t("refresh")
|
|
1155
|
-
})]
|
|
1156
|
-
}),
|
|
1157
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1158
|
-
className: "dap-hint",
|
|
1159
|
-
children: t("modelsHint")
|
|
1160
|
-
}),
|
|
1161
|
-
problem === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1162
|
-
className: "dap-warnNote",
|
|
1163
|
-
children: problem
|
|
1164
|
-
}),
|
|
1165
|
-
report === null ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1166
|
-
className: "dap-hint",
|
|
1167
|
-
children: t("loading")
|
|
1168
|
-
}) : report.models.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1169
|
-
className: "dap-empty",
|
|
1170
|
-
children: state.available && state.baseUrl.text === "" ? t("dormantHint") : t("noModels")
|
|
1171
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
1172
|
-
className: "dap-rows",
|
|
1173
|
-
children: report.models.map((model) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
1174
|
-
className: "dap-card",
|
|
1175
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelRow, {
|
|
1176
|
-
model,
|
|
1177
|
-
draft: draftOf(model),
|
|
1178
|
-
open: opened[model.id] === true,
|
|
1179
|
-
busy,
|
|
1180
|
-
writtenRoutes,
|
|
1181
|
-
t,
|
|
1182
|
-
onToggle: () => toggleRow(model),
|
|
1183
|
-
onStage: (changes) => stage(model, changes),
|
|
1184
|
-
onCancel: () => cancelRow(model),
|
|
1185
|
-
onSave: () => submitRow(model),
|
|
1186
|
-
onClear: () => clearOverrides(model)
|
|
1187
|
-
})
|
|
1188
|
-
}, model.id))
|
|
1189
|
-
})
|
|
1190
|
-
]
|
|
1384
|
+
problem === null ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1385
|
+
className: "dap-warnNote",
|
|
1386
|
+
children: problem
|
|
1191
1387
|
})
|
|
1192
1388
|
]
|
|
1193
1389
|
});
|
|
@@ -1254,7 +1450,7 @@ window.__ModuleLoader__.load({
|
|
|
1254
1450
|
});
|
|
1255
1451
|
//#endregion
|
|
1256
1452
|
//#region \0dsh-aperture-css-inline:src/client/styles.css.mjs
|
|
1257
|
-
var styles_css_default = "[data-dsh-aperture] {\n display: flex;\n flex-direction: column;\n gap: 20px;\n font-size: 13px;\n color: var(--dsw-alias-label-primary, #e6e6e6);\n}\n[data-dsh-aperture] .dap-
|
|
1453
|
+
var styles_css_default = "[data-dsh-aperture] {\n display: flex;\n flex-direction: column;\n gap: 20px;\n font-size: 13px;\n color: var(--dsw-alias-label-primary, #e6e6e6);\n}\n/* 折叠头按官方「模型」页自己那条折叠行的语言画:`border-l2` 上一条细线,`label-secondary` 的\n `500` 小字,hover 时提到 `label-primary`。官方 `DisclosureRow` 是聊天里 24px 高、没有内边距也\n 没有反馈的紧凑流式行,箭头还要 hover 才出现,摆在设置卡里就是浮在中间的一条细线。\n 左右各外扩 6px:背景与聚焦框能铺满一行,文字仍与卡片头对齐(页主那条折叠行也是这么让位的)。 */\n[data-dsh-aperture] .dap-models {\n display: flex;\n flex-direction: column;\n border-top: 0.5px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.28));\n padding-top: 10px;\n}\n[data-dsh-aperture] .dap-modelsToggle {\n display: flex;\n align-items: center;\n gap: 8px;\n width: auto;\n min-height: 32px;\n margin: 0 -6px;\n padding: 0 6px;\n border: 0;\n border-radius: var(--dsw-radius-sm, 6px);\n background: none;\n color: var(--dsw-alias-label-secondary, #c9c9c9);\n font: inherit;\n text-align: left;\n cursor: pointer;\n}\n[data-dsh-aperture] .dap-modelsToggle:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(255, 255, 255, 0.06));\n color: var(--dsw-alias-label-primary, #e6e6e6);\n}\n[data-dsh-aperture] .dap-modelsToggle:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary, #7aaaff);\n outline-offset: 1px;\n}\n/* 标题过长时省略;数目与箭头都不许被挤走。 */\n[data-dsh-aperture] .dap-modelsTitle {\n min-width: 0;\n overflow: hidden;\n font-size: 13px;\n font-weight: 500;\n line-height: 20px;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n[data-dsh-aperture] .dap-modelsToggle .dap-count {\n flex: none;\n margin-left: 2px;\n}\n[data-dsh-aperture] .dap-modelsToggle .dap-chevron {\n margin-left: auto;\n}\n/* 折叠内容留在折叠头下面。 */\n[data-dsh-aperture] .dap-modelsBody {\n display: flex;\n flex-direction: column;\n gap: 12px;\n padding-top: 12px;\n}\n/* 数目跟在标题后面,用等宽数字,免得一轮刷新改写时宽度乱跳。 */\n[data-dsh-aperture] .dap-count {\n font-size: 12px;\n line-height: 18px;\n font-variant-numeric: tabular-nums;\n color: var(--dsw-alias-label-secondary, #c9c9c9);\n}\n/* 空状态是官方「模型」页那条虚线盒子:没有内容时给个形状,不留白。 */\n[data-dsh-aperture] .dap-empty {\n margin: 0;\n padding: 12px;\n border: 0.5px dashed var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.28));\n border-radius: var(--dsw-radius-lg, 16px);\n text-align: center;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary, #8b8b8b);\n}\n[data-dsh-aperture] .dap-hint {\n margin: 0;\n font-size: 12px;\n line-height: 1.6;\n color: var(--dsw-alias-label-tertiary, #8b8b8b);\n}\n[data-dsh-aperture] .dap-banner {\n margin: 0;\n font-size: 12px;\n line-height: 1.6;\n color: var(--dsw-alias-label-secondary, #c9c9c9);\n}\n[data-dsh-aperture] .dap-banner[data-ok='false'] {\n color: var(--dsw-alias-state-error-primary, #e06c75);\n}\n[data-dsh-aperture] .dap-toggleRow {\n display: flex;\n align-items: flex-start;\n justify-content: space-between;\n gap: 16px;\n font-size: 13px;\n line-height: 1.5;\n}\n[data-dsh-aperture] .dap-toggleText {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n/* 模型清单沿用官方模型页的描边卡片;颜色只使用插件页确实提供的通用 token。 */\n[data-dsh-aperture] .dap-rows {\n display: flex;\n flex-direction: column;\n gap: 8px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n[data-dsh-aperture] .dap-card {\n display: flex;\n flex-direction: column;\n min-width: 0;\n border: 0.5px solid var(--dsw-alias-border-l4, rgba(128, 128, 128, 0.36));\n border-radius: var(--dsw-radius-xl, 20px);\n background: var(--dsw-alias-bg-layer-2, transparent);\n}\n/* 行首是一条盖满整行的按钮:点哪儿都能展开这一行。 */\n[data-dsh-aperture] .dap-cardHead {\n display: flex;\n /* 顶着第一行走,不居中:这一行有两行身份(名字 + 事实),居中的话状态点会落在两行中间。 */\n align-items: flex-start;\n gap: 10px;\n width: 100%;\n padding: 12px 14px;\n border: 0;\n border-radius: inherit;\n background: none;\n color: inherit;\n font: inherit;\n text-align: left;\n cursor: pointer;\n}\n[data-dsh-aperture] .dap-cardHead:hover {\n background: var(--dsw-alias-interactive-bg-hover, rgba(255, 255, 255, 0.06));\n}\n[data-dsh-aperture] .dap-cardHead[aria-expanded='true'] {\n border-bottom: 0.5px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.28));\n border-radius: var(--dsw-radius-xl, 20px) var(--dsw-radius-xl, 20px) 0 0;\n}\n[data-dsh-aperture] .dap-cardHead:focus-visible {\n outline: 2px solid var(--dsw-alias-brand-primary, #7aaaff);\n outline-offset: 1px;\n}\n/* 状态点:写入与否这一列永远在同一处,扫一眼就能比。22px 就是名字那一行的高度,点因此落在名字中间。 */\n[data-dsh-aperture] .dap-status {\n display: inline-flex;\n align-items: center;\n flex: none;\n height: 22px;\n}\n[data-dsh-aperture] .dap-identity {\n display: flex;\n flex-direction: column;\n gap: 2px;\n flex: 1;\n min-width: 0;\n}\n[data-dsh-aperture] .dap-identityTop {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 6px;\n min-width: 0;\n}\n[data-dsh-aperture] .dap-name {\n overflow: hidden;\n font-size: 14px;\n font-weight: 500;\n line-height: 22px;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n/* 事实一项一句(「路由 x」「上下文 1M」),之间用小圆点分开:比一串空格好认,也不抢字号。\n 名字必须是 .dap-factRow 而不是 .dap-facts:报告那张 dl 已经占了 .dap-facts,而且它的规则在后面,\n 同名的话会把这里压成竖排(一条一行)。 */\n[data-dsh-aperture] .dap-factRow {\n display: flex;\n align-items: baseline;\n flex-wrap: wrap;\n column-gap: 6px;\n min-width: 0;\n font-size: 12px;\n line-height: 18px;\n font-variant-numeric: tabular-nums;\n color: var(--dsw-alias-label-tertiary, #8b8b8b);\n}\n[data-dsh-aperture] .dap-factItem + .dap-factItem::before {\n content: '·';\n margin-right: 6px;\n color: var(--dsw-alias-label-tertiary, #8b8b8b);\n}\n[data-dsh-aperture] .dap-chevron {\n display: inline-flex;\n align-items: center;\n flex: none;\n height: 22px;\n color: var(--dsw-alias-label-tertiary, #8b8b8b);\n transition: transform 160ms ease;\n}\n[data-dsh-aperture] .dap-chevron[data-open='true'] {\n transform: rotate(90deg);\n}\n/* 展开内容留在模型卡片里;四边使用相同的 12px 间距,不再另套一层描边。 */\n[data-dsh-aperture] .dap-editor {\n display: flex;\n flex-direction: column;\n gap: 12px;\n margin: 12px;\n}\n[data-dsh-aperture] .dap-editorHead {\n display: flex;\n align-items: center;\n gap: 8px;\n min-width: 0;\n}\n[data-dsh-aperture] .dap-editorId {\n overflow: hidden;\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary, #8b8b8b);\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n[data-dsh-aperture] .dap-editorDirty {\n margin-left: auto;\n}\n[data-dsh-aperture] .dap-warnNote {\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-state-warn-primary, #dd8629);\n}\n[data-dsh-aperture] .dap-editGroup {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n[data-dsh-aperture] .dap-editGroupTitle {\n font-size: 12px;\n font-weight: 500;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary, #c9c9c9);\n}\n/* 字段按官方设置表单单列排列,并恢复相邻字段的发丝分隔线。 */\n[data-dsh-aperture] .dap-fields {\n display: flex;\n flex-direction: column;\n}\n[data-dsh-aperture] .dap-fieldCell {\n min-width: 0;\n}\n[data-dsh-aperture] .dap-fieldCell + .dap-fieldCell {\n border-top: 0.5px solid var(--dsw-alias-border-l2, rgba(128, 128, 128, 0.28));\n}\n[data-dsh-aperture] .dap-selectField {\n display: flex;\n flex-direction: column;\n gap: 6px;\n padding: 12px 0;\n}\n[data-dsh-aperture] .dap-selectHead {\n display: flex;\n align-items: center;\n gap: 8px;\n}\n[data-dsh-aperture] .dap-selectLabel {\n flex: 1;\n min-width: 0;\n font-size: 13px;\n font-weight: 500;\n line-height: 1.5;\n}\n[data-dsh-aperture] .dap-select {\n box-sizing: border-box;\n height: 34px;\n padding: 0 12px;\n border: 0.5px solid var(--dsw-alias-border-l4, rgba(128, 128, 128, 0.36));\n border-radius: 8px;\n background: var(--dsw-alias-bg-layer-3, transparent);\n color: var(--dsw-alias-label-primary, #e6e6e6);\n font: inherit;\n font-size: 13px;\n line-height: 1.5;\n}\n[data-dsh-aperture] .dap-select:focus-visible {\n outline: none;\n border-color: var(--dsw-alias-brand-primary, #7aaaff);\n}\n[data-dsh-aperture] .dap-select:disabled {\n color: var(--dsw-alias-label-tertiary, #8b8b8b);\n cursor: default;\n}\n[data-dsh-aperture] .dap-endpoints {\n display: flex;\n flex-direction: column;\n gap: 4px;\n}\n[data-dsh-aperture] .dap-endpointList {\n display: flex;\n flex-direction: column;\n gap: 2px;\n margin: 0;\n padding: 0;\n list-style: none;\n}\n[data-dsh-aperture] .dap-endpoint {\n font-family: ui-monospace, SFMono-Regular, Menlo, monospace;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-secondary, #c9c9c9);\n overflow-wrap: anywhere;\n}\n[data-dsh-aperture] .dap-inline {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 16px;\n}\n[data-dsh-aperture] .dap-control {\n display: flex;\n align-items: center;\n gap: 8px;\n font-size: 13px;\n line-height: 1.5;\n}\n/* flex 列的默认 `align-items: stretch` 会把分段控件从「贴着标签宽」撑成整行宽;官方自己是把它\n 放进 `align-items: flex-start` 的容器里用的,这里用一条 `align-self` 还原。 */\n[data-dsh-aperture] .dap-controlStart {\n align-self: flex-start;\n}\n[data-dsh-aperture] .dap-actions {\n display: flex;\n align-items: center;\n flex-wrap: wrap;\n gap: 8px;\n padding-top: 4px;\n}\n/* 左边那句「还有几项没写下去」,按钮一律靠右,主按钮在最右。 */\n[data-dsh-aperture] .dap-actionsNote {\n margin-right: auto;\n font-size: 12px;\n line-height: 18px;\n color: var(--dsw-alias-label-tertiary, #8b8b8b);\n}\n@media (prefers-reduced-motion: reduce) {\n [data-dsh-aperture] .dap-chevron:where(*) {\n transition: none;\n }\n}\n";
|
|
1258
1454
|
//#endregion
|
|
1259
1455
|
//#region src/client/styles.ts
|
|
1260
1456
|
/**
|
|
@@ -1389,14 +1585,17 @@ window.__ModuleLoader__.load({
|
|
|
1389
1585
|
}, "dsh-aperture: remote contribution");
|
|
1390
1586
|
}
|
|
1391
1587
|
/**
|
|
1392
|
-
* 浏览器插件主体:字典、样式、Remote
|
|
1588
|
+
* 浏览器插件主体:字典、样式、Remote 贡献,以及两个槽位上的注册——「插件」页里本插件那个包页上的
|
|
1589
|
+
* 设置页,与官方「模型」页上模型清单的卡片座位。
|
|
1393
1590
|
*
|
|
1394
|
-
* `ctx.slots.inject`
|
|
1395
|
-
*
|
|
1591
|
+
* `ctx.slots.inject` 是必需的,不是可选的:这两个槽位都由别的页声明,那些声明完全可能在本插件
|
|
1592
|
+
* `apply` 之后才发生,直接 register 会撞上「槽位尚未声明」。
|
|
1396
1593
|
*
|
|
1397
|
-
*
|
|
1398
|
-
*
|
|
1399
|
-
*
|
|
1594
|
+
* 注册的键分两种:配置槽位按**包名**找贡献,点开插件列表里的本插件就是这一页;「模型」页那个卡片
|
|
1595
|
+
* 座位按**设置命名空间**(`aperture`)派发,于是本插件的每一行路由都会得到同一份贡献,组件再从递
|
|
1596
|
+
* 进来的目录行认出自己管哪一条路由。设置那一份表单也在这里取——页主只递 `view`,
|
|
1597
|
+
* `configForms.get(命名空间)` 才是配置读写面;服务按命名空间缓存控制器,因此两个组件拿到的是同一
|
|
1598
|
+
* 份。
|
|
1400
1599
|
*
|
|
1401
1600
|
* @param {object} ctx - 客户端根上下文。
|
|
1402
1601
|
*/
|
|
@@ -1438,6 +1637,15 @@ window.__ModuleLoader__.load({
|
|
|
1438
1637
|
failed: () => form.shell().failed
|
|
1439
1638
|
})
|
|
1440
1639
|
}, AperturePanel));
|
|
1640
|
+
scope.slots.inject("settings.models.provider-card", () => scope.slots.register({
|
|
1641
|
+
name: "settings.models.provider-card",
|
|
1642
|
+
key: SETTINGS_NS,
|
|
1643
|
+
locale: NS,
|
|
1644
|
+
inject: () => ({
|
|
1645
|
+
hooks: { apertureCard: card },
|
|
1646
|
+
panel
|
|
1647
|
+
})
|
|
1648
|
+
}, ApertureModels));
|
|
1441
1649
|
});
|
|
1442
1650
|
}
|
|
1443
1651
|
const name = PACKAGE;
|