dsh-thinking-levels 0.6.0 → 0.7.1-beta.2
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/CHANGELOG.ja.md +117 -89
- package/CHANGELOG.ko.md +117 -89
- package/CHANGELOG.md +51 -0
- package/README.ja.md +170 -168
- package/README.ko.md +170 -168
- package/README.md +231 -195
- package/README.zh.md +179 -174
- package/dsh.plugin.json +16 -0
- package/lib/client.js +764 -106
- package/lib/client.js.map +1 -1
- package/lib/context-window.d.ts +41 -0
- package/lib/context-window.js +54 -0
- package/lib/index.d.ts +12 -1
- package/lib/index.js +32 -56
- package/lib/takeover-sync.d.ts +57 -32
- package/lib/takeover-sync.js +151 -45
- package/package.json +15 -4
package/lib/client.js
CHANGED
|
@@ -31,7 +31,7 @@ window.__ModuleLoader__.load({
|
|
|
31
31
|
"card.readonly": "只读",
|
|
32
32
|
"card.capabilities": "模型能力(llm-pi-ai 自定义提供方)",
|
|
33
33
|
"card.capabilities.hint": "直接读写 llm-pi-ai 配置:勾选档位并填写发送给网关的线上值(例如 high → ultra);off 留空表示不发送。视觉决定图片输入;思考开关决定 enable_thinking 置位;thinkingFormat 决定 wire 序列化格式。",
|
|
34
|
-
"card.capabilities.empty": "
|
|
34
|
+
"card.capabilities.empty": "llm-pi-ai 中没有已配置模型的自定义提供方。请先在「设置 → 模型」添加提供方与模型。",
|
|
35
35
|
"card.capabilities.unavailable": "llm-pi-ai 设置命名空间不可用。",
|
|
36
36
|
"card.capabilities.none": "(无模型)",
|
|
37
37
|
"card.capabilities.search": "搜索模型(名称或 ID)…",
|
|
@@ -40,8 +40,8 @@ window.__ModuleLoader__.load({
|
|
|
40
40
|
"card.capabilities.presetOfficial": "应用到全部:Off / High / Max(官方 DeepSeek 风格)",
|
|
41
41
|
"card.capabilities.presetGeneric": "应用到全部:Off / Low / Medium / High(通用)",
|
|
42
42
|
"card.capabilities.vendor": "提供方",
|
|
43
|
-
"card.capabilities.
|
|
44
|
-
"card.capabilities.
|
|
43
|
+
"card.capabilities.developerRole": "网关不支持 developer 角色",
|
|
44
|
+
"card.capabilities.developerRoleHint": "官方兼容开关(dsh ≥ v0.1.0-rc.8):写入路由级 compat.supportsDeveloperRole: false,系统提示词按 system 角色发送,修复 vLLM / SGLang 等网关的 Unexpected message role 400。取消勾选 = 删除该字段、恢复继承。",
|
|
45
45
|
"card.capabilities.expandProvider": "展开提供方",
|
|
46
46
|
"card.capabilities.collapseProvider": "收起提供方",
|
|
47
47
|
"card.capabilities.openModelSettings": "打开模型设置",
|
|
@@ -60,6 +60,21 @@ window.__ModuleLoader__.load({
|
|
|
60
60
|
"card.capabilities.saved": "已保存",
|
|
61
61
|
"card.capabilities.thinkingFormat": "思考格式",
|
|
62
62
|
"card.capabilities.thinkingFormat.inherit": "继承",
|
|
63
|
+
"card.capabilities.contextWindow": "上下文窗口上限",
|
|
64
|
+
"card.capabilities.contextCustomPlaceholder": "自定义整数,如 256000",
|
|
65
|
+
"card.capabilities.contextClear": "清除",
|
|
66
|
+
"card.capabilities.contextInteger": "上下文长度必须是整数(2000-1000000)",
|
|
67
|
+
"card.capabilities.contextRange": "上下文长度必须在 2000 到 1000000 之间",
|
|
68
|
+
"card.capabilities.contextHint": "选择预设或输入整数(2000–1000000),写入 llm-pi-ai 供上下文压力/压缩使用,无需重启即对下一请求生效。",
|
|
69
|
+
"input.context.title": "上下文窗口",
|
|
70
|
+
"input.context.globalHint": "全局生效:作用于所有使用该模型的会话(清除可恢复默认)",
|
|
71
|
+
"input.context.unset": "ctx 未设",
|
|
72
|
+
"input.context.noModel": "暂无会话模型",
|
|
73
|
+
"input.context.customPlaceholder": "自定义整数,如 256000",
|
|
74
|
+
"input.context.apply": "应用",
|
|
75
|
+
"input.context.clear": "清除",
|
|
76
|
+
"input.context.integer": "上下文长度必须是整数(2000-1000000)",
|
|
77
|
+
"input.context.range": "上下文长度必须在 2000 到 1000000 之间",
|
|
63
78
|
"card.capabilities.failed": "保存失败:配置被拒绝或冲突,请检查值。"
|
|
64
79
|
};
|
|
65
80
|
/** English dictionary (keys mirror zh). */
|
|
@@ -83,7 +98,7 @@ window.__ModuleLoader__.load({
|
|
|
83
98
|
"card.readonly": "Read-only",
|
|
84
99
|
"card.capabilities": "Model capabilities (llm-pi-ai custom providers)",
|
|
85
100
|
"card.capabilities.hint": "Reads and writes the llm-pi-ai config directly: tick a level and enter the exact value sent to the gateway (e.g. high → ultra); leaving off empty means “do not send”. Vision gates image input; the thinking toggle drives enable_thinking; thinkingFormat picks the wire serialization.",
|
|
86
|
-
"card.capabilities.empty": "No provider
|
|
101
|
+
"card.capabilities.empty": "No custom provider has models configured in llm-pi-ai. Add a provider and models under Settings → Models first.",
|
|
87
102
|
"card.capabilities.unavailable": "The llm-pi-ai settings namespace is unavailable.",
|
|
88
103
|
"card.capabilities.none": "(no models)",
|
|
89
104
|
"card.capabilities.search": "Search models by name or ID…",
|
|
@@ -92,8 +107,8 @@ window.__ModuleLoader__.load({
|
|
|
92
107
|
"card.capabilities.presetOfficial": "Apply to all: Off / High / Max (official DeepSeek style)",
|
|
93
108
|
"card.capabilities.presetGeneric": "Apply to all: Off / Low / Medium / High (generic)",
|
|
94
109
|
"card.capabilities.vendor": "Provider",
|
|
95
|
-
"card.capabilities.
|
|
96
|
-
"card.capabilities.
|
|
110
|
+
"card.capabilities.developerRole": "Gateway rejects the developer role",
|
|
111
|
+
"card.capabilities.developerRoleHint": "Official compat switch (dsh ≥ v0.1.0-rc.8): writes route-level compat.supportsDeveloperRole: false so the system prompt is sent as role system — fixes the Unexpected message role 400 on vLLM / SGLang gateways. Unchecking deletes the field and restores inheritance.",
|
|
97
112
|
"card.capabilities.expandProvider": "Expand provider",
|
|
98
113
|
"card.capabilities.collapseProvider": "Collapse provider",
|
|
99
114
|
"card.capabilities.openModelSettings": "Open model settings",
|
|
@@ -112,6 +127,21 @@ window.__ModuleLoader__.load({
|
|
|
112
127
|
"card.capabilities.saved": "Saved",
|
|
113
128
|
"card.capabilities.thinkingFormat": "Thinking format",
|
|
114
129
|
"card.capabilities.thinkingFormat.inherit": "Inherit",
|
|
130
|
+
"card.capabilities.contextWindow": "Context window limit",
|
|
131
|
+
"card.capabilities.contextCustomPlaceholder": "Custom integer, e.g. 256000",
|
|
132
|
+
"card.capabilities.contextClear": "Clear",
|
|
133
|
+
"card.capabilities.contextInteger": "Context length must be an integer (2000-1000000)",
|
|
134
|
+
"card.capabilities.contextRange": "Context length must be between 2000 and 1000000",
|
|
135
|
+
"card.capabilities.contextHint": "Pick a preset or enter an integer (2000–1000000); written to llm-pi-ai for context pressure/compaction and applied to the next request without a restart.",
|
|
136
|
+
"input.context.title": "Context window",
|
|
137
|
+
"input.context.globalHint": "Applies globally to every session using this model (Clear restores the default)",
|
|
138
|
+
"input.context.unset": "ctx unset",
|
|
139
|
+
"input.context.noModel": "No session model yet",
|
|
140
|
+
"input.context.customPlaceholder": "Custom integer, e.g. 256000",
|
|
141
|
+
"input.context.apply": "Apply",
|
|
142
|
+
"input.context.clear": "Clear",
|
|
143
|
+
"input.context.integer": "Context length must be an integer (2000-1000000)",
|
|
144
|
+
"input.context.range": "Context length must be between 2000 and 1000000",
|
|
115
145
|
"card.capabilities.failed": "Save failed: the value was rejected or conflicted. Check it."
|
|
116
146
|
};
|
|
117
147
|
/** Japanese dictionary (keys mirror zh). */
|
|
@@ -135,7 +165,7 @@ window.__ModuleLoader__.load({
|
|
|
135
165
|
"card.readonly": "読み取り専用",
|
|
136
166
|
"card.capabilities": "モデル能力(llm-pi-ai カスタムプロバイダー)",
|
|
137
167
|
"card.capabilities.hint": "llm-pi-ai 設定を直接読み書きします:レベルにチェックを入れ、ゲートウェイに送信する値を入力(例:high → ultra)。off を空欄にすると送信しません。視覚は画像入力を決定、思考トグルは enable_thinking を制御、thinkingFormat は wire シリアライズ形式を選択します。",
|
|
138
|
-
"card.capabilities.empty": "
|
|
168
|
+
"card.capabilities.empty": "llm-pi-ai にモデルが設定されたカスタムプロバイダーがありません。先に「設定 → モデル」でプロバイダーとモデルを追加してください。",
|
|
139
169
|
"card.capabilities.unavailable": "llm-pi-ai の設定名前空間が利用できません。",
|
|
140
170
|
"card.capabilities.none": "(モデルなし)",
|
|
141
171
|
"card.capabilities.search": "モデル名または ID で検索…",
|
|
@@ -144,8 +174,8 @@ window.__ModuleLoader__.load({
|
|
|
144
174
|
"card.capabilities.presetOfficial": "すべてに適用:Off / High / Max(公式 DeepSeek 形式)",
|
|
145
175
|
"card.capabilities.presetGeneric": "すべてに適用:Off / Low / Medium / High(汎用)",
|
|
146
176
|
"card.capabilities.vendor": "プロバイダー",
|
|
147
|
-
"card.capabilities.
|
|
148
|
-
"card.capabilities.
|
|
177
|
+
"card.capabilities.developerRole": "ゲートウェイは developer ロール非対応",
|
|
178
|
+
"card.capabilities.developerRoleHint": "公式互換スイッチ(dsh ≥ v0.1.0-rc.8):ルートレベルの compat.supportsDeveloperRole: false を書き込み、システムプロンプトを system ロールで送信します。vLLM / SGLang などの Unexpected message role 400 を修正。チェックを外すとフィールドを削除し継承に戻します。",
|
|
149
179
|
"card.capabilities.expandProvider": "プロバイダーを展開",
|
|
150
180
|
"card.capabilities.collapseProvider": "プロバイダーを折りたたむ",
|
|
151
181
|
"card.capabilities.openModelSettings": "モデル設定を開く",
|
|
@@ -164,6 +194,21 @@ window.__ModuleLoader__.load({
|
|
|
164
194
|
"card.capabilities.saved": "保存済み",
|
|
165
195
|
"card.capabilities.thinkingFormat": "思考形式",
|
|
166
196
|
"card.capabilities.thinkingFormat.inherit": "継承",
|
|
197
|
+
"card.capabilities.contextWindow": "コンテキストウィンドウ上限",
|
|
198
|
+
"card.capabilities.contextCustomPlaceholder": "カスタム整数(例:256000)",
|
|
199
|
+
"card.capabilities.contextClear": "クリア",
|
|
200
|
+
"card.capabilities.contextInteger": "コンテキスト長は整数で入力してください(2000-1000000)",
|
|
201
|
+
"card.capabilities.contextRange": "コンテキスト長は 2000 から 1000000 の範囲で指定してください",
|
|
202
|
+
"card.capabilities.contextHint": "プリセットを選ぶか整数を入力(2000–1000000)。llm-pi-ai に書き込まれ、コンテキスト圧力/圧縮に使用され、再起動なしで次のリクエストに反映されます。",
|
|
203
|
+
"input.context.title": "コンテキストウィンドウ",
|
|
204
|
+
"input.context.globalHint": "グローバルに有効:このモデルを使用するすべてのセッションに適用されます(クリアで既定値に戻ります)",
|
|
205
|
+
"input.context.unset": "ctx 未設定",
|
|
206
|
+
"input.context.noModel": "セッションモデルがまだありません",
|
|
207
|
+
"input.context.customPlaceholder": "カスタム整数(例:256000)",
|
|
208
|
+
"input.context.apply": "適用",
|
|
209
|
+
"input.context.clear": "クリア",
|
|
210
|
+
"input.context.integer": "コンテキスト長は整数で入力してください(2000-1000000)",
|
|
211
|
+
"input.context.range": "コンテキスト長は 2000 から 1000000 の範囲で指定してください",
|
|
167
212
|
"card.capabilities.failed": "保存に失敗しました:値が拒否されたか競合しています。確認してください。"
|
|
168
213
|
};
|
|
169
214
|
/** Korean dictionary (keys mirror zh). */
|
|
@@ -187,7 +232,7 @@ window.__ModuleLoader__.load({
|
|
|
187
232
|
"card.readonly": "읽기 전용",
|
|
188
233
|
"card.capabilities": "모델 기능(llm-pi-ai 사용자 지정 제공자)",
|
|
189
234
|
"card.capabilities.hint": "llm-pi-ai 설정을 직접 읽고 씁니다: 수준을 체크하고 게이트웨이에 보낼 값을 입력(예: high → ultra). off를 비워 두면 전송하지 않습니다. 시각은 이미지 입력을 결정하고, 사고 토글은 enable_thinking을 제어하며, thinkingFormat은 wire 직렬화 형식을 선택합니다.",
|
|
190
|
-
"card.capabilities.empty": "
|
|
235
|
+
"card.capabilities.empty": "llm-pi-ai에 모델이 구성된 사용자 지정 제공자가 없습니다. 먼저 「설정 → 모델」에서 제공자와 모델을 추가하세요.",
|
|
191
236
|
"card.capabilities.unavailable": "llm-pi-ai 설정 네임스페이스를 사용할 수 없습니다.",
|
|
192
237
|
"card.capabilities.none": "(모델 없음)",
|
|
193
238
|
"card.capabilities.search": "모델 이름 또는 ID로 검색…",
|
|
@@ -196,8 +241,8 @@ window.__ModuleLoader__.load({
|
|
|
196
241
|
"card.capabilities.presetOfficial": "전체에 적용: Off / High / Max(공식 DeepSeek 방식)",
|
|
197
242
|
"card.capabilities.presetGeneric": "전체에 적용: Off / Low / Medium / High(일반 방식)",
|
|
198
243
|
"card.capabilities.vendor": "제공자",
|
|
199
|
-
"card.capabilities.
|
|
200
|
-
"card.capabilities.
|
|
244
|
+
"card.capabilities.developerRole": "게이트웨이가 developer 역할 미지원",
|
|
245
|
+
"card.capabilities.developerRoleHint": "공식 호환 스위치(dsh ≥ v0.1.0-rc.8): 라우트 수준 compat.supportsDeveloperRole: false 를 기록하여 시스템 프롬프트를 system 역할로 전송합니다. vLLM / SGLang 등의 Unexpected message role 400 을 수정. 체크 해제 시 필드를 삭제하고 상속을 복원합니다.",
|
|
201
246
|
"card.capabilities.expandProvider": "제공자 펼치기",
|
|
202
247
|
"card.capabilities.collapseProvider": "제공자 접기",
|
|
203
248
|
"card.capabilities.openModelSettings": "모델 설정 열기",
|
|
@@ -216,8 +261,84 @@ window.__ModuleLoader__.load({
|
|
|
216
261
|
"card.capabilities.saved": "저장됨",
|
|
217
262
|
"card.capabilities.thinkingFormat": "사고 형식",
|
|
218
263
|
"card.capabilities.thinkingFormat.inherit": "상속",
|
|
264
|
+
"card.capabilities.contextWindow": "컨텍스트 창 상한",
|
|
265
|
+
"card.capabilities.contextCustomPlaceholder": "사용자 지정 정수(예: 256000)",
|
|
266
|
+
"card.capabilities.contextClear": "지우기",
|
|
267
|
+
"card.capabilities.contextInteger": "컨텍스트 길이는 정수여야 합니다 (2000-1000000)",
|
|
268
|
+
"card.capabilities.contextRange": "컨텍스트 길이는 2000에서 1000000 사이여야 합니다",
|
|
269
|
+
"card.capabilities.contextHint": "프리셋을 선택하거나 정수를 입력하세요(2000–1000000). llm-pi-ai에 기록되어 컨텍스트 압력/압축에 사용되며, 재시작 없이 다음 요청에 반영됩니다.",
|
|
270
|
+
"input.context.title": "컨텍스트 창",
|
|
271
|
+
"input.context.globalHint": "전역 적용: 이 모델을 사용하는 모든 세션에 적용됩니다(지우면 기본값 복원)",
|
|
272
|
+
"input.context.unset": "ctx 미설정",
|
|
273
|
+
"input.context.noModel": "세션 모델이 아직 없습니다",
|
|
274
|
+
"input.context.customPlaceholder": "사용자 지정 정수(예: 256000)",
|
|
275
|
+
"input.context.apply": "적용",
|
|
276
|
+
"input.context.clear": "지우기",
|
|
277
|
+
"input.context.integer": "컨텍스트 길이는 정수여야 합니다 (2000-1000000)",
|
|
278
|
+
"input.context.range": "컨텍스트 길이는 2000에서 1000000 사이여야 합니다",
|
|
219
279
|
"card.capabilities.failed": "저장 실패: 값이 거부되었거나 충돌합니다. 확인하세요."
|
|
220
280
|
};
|
|
281
|
+
/** The multi-level context-window presets, in ascending order. */
|
|
282
|
+
const CONTEXT_WINDOW_PRESETS = [
|
|
283
|
+
{
|
|
284
|
+
label: "64K",
|
|
285
|
+
value: 64e3
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
label: "128K",
|
|
289
|
+
value: 131072
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
label: "256K",
|
|
293
|
+
value: 256e3
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
label: "400K",
|
|
297
|
+
value: 4e5
|
|
298
|
+
},
|
|
299
|
+
{
|
|
300
|
+
label: "512K",
|
|
301
|
+
value: 524288
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
label: "1M",
|
|
305
|
+
value: 1e6
|
|
306
|
+
}
|
|
307
|
+
];
|
|
308
|
+
/** Format a token count as a readable label (exact presets keep their label). */
|
|
309
|
+
function formatContextWindow(value) {
|
|
310
|
+
const preset = CONTEXT_WINDOW_PRESETS.find((candidate) => candidate.value === value);
|
|
311
|
+
if (preset !== void 0) return preset.label;
|
|
312
|
+
if (value >= 1e6) return "1M";
|
|
313
|
+
if (value >= 1024) return `${Math.round(value / 1024)}K`;
|
|
314
|
+
return String(value);
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Validate a context-window candidate (number or numeric string). Accepts only
|
|
318
|
+
* base-10 integers inside [CONTEXT_WINDOW_MIN, CONTEXT_WINDOW_MAX]; anything
|
|
319
|
+
* else (float, 'abc', '1e3', out-of-range) is rejected with a reason.
|
|
320
|
+
*/
|
|
321
|
+
function validateContextWindow(value) {
|
|
322
|
+
const raw = typeof value === "string" ? value.trim() : value;
|
|
323
|
+
const asString = typeof raw === "string" ? raw : String(raw);
|
|
324
|
+
if (!/^\d+$/.test(asString)) return {
|
|
325
|
+
ok: false,
|
|
326
|
+
reason: "integer"
|
|
327
|
+
};
|
|
328
|
+
const numeric = Number(asString);
|
|
329
|
+
if (!Number.isSafeInteger(numeric)) return {
|
|
330
|
+
ok: false,
|
|
331
|
+
reason: "integer"
|
|
332
|
+
};
|
|
333
|
+
if (numeric < 2e3 || numeric > 1e6) return {
|
|
334
|
+
ok: false,
|
|
335
|
+
reason: "range"
|
|
336
|
+
};
|
|
337
|
+
return {
|
|
338
|
+
ok: true,
|
|
339
|
+
value: numeric
|
|
340
|
+
};
|
|
341
|
+
}
|
|
221
342
|
//#endregion
|
|
222
343
|
//#region src/client/card.tsx
|
|
223
344
|
/**
|
|
@@ -310,7 +431,7 @@ window.__ModuleLoader__.load({
|
|
|
310
431
|
fontSize: "13px",
|
|
311
432
|
lineHeight: "20px"
|
|
312
433
|
};
|
|
313
|
-
const labelStyle = {
|
|
434
|
+
const labelStyle$1 = {
|
|
314
435
|
margin: 0,
|
|
315
436
|
color: "var(--dsw-alias-label-primary)"
|
|
316
437
|
};
|
|
@@ -338,7 +459,7 @@ window.__ModuleLoader__.load({
|
|
|
338
459
|
lineHeight: "18px",
|
|
339
460
|
color: "var(--dsw-alias-label-tertiary)"
|
|
340
461
|
};
|
|
341
|
-
const hintStyle = {
|
|
462
|
+
const hintStyle$1 = {
|
|
342
463
|
margin: "6px 0 0",
|
|
343
464
|
fontSize: "12px",
|
|
344
465
|
lineHeight: "18px",
|
|
@@ -469,13 +590,6 @@ window.__ModuleLoader__.load({
|
|
|
469
590
|
};
|
|
470
591
|
return table;
|
|
471
592
|
}
|
|
472
|
-
/** The `compat.thinkingFormat` a row declares, or `undefined` when it declares none. */
|
|
473
|
-
function formatOf(model) {
|
|
474
|
-
const compat = model["compat"];
|
|
475
|
-
if (typeof compat !== "object" || compat === null || Array.isArray(compat)) return void 0;
|
|
476
|
-
const format = compat["thinkingFormat"];
|
|
477
|
-
return typeof format === "string" ? format : void 0;
|
|
478
|
-
}
|
|
479
593
|
/** Whether a row declares `compat.supportsReasoningEffort` (the wire sends reasoning_effort). */
|
|
480
594
|
function supportsEffortOf(model) {
|
|
481
595
|
const compat = model["compat"];
|
|
@@ -490,47 +604,57 @@ window.__ModuleLoader__.load({
|
|
|
490
604
|
else row["compat"] = compat;
|
|
491
605
|
}
|
|
492
606
|
/** The user-layer `providers` value of the llm-pi-ai namespace, when present. */
|
|
493
|
-
function providersOf(snapshot) {
|
|
607
|
+
function providersOf$1(snapshot) {
|
|
494
608
|
if (typeof snapshot !== "object" || snapshot === null) return {};
|
|
495
609
|
const user = snapshot.user;
|
|
496
610
|
if (typeof user !== "object" || user === null || Array.isArray(user)) return {};
|
|
497
611
|
const providers = user["providers"];
|
|
498
612
|
return typeof providers === "object" && providers !== null && !Array.isArray(providers) ? providers : {};
|
|
499
613
|
}
|
|
500
|
-
/**
|
|
501
|
-
function
|
|
502
|
-
if (typeof
|
|
503
|
-
const
|
|
504
|
-
if (typeof
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
614
|
+
/** Whether a route-level profile declares `compat.supportsDeveloperRole: false`. */
|
|
615
|
+
function developerRoleDisabledOf(profile) {
|
|
616
|
+
if (typeof profile !== "object" || profile === null) return false;
|
|
617
|
+
const compat = profile["compat"];
|
|
618
|
+
if (typeof compat !== "object" || compat === null || Array.isArray(compat)) return false;
|
|
619
|
+
return compat["supportsDeveloperRole"] === false;
|
|
620
|
+
}
|
|
621
|
+
/** The effective `compat` of an entry: its own `compat` merged over the provider-level `compat`. */
|
|
622
|
+
function compatOf(entry) {
|
|
623
|
+
const base = typeof entry.providerCompat === "object" && entry.providerCompat !== null ? entry.providerCompat : {};
|
|
624
|
+
const own = entry.model["compat"];
|
|
625
|
+
return typeof own === "object" && own !== null && !Array.isArray(own) ? {
|
|
626
|
+
...base,
|
|
627
|
+
...own
|
|
628
|
+
} : base;
|
|
508
629
|
}
|
|
509
630
|
/** Flatten the user-layer providers into capability entries (models arrays only). */
|
|
510
631
|
function entriesOf(providers) {
|
|
511
632
|
return Object.entries(providers).flatMap(([providerId, profile]) => {
|
|
512
|
-
const
|
|
633
|
+
const raw = profile;
|
|
634
|
+
const models = raw["models"];
|
|
513
635
|
if (!Array.isArray(models)) return [];
|
|
636
|
+
const providerCompat = raw["compat"];
|
|
637
|
+
const providerInput = Array.isArray(raw["defaultInput"]) ? raw["defaultInput"] : void 0;
|
|
514
638
|
return models.map((model, index) => ({
|
|
515
639
|
providerId,
|
|
516
640
|
index,
|
|
517
641
|
model: typeof model === "object" && model !== null && !Array.isArray(model) ? model : {},
|
|
518
|
-
modelId: typeof model === "object" && model !== null && typeof model["id"] === "string" ? model["id"] : `#${index + 1}
|
|
642
|
+
modelId: typeof model === "object" && model !== null && typeof model["id"] === "string" ? model["id"] : `#${index + 1}`,
|
|
643
|
+
providerCompat,
|
|
644
|
+
providerInput
|
|
519
645
|
}));
|
|
520
646
|
});
|
|
521
647
|
}
|
|
522
648
|
/** Human-readable capability summary of one entry (input modalities + declared context window). */
|
|
523
649
|
function summaryOf(entry) {
|
|
524
|
-
const input = entry.model["input"];
|
|
650
|
+
const input = Array.isArray(entry.model["input"]) ? entry.model["input"] : entry.providerInput;
|
|
525
651
|
const text = !Array.isArray(input) || input.length === 0 || input.includes("text");
|
|
526
652
|
const image = Array.isArray(input) && input.includes("image");
|
|
527
653
|
const contextWindow = entry.model["contextWindow"];
|
|
528
|
-
let context = null;
|
|
529
|
-
if (typeof contextWindow === "number" && Number.isFinite(contextWindow) && contextWindow > 0) context = contextWindow >= 1024 ? `${Math.round(contextWindow / 1024)}K` : String(contextWindow);
|
|
530
654
|
return {
|
|
531
655
|
text,
|
|
532
656
|
image,
|
|
533
|
-
context
|
|
657
|
+
context: typeof contextWindow === "number" && Number.isFinite(contextWindow) && contextWindow > 0 ? formatContextWindow(contextWindow) : null
|
|
534
658
|
};
|
|
535
659
|
}
|
|
536
660
|
/** A tiny inline chevron icon (no CSS modules). */
|
|
@@ -564,18 +688,18 @@ window.__ModuleLoader__.load({
|
|
|
564
688
|
* @returns the capabilities block, or a placeholder when nothing is configured.
|
|
565
689
|
*/
|
|
566
690
|
function ModelCapabilities(props) {
|
|
567
|
-
const { scope,
|
|
691
|
+
const { scope, t, readonly } = props;
|
|
568
692
|
const snapshot = (0, react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
|
|
569
|
-
const takeover = (0, react.useSyncExternalStore)((listener) => takeoverScope.subscribe(listener), () => takeoverScope.getSnapshot());
|
|
570
693
|
const unavailable = snapshot.status === "unavailable";
|
|
571
|
-
const providers = snapshot.status === "ready" ? providersOf(snapshot) : {};
|
|
572
|
-
const takeoverList = takeover.status === "ready" ? takeoverListOf(takeover) : [];
|
|
694
|
+
const providers = snapshot.status === "ready" ? providersOf$1(snapshot) : {};
|
|
573
695
|
const allEntries = entriesOf(providers);
|
|
574
696
|
const [query, setQuery] = (0, react.useState)("");
|
|
575
697
|
const [expandedProviders, setExpandedProviders] = (0, react.useState)({});
|
|
576
698
|
const [expandedModels, setExpandedModels] = (0, react.useState)({});
|
|
577
699
|
const [drafts, setDrafts] = (0, react.useState)({});
|
|
578
700
|
const [busy, setBusy] = (0, react.useState)(false);
|
|
701
|
+
const [contextRaw, setContextRaw] = (0, react.useState)({});
|
|
702
|
+
const [contextError, setContextError] = (0, react.useState)({});
|
|
579
703
|
const entryKey = (entry) => `${entry.providerId}\u0000${entry.index}`;
|
|
580
704
|
/** Commit one patch over the user-layer providers. */
|
|
581
705
|
const commitProviders = (mutate) => {
|
|
@@ -587,16 +711,17 @@ window.__ModuleLoader__.load({
|
|
|
587
711
|
setBusy(false);
|
|
588
712
|
});
|
|
589
713
|
};
|
|
590
|
-
/** Toggle
|
|
591
|
-
const
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
714
|
+
/** Toggle the route-level official compat flag: unchecked = inherit (unset). */
|
|
715
|
+
const toggleDeveloperRole = (providerId, next) => {
|
|
716
|
+
commitProviders((current) => {
|
|
717
|
+
const profile = current[providerId];
|
|
718
|
+
if (profile === void 0) return current;
|
|
719
|
+
const compat = typeof profile["compat"] === "object" && profile["compat"] !== null && !Array.isArray(profile["compat"]) ? { ...profile["compat"] } : {};
|
|
720
|
+
if (next) compat["supportsDeveloperRole"] = false;
|
|
721
|
+
else delete compat["supportsDeveloperRole"];
|
|
722
|
+
if (Object.keys(compat).length === 0) delete profile["compat"];
|
|
723
|
+
else profile["compat"] = compat;
|
|
724
|
+
return current;
|
|
600
725
|
});
|
|
601
726
|
};
|
|
602
727
|
/** Patch one model row of one provider. */
|
|
@@ -613,11 +738,16 @@ window.__ModuleLoader__.load({
|
|
|
613
738
|
/** Toggle whether a model is a thinking model (reasoningEfforts table vs false). */
|
|
614
739
|
const toggleThinking = (entry, next) => {
|
|
615
740
|
patchModel(entry.providerId, entry.index, (row) => {
|
|
616
|
-
if (next)
|
|
617
|
-
|
|
618
|
-
high: "high"
|
|
619
|
-
|
|
620
|
-
|
|
741
|
+
if (next) {
|
|
742
|
+
const effortCapable = supportsEffortOf(row);
|
|
743
|
+
row["reasoningEfforts"] = effortCapable ? effortTableOf({ high: "high" }) : {
|
|
744
|
+
off: null,
|
|
745
|
+
high: "high"
|
|
746
|
+
};
|
|
747
|
+
if (!effortCapable) patchCompat(row, (compat) => {
|
|
748
|
+
if (compat["thinkingFormat"] === void 0) compat["thinkingFormat"] = "qwen-chat-template";
|
|
749
|
+
});
|
|
750
|
+
} else row["reasoningEfforts"] = false;
|
|
621
751
|
});
|
|
622
752
|
};
|
|
623
753
|
/** Toggle whether a model accepts reasoning_effort levels. */
|
|
@@ -625,6 +755,7 @@ window.__ModuleLoader__.load({
|
|
|
625
755
|
patchModel(entry.providerId, entry.index, (row) => {
|
|
626
756
|
patchCompat(row, (compat) => {
|
|
627
757
|
compat["supportsReasoningEffort"] = next;
|
|
758
|
+
if (next && compat["thinkingFormat"] === "qwen-chat-template") delete compat["thinkingFormat"];
|
|
628
759
|
});
|
|
629
760
|
});
|
|
630
761
|
};
|
|
@@ -686,10 +817,71 @@ window.__ModuleLoader__.load({
|
|
|
686
817
|
return current;
|
|
687
818
|
});
|
|
688
819
|
};
|
|
820
|
+
/** Seed a model's context-window input when it is first expanded. */
|
|
821
|
+
const seedContext = (entry) => {
|
|
822
|
+
const key = entryKey(entry);
|
|
823
|
+
setContextRaw((current) => {
|
|
824
|
+
if (current[key] !== void 0) return current;
|
|
825
|
+
const value = entry.model["contextWindow"];
|
|
826
|
+
return {
|
|
827
|
+
...current,
|
|
828
|
+
[key]: typeof value === "number" && Number.isFinite(value) ? String(value) : ""
|
|
829
|
+
};
|
|
830
|
+
});
|
|
831
|
+
};
|
|
832
|
+
/** Write (or delete) a model's `contextWindow` in the llm-pi-ai entry. */
|
|
833
|
+
const commitContextWindow = (entry, value) => {
|
|
834
|
+
const key = entryKey(entry);
|
|
835
|
+
patchModel(entry.providerId, entry.index, (row) => {
|
|
836
|
+
if (value === void 0) delete row["contextWindow"];
|
|
837
|
+
else row["contextWindow"] = value;
|
|
838
|
+
});
|
|
839
|
+
setContextError((current) => {
|
|
840
|
+
const next = { ...current };
|
|
841
|
+
delete next[key];
|
|
842
|
+
return next;
|
|
843
|
+
});
|
|
844
|
+
};
|
|
845
|
+
/** Apply one preset immediately. */
|
|
846
|
+
const applyContextPreset = (entry, value) => {
|
|
847
|
+
const key = entryKey(entry);
|
|
848
|
+
setContextRaw((current) => ({
|
|
849
|
+
...current,
|
|
850
|
+
[key]: String(value)
|
|
851
|
+
}));
|
|
852
|
+
commitContextWindow(entry, value);
|
|
853
|
+
};
|
|
854
|
+
/** Validate and commit the custom input (blur / Enter); empty clears it. */
|
|
855
|
+
const applyContextInput = (entry) => {
|
|
856
|
+
const key = entryKey(entry);
|
|
857
|
+
const raw = (contextRaw[key] ?? "").trim();
|
|
858
|
+
if (raw === "") {
|
|
859
|
+
commitContextWindow(entry, void 0);
|
|
860
|
+
return;
|
|
861
|
+
}
|
|
862
|
+
const validation = validateContextWindow(raw);
|
|
863
|
+
if (!validation.ok) {
|
|
864
|
+
setContextError((current) => ({
|
|
865
|
+
...current,
|
|
866
|
+
[key]: t(validation.reason === "integer" ? "card.capabilities.contextInteger" : "card.capabilities.contextRange")
|
|
867
|
+
}));
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
commitContextWindow(entry, validation.value);
|
|
871
|
+
};
|
|
872
|
+
/** Clear the model's context-window declaration (delete the field). */
|
|
873
|
+
const clearContext = (entry) => {
|
|
874
|
+
const key = entryKey(entry);
|
|
875
|
+
setContextRaw((current) => ({
|
|
876
|
+
...current,
|
|
877
|
+
[key]: ""
|
|
878
|
+
}));
|
|
879
|
+
commitContextWindow(entry, void 0);
|
|
880
|
+
};
|
|
689
881
|
if (unavailable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
690
882
|
style: sectionStyle,
|
|
691
883
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
692
|
-
style: hintStyle,
|
|
884
|
+
style: hintStyle$1,
|
|
693
885
|
children: t("card.capabilities.unavailable")
|
|
694
886
|
})
|
|
695
887
|
});
|
|
@@ -699,7 +891,7 @@ window.__ModuleLoader__.load({
|
|
|
699
891
|
style: fieldLabelStyle,
|
|
700
892
|
children: t("card.capabilities")
|
|
701
893
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
702
|
-
style: hintStyle,
|
|
894
|
+
style: hintStyle$1,
|
|
703
895
|
children: t("card.capabilities.empty")
|
|
704
896
|
})]
|
|
705
897
|
});
|
|
@@ -714,7 +906,7 @@ window.__ModuleLoader__.load({
|
|
|
714
906
|
children: t("card.capabilities")
|
|
715
907
|
}),
|
|
716
908
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
717
|
-
style: hintStyle,
|
|
909
|
+
style: hintStyle$1,
|
|
718
910
|
children: t("card.capabilities.hint")
|
|
719
911
|
}),
|
|
720
912
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -749,7 +941,7 @@ window.__ModuleLoader__.load({
|
|
|
749
941
|
}, preset.key))]
|
|
750
942
|
}),
|
|
751
943
|
visible.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
752
|
-
style: hintStyle,
|
|
944
|
+
style: hintStyle$1,
|
|
753
945
|
children: t("card.capabilities.noMatches")
|
|
754
946
|
}) : providerIds.map((providerId) => {
|
|
755
947
|
const providerEntries = visible.filter((entry) => entry.providerId === providerId);
|
|
@@ -787,25 +979,27 @@ window.__ModuleLoader__.load({
|
|
|
787
979
|
whiteSpace: "nowrap",
|
|
788
980
|
color: "var(--dsw-alias-label-secondary)"
|
|
789
981
|
},
|
|
982
|
+
title: t("card.capabilities.developerRoleHint"),
|
|
790
983
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
791
984
|
type: "checkbox",
|
|
792
|
-
checked:
|
|
985
|
+
checked: developerRoleDisabledOf(providers[providerId]),
|
|
793
986
|
disabled: readonly || busy,
|
|
794
|
-
onChange: () =>
|
|
795
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.
|
|
987
|
+
onChange: (event) => toggleDeveloperRole(providerId, event.currentTarget.checked)
|
|
988
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.developerRole") })]
|
|
796
989
|
}),
|
|
797
990
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
798
991
|
style: providerBadgeStyle,
|
|
799
992
|
children: providerEntries.length
|
|
800
993
|
})
|
|
801
994
|
]
|
|
802
|
-
}), providerOpen ?
|
|
995
|
+
}), providerOpen ? providerEntries.map((entry) => {
|
|
803
996
|
const key = entryKey(entry);
|
|
804
997
|
const modelOpen = expandedModels[key] === true;
|
|
805
998
|
const thinking = typeof effortsOf(entry.model) === "object";
|
|
806
|
-
const
|
|
999
|
+
const compat = compatOf(entry);
|
|
1000
|
+
const supportsEffort = compat["supportsReasoningEffort"] === true;
|
|
807
1001
|
const meta = summaryOf(entry);
|
|
808
|
-
const format =
|
|
1002
|
+
const format = typeof compat["thinkingFormat"] === "string" ? compat["thinkingFormat"] : void 0;
|
|
809
1003
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
810
1004
|
style: modelRowStyle,
|
|
811
1005
|
children: [
|
|
@@ -819,7 +1013,10 @@ window.__ModuleLoader__.load({
|
|
|
819
1013
|
...current,
|
|
820
1014
|
[key]: next
|
|
821
1015
|
}));
|
|
822
|
-
if (next)
|
|
1016
|
+
if (next) {
|
|
1017
|
+
ensureDraft(entry);
|
|
1018
|
+
seedContext(entry);
|
|
1019
|
+
}
|
|
823
1020
|
},
|
|
824
1021
|
style: {
|
|
825
1022
|
...iconButtonStyle,
|
|
@@ -877,7 +1074,7 @@ window.__ModuleLoader__.load({
|
|
|
877
1074
|
disabled: readonly || busy,
|
|
878
1075
|
onChange: (event) => toggleThinking(entry, event.currentTarget.checked)
|
|
879
1076
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.thinking") })]
|
|
880
|
-
}),
|
|
1077
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
881
1078
|
style: {
|
|
882
1079
|
display: "inline-flex",
|
|
883
1080
|
alignItems: "center",
|
|
@@ -886,12 +1083,31 @@ window.__ModuleLoader__.load({
|
|
|
886
1083
|
},
|
|
887
1084
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
888
1085
|
type: "checkbox",
|
|
889
|
-
checked:
|
|
1086
|
+
checked: meta.image,
|
|
890
1087
|
disabled: readonly || busy,
|
|
891
|
-
onChange: (event) =>
|
|
892
|
-
|
|
893
|
-
|
|
1088
|
+
onChange: (event) => {
|
|
1089
|
+
patchModel(entry.providerId, entry.index, (row) => {
|
|
1090
|
+
row["input"] = event.currentTarget.checked ? ["text", "image"] : ["text"];
|
|
1091
|
+
});
|
|
1092
|
+
}
|
|
1093
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.vision") })]
|
|
1094
|
+
})]
|
|
894
1095
|
}),
|
|
1096
|
+
thinking ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1097
|
+
style: {
|
|
1098
|
+
display: "inline-flex",
|
|
1099
|
+
alignItems: "center",
|
|
1100
|
+
gap: "6px",
|
|
1101
|
+
fontSize: "12px",
|
|
1102
|
+
margin: "0 0 8px"
|
|
1103
|
+
},
|
|
1104
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1105
|
+
type: "checkbox",
|
|
1106
|
+
checked: supportsEffort,
|
|
1107
|
+
disabled: readonly || busy,
|
|
1108
|
+
onChange: (event) => toggleEffortCapable(entry, event.currentTarget.checked)
|
|
1109
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.supportsEffort") })]
|
|
1110
|
+
}) : null,
|
|
895
1111
|
thinking && supportsEffort ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
896
1112
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
897
1113
|
style: fieldLabelStyle,
|
|
@@ -983,31 +1199,14 @@ window.__ModuleLoader__.load({
|
|
|
983
1199
|
})]
|
|
984
1200
|
})
|
|
985
1201
|
] }) : null,
|
|
986
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
1202
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
987
1203
|
style: {
|
|
988
1204
|
display: "flex",
|
|
989
1205
|
gap: "16px",
|
|
990
1206
|
flexWrap: "wrap",
|
|
991
1207
|
marginTop: "10px"
|
|
992
1208
|
},
|
|
993
|
-
children:
|
|
994
|
-
style: {
|
|
995
|
-
display: "inline-flex",
|
|
996
|
-
alignItems: "center",
|
|
997
|
-
gap: "6px",
|
|
998
|
-
fontSize: "12px"
|
|
999
|
-
},
|
|
1000
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1001
|
-
type: "checkbox",
|
|
1002
|
-
checked: meta.image,
|
|
1003
|
-
disabled: readonly || busy,
|
|
1004
|
-
onChange: (event) => {
|
|
1005
|
-
patchModel(entry.providerId, entry.index, (row) => {
|
|
1006
|
-
row["input"] = event.currentTarget.checked ? ["text", "image"] : ["text"];
|
|
1007
|
-
});
|
|
1008
|
-
}
|
|
1009
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.vision") })]
|
|
1010
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1209
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1011
1210
|
style: fieldStyle,
|
|
1012
1211
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1013
1212
|
style: fieldLabelStyle,
|
|
@@ -1033,21 +1232,95 @@ window.__ModuleLoader__.load({
|
|
|
1033
1232
|
children: formatOption
|
|
1034
1233
|
}, formatOption))]
|
|
1035
1234
|
})]
|
|
1036
|
-
})
|
|
1235
|
+
})
|
|
1236
|
+
}),
|
|
1237
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1238
|
+
style: {
|
|
1239
|
+
display: "flex",
|
|
1240
|
+
gap: "16px",
|
|
1241
|
+
flexWrap: "wrap",
|
|
1242
|
+
marginTop: "10px"
|
|
1243
|
+
},
|
|
1244
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1245
|
+
style: fieldStyle,
|
|
1246
|
+
children: [
|
|
1247
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1248
|
+
style: fieldLabelStyle,
|
|
1249
|
+
children: t("card.capabilities.contextWindow")
|
|
1250
|
+
}),
|
|
1251
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1252
|
+
style: {
|
|
1253
|
+
display: "flex",
|
|
1254
|
+
gap: "6px",
|
|
1255
|
+
flexWrap: "wrap",
|
|
1256
|
+
alignItems: "center"
|
|
1257
|
+
},
|
|
1258
|
+
children: [
|
|
1259
|
+
CONTEXT_WINDOW_PRESETS.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1260
|
+
type: "button",
|
|
1261
|
+
disabled: readonly || busy,
|
|
1262
|
+
onClick: () => applyContextPreset(entry, preset.value),
|
|
1263
|
+
style: {
|
|
1264
|
+
...controlStyle,
|
|
1265
|
+
padding: "2px 8px",
|
|
1266
|
+
cursor: readonly || busy ? "default" : "pointer",
|
|
1267
|
+
opacity: readonly || busy ? .5 : 1
|
|
1268
|
+
},
|
|
1269
|
+
children: preset.label
|
|
1270
|
+
}, preset.value)),
|
|
1271
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1272
|
+
type: "text",
|
|
1273
|
+
value: contextRaw[key] ?? "",
|
|
1274
|
+
disabled: readonly || busy,
|
|
1275
|
+
placeholder: t("card.capabilities.contextCustomPlaceholder"),
|
|
1276
|
+
style: {
|
|
1277
|
+
...controlStyle,
|
|
1278
|
+
width: "120px"
|
|
1279
|
+
},
|
|
1280
|
+
onChange: (event) => {
|
|
1281
|
+
const next = event.currentTarget.value;
|
|
1282
|
+
setContextRaw((current) => ({
|
|
1283
|
+
...current,
|
|
1284
|
+
[key]: next
|
|
1285
|
+
}));
|
|
1286
|
+
},
|
|
1287
|
+
onBlur: () => applyContextInput(entry),
|
|
1288
|
+
onKeyDown: (event) => {
|
|
1289
|
+
if (event.key === "Enter") event.currentTarget.blur();
|
|
1290
|
+
}
|
|
1291
|
+
}),
|
|
1292
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1293
|
+
type: "button",
|
|
1294
|
+
disabled: readonly || busy,
|
|
1295
|
+
onClick: () => clearContext(entry),
|
|
1296
|
+
style: {
|
|
1297
|
+
...controlStyle,
|
|
1298
|
+
cursor: readonly || busy ? "default" : "pointer",
|
|
1299
|
+
opacity: readonly || busy ? .5 : 1
|
|
1300
|
+
},
|
|
1301
|
+
children: t("card.capabilities.contextClear")
|
|
1302
|
+
})
|
|
1303
|
+
]
|
|
1304
|
+
}),
|
|
1305
|
+
contextError[key] !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1306
|
+
style: {
|
|
1307
|
+
margin: 0,
|
|
1308
|
+
fontSize: "12px",
|
|
1309
|
+
lineHeight: "18px",
|
|
1310
|
+
color: "var(--dsw-alias-danger, #e5484d)"
|
|
1311
|
+
},
|
|
1312
|
+
children: contextError[key]
|
|
1313
|
+
}) : null
|
|
1314
|
+
]
|
|
1315
|
+
})
|
|
1037
1316
|
})
|
|
1038
1317
|
]
|
|
1039
1318
|
}) : null] }, key);
|
|
1040
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1041
|
-
style: {
|
|
1042
|
-
...hintStyle,
|
|
1043
|
-
padding: "8px 10px"
|
|
1044
|
-
},
|
|
1045
|
-
children: t("card.capabilities.notTakenOver")
|
|
1046
1319
|
}) : null]
|
|
1047
1320
|
}, providerId);
|
|
1048
1321
|
}),
|
|
1049
1322
|
readonly ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1050
|
-
style: hintStyle,
|
|
1323
|
+
style: hintStyle$1,
|
|
1051
1324
|
children: t("card.readonly")
|
|
1052
1325
|
}) : null
|
|
1053
1326
|
]
|
|
@@ -1059,7 +1332,7 @@ window.__ModuleLoader__.load({
|
|
|
1059
1332
|
* default so the plugin tab stays a tidy list of drawers.
|
|
1060
1333
|
* @param props - locale copy and the injected scopes.
|
|
1061
1334
|
*/
|
|
1062
|
-
function ThinkingLevelsCard({ t, scope, piAiScope
|
|
1335
|
+
function ThinkingLevelsCard({ t, scope, piAiScope }) {
|
|
1063
1336
|
const [open, setOpen] = (0, react.useState)(false);
|
|
1064
1337
|
const snapshot = (0, react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
|
|
1065
1338
|
const unavailable = snapshot.status === "unavailable";
|
|
@@ -1147,7 +1420,7 @@ window.__ModuleLoader__.load({
|
|
|
1147
1420
|
style: rowStyle,
|
|
1148
1421
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1149
1422
|
htmlFor: "plugin-config-thinking-levels-level",
|
|
1150
|
-
style: labelStyle,
|
|
1423
|
+
style: labelStyle$1,
|
|
1151
1424
|
children: t("card.level")
|
|
1152
1425
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
1153
1426
|
id: "plugin-config-thinking-levels-level",
|
|
@@ -1167,7 +1440,7 @@ window.__ModuleLoader__.load({
|
|
|
1167
1440
|
style: rowStyle,
|
|
1168
1441
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1169
1442
|
htmlFor: "plugin-config-thinking-levels-enabled",
|
|
1170
|
-
style: labelStyle,
|
|
1443
|
+
style: labelStyle$1,
|
|
1171
1444
|
children: t("card.enabled")
|
|
1172
1445
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1173
1446
|
id: "plugin-config-thinking-levels-enabled",
|
|
@@ -1183,7 +1456,7 @@ window.__ModuleLoader__.load({
|
|
|
1183
1456
|
style: rowStyle,
|
|
1184
1457
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1185
1458
|
htmlFor: "plugin-config-thinking-levels-downgrade",
|
|
1186
|
-
style: labelStyle,
|
|
1459
|
+
style: labelStyle$1,
|
|
1187
1460
|
children: t("card.allowDowngrade")
|
|
1188
1461
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1189
1462
|
id: "plugin-config-thinking-levels-downgrade",
|
|
@@ -1199,7 +1472,7 @@ window.__ModuleLoader__.load({
|
|
|
1199
1472
|
style: rowStyle,
|
|
1200
1473
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1201
1474
|
htmlFor: "plugin-config-thinking-levels-upgrade",
|
|
1202
|
-
style: labelStyle,
|
|
1475
|
+
style: labelStyle$1,
|
|
1203
1476
|
children: t("card.allowUpgrade")
|
|
1204
1477
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1205
1478
|
id: "plugin-config-thinking-levels-upgrade",
|
|
@@ -1221,7 +1494,6 @@ window.__ModuleLoader__.load({
|
|
|
1221
1494
|
}),
|
|
1222
1495
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelCapabilities, {
|
|
1223
1496
|
scope: piAiScope,
|
|
1224
|
-
takeoverScope,
|
|
1225
1497
|
t,
|
|
1226
1498
|
readonly
|
|
1227
1499
|
})
|
|
@@ -1230,6 +1502,380 @@ window.__ModuleLoader__.load({
|
|
|
1230
1502
|
});
|
|
1231
1503
|
}
|
|
1232
1504
|
//#endregion
|
|
1505
|
+
//#region src/client/context-quick.tsx
|
|
1506
|
+
/**
|
|
1507
|
+
* Context-window quick control for the composer tool row
|
|
1508
|
+
* (`conversation.input.right`, the seat just left of the send button and next
|
|
1509
|
+
* to the model/effort select).
|
|
1510
|
+
*
|
|
1511
|
+
* It targets the CURRENT session's active model (read from the trajectory
|
|
1512
|
+
* view's latest assistant request) and lets the user cap that model's context
|
|
1513
|
+
* window on the fly — presets, a custom integer, or clear to restore.
|
|
1514
|
+
*
|
|
1515
|
+
* Two model families are served, each with its own writable settings
|
|
1516
|
+
* namespace (both consumed live by `resolveModelInfo(...).context.contextWindow`,
|
|
1517
|
+
* so a write takes effect on the next request without a restart):
|
|
1518
|
+
* - Custom gateways (`llm-pi-ai` providers): writes the model entry's
|
|
1519
|
+
* `contextWindow` under `providers[provider].models[i]`.
|
|
1520
|
+
* - Official DeepSeek models (`deepseek-official`, the `llm-deepseek`
|
|
1521
|
+
* namespace): writes the catalog model's `contextWindow` when the model is
|
|
1522
|
+
* listed, otherwise caps via `defaultContextWindow`.
|
|
1523
|
+
*
|
|
1524
|
+
* Kept dependency-free beyond react + the injected scopes: the trigger is a
|
|
1525
|
+
* plain pill, the popover renders inline (absolutely positioned above the tool
|
|
1526
|
+
* row), and validation reuses the shared `validateContextWindow`.
|
|
1527
|
+
*/
|
|
1528
|
+
/** The official DeepSeek provider route owned by the llm-deepseek adapter. */
|
|
1529
|
+
const DEEPSEEK_PROVIDER = "deepseek-official";
|
|
1530
|
+
/** llm-deepseek's native default context capacity (DEFAULT_CONTEXT_WINDOW). */
|
|
1531
|
+
const DEEPSEEK_DEFAULT_WINDOW = 1e6;
|
|
1532
|
+
const pillStyle = {
|
|
1533
|
+
display: "inline-flex",
|
|
1534
|
+
alignItems: "center",
|
|
1535
|
+
gap: "4px",
|
|
1536
|
+
height: "24px",
|
|
1537
|
+
padding: "0 8px",
|
|
1538
|
+
background: "var(--dsw-alias-bg-surface, #fff)",
|
|
1539
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
1540
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
1541
|
+
borderRadius: "6px",
|
|
1542
|
+
fontSize: "11px",
|
|
1543
|
+
lineHeight: "16px",
|
|
1544
|
+
fontFamily: "var(--ds-font-family-code, monospace)",
|
|
1545
|
+
cursor: "pointer",
|
|
1546
|
+
whiteSpace: "nowrap"
|
|
1547
|
+
};
|
|
1548
|
+
const popStyle = {
|
|
1549
|
+
position: "absolute",
|
|
1550
|
+
bottom: "calc(100% + 8px)",
|
|
1551
|
+
right: "0",
|
|
1552
|
+
zIndex: 1200,
|
|
1553
|
+
minWidth: "240px",
|
|
1554
|
+
padding: "10px",
|
|
1555
|
+
background: "var(--dsw-alias-bg-layer-3, rgba(127,127,127,0.05))",
|
|
1556
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1557
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
1558
|
+
borderRadius: "10px",
|
|
1559
|
+
boxShadow: "0 8px 28px rgba(0,0,0,0.18)",
|
|
1560
|
+
display: "flex",
|
|
1561
|
+
flexDirection: "column",
|
|
1562
|
+
gap: "8px"
|
|
1563
|
+
};
|
|
1564
|
+
const backdropStyle = {
|
|
1565
|
+
position: "fixed",
|
|
1566
|
+
inset: 0,
|
|
1567
|
+
zIndex: 1199
|
|
1568
|
+
};
|
|
1569
|
+
const labelStyle = {
|
|
1570
|
+
margin: 0,
|
|
1571
|
+
fontSize: "12px",
|
|
1572
|
+
lineHeight: "18px",
|
|
1573
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
1574
|
+
};
|
|
1575
|
+
const hintStyle = {
|
|
1576
|
+
margin: 0,
|
|
1577
|
+
fontSize: "11px",
|
|
1578
|
+
lineHeight: "16px",
|
|
1579
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
1580
|
+
};
|
|
1581
|
+
const presetRowStyle = {
|
|
1582
|
+
display: "flex",
|
|
1583
|
+
flexWrap: "wrap",
|
|
1584
|
+
gap: "5px"
|
|
1585
|
+
};
|
|
1586
|
+
const presetStyle = {
|
|
1587
|
+
height: "22px",
|
|
1588
|
+
padding: "0 8px",
|
|
1589
|
+
background: "var(--dsw-alias-bg-surface, #fff)",
|
|
1590
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
1591
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
1592
|
+
borderRadius: "5px",
|
|
1593
|
+
fontSize: "11px",
|
|
1594
|
+
lineHeight: "16px",
|
|
1595
|
+
fontFamily: "var(--ds-font-family-code, monospace)",
|
|
1596
|
+
cursor: "pointer"
|
|
1597
|
+
};
|
|
1598
|
+
const inputStyle = {
|
|
1599
|
+
flex: "1 1 auto",
|
|
1600
|
+
minWidth: "0",
|
|
1601
|
+
background: "var(--dsw-alias-bg-surface, #fff)",
|
|
1602
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1603
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
1604
|
+
borderRadius: "5px",
|
|
1605
|
+
padding: "3px 8px",
|
|
1606
|
+
fontSize: "12px",
|
|
1607
|
+
fontFamily: "var(--ds-font-family-code, monospace)",
|
|
1608
|
+
boxSizing: "border-box"
|
|
1609
|
+
};
|
|
1610
|
+
const actionStyle = {
|
|
1611
|
+
height: "24px",
|
|
1612
|
+
padding: "0 10px",
|
|
1613
|
+
background: "var(--dsw-alias-bg-surface, #fff)",
|
|
1614
|
+
color: "var(--dsw-alias-label-primary)",
|
|
1615
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
1616
|
+
borderRadius: "5px",
|
|
1617
|
+
fontSize: "12px",
|
|
1618
|
+
lineHeight: "18px",
|
|
1619
|
+
cursor: "pointer"
|
|
1620
|
+
};
|
|
1621
|
+
const errorStyle = {
|
|
1622
|
+
margin: 0,
|
|
1623
|
+
fontSize: "11px",
|
|
1624
|
+
lineHeight: "16px",
|
|
1625
|
+
color: "var(--dsw-alias-danger, #e5484d)"
|
|
1626
|
+
};
|
|
1627
|
+
/** The user-layer `providers` value of the llm-pi-ai namespace, when present. */
|
|
1628
|
+
function providersOf(snapshot) {
|
|
1629
|
+
if (typeof snapshot !== "object" || snapshot === null) return {};
|
|
1630
|
+
const user = snapshot.user;
|
|
1631
|
+
if (typeof user !== "object" || user === null || Array.isArray(user)) return {};
|
|
1632
|
+
const providers = user["providers"];
|
|
1633
|
+
return typeof providers === "object" && providers !== null && !Array.isArray(providers) ? providers : {};
|
|
1634
|
+
}
|
|
1635
|
+
/** The user-layer `models`/`defaultContextWindow` of the llm-deepseek namespace. */
|
|
1636
|
+
function deepseekSectionOf(snapshot) {
|
|
1637
|
+
if (typeof snapshot !== "object" || snapshot === null) return {};
|
|
1638
|
+
const user = snapshot.user;
|
|
1639
|
+
if (typeof user !== "object" || user === null || Array.isArray(user)) return {};
|
|
1640
|
+
const section = user;
|
|
1641
|
+
const models = Array.isArray(section.models) ? section.models.filter((model) => typeof model === "object" && model !== null && !Array.isArray(model)) : void 0;
|
|
1642
|
+
const defaultContextWindow = typeof section.defaultContextWindow === "number" ? section.defaultContextWindow : void 0;
|
|
1643
|
+
return {
|
|
1644
|
+
...models === void 0 ? {} : { models },
|
|
1645
|
+
...defaultContextWindow === void 0 ? {} : { defaultContextWindow }
|
|
1646
|
+
};
|
|
1647
|
+
}
|
|
1648
|
+
/**
|
|
1649
|
+
* The current session's active model, reconstructed from the trajectory view's
|
|
1650
|
+
* latest assistant request prompt config. Absent for a blank session (no
|
|
1651
|
+
* request yet) — the control then renders read-only/disabled.
|
|
1652
|
+
*/
|
|
1653
|
+
function activeModelOf(session) {
|
|
1654
|
+
if (typeof session !== "object" || session === null) return void 0;
|
|
1655
|
+
const requests = (session.views?.get?.("trajectory"))?.requests ?? [];
|
|
1656
|
+
for (let index = requests.length - 1; index >= 0; index -= 1) {
|
|
1657
|
+
const config = requests[index]?.prompt?.config;
|
|
1658
|
+
if (requests[index]?.purpose === "assistant" && typeof config?.provider === "string" && typeof config?.model === "string") return {
|
|
1659
|
+
provider: config.provider,
|
|
1660
|
+
model: config.model
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
/** One model entry's declared contextWindow, when present. */
|
|
1665
|
+
function contextWindowOf(model) {
|
|
1666
|
+
const value = model["contextWindow"];
|
|
1667
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : void 0;
|
|
1668
|
+
}
|
|
1669
|
+
/**
|
|
1670
|
+
* The composer context-window quick control: a pill showing the current
|
|
1671
|
+
* session model's context window that opens an inline popover with preset
|
|
1672
|
+
* quick-picks, a custom integer input and a clear (restore default) action.
|
|
1673
|
+
* Custom gateways and official DeepSeek models are both supported (see module
|
|
1674
|
+
* doc for the namespace each writes).
|
|
1675
|
+
* @param props - injected scopes, session standard seats, copy.
|
|
1676
|
+
*/
|
|
1677
|
+
function ContextQuick({ useSession, piAiScope, deepseekScope, t }) {
|
|
1678
|
+
const active = activeModelOf(useSession());
|
|
1679
|
+
const official = active !== void 0 && active.provider === DEEPSEEK_PROVIDER;
|
|
1680
|
+
const piSnapshot = (0, react.useSyncExternalStore)((listener) => piAiScope.subscribe(listener), () => piAiScope.getSnapshot());
|
|
1681
|
+
const dsSnapshot = (0, react.useSyncExternalStore)((listener) => deepseekScope.subscribe(listener), () => deepseekScope.getSnapshot());
|
|
1682
|
+
const snapshot = official ? dsSnapshot : piSnapshot;
|
|
1683
|
+
const readonly = snapshot.status === "unavailable" || !snapshot.writable;
|
|
1684
|
+
const providers = official ? {} : providersOf(piSnapshot);
|
|
1685
|
+
const dsSection = official ? deepseekSectionOf(dsSnapshot) : void 0;
|
|
1686
|
+
let currentWindow;
|
|
1687
|
+
let writableTarget = false;
|
|
1688
|
+
if (official && active !== void 0) {
|
|
1689
|
+
const models = dsSection?.models ?? [];
|
|
1690
|
+
const index = models.findIndex((model) => model["id"] === active.model);
|
|
1691
|
+
currentWindow = index >= 0 ? contextWindowOf(models[index]) : void 0;
|
|
1692
|
+
if (currentWindow === void 0) currentWindow = dsSection?.defaultContextWindow;
|
|
1693
|
+
writableTarget = true;
|
|
1694
|
+
} else if (active !== void 0) {
|
|
1695
|
+
const profile = providers[active.provider];
|
|
1696
|
+
const model = profile !== void 0 && Array.isArray(profile.models) ? profile.models.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === active.model) : void 0;
|
|
1697
|
+
currentWindow = model === void 0 ? void 0 : contextWindowOf(model);
|
|
1698
|
+
writableTarget = model !== void 0;
|
|
1699
|
+
}
|
|
1700
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
1701
|
+
const [raw, setRaw] = (0, react.useState)("");
|
|
1702
|
+
const [error, setError] = (0, react.useState)(null);
|
|
1703
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
1704
|
+
const disabled = readonly || busy || active === void 0 || !writableTarget;
|
|
1705
|
+
/** Commit (or delete) the active model's context window. */
|
|
1706
|
+
const commitWindow = (value) => {
|
|
1707
|
+
if (active === void 0 || snapshot.status !== "ready" || !writableTarget) return;
|
|
1708
|
+
setBusy(true);
|
|
1709
|
+
if (official) {
|
|
1710
|
+
const models = (deepseekSectionOf(dsSnapshot).models ?? []).map((model) => ({ ...model }));
|
|
1711
|
+
const index = models.findIndex((model) => model["id"] === active.model);
|
|
1712
|
+
(index >= 0 ? deepseekScope.set("models", models.map((model, at) => {
|
|
1713
|
+
if (at !== index) return model;
|
|
1714
|
+
if (value === void 0) {
|
|
1715
|
+
const rest = { ...model };
|
|
1716
|
+
delete rest["contextWindow"];
|
|
1717
|
+
return rest;
|
|
1718
|
+
}
|
|
1719
|
+
return {
|
|
1720
|
+
...model,
|
|
1721
|
+
contextWindow: value
|
|
1722
|
+
};
|
|
1723
|
+
})) : deepseekScope.set("defaultContextWindow", value === void 0 ? DEEPSEEK_DEFAULT_WINDOW : value)).then(() => {
|
|
1724
|
+
setBusy(false);
|
|
1725
|
+
}).catch(() => {
|
|
1726
|
+
setBusy(false);
|
|
1727
|
+
});
|
|
1728
|
+
return;
|
|
1729
|
+
}
|
|
1730
|
+
const next = structuredClone(providers);
|
|
1731
|
+
const entry = next[active.provider]?.models?.find((candidate) => typeof candidate === "object" && candidate !== null && candidate["id"] === active.model);
|
|
1732
|
+
if (entry === void 0) {
|
|
1733
|
+
setBusy(false);
|
|
1734
|
+
return;
|
|
1735
|
+
}
|
|
1736
|
+
if (value === void 0) delete entry["contextWindow"];
|
|
1737
|
+
else entry["contextWindow"] = value;
|
|
1738
|
+
piAiScope.set("providers", next).then(() => {
|
|
1739
|
+
setBusy(false);
|
|
1740
|
+
}).catch(() => {
|
|
1741
|
+
setBusy(false);
|
|
1742
|
+
});
|
|
1743
|
+
};
|
|
1744
|
+
/** Pick one preset immediately. */
|
|
1745
|
+
const pickPreset = (value) => {
|
|
1746
|
+
setRaw(String(value));
|
|
1747
|
+
setError(null);
|
|
1748
|
+
commitWindow(value);
|
|
1749
|
+
};
|
|
1750
|
+
/** Validate and commit the custom input; empty clears. */
|
|
1751
|
+
const applyCustom = () => {
|
|
1752
|
+
const trimmed = raw.trim();
|
|
1753
|
+
if (trimmed === "") {
|
|
1754
|
+
setError(null);
|
|
1755
|
+
commitWindow(void 0);
|
|
1756
|
+
return;
|
|
1757
|
+
}
|
|
1758
|
+
const validation = validateContextWindow(trimmed);
|
|
1759
|
+
if (!validation.ok) {
|
|
1760
|
+
setError(t(validation.reason === "integer" ? "input.context.integer" : "input.context.range"));
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
setError(null);
|
|
1764
|
+
commitWindow(validation.value);
|
|
1765
|
+
};
|
|
1766
|
+
const triggerLabel = currentWindow === void 0 ? t("input.context.unset") : formatContextWindow(currentWindow);
|
|
1767
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1768
|
+
style: {
|
|
1769
|
+
position: "relative",
|
|
1770
|
+
display: "inline-flex"
|
|
1771
|
+
},
|
|
1772
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1773
|
+
type: "button",
|
|
1774
|
+
disabled,
|
|
1775
|
+
style: {
|
|
1776
|
+
...pillStyle,
|
|
1777
|
+
cursor: disabled ? "default" : "pointer",
|
|
1778
|
+
opacity: disabled ? .55 : 1
|
|
1779
|
+
},
|
|
1780
|
+
title: active === void 0 ? t("input.context.noModel") : `${active.provider}/${active.model}`,
|
|
1781
|
+
onClick: () => {
|
|
1782
|
+
setOpen((current) => !current);
|
|
1783
|
+
},
|
|
1784
|
+
children: triggerLabel
|
|
1785
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1786
|
+
style: backdropStyle,
|
|
1787
|
+
onClick: () => setOpen(false)
|
|
1788
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1789
|
+
style: popStyle,
|
|
1790
|
+
role: "dialog",
|
|
1791
|
+
"aria-label": t("input.context.title"),
|
|
1792
|
+
children: [
|
|
1793
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("p", {
|
|
1794
|
+
style: labelStyle,
|
|
1795
|
+
children: [t("input.context.title"), active !== void 0 ? ` · ${active.provider}/${active.model}` : ""]
|
|
1796
|
+
}),
|
|
1797
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1798
|
+
style: hintStyle,
|
|
1799
|
+
children: t("input.context.globalHint")
|
|
1800
|
+
}),
|
|
1801
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1802
|
+
style: presetRowStyle,
|
|
1803
|
+
children: CONTEXT_WINDOW_PRESETS.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1804
|
+
type: "button",
|
|
1805
|
+
disabled,
|
|
1806
|
+
style: {
|
|
1807
|
+
...presetStyle,
|
|
1808
|
+
cursor: disabled ? "default" : "pointer",
|
|
1809
|
+
opacity: disabled ? .5 : 1
|
|
1810
|
+
},
|
|
1811
|
+
onClick: () => pickPreset(preset.value),
|
|
1812
|
+
children: preset.label
|
|
1813
|
+
}, preset.value))
|
|
1814
|
+
}),
|
|
1815
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1816
|
+
style: {
|
|
1817
|
+
display: "flex",
|
|
1818
|
+
gap: "6px",
|
|
1819
|
+
alignItems: "center"
|
|
1820
|
+
},
|
|
1821
|
+
children: [
|
|
1822
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1823
|
+
type: "text",
|
|
1824
|
+
value: raw,
|
|
1825
|
+
disabled,
|
|
1826
|
+
placeholder: t("input.context.customPlaceholder"),
|
|
1827
|
+
style: inputStyle,
|
|
1828
|
+
onChange: (event) => {
|
|
1829
|
+
setRaw(event.currentTarget.value);
|
|
1830
|
+
},
|
|
1831
|
+
onKeyDown: (event) => {
|
|
1832
|
+
if (event.key === "Enter") {
|
|
1833
|
+
setOpen(false);
|
|
1834
|
+
applyCustom();
|
|
1835
|
+
}
|
|
1836
|
+
}
|
|
1837
|
+
}),
|
|
1838
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1839
|
+
type: "button",
|
|
1840
|
+
disabled,
|
|
1841
|
+
style: {
|
|
1842
|
+
...actionStyle,
|
|
1843
|
+
cursor: disabled ? "default" : "pointer",
|
|
1844
|
+
opacity: disabled ? .5 : 1
|
|
1845
|
+
},
|
|
1846
|
+
onClick: () => {
|
|
1847
|
+
setOpen(false);
|
|
1848
|
+
applyCustom();
|
|
1849
|
+
},
|
|
1850
|
+
children: t("input.context.apply")
|
|
1851
|
+
}),
|
|
1852
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1853
|
+
type: "button",
|
|
1854
|
+
disabled,
|
|
1855
|
+
style: {
|
|
1856
|
+
...actionStyle,
|
|
1857
|
+
cursor: disabled ? "default" : "pointer",
|
|
1858
|
+
opacity: disabled ? .5 : 1
|
|
1859
|
+
},
|
|
1860
|
+
onClick: () => {
|
|
1861
|
+
setOpen(false);
|
|
1862
|
+
setRaw("");
|
|
1863
|
+
setError(null);
|
|
1864
|
+
commitWindow(void 0);
|
|
1865
|
+
},
|
|
1866
|
+
children: t("input.context.clear")
|
|
1867
|
+
})
|
|
1868
|
+
]
|
|
1869
|
+
}),
|
|
1870
|
+
error !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1871
|
+
style: errorStyle,
|
|
1872
|
+
children: error
|
|
1873
|
+
})
|
|
1874
|
+
]
|
|
1875
|
+
})] }) : null]
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
//#endregion
|
|
1233
1879
|
//#region src/client/index.ts
|
|
1234
1880
|
/** The settings namespace the host half registers (kept in lockstep with src/index.ts). */
|
|
1235
1881
|
const THINKING_LEVELS_NS = "thinking-levels";
|
|
@@ -1259,12 +1905,24 @@ window.__ModuleLoader__.load({
|
|
|
1259
1905
|
inject: () => {
|
|
1260
1906
|
return {
|
|
1261
1907
|
scope: ctx.settingsScope.bind({ namespace: THINKING_LEVELS_NS }),
|
|
1262
|
-
piAiScope: ctx.settingsScope.bind({ namespace: "llm-pi-ai" })
|
|
1263
|
-
takeoverScope: ctx.settingsScope.bind({ namespace: "llm-openai-completions" })
|
|
1908
|
+
piAiScope: ctx.settingsScope.bind({ namespace: "llm-pi-ai" })
|
|
1264
1909
|
};
|
|
1265
1910
|
}
|
|
1266
1911
|
}, ThinkingLevelsCard);
|
|
1267
1912
|
});
|
|
1913
|
+
ctx.slots.inject("conversation.input.right", function* () {
|
|
1914
|
+
yield ctx.slots.register({
|
|
1915
|
+
name: "conversation.input.right",
|
|
1916
|
+
id: "context-window-quick",
|
|
1917
|
+
locale: NS,
|
|
1918
|
+
inject: () => {
|
|
1919
|
+
return {
|
|
1920
|
+
piAiScope: ctx.settingsScope.bind({ namespace: "llm-pi-ai" }),
|
|
1921
|
+
deepseekScope: ctx.settingsScope.bind({ namespace: "llm-deepseek" })
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1924
|
+
}, ContextQuick);
|
|
1925
|
+
});
|
|
1268
1926
|
}
|
|
1269
1927
|
//#endregion
|
|
1270
1928
|
exports.apply = apply;
|