dsh-thinking-levels 3.3.3 → 3.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/lib/client.js +508 -333
- package/lib/client.js.map +1 -1
- package/package.json +18 -3
package/lib/client.js
CHANGED
|
@@ -77,6 +77,11 @@ window.__ModuleLoader__.load({
|
|
|
77
77
|
"input.context.clear": "清除",
|
|
78
78
|
"input.context.integer": "上下文长度必须是整数(2000-1000000)",
|
|
79
79
|
"input.context.range": "上下文长度必须在 2000 到 1000000 之间",
|
|
80
|
+
"model.panel.choose": "选择模型",
|
|
81
|
+
"model.panel.loading": "模型目录加载中…",
|
|
82
|
+
"model.panel.empty": "没有可用模型",
|
|
83
|
+
"model.panel.window": "窗口",
|
|
84
|
+
"model.panel.noTarget": "该模型没有可写的配置项",
|
|
80
85
|
"card.capabilities.failed": "保存失败:配置被拒绝或冲突,请检查值。"
|
|
81
86
|
};
|
|
82
87
|
/** English dictionary (keys mirror zh). */
|
|
@@ -146,6 +151,11 @@ window.__ModuleLoader__.load({
|
|
|
146
151
|
"input.context.clear": "Clear",
|
|
147
152
|
"input.context.integer": "Context length must be an integer (2000-1000000)",
|
|
148
153
|
"input.context.range": "Context length must be between 2000 and 1000000",
|
|
154
|
+
"model.panel.choose": "Choose model",
|
|
155
|
+
"model.panel.loading": "Loading the model directory…",
|
|
156
|
+
"model.panel.empty": "No models available",
|
|
157
|
+
"model.panel.window": "Window",
|
|
158
|
+
"model.panel.noTarget": "No writable config entry for this model",
|
|
149
159
|
"card.capabilities.failed": "Save failed: the value was rejected or conflicted. Check it."
|
|
150
160
|
};
|
|
151
161
|
/** Japanese dictionary (keys mirror zh). */
|
|
@@ -215,6 +225,11 @@ window.__ModuleLoader__.load({
|
|
|
215
225
|
"input.context.clear": "クリア",
|
|
216
226
|
"input.context.integer": "コンテキスト長は整数で入力してください(2000-1000000)",
|
|
217
227
|
"input.context.range": "コンテキスト長は 2000 から 1000000 の範囲で指定してください",
|
|
228
|
+
"model.panel.choose": "モデルを選択",
|
|
229
|
+
"model.panel.loading": "モデルディレクトリを読み込み中…",
|
|
230
|
+
"model.panel.empty": "利用可能なモデルがありません",
|
|
231
|
+
"model.panel.window": "ウィンドウ",
|
|
232
|
+
"model.panel.noTarget": "このモデルには書き込み可能な設定項目がありません",
|
|
218
233
|
"card.capabilities.failed": "保存に失敗しました:値が拒否されたか競合しています。確認してください。"
|
|
219
234
|
};
|
|
220
235
|
/** Korean dictionary (keys mirror zh). */
|
|
@@ -284,6 +299,11 @@ window.__ModuleLoader__.load({
|
|
|
284
299
|
"input.context.clear": "지우기",
|
|
285
300
|
"input.context.integer": "컨텍스트 길이는 정수여야 합니다 (2000-1000000)",
|
|
286
301
|
"input.context.range": "컨텍스트 길이는 2000에서 1000000 사이여야 합니다",
|
|
302
|
+
"model.panel.choose": "모델 선택",
|
|
303
|
+
"model.panel.loading": "모델 디렉터리를 불러오는 중…",
|
|
304
|
+
"model.panel.empty": "사용 가능한 모델이 없습니다",
|
|
305
|
+
"model.panel.window": "창",
|
|
306
|
+
"model.panel.noTarget": "이 모델에는 쓰기 가능한 설정 항목이 없습니다",
|
|
287
307
|
"card.capabilities.failed": "저장 실패: 값이 거부되었거나 충돌합니다. 확인하세요."
|
|
288
308
|
};
|
|
289
309
|
/** The multi-level context-window presets, in ascending order. */
|
|
@@ -348,44 +368,36 @@ window.__ModuleLoader__.load({
|
|
|
348
368
|
};
|
|
349
369
|
}
|
|
350
370
|
//#endregion
|
|
351
|
-
//#region src/client/
|
|
371
|
+
//#region src/client/model-panel.tsx
|
|
352
372
|
/**
|
|
353
|
-
*
|
|
354
|
-
* (`conversation.input.right`, the seat just left of the model/effort select).
|
|
373
|
+
* Model-seat panel for the composer (`conversation.input.model`).
|
|
355
374
|
*
|
|
356
|
-
* Why this seat: the
|
|
357
|
-
*
|
|
358
|
-
*
|
|
359
|
-
*
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
375
|
+
* Why this seat: the shipped `ModelSelect` renders no slots inside its popup,
|
|
376
|
+
* so a plugin can never contribute *into* that panel — the working pattern
|
|
377
|
+
* (proven by dsh-reasoning-effort) is to occupy the model seat itself: one
|
|
378
|
+
* registered entry named after the seat with `priority: -1` replaces the
|
|
379
|
+
* shipped trigger and popup outright. This component then renders its own
|
|
380
|
+
* picker over the harness's shared model directory (`modelDirectories`
|
|
381
|
+
* service), so model switching keeps working, and adds what the official
|
|
382
|
+
* popup cannot offer: a context-window editor on every model line.
|
|
363
383
|
*
|
|
364
|
-
*
|
|
365
|
-
*
|
|
366
|
-
* `
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
* `
|
|
370
|
-
*
|
|
371
|
-
* here instead of a dead control.
|
|
372
|
-
*
|
|
373
|
-
* Two model families are served, each with its own writable config form
|
|
374
|
-
* (both consumed live by `resolveModelInfo(...).context.contextWindow`,
|
|
375
|
-
* so a write takes effect on the next request without a restart):
|
|
384
|
+
* Per-line context window (the "max context window" moved into each line):
|
|
385
|
+
* each model row carries a compact chip showing the model's effective
|
|
386
|
+
* `contextWindow`; clicking it opens an inline editor row (preset slider,
|
|
387
|
+
* custom-integer input, Clear). Writes follow the same two-family discipline
|
|
388
|
+
* the retired composer pill used (both consumed live by
|
|
389
|
+
* `resolveModelInfo(...).context.contextWindow`, effective on the next
|
|
390
|
+
* request without a restart):
|
|
376
391
|
* - Custom gateways (`llm-pi-ai` providers): writes the model entry's
|
|
377
|
-
* `contextWindow` under `providers[provider].models[i]
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* listed, otherwise caps via
|
|
381
|
-
*
|
|
382
|
-
* Write discipline: dragging the slider only moves a local draft; the config
|
|
383
|
-
* write happens once per gesture (pointer release, key release, blur), so a
|
|
384
|
-
* drag never floods the host with intermediate values.
|
|
392
|
+
* `contextWindow` under `providers[provider].models[i]`; a gateway model
|
|
393
|
+
* missing from the config has no write target and renders the chip disabled.
|
|
394
|
+
* - Official DeepSeek (`deepseek-official`, the `llm-deepseek` entry): writes
|
|
395
|
+
* the catalog model's `contextWindow` when listed, otherwise caps via
|
|
396
|
+
* `defaultContextWindow`.
|
|
385
397
|
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
398
|
+
* Graceful degradation: when the harness provides no `modelDirectories`
|
|
399
|
+
* service (older lines) the registration is skipped entirely and the shipped
|
|
400
|
+
* model selector stays untouched.
|
|
389
401
|
*/
|
|
390
402
|
/** The official DeepSeek provider route owned by the llm-deepseek adapter. */
|
|
391
403
|
const DEEPSEEK_PROVIDER = "deepseek-official";
|
|
@@ -393,29 +405,43 @@ window.__ModuleLoader__.load({
|
|
|
393
405
|
const DEEPSEEK_DEFAULT_WINDOW = 1e6;
|
|
394
406
|
/** Slider stop an unset window parks on: the thumb needs a position, the readout stays "unset". */
|
|
395
407
|
const UNSET_STOP_INDEX = CONTEXT_WINDOW_PRESETS.findIndex((preset) => preset.value === 256e3);
|
|
396
|
-
const
|
|
408
|
+
const rootStyle = {
|
|
409
|
+
position: "relative",
|
|
410
|
+
display: "inline-flex"
|
|
411
|
+
};
|
|
412
|
+
const triggerStyle = {
|
|
397
413
|
display: "inline-flex",
|
|
398
414
|
alignItems: "center",
|
|
399
|
-
gap: "
|
|
400
|
-
height: "
|
|
401
|
-
padding: "0
|
|
415
|
+
gap: "6px",
|
|
416
|
+
height: "26px",
|
|
417
|
+
padding: "0 10px",
|
|
402
418
|
background: "var(--dsw-alias-bg-surface, #fff)",
|
|
403
|
-
color: "var(--dsw-alias-label-
|
|
419
|
+
color: "var(--dsw-alias-label-primary)",
|
|
404
420
|
border: "1px solid var(--dsw-alias-border-l2)",
|
|
405
|
-
borderRadius: "
|
|
406
|
-
fontSize: "
|
|
407
|
-
lineHeight: "
|
|
408
|
-
fontFamily: "var(--ds-font-family-code, monospace)",
|
|
421
|
+
borderRadius: "8px",
|
|
422
|
+
fontSize: "12px",
|
|
423
|
+
lineHeight: "18px",
|
|
409
424
|
cursor: "pointer",
|
|
410
|
-
whiteSpace: "nowrap"
|
|
425
|
+
whiteSpace: "nowrap",
|
|
426
|
+
maxWidth: "220px"
|
|
427
|
+
};
|
|
428
|
+
const triggerNameStyle = {
|
|
429
|
+
minWidth: 0,
|
|
430
|
+
overflow: "hidden",
|
|
431
|
+
textOverflow: "ellipsis"
|
|
432
|
+
};
|
|
433
|
+
const chevronStyle = {
|
|
434
|
+
flex: "0 0 auto",
|
|
435
|
+
fontSize: "9px",
|
|
436
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
411
437
|
};
|
|
412
438
|
const popStyle = {
|
|
413
439
|
position: "absolute",
|
|
414
440
|
bottom: "calc(100% + 8px)",
|
|
415
|
-
|
|
441
|
+
left: "0",
|
|
416
442
|
zIndex: 1200,
|
|
417
|
-
|
|
418
|
-
padding: "
|
|
443
|
+
width: "320px",
|
|
444
|
+
padding: "8px",
|
|
419
445
|
background: "var(--dsw-alias-bg-layer-3, rgba(127,127,127,0.05))",
|
|
420
446
|
color: "var(--dsw-alias-label-primary)",
|
|
421
447
|
border: "1px solid var(--dsw-alias-border-l2)",
|
|
@@ -423,32 +449,125 @@ window.__ModuleLoader__.load({
|
|
|
423
449
|
boxShadow: "0 8px 28px rgba(0,0,0,0.18)",
|
|
424
450
|
display: "flex",
|
|
425
451
|
flexDirection: "column",
|
|
426
|
-
gap: "
|
|
452
|
+
gap: "4px"
|
|
427
453
|
};
|
|
428
454
|
const backdropStyle = {
|
|
429
455
|
position: "fixed",
|
|
430
456
|
inset: 0,
|
|
431
457
|
zIndex: 1199
|
|
432
458
|
};
|
|
433
|
-
const
|
|
459
|
+
const modelsStyle = {
|
|
460
|
+
maxHeight: "320px",
|
|
461
|
+
overflowY: "auto",
|
|
462
|
+
display: "flex",
|
|
463
|
+
flexDirection: "column",
|
|
464
|
+
gap: "2px"
|
|
465
|
+
};
|
|
466
|
+
const providerToggleStyle = {
|
|
434
467
|
display: "flex",
|
|
435
468
|
alignItems: "center",
|
|
436
|
-
gap: "
|
|
469
|
+
gap: "6px",
|
|
470
|
+
width: "100%",
|
|
471
|
+
padding: "6px 8px",
|
|
472
|
+
border: "none",
|
|
473
|
+
borderRadius: "6px",
|
|
474
|
+
background: "transparent",
|
|
475
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
476
|
+
font: "inherit",
|
|
437
477
|
fontSize: "12px",
|
|
438
|
-
|
|
439
|
-
|
|
478
|
+
cursor: "pointer",
|
|
479
|
+
textAlign: "left"
|
|
440
480
|
};
|
|
441
|
-
const
|
|
481
|
+
const providerNameStyle$1 = {
|
|
482
|
+
flex: "1 1 auto",
|
|
483
|
+
fontWeight: 600
|
|
484
|
+
};
|
|
485
|
+
const providerMetaStyle = {
|
|
442
486
|
flex: "0 0 auto",
|
|
443
|
-
|
|
487
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
488
|
+
fontSize: "11px"
|
|
489
|
+
};
|
|
490
|
+
const modelRowStyle$1 = {
|
|
491
|
+
display: "flex",
|
|
492
|
+
alignItems: "center",
|
|
493
|
+
gap: "6px",
|
|
494
|
+
width: "100%",
|
|
495
|
+
padding: "6px 8px 6px 18px",
|
|
496
|
+
border: "none",
|
|
497
|
+
borderRadius: "6px",
|
|
498
|
+
background: "transparent",
|
|
499
|
+
color: "var(--dsw-alias-label-primary)",
|
|
500
|
+
font: "inherit",
|
|
501
|
+
fontSize: "12px",
|
|
502
|
+
cursor: "pointer",
|
|
503
|
+
textAlign: "left"
|
|
504
|
+
};
|
|
505
|
+
const modelRowActiveStyle = {
|
|
506
|
+
...modelRowStyle$1,
|
|
507
|
+
background: "var(--dsw-alias-state-business-primary-weak, rgba(77,107,254,0.10))"
|
|
508
|
+
};
|
|
509
|
+
const modelCopyStyle = {
|
|
510
|
+
flex: "1 1 auto",
|
|
511
|
+
minWidth: 0,
|
|
512
|
+
display: "flex",
|
|
513
|
+
flexDirection: "column",
|
|
514
|
+
gap: "1px"
|
|
515
|
+
};
|
|
516
|
+
const modelNameStyle = {
|
|
517
|
+
overflow: "hidden",
|
|
518
|
+
textOverflow: "ellipsis",
|
|
519
|
+
whiteSpace: "nowrap"
|
|
520
|
+
};
|
|
521
|
+
const modelDescriptionStyle = {
|
|
444
522
|
overflow: "hidden",
|
|
445
523
|
textOverflow: "ellipsis",
|
|
446
524
|
whiteSpace: "nowrap",
|
|
525
|
+
fontSize: "11px",
|
|
447
526
|
color: "var(--dsw-alias-label-tertiary)"
|
|
448
527
|
};
|
|
528
|
+
const checkStyle = {
|
|
529
|
+
flex: "0 0 auto",
|
|
530
|
+
color: "var(--dsw-alias-state-business-primary)"
|
|
531
|
+
};
|
|
532
|
+
const chipStyle = {
|
|
533
|
+
flex: "0 0 auto",
|
|
534
|
+
height: "18px",
|
|
535
|
+
padding: "0 6px",
|
|
536
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
537
|
+
borderRadius: "5px",
|
|
538
|
+
background: "var(--dsw-alias-bg-surface, #fff)",
|
|
539
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
540
|
+
fontSize: "11px",
|
|
541
|
+
lineHeight: "16px",
|
|
542
|
+
fontFamily: "var(--ds-font-family-code, monospace)",
|
|
543
|
+
fontVariantNumeric: "tabular-nums",
|
|
544
|
+
cursor: "pointer",
|
|
545
|
+
whiteSpace: "nowrap"
|
|
546
|
+
};
|
|
547
|
+
const chipDisabledStyle = {
|
|
548
|
+
...chipStyle,
|
|
549
|
+
cursor: "default",
|
|
550
|
+
opacity: .55
|
|
551
|
+
};
|
|
552
|
+
const editorRowStyle = {
|
|
553
|
+
display: "flex",
|
|
554
|
+
alignItems: "center",
|
|
555
|
+
gap: "6px",
|
|
556
|
+
margin: "2px 8px 6px 18px",
|
|
557
|
+
padding: "6px",
|
|
558
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
559
|
+
borderRadius: "6px",
|
|
560
|
+
background: "var(--dsw-alias-bg-surface, #fff)",
|
|
561
|
+
fontSize: "12px"
|
|
562
|
+
};
|
|
563
|
+
const labelStyle$1 = {
|
|
564
|
+
flex: "0 0 auto",
|
|
565
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
566
|
+
whiteSpace: "nowrap"
|
|
567
|
+
};
|
|
449
568
|
const sliderStyle = {
|
|
450
569
|
flex: "1 1 auto",
|
|
451
|
-
minWidth: "
|
|
570
|
+
minWidth: "48px",
|
|
452
571
|
height: "14px",
|
|
453
572
|
margin: "0",
|
|
454
573
|
accentColor: "var(--dsw-alias-state-business-primary)",
|
|
@@ -456,23 +575,12 @@ window.__ModuleLoader__.load({
|
|
|
456
575
|
};
|
|
457
576
|
const valueStyle = {
|
|
458
577
|
flex: "0 0 auto",
|
|
459
|
-
minWidth: "
|
|
578
|
+
minWidth: "36px",
|
|
460
579
|
textAlign: "right",
|
|
461
580
|
color: "var(--dsw-alias-label-primary)",
|
|
462
581
|
fontFamily: "var(--ds-font-family-code, monospace)",
|
|
463
582
|
fontVariantNumeric: "tabular-nums"
|
|
464
583
|
};
|
|
465
|
-
const glyphButtonStyle = {
|
|
466
|
-
flex: "0 0 auto",
|
|
467
|
-
height: "18px",
|
|
468
|
-
padding: "0 5px",
|
|
469
|
-
border: "1px solid transparent",
|
|
470
|
-
borderRadius: "4px",
|
|
471
|
-
background: "transparent",
|
|
472
|
-
color: "var(--dsw-alias-label-tertiary)",
|
|
473
|
-
font: "inherit",
|
|
474
|
-
cursor: "pointer"
|
|
475
|
-
};
|
|
476
584
|
const actionButtonStyle = {
|
|
477
585
|
flex: "0 0 auto",
|
|
478
586
|
height: "18px",
|
|
@@ -484,11 +592,6 @@ window.__ModuleLoader__.load({
|
|
|
484
592
|
font: "inherit",
|
|
485
593
|
cursor: "pointer"
|
|
486
594
|
};
|
|
487
|
-
const customRowStyle = {
|
|
488
|
-
display: "flex",
|
|
489
|
-
alignItems: "center",
|
|
490
|
-
gap: "6px"
|
|
491
|
-
};
|
|
492
595
|
const inputStyle = {
|
|
493
596
|
flex: "1 1 auto",
|
|
494
597
|
minWidth: "0",
|
|
@@ -502,7 +605,20 @@ window.__ModuleLoader__.load({
|
|
|
502
605
|
};
|
|
503
606
|
const errorStyle = {
|
|
504
607
|
flex: "0 0 auto",
|
|
505
|
-
color: "var(--dsw-alias-danger, #e5484d)"
|
|
608
|
+
color: "var(--dsw-alias-danger, #e5484d)",
|
|
609
|
+
fontSize: "11px"
|
|
610
|
+
};
|
|
611
|
+
const statusStyle = {
|
|
612
|
+
padding: "10px 8px",
|
|
613
|
+
fontSize: "12px",
|
|
614
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
615
|
+
};
|
|
616
|
+
const errorBannerStyle = {
|
|
617
|
+
padding: "6px 8px",
|
|
618
|
+
borderRadius: "6px",
|
|
619
|
+
background: "var(--dsw-alias-danger-weak, rgba(229,72,77,0.10))",
|
|
620
|
+
color: "var(--dsw-alias-danger, #e5484d)",
|
|
621
|
+
fontSize: "11px"
|
|
506
622
|
};
|
|
507
623
|
/** The user-layer `providers` value of the llm-pi-ai namespace, when present. */
|
|
508
624
|
function providersOf$1(snapshot) {
|
|
@@ -525,54 +641,19 @@ window.__ModuleLoader__.load({
|
|
|
525
641
|
...defaultContextWindow === void 0 ? {} : { defaultContextWindow }
|
|
526
642
|
};
|
|
527
643
|
}
|
|
528
|
-
/**
|
|
529
|
-
* The stable trajectory-ledger selector (the `useTrajectory` seat): the seat
|
|
530
|
-
* memoizes its selection on the selector reference, so it must not be a fresh
|
|
531
|
-
* closure per render. The ledger is a store-owned array whose reference only
|
|
532
|
-
* moves when the trajectory changes.
|
|
533
|
-
* @param snapshot - the current trajectory snapshot.
|
|
534
|
-
* @returns the request ledger.
|
|
535
|
-
*/
|
|
536
|
-
const selectRequests = (snapshot) => snapshot.requests;
|
|
537
|
-
/**
|
|
538
|
-
* The stable trajectory-view selector (the `useConversation` seat): selecting
|
|
539
|
-
* the view snapshot (a store-owned reference, not a derived object) keeps the
|
|
540
|
-
* selected value stable between snapshots — a selector that built a new object
|
|
541
|
-
* would re-render forever.
|
|
542
|
-
* @param snapshot - the current conversation snapshot.
|
|
543
|
-
* @returns the trajectory view snapshot, absent while the view is unregistered.
|
|
544
|
-
*/
|
|
545
|
-
const selectTrajectory = (snapshot) => snapshot.views?.get?.("trajectory");
|
|
546
|
-
/**
|
|
547
|
-
* The current session's active model, taken from the trajectory ledger's
|
|
548
|
-
* latest assistant request prompt config. Absent for a blank session (no
|
|
549
|
-
* request yet) — the control then renders disabled.
|
|
550
|
-
* @param source - the request ledger, or a trajectory snapshot carrying it.
|
|
551
|
-
* @returns the provider/model pair, or undefined when the ledger has none.
|
|
552
|
-
*/
|
|
553
|
-
function activeModelOf(source) {
|
|
554
|
-
const requests = Array.isArray(source) ? source ?? [] : typeof source === "object" && source !== null ? source.requests ?? [] : [];
|
|
555
|
-
for (let index = requests.length - 1; index >= 0; index -= 1) {
|
|
556
|
-
const config = requests[index]?.prompt?.config;
|
|
557
|
-
if (requests[index]?.purpose === "assistant" && typeof config?.provider === "string" && typeof config?.model === "string") return {
|
|
558
|
-
provider: config.provider,
|
|
559
|
-
model: config.model
|
|
560
|
-
};
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
644
|
/** One model entry's declared contextWindow, when present. */
|
|
564
645
|
function contextWindowOf(model) {
|
|
565
646
|
const value = model["contextWindow"];
|
|
566
647
|
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
567
648
|
}
|
|
568
|
-
/**
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
*/
|
|
649
|
+
/** A provider's model entry in the llm-pi-ai user layer, when present. */
|
|
650
|
+
function piModelEntry(providers, provider, model) {
|
|
651
|
+
const profile = providers[provider];
|
|
652
|
+
return profile !== void 0 && Array.isArray(profile.models) ? profile.models.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === model) : void 0;
|
|
653
|
+
}
|
|
654
|
+
/** The slider stop nearest to a committed token count. */
|
|
574
655
|
function stopIndexOf(value) {
|
|
575
|
-
if (value === void 0) return UNSET_STOP_INDEX;
|
|
656
|
+
if (value === void 0) return Math.max(0, UNSET_STOP_INDEX);
|
|
576
657
|
let best = 0;
|
|
577
658
|
let bestDistance = Number.POSITIVE_INFINITY;
|
|
578
659
|
CONTEXT_WINDOW_PRESETS.forEach((preset, index) => {
|
|
@@ -585,111 +666,99 @@ window.__ModuleLoader__.load({
|
|
|
585
666
|
return best;
|
|
586
667
|
}
|
|
587
668
|
/**
|
|
588
|
-
* The
|
|
589
|
-
*
|
|
590
|
-
* (
|
|
591
|
-
* @param props - injected
|
|
592
|
-
*/
|
|
593
|
-
function ContextQuick(props) {
|
|
594
|
-
if (typeof props.useTrajectory === "function") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TrajectoryBound, {
|
|
595
|
-
...props,
|
|
596
|
-
useTrajectory: props.useTrajectory
|
|
597
|
-
});
|
|
598
|
-
if (typeof props.useConversation === "function") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConversationBound, {
|
|
599
|
-
...props,
|
|
600
|
-
useConversation: props.useConversation
|
|
601
|
-
});
|
|
602
|
-
return null;
|
|
603
|
-
}
|
|
604
|
-
/**
|
|
605
|
-
* The trajectory-seat binding (DSH 0.1.2+).
|
|
606
|
-
* @param props - the control props plus the present trajectory seat.
|
|
669
|
+
* The model-seat panel: replaces the shipped model selector on this seat and
|
|
670
|
+
* renders one picker whose every model line carries a context-window chip
|
|
671
|
+
* (the "max context window" editor moved into each line).
|
|
672
|
+
* @param props - injected directory + config forms, session seat, copy.
|
|
607
673
|
*/
|
|
608
|
-
function
|
|
609
|
-
|
|
610
|
-
...rest,
|
|
611
|
-
active: activeModelOf(useTrajectory(selectRequests))
|
|
612
|
-
});
|
|
613
|
-
}
|
|
614
|
-
/**
|
|
615
|
-
* The conversation-seat binding (harness lines without the trajectory seat).
|
|
616
|
-
* @param props - the control props plus the present conversation seat.
|
|
617
|
-
*/
|
|
618
|
-
function ConversationBound({ useConversation, ...rest }) {
|
|
619
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextQuickView, {
|
|
620
|
-
...rest,
|
|
621
|
-
active: activeModelOf(useConversation(selectTrajectory))
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* The bound control: a value pill that opens a one-row slider popover
|
|
626
|
-
* (preset slider, committed value, collapsed custom-integer editor, Clear).
|
|
627
|
-
* Custom gateways and official DeepSeek models are both supported (see module
|
|
628
|
-
* doc for the namespace each writes).
|
|
629
|
-
* @param props - injected scopes, the resolved active model, copy.
|
|
630
|
-
*/
|
|
631
|
-
function ContextQuickView({ active, piAiScope, deepseekScope, t }) {
|
|
632
|
-
const official = active !== void 0 && active.provider === DEEPSEEK_PROVIDER;
|
|
674
|
+
function ModelPanel({ directory, piAiScope, deepseekScope, t }) {
|
|
675
|
+
const state = (0, react.useSyncExternalStore)((listener) => directory.store.subscribe(listener), () => directory.store.getSnapshot());
|
|
633
676
|
const piSnapshot = (0, react.useSyncExternalStore)((listener) => piAiScope.subscribe(listener), () => piAiScope.getSnapshot());
|
|
634
677
|
const dsSnapshot = (0, react.useSyncExternalStore)((listener) => deepseekScope.subscribe(listener), () => deepseekScope.getSnapshot());
|
|
635
|
-
const snapshot = official ? dsSnapshot : piSnapshot;
|
|
636
|
-
const readonly = snapshot.status === "unavailable" || !snapshot.writable;
|
|
637
|
-
const providers = official ? {} : providersOf$1(piSnapshot);
|
|
638
|
-
const dsSection = official ? deepseekSectionOf(dsSnapshot) : void 0;
|
|
639
|
-
let currentWindow;
|
|
640
|
-
let writableTarget = false;
|
|
641
|
-
if (official && active !== void 0) {
|
|
642
|
-
const models = dsSection?.models ?? [];
|
|
643
|
-
const index = models.findIndex((model) => model["id"] === active.model);
|
|
644
|
-
currentWindow = index >= 0 ? contextWindowOf(models[index]) : void 0;
|
|
645
|
-
if (currentWindow === void 0) currentWindow = dsSection?.defaultContextWindow;
|
|
646
|
-
writableTarget = true;
|
|
647
|
-
} else if (active !== void 0) {
|
|
648
|
-
const profile = providers[active.provider];
|
|
649
|
-
const model = profile !== void 0 && Array.isArray(profile.models) ? profile.models.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === active.model) : void 0;
|
|
650
|
-
currentWindow = model === void 0 ? void 0 : contextWindowOf(model);
|
|
651
|
-
writableTarget = model !== void 0;
|
|
652
|
-
}
|
|
653
678
|
const [open, setOpen] = (0, react.useState)(false);
|
|
679
|
+
const [expanded, setExpanded] = (0, react.useState)(() => /* @__PURE__ */ new Set());
|
|
680
|
+
const [editing, setEditing] = (0, react.useState)(null);
|
|
654
681
|
const [draft, setDraft] = (0, react.useState)(null);
|
|
655
682
|
const [custom, setCustom] = (0, react.useState)(false);
|
|
656
683
|
const [raw, setRaw] = (0, react.useState)("");
|
|
657
684
|
const [error, setError] = (0, react.useState)(null);
|
|
658
685
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
659
|
-
const
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
686
|
+
const rootRef = (0, react.useRef)(null);
|
|
687
|
+
(0, react.useEffect)(() => {
|
|
688
|
+
if (!open) return;
|
|
689
|
+
directory.load().catch(() => {});
|
|
690
|
+
}, [directory, open]);
|
|
691
|
+
const close = (0, react.useCallback)(() => {
|
|
692
|
+
setOpen(false);
|
|
693
|
+
setEditing(null);
|
|
694
|
+
setError(null);
|
|
695
|
+
}, []);
|
|
696
|
+
(0, react.useEffect)(() => {
|
|
697
|
+
if (!open) return;
|
|
698
|
+
const onOutside = (event) => {
|
|
699
|
+
const target = event.target;
|
|
700
|
+
if (target instanceof Node && rootRef.current?.contains(target)) return;
|
|
701
|
+
close();
|
|
702
|
+
};
|
|
703
|
+
document.addEventListener("mousedown", onOutside);
|
|
704
|
+
return () => document.removeEventListener("mousedown", onOutside);
|
|
705
|
+
}, [close, open]);
|
|
706
|
+
const writable = piSnapshot.status === "ready" && piSnapshot.writable && dsSnapshot.status === "ready" && dsSnapshot.writable;
|
|
707
|
+
const current = (0, react.useMemo)(() => {
|
|
708
|
+
if (state.current === null) return void 0;
|
|
709
|
+
for (const group of state.groups) {
|
|
710
|
+
if (group.id !== state.current.provider) continue;
|
|
711
|
+
const model = group.models.find((candidate) => candidate.id === state.current?.model);
|
|
712
|
+
if (model !== void 0) return {
|
|
713
|
+
model,
|
|
714
|
+
name: model.name
|
|
715
|
+
};
|
|
666
716
|
}
|
|
717
|
+
}, [state]);
|
|
718
|
+
const providers = (0, react.useMemo)(() => providersOf$1(piSnapshot), [piSnapshot]);
|
|
719
|
+
const dsSection = (0, react.useMemo)(() => deepseekSectionOf(dsSnapshot), [dsSnapshot]);
|
|
720
|
+
/** The effective window of one model line, resolved against its family. */
|
|
721
|
+
const windowOf = (provider, model) => {
|
|
722
|
+
if (provider === DEEPSEEK_PROVIDER) {
|
|
723
|
+
const models = dsSection.models ?? [];
|
|
724
|
+
const index = models.findIndex((entry) => entry["id"] === model);
|
|
725
|
+
return index >= 0 ? contextWindowOf(models[index]) : dsSection.defaultContextWindow;
|
|
726
|
+
}
|
|
727
|
+
const entry = piModelEntry(providers, provider, model);
|
|
728
|
+
return entry === void 0 ? void 0 : contextWindowOf(entry);
|
|
729
|
+
};
|
|
730
|
+
/** Whether one model line has a config write target. */
|
|
731
|
+
const writableLine = (provider, model) => {
|
|
732
|
+
if (!writable) return false;
|
|
733
|
+
if (provider === DEEPSEEK_PROVIDER) return true;
|
|
734
|
+
return piModelEntry(providers, provider, model) !== void 0;
|
|
735
|
+
};
|
|
736
|
+
/** Commit (or delete) one model line's context window. */
|
|
737
|
+
const commitWindow = (provider, model, value) => {
|
|
667
738
|
setBusy(true);
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
739
|
+
const done = () => {
|
|
740
|
+
setBusy(false);
|
|
741
|
+
setDraft(null);
|
|
742
|
+
};
|
|
743
|
+
if (provider === DEEPSEEK_PROVIDER) {
|
|
744
|
+
const models = (deepseekSectionOf(dsSnapshot).models ?? []).map((entry) => ({ ...entry }));
|
|
745
|
+
const index = models.findIndex((entry) => entry["id"] === model);
|
|
746
|
+
(index >= 0 ? deepseekScope.set("models", models.map((entry, at) => {
|
|
747
|
+
if (at !== index) return entry;
|
|
673
748
|
if (value === void 0) {
|
|
674
|
-
const rest = { ...
|
|
749
|
+
const rest = { ...entry };
|
|
675
750
|
delete rest["contextWindow"];
|
|
676
751
|
return rest;
|
|
677
752
|
}
|
|
678
753
|
return {
|
|
679
|
-
...
|
|
754
|
+
...entry,
|
|
680
755
|
contextWindow: value
|
|
681
756
|
};
|
|
682
|
-
})) : deepseekScope.set("defaultContextWindow", value === void 0 ? DEEPSEEK_DEFAULT_WINDOW : value)).then(
|
|
683
|
-
setBusy(false);
|
|
684
|
-
setDraft(null);
|
|
685
|
-
}).catch(() => {
|
|
686
|
-
setBusy(false);
|
|
687
|
-
setDraft(null);
|
|
688
|
-
});
|
|
757
|
+
})) : deepseekScope.set("defaultContextWindow", value === void 0 ? DEEPSEEK_DEFAULT_WINDOW : value)).then(done, done);
|
|
689
758
|
return;
|
|
690
759
|
}
|
|
691
760
|
const next = structuredClone(providers);
|
|
692
|
-
const entry = next
|
|
761
|
+
const entry = piModelEntry(next, provider, model);
|
|
693
762
|
if (entry === void 0) {
|
|
694
763
|
setBusy(false);
|
|
695
764
|
setDraft(null);
|
|
@@ -697,25 +766,15 @@ window.__ModuleLoader__.load({
|
|
|
697
766
|
}
|
|
698
767
|
if (value === void 0) delete entry["contextWindow"];
|
|
699
768
|
else entry["contextWindow"] = value;
|
|
700
|
-
piAiScope.set("providers", next).then(
|
|
701
|
-
setBusy(false);
|
|
702
|
-
setDraft(null);
|
|
703
|
-
}).catch(() => {
|
|
704
|
-
setBusy(false);
|
|
705
|
-
setDraft(null);
|
|
706
|
-
});
|
|
707
|
-
};
|
|
708
|
-
/** Write the stop the gesture landed on; a drag only moves the draft. */
|
|
709
|
-
const commitStop = () => {
|
|
710
|
-
if (disabled || draft === null) return;
|
|
711
|
-
commitWindow(CONTEXT_WINDOW_PRESETS[draft]?.value);
|
|
769
|
+
piAiScope.set("providers", next).then(done, done);
|
|
712
770
|
};
|
|
713
771
|
/** Validate and commit the custom input; empty clears. */
|
|
714
772
|
const applyCustom = () => {
|
|
773
|
+
if (editing === null) return;
|
|
715
774
|
const trimmed = raw.trim();
|
|
716
775
|
if (trimmed === "") {
|
|
717
776
|
setError(null);
|
|
718
|
-
commitWindow(void 0);
|
|
777
|
+
commitWindow(editing.provider, editing.model, void 0);
|
|
719
778
|
return;
|
|
720
779
|
}
|
|
721
780
|
const validation = validateContextWindow(trimmed);
|
|
@@ -724,138 +783,250 @@ window.__ModuleLoader__.load({
|
|
|
724
783
|
return;
|
|
725
784
|
}
|
|
726
785
|
setError(null);
|
|
727
|
-
commitWindow(validation.value);
|
|
786
|
+
commitWindow(editing.provider, editing.model, validation.value);
|
|
728
787
|
};
|
|
729
|
-
const
|
|
788
|
+
const openEditor = (provider, model) => {
|
|
789
|
+
setEditing({
|
|
790
|
+
provider,
|
|
791
|
+
model
|
|
792
|
+
});
|
|
793
|
+
setDraft(null);
|
|
794
|
+
setCustom(false);
|
|
795
|
+
setRaw("");
|
|
796
|
+
setError(null);
|
|
797
|
+
};
|
|
798
|
+
const toggleProvider = (provider) => {
|
|
799
|
+
setExpanded((previous) => {
|
|
800
|
+
const next = new Set(previous);
|
|
801
|
+
if (next.has(provider)) next.delete(provider);
|
|
802
|
+
else next.add(provider);
|
|
803
|
+
return next;
|
|
804
|
+
});
|
|
805
|
+
};
|
|
806
|
+
const chooseModel = (provider, model) => {
|
|
807
|
+
if (busy) return;
|
|
808
|
+
setBusy(true);
|
|
809
|
+
directory.select({
|
|
810
|
+
provider,
|
|
811
|
+
model
|
|
812
|
+
}).then(() => {
|
|
813
|
+
setBusy(false);
|
|
814
|
+
close();
|
|
815
|
+
}).catch(() => {
|
|
816
|
+
setBusy(false);
|
|
817
|
+
});
|
|
818
|
+
};
|
|
819
|
+
const triggerLabel = current?.name ?? state.current?.model ?? t("model.panel.choose");
|
|
730
820
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
731
|
-
|
|
732
|
-
|
|
821
|
+
ref: rootRef,
|
|
822
|
+
style: rootStyle,
|
|
823
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
733
824
|
type: "button",
|
|
734
|
-
|
|
825
|
+
style: triggerStyle,
|
|
735
826
|
"aria-expanded": open,
|
|
736
|
-
"aria-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
...pillStyle,
|
|
740
|
-
cursor: disabled ? "default" : "pointer",
|
|
741
|
-
opacity: disabled ? .55 : 1
|
|
742
|
-
},
|
|
827
|
+
"aria-haspopup": "dialog",
|
|
828
|
+
"aria-label": t("model.panel.choose"),
|
|
829
|
+
title: state.current === null ? triggerLabel : `${state.current.provider}/${triggerLabel}`,
|
|
743
830
|
onClick: () => {
|
|
744
|
-
|
|
745
|
-
|
|
831
|
+
if (open) close();
|
|
832
|
+
else {
|
|
833
|
+
setOpen(true);
|
|
834
|
+
setError(null);
|
|
835
|
+
}
|
|
746
836
|
},
|
|
747
|
-
children:
|
|
837
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
838
|
+
style: triggerNameStyle,
|
|
839
|
+
children: triggerLabel
|
|
840
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
841
|
+
style: chevronStyle,
|
|
842
|
+
children: open ? "▲" : "▼"
|
|
843
|
+
})]
|
|
748
844
|
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
749
845
|
style: backdropStyle,
|
|
750
|
-
onClick:
|
|
751
|
-
setOpen(false);
|
|
752
|
-
setError(null);
|
|
753
|
-
}
|
|
846
|
+
onClick: close
|
|
754
847
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
755
848
|
style: popStyle,
|
|
756
|
-
role: "
|
|
757
|
-
"aria-label": t("
|
|
849
|
+
role: "dialog",
|
|
850
|
+
"aria-label": t("model.panel.choose"),
|
|
758
851
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
759
|
-
style:
|
|
760
|
-
children: [
|
|
761
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
762
|
-
style: labelStyle$1,
|
|
763
|
-
title: t("input.context.globalHint"),
|
|
764
|
-
children: t("input.context.title")
|
|
765
|
-
}),
|
|
766
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
767
|
-
type: "range",
|
|
768
|
-
min: 0,
|
|
769
|
-
max: CONTEXT_WINDOW_PRESETS.length - 1,
|
|
770
|
-
step: 1,
|
|
771
|
-
value: stop,
|
|
772
|
-
disabled,
|
|
773
|
-
"aria-label": t("input.context.title"),
|
|
774
|
-
style: {
|
|
775
|
-
...sliderStyle,
|
|
776
|
-
cursor: disabled ? "default" : "pointer",
|
|
777
|
-
opacity: disabled ? .55 : 1
|
|
778
|
-
},
|
|
779
|
-
onChange: (event) => {
|
|
780
|
-
setDraft(Number(event.currentTarget.value));
|
|
781
|
-
},
|
|
782
|
-
onPointerUp: commitStop,
|
|
783
|
-
onKeyUp: commitStop,
|
|
784
|
-
onBlur: commitStop
|
|
785
|
-
}),
|
|
786
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
787
|
-
style: valueStyle,
|
|
788
|
-
children: value
|
|
789
|
-
}),
|
|
790
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
791
|
-
type: "button",
|
|
792
|
-
disabled,
|
|
793
|
-
"aria-label": t("input.context.custom"),
|
|
794
|
-
"aria-expanded": custom,
|
|
795
|
-
title: t("input.context.custom"),
|
|
796
|
-
style: {
|
|
797
|
-
...glyphButtonStyle,
|
|
798
|
-
cursor: disabled ? "default" : "pointer",
|
|
799
|
-
opacity: disabled ? .55 : 1
|
|
800
|
-
},
|
|
801
|
-
onClick: () => {
|
|
802
|
-
setCustom((open) => !open);
|
|
803
|
-
setError(null);
|
|
804
|
-
},
|
|
805
|
-
children: "⋯"
|
|
806
|
-
}),
|
|
807
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
808
|
-
type: "button",
|
|
809
|
-
disabled: disabled || currentWindow === void 0,
|
|
810
|
-
style: {
|
|
811
|
-
...actionButtonStyle,
|
|
812
|
-
cursor: disabled || currentWindow === void 0 ? "default" : "pointer",
|
|
813
|
-
opacity: disabled || currentWindow === void 0 ? .55 : 1
|
|
814
|
-
},
|
|
815
|
-
onClick: () => {
|
|
816
|
-
setDraft(null);
|
|
817
|
-
setError(null);
|
|
818
|
-
setRaw("");
|
|
819
|
-
commitWindow(void 0);
|
|
820
|
-
},
|
|
821
|
-
children: t("input.context.clear")
|
|
822
|
-
})
|
|
823
|
-
]
|
|
824
|
-
}), custom ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
825
|
-
style: customRowStyle,
|
|
852
|
+
style: modelsStyle,
|
|
826
853
|
children: [
|
|
827
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
value: raw,
|
|
831
|
-
disabled,
|
|
832
|
-
placeholder: t("input.context.customPlaceholder"),
|
|
833
|
-
"aria-label": t("input.context.customPlaceholder"),
|
|
834
|
-
style: inputStyle,
|
|
835
|
-
onChange: (event) => {
|
|
836
|
-
setRaw(event.currentTarget.value);
|
|
837
|
-
},
|
|
838
|
-
onKeyDown: (event) => {
|
|
839
|
-
if (event.key === "Enter") applyCustom();
|
|
840
|
-
}
|
|
854
|
+
state.status === "loading" && state.groups.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
855
|
+
style: statusStyle,
|
|
856
|
+
children: t("model.panel.loading")
|
|
841
857
|
}),
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
858
|
+
state.groups.map((group) => {
|
|
859
|
+
const isExpanded = expanded.has(group.id);
|
|
860
|
+
const name = group.name ?? group.label ?? group.id;
|
|
861
|
+
const activeModel = state.current?.provider === group.id ? state.current.model : void 0;
|
|
862
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
863
|
+
type: "button",
|
|
864
|
+
style: providerToggleStyle,
|
|
865
|
+
"aria-expanded": isExpanded,
|
|
866
|
+
onClick: () => toggleProvider(group.id),
|
|
867
|
+
children: [
|
|
868
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
869
|
+
style: providerNameStyle$1,
|
|
870
|
+
children: name
|
|
871
|
+
}),
|
|
872
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
873
|
+
style: providerMetaStyle,
|
|
874
|
+
children: group.models.length
|
|
875
|
+
}),
|
|
876
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
877
|
+
style: chevronStyle,
|
|
878
|
+
children: isExpanded ? "▼" : "▶"
|
|
879
|
+
})
|
|
880
|
+
]
|
|
881
|
+
}), isExpanded && group.models.map((model) => {
|
|
882
|
+
const active = activeModel === model.id;
|
|
883
|
+
const lineWritable = writableLine(group.id, model.id);
|
|
884
|
+
const lineWindow = windowOf(group.id, model.id);
|
|
885
|
+
const isEditing = editing !== null && editing.provider === group.id && editing.model === model.id;
|
|
886
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
887
|
+
type: "button",
|
|
888
|
+
role: "option",
|
|
889
|
+
"aria-selected": active,
|
|
890
|
+
style: active ? modelRowActiveStyle : modelRowStyle$1,
|
|
891
|
+
disabled: busy,
|
|
892
|
+
onClick: () => chooseModel(group.id, model.id),
|
|
893
|
+
children: [
|
|
894
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
895
|
+
style: modelCopyStyle,
|
|
896
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
897
|
+
style: modelNameStyle,
|
|
898
|
+
children: model.name
|
|
899
|
+
}), model.description !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
900
|
+
style: modelDescriptionStyle,
|
|
901
|
+
children: model.description
|
|
902
|
+
})]
|
|
903
|
+
}),
|
|
904
|
+
active && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
905
|
+
style: checkStyle,
|
|
906
|
+
"aria-hidden": "true",
|
|
907
|
+
children: "✓"
|
|
908
|
+
}),
|
|
909
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
910
|
+
role: "button",
|
|
911
|
+
tabIndex: 0,
|
|
912
|
+
"aria-label": t("input.context.title"),
|
|
913
|
+
title: lineWritable ? t("input.context.globalHint") : t("model.panel.noTarget"),
|
|
914
|
+
style: lineWritable && !busy ? chipStyle : chipDisabledStyle,
|
|
915
|
+
onClick: (event) => {
|
|
916
|
+
event.stopPropagation();
|
|
917
|
+
if (!lineWritable || busy) return;
|
|
918
|
+
if (isEditing) {
|
|
919
|
+
setEditing(null);
|
|
920
|
+
return;
|
|
921
|
+
}
|
|
922
|
+
openEditor(group.id, model.id);
|
|
923
|
+
},
|
|
924
|
+
onKeyDown: (event) => {
|
|
925
|
+
if (event.key !== "Enter" && event.key !== " ") return;
|
|
926
|
+
event.preventDefault();
|
|
927
|
+
event.stopPropagation();
|
|
928
|
+
if (!lineWritable || busy) return;
|
|
929
|
+
openEditor(group.id, model.id);
|
|
930
|
+
},
|
|
931
|
+
children: lineWindow === void 0 ? t("input.context.unset") : formatContextWindow(lineWindow)
|
|
932
|
+
})
|
|
933
|
+
]
|
|
934
|
+
}), isEditing && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
935
|
+
style: editorRowStyle,
|
|
936
|
+
children: [
|
|
937
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
938
|
+
style: labelStyle$1,
|
|
939
|
+
title: t("input.context.globalHint"),
|
|
940
|
+
children: t("model.panel.window")
|
|
941
|
+
}),
|
|
942
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
943
|
+
type: "range",
|
|
944
|
+
min: 0,
|
|
945
|
+
max: CONTEXT_WINDOW_PRESETS.length - 1,
|
|
946
|
+
step: 1,
|
|
947
|
+
value: draft ?? stopIndexOf(lineWindow),
|
|
948
|
+
disabled: busy,
|
|
949
|
+
"aria-label": t("input.context.title"),
|
|
950
|
+
style: sliderStyle,
|
|
951
|
+
onChange: (event) => {
|
|
952
|
+
setDraft(Number(event.currentTarget.value));
|
|
953
|
+
},
|
|
954
|
+
onPointerUp: () => {
|
|
955
|
+
if (draft === null) return;
|
|
956
|
+
commitWindow(group.id, model.id, CONTEXT_WINDOW_PRESETS[draft]?.value);
|
|
957
|
+
},
|
|
958
|
+
onKeyUp: () => {
|
|
959
|
+
if (draft === null) return;
|
|
960
|
+
commitWindow(group.id, model.id, CONTEXT_WINDOW_PRESETS[draft]?.value);
|
|
961
|
+
}
|
|
962
|
+
}),
|
|
963
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
964
|
+
style: valueStyle,
|
|
965
|
+
children: draft === null ? lineWindow === void 0 ? t("input.context.unset") : formatContextWindow(lineWindow) : formatContextWindow(CONTEXT_WINDOW_PRESETS[draft]?.value ?? 0)
|
|
966
|
+
}),
|
|
967
|
+
custom ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
968
|
+
type: "text",
|
|
969
|
+
inputMode: "numeric",
|
|
970
|
+
value: raw,
|
|
971
|
+
disabled: busy,
|
|
972
|
+
placeholder: t("input.context.customPlaceholder"),
|
|
973
|
+
"aria-label": t("input.context.customPlaceholder"),
|
|
974
|
+
style: inputStyle,
|
|
975
|
+
onChange: (event) => {
|
|
976
|
+
setRaw(event.currentTarget.value);
|
|
977
|
+
},
|
|
978
|
+
onKeyDown: (event) => {
|
|
979
|
+
if (event.key === "Enter") applyCustom();
|
|
980
|
+
}
|
|
981
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
982
|
+
type: "button",
|
|
983
|
+
disabled: busy,
|
|
984
|
+
style: actionButtonStyle,
|
|
985
|
+
onClick: applyCustom,
|
|
986
|
+
children: t("input.context.apply")
|
|
987
|
+
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
988
|
+
type: "button",
|
|
989
|
+
disabled: busy,
|
|
990
|
+
"aria-label": t("input.context.custom"),
|
|
991
|
+
title: t("input.context.custom"),
|
|
992
|
+
style: actionButtonStyle,
|
|
993
|
+
onClick: () => {
|
|
994
|
+
setCustom(true);
|
|
995
|
+
setError(null);
|
|
996
|
+
},
|
|
997
|
+
children: "⋯"
|
|
998
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
999
|
+
type: "button",
|
|
1000
|
+
disabled: busy || lineWindow === void 0,
|
|
1001
|
+
style: {
|
|
1002
|
+
...actionButtonStyle,
|
|
1003
|
+
opacity: lineWindow === void 0 ? .55 : 1
|
|
1004
|
+
},
|
|
1005
|
+
onClick: () => {
|
|
1006
|
+
setDraft(null);
|
|
1007
|
+
setError(null);
|
|
1008
|
+
commitWindow(group.id, model.id, void 0);
|
|
1009
|
+
},
|
|
1010
|
+
children: t("input.context.clear")
|
|
1011
|
+
})] }),
|
|
1012
|
+
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1013
|
+
style: errorStyle,
|
|
1014
|
+
children: error
|
|
1015
|
+
})
|
|
1016
|
+
]
|
|
1017
|
+
})] }, group.id + ":" + model.id);
|
|
1018
|
+
})] }, group.id);
|
|
852
1019
|
}),
|
|
853
|
-
|
|
854
|
-
style:
|
|
855
|
-
children:
|
|
1020
|
+
state.status !== "loading" && state.groups.length === 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1021
|
+
style: statusStyle,
|
|
1022
|
+
children: t("model.panel.empty")
|
|
856
1023
|
})
|
|
857
1024
|
]
|
|
858
|
-
})
|
|
1025
|
+
}), state.error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1026
|
+
style: errorBannerStyle,
|
|
1027
|
+
role: "status",
|
|
1028
|
+
children: state.error
|
|
1029
|
+
})]
|
|
859
1030
|
})] }) : null]
|
|
860
1031
|
});
|
|
861
1032
|
}
|
|
@@ -2106,7 +2277,8 @@ window.__ModuleLoader__.load({
|
|
|
2106
2277
|
const inject = [
|
|
2107
2278
|
"slots",
|
|
2108
2279
|
"locale",
|
|
2109
|
-
"configForms"
|
|
2280
|
+
"configForms",
|
|
2281
|
+
"modelDirectories"
|
|
2110
2282
|
];
|
|
2111
2283
|
/**
|
|
2112
2284
|
* Client plugin body: dictionaries plus the composer quick-control slot.
|
|
@@ -2127,18 +2299,21 @@ window.__ModuleLoader__.load({
|
|
|
2127
2299
|
for (const dispose of disposers) dispose();
|
|
2128
2300
|
};
|
|
2129
2301
|
}, "dsh-thinking-levels: dictionaries");
|
|
2130
|
-
|
|
2302
|
+
const directories = ctx.modelDirectories;
|
|
2303
|
+
if (directories !== void 0) ctx.slots.inject("conversation.input.model", function* () {
|
|
2131
2304
|
yield ctx.slots.register({
|
|
2132
|
-
name: "conversation.input.
|
|
2133
|
-
id: "context-window-
|
|
2305
|
+
name: "conversation.input.model",
|
|
2306
|
+
id: "context-window-model-panel",
|
|
2307
|
+
priority: -1,
|
|
2134
2308
|
locale: NS,
|
|
2135
|
-
inject: () => {
|
|
2309
|
+
inject: (sessionId) => {
|
|
2136
2310
|
return {
|
|
2311
|
+
directory: directories.directoryFor(sessionId),
|
|
2137
2312
|
piAiScope: ctx.configForms.get("llm-pi-ai"),
|
|
2138
2313
|
deepseekScope: ctx.configForms.get("llm-deepseek")
|
|
2139
2314
|
};
|
|
2140
2315
|
}
|
|
2141
|
-
},
|
|
2316
|
+
}, ModelPanel);
|
|
2142
2317
|
});
|
|
2143
2318
|
/** Registrant labels arrive as a string or a locale thunk; unwrap either.
|
|
2144
2319
|
* A throwing thunk (e.g. a contributor whose label touches a service its own
|