dsh-thinking-levels 0.4.1 → 0.7.0-beta.1
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 -0
- package/CHANGELOG.ko.md +117 -0
- package/CHANGELOG.md +126 -0
- package/INSTALL.ja.md +163 -0
- package/INSTALL.ko.md +163 -0
- package/INSTALL.md +163 -0
- package/INSTALL.zh.md +163 -0
- package/LICENSE +21 -0
- package/README.ja.md +168 -0
- package/README.ko.md +168 -0
- package/README.md +222 -108
- package/README.zh.md +174 -108
- package/lib/client.js +1801 -94
- 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 +41 -3
- package/lib/index.js +227 -26
- package/lib/takeover-sync.d.ts +123 -0
- package/lib/takeover-sync.js +237 -0
- package/lib/thinking-level.d.ts +106 -16
- package/lib/thinking-level.js +126 -13
- package/package.json +88 -79
package/lib/client.js
CHANGED
|
@@ -7,41 +7,338 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
let react = require("react");
|
|
8
8
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
9
9
|
//#region src/client/locales.ts
|
|
10
|
-
/** `thinking-levels` client dictionaries. */
|
|
10
|
+
/** `thinking-levels` client dictionaries (zh / en / ja / ko). */
|
|
11
11
|
/** Dictionary namespace owned by this plugin. */
|
|
12
12
|
const NS = "thinking-levels";
|
|
13
13
|
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
14
14
|
const zh = {
|
|
15
15
|
"card.title": "思考档位",
|
|
16
|
-
"card.description": "在模型选择器中可选 Auto(mask):按工具调用历史自动在 low / high / max 间调度后提交 API
|
|
16
|
+
"card.description": "在模型选择器中可选 Auto(mask):按工具调用历史自动在 low / high / max 间调度后提交 API。此处配置默认档位、调度边界与模型能力(档位 → 网关线上值映射)。",
|
|
17
17
|
"card.level": "默认档位",
|
|
18
18
|
"card.level.off": "off — 关闭思考(仅手动,永不自动选择)",
|
|
19
|
+
"card.level.on": "on — 开启思考(仅 toggle 型模型;只发 enable_thinking,不发 effort)",
|
|
20
|
+
"card.level.minimal": "minimal — 最低(极轻任务)",
|
|
19
21
|
"card.level.low": "low — 低(简单任务,廉价轮保持廉价)",
|
|
22
|
+
"card.level.medium": "medium — 中",
|
|
20
23
|
"card.level.high": "high — 高(官方默认)",
|
|
24
|
+
"card.level.xhigh": "xhigh — 特高",
|
|
21
25
|
"card.level.max": "max — 最大(重任务)",
|
|
22
26
|
"card.level.auto": "auto — 按工具历史自动调度(默认)",
|
|
23
27
|
"card.enabled": "启用",
|
|
24
28
|
"card.allowDowngrade": "允许降档(auto 可降至 low)",
|
|
25
29
|
"card.allowUpgrade": "允许升档(auto 可升至 max)",
|
|
26
30
|
"card.unavailable": "设置命名空间不可用:请确认 dsh-thinking-levels 已装配进 profile。",
|
|
27
|
-
"card.readonly": "只读"
|
|
31
|
+
"card.readonly": "只读",
|
|
32
|
+
"card.capabilities": "模型能力(llm-pi-ai 自定义提供方)",
|
|
33
|
+
"card.capabilities.hint": "直接读写 llm-pi-ai 配置:勾选档位并填写发送给网关的线上值(例如 high → ultra);off 留空表示不发送。视觉决定图片输入;思考开关决定 enable_thinking 置位;thinkingFormat 决定 wire 序列化格式。",
|
|
34
|
+
"card.capabilities.empty": "llm-pi-ai 中没有已配置模型的自定义提供方。请先在「设置 → 模型」添加提供方与模型。",
|
|
35
|
+
"card.capabilities.unavailable": "llm-pi-ai 设置命名空间不可用。",
|
|
36
|
+
"card.capabilities.none": "(无模型)",
|
|
37
|
+
"card.capabilities.search": "搜索模型(名称或 ID)…",
|
|
38
|
+
"card.capabilities.noMatches": "没有匹配的模型",
|
|
39
|
+
"card.capabilities.quickSettings": "一键设置",
|
|
40
|
+
"card.capabilities.presetOfficial": "应用到全部:Off / High / Max(官方 DeepSeek 风格)",
|
|
41
|
+
"card.capabilities.presetGeneric": "应用到全部:Off / Low / Medium / High(通用)",
|
|
42
|
+
"card.capabilities.vendor": "提供方",
|
|
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
|
+
"card.capabilities.expandProvider": "展开提供方",
|
|
46
|
+
"card.capabilities.collapseProvider": "收起提供方",
|
|
47
|
+
"card.capabilities.openModelSettings": "打开模型设置",
|
|
48
|
+
"card.capabilities.closeModelSettings": "收起模型设置",
|
|
49
|
+
"card.capabilities.vision": "视觉模型",
|
|
50
|
+
"card.capabilities.thinking": "思考模型",
|
|
51
|
+
"card.capabilities.supportsEffort": "支持 think effort",
|
|
52
|
+
"card.capabilities.efforts": "思考档位(勾选后填写线上值)",
|
|
53
|
+
"card.capabilities.wirePlaceholder": "线上值,如 ultra",
|
|
54
|
+
"card.capabilities.offPlaceholder": "留空 = 不发送",
|
|
55
|
+
"card.capabilities.atLeastThinking": "至少需要一个思考档位(off 除外)",
|
|
56
|
+
"card.capabilities.applyLevel": "应用此档位",
|
|
57
|
+
"card.capabilities.restoreDefault": "恢复默认档位",
|
|
58
|
+
"card.capabilities.unsaved": "未保存",
|
|
59
|
+
"card.capabilities.saveChanges": "保存更改",
|
|
60
|
+
"card.capabilities.saved": "已保存",
|
|
61
|
+
"card.capabilities.thinkingFormat": "思考格式",
|
|
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 之间",
|
|
78
|
+
"card.capabilities.failed": "保存失败:配置被拒绝或冲突,请检查值。"
|
|
28
79
|
};
|
|
29
80
|
/** English dictionary (keys mirror zh). */
|
|
30
81
|
const en = {
|
|
31
82
|
"card.title": "Thinking Levels",
|
|
32
|
-
"card.description": "Pick Auto in the model selector: the plugin schedules low / high / max per tool round before submitting the API effort. Here you configure the default level and
|
|
83
|
+
"card.description": "Pick Auto in the model selector: the plugin schedules low / high / max per tool round before submitting the API effort. Here you configure the default level, scheduler bounds, and per-model capabilities (level → gateway wire value mapping).",
|
|
33
84
|
"card.level": "Default level",
|
|
34
85
|
"card.level.off": "off — disable thinking (manual only, never auto-picked)",
|
|
86
|
+
"card.level.on": "on — enable thinking (toggle-only models only; sends enable_thinking, never an effort)",
|
|
87
|
+
"card.level.minimal": "minimal — least (very light tasks)",
|
|
35
88
|
"card.level.low": "low — cheap rounds stay cheap",
|
|
89
|
+
"card.level.medium": "medium — medium",
|
|
36
90
|
"card.level.high": "high — the official default",
|
|
91
|
+
"card.level.xhigh": "xhigh — extra high",
|
|
37
92
|
"card.level.max": "max — heavy work",
|
|
38
93
|
"card.level.auto": "auto — schedule from tool history (default)",
|
|
39
94
|
"card.enabled": "Enabled",
|
|
40
95
|
"card.allowDowngrade": "Allow downgrade (auto may drop to low)",
|
|
41
96
|
"card.allowUpgrade": "Allow upgrade (auto may lift to max)",
|
|
42
97
|
"card.unavailable": "Settings namespace unavailable: make sure dsh-thinking-levels is assembled into this profile.",
|
|
43
|
-
"card.readonly": "Read-only"
|
|
98
|
+
"card.readonly": "Read-only",
|
|
99
|
+
"card.capabilities": "Model capabilities (llm-pi-ai custom providers)",
|
|
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.",
|
|
101
|
+
"card.capabilities.empty": "No custom provider has models configured in llm-pi-ai. Add a provider and models under Settings → Models first.",
|
|
102
|
+
"card.capabilities.unavailable": "The llm-pi-ai settings namespace is unavailable.",
|
|
103
|
+
"card.capabilities.none": "(no models)",
|
|
104
|
+
"card.capabilities.search": "Search models by name or ID…",
|
|
105
|
+
"card.capabilities.noMatches": "No matching models",
|
|
106
|
+
"card.capabilities.quickSettings": "Quick settings",
|
|
107
|
+
"card.capabilities.presetOfficial": "Apply to all: Off / High / Max (official DeepSeek style)",
|
|
108
|
+
"card.capabilities.presetGeneric": "Apply to all: Off / Low / Medium / High (generic)",
|
|
109
|
+
"card.capabilities.vendor": "Provider",
|
|
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.",
|
|
112
|
+
"card.capabilities.expandProvider": "Expand provider",
|
|
113
|
+
"card.capabilities.collapseProvider": "Collapse provider",
|
|
114
|
+
"card.capabilities.openModelSettings": "Open model settings",
|
|
115
|
+
"card.capabilities.closeModelSettings": "Collapse model settings",
|
|
116
|
+
"card.capabilities.vision": "Vision model",
|
|
117
|
+
"card.capabilities.thinking": "Thinking model",
|
|
118
|
+
"card.capabilities.supportsEffort": "Supports think effort",
|
|
119
|
+
"card.capabilities.efforts": "Thinking effort levels (tick, then enter the wire value)",
|
|
120
|
+
"card.capabilities.wirePlaceholder": "Wire value, e.g. ultra",
|
|
121
|
+
"card.capabilities.offPlaceholder": "Empty = do not send",
|
|
122
|
+
"card.capabilities.atLeastThinking": "Select at least one thinking level (other than off)",
|
|
123
|
+
"card.capabilities.applyLevel": "Apply levels",
|
|
124
|
+
"card.capabilities.restoreDefault": "Restore defaults",
|
|
125
|
+
"card.capabilities.unsaved": "Unsaved",
|
|
126
|
+
"card.capabilities.saveChanges": "Save changes",
|
|
127
|
+
"card.capabilities.saved": "Saved",
|
|
128
|
+
"card.capabilities.thinkingFormat": "Thinking format",
|
|
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",
|
|
145
|
+
"card.capabilities.failed": "Save failed: the value was rejected or conflicted. Check it."
|
|
44
146
|
};
|
|
147
|
+
/** Japanese dictionary (keys mirror zh). */
|
|
148
|
+
const ja = {
|
|
149
|
+
"card.title": "思考レベル",
|
|
150
|
+
"card.description": "モデルセレクターで Auto(マスク)を選択すると、ツール呼び出し履歴から low / high / max を自動スケジュールして API に送信します。ここでは既定レベル、スケジューラーの境界、モデル能力(レベル → ゲートウェイ送信値のマッピング)を設定します。",
|
|
151
|
+
"card.level": "既定レベル",
|
|
152
|
+
"card.level.off": "off — 思考を無効化(手動のみ、自動選択はされません)",
|
|
153
|
+
"card.level.on": "on — 思考を有効化(トグルのみのモデル向け。enable_thinking のみ送信、effort は送信しません)",
|
|
154
|
+
"card.level.minimal": "minimal — 最小(非常に軽いタスク)",
|
|
155
|
+
"card.level.low": "low — 低(軽いラウンドは軽いまま)",
|
|
156
|
+
"card.level.medium": "medium — 中",
|
|
157
|
+
"card.level.high": "high — 高(公式既定値)",
|
|
158
|
+
"card.level.xhigh": "xhigh — 特高",
|
|
159
|
+
"card.level.max": "max — 最大(重いタスク)",
|
|
160
|
+
"card.level.auto": "auto — ツール履歴から自動スケジュール(既定)",
|
|
161
|
+
"card.enabled": "有効",
|
|
162
|
+
"card.allowDowngrade": "降格を許可(auto は low まで下げられる)",
|
|
163
|
+
"card.allowUpgrade": "昇格を許可(auto は max まで上げられる)",
|
|
164
|
+
"card.unavailable": "設定名前空間が利用できません:dsh-thinking-levels が profile に組み込まれているか確認してください。",
|
|
165
|
+
"card.readonly": "読み取り専用",
|
|
166
|
+
"card.capabilities": "モデル能力(llm-pi-ai カスタムプロバイダー)",
|
|
167
|
+
"card.capabilities.hint": "llm-pi-ai 設定を直接読み書きします:レベルにチェックを入れ、ゲートウェイに送信する値を入力(例:high → ultra)。off を空欄にすると送信しません。視覚は画像入力を決定、思考トグルは enable_thinking を制御、thinkingFormat は wire シリアライズ形式を選択します。",
|
|
168
|
+
"card.capabilities.empty": "llm-pi-ai にモデルが設定されたカスタムプロバイダーがありません。先に「設定 → モデル」でプロバイダーとモデルを追加してください。",
|
|
169
|
+
"card.capabilities.unavailable": "llm-pi-ai の設定名前空間が利用できません。",
|
|
170
|
+
"card.capabilities.none": "(モデルなし)",
|
|
171
|
+
"card.capabilities.search": "モデル名または ID で検索…",
|
|
172
|
+
"card.capabilities.noMatches": "一致するモデルがありません",
|
|
173
|
+
"card.capabilities.quickSettings": "クイック設定",
|
|
174
|
+
"card.capabilities.presetOfficial": "すべてに適用:Off / High / Max(公式 DeepSeek 形式)",
|
|
175
|
+
"card.capabilities.presetGeneric": "すべてに適用:Off / Low / Medium / High(汎用)",
|
|
176
|
+
"card.capabilities.vendor": "プロバイダー",
|
|
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 を修正。チェックを外すとフィールドを削除し継承に戻します。",
|
|
179
|
+
"card.capabilities.expandProvider": "プロバイダーを展開",
|
|
180
|
+
"card.capabilities.collapseProvider": "プロバイダーを折りたたむ",
|
|
181
|
+
"card.capabilities.openModelSettings": "モデル設定を開く",
|
|
182
|
+
"card.capabilities.closeModelSettings": "モデル設定を折りたたむ",
|
|
183
|
+
"card.capabilities.vision": "視覚モデル",
|
|
184
|
+
"card.capabilities.thinking": "思考モデル",
|
|
185
|
+
"card.capabilities.supportsEffort": "think effort をサポート",
|
|
186
|
+
"card.capabilities.efforts": "思考レベル(チェック後、送信値を入力)",
|
|
187
|
+
"card.capabilities.wirePlaceholder": "送信値(例:ultra)",
|
|
188
|
+
"card.capabilities.offPlaceholder": "空欄 = 送信しない",
|
|
189
|
+
"card.capabilities.atLeastThinking": "思考レベルを 1 つ以上選択してください(off 以外)",
|
|
190
|
+
"card.capabilities.applyLevel": "レベルを適用",
|
|
191
|
+
"card.capabilities.restoreDefault": "既定値に戻す",
|
|
192
|
+
"card.capabilities.unsaved": "未保存",
|
|
193
|
+
"card.capabilities.saveChanges": "変更を保存",
|
|
194
|
+
"card.capabilities.saved": "保存済み",
|
|
195
|
+
"card.capabilities.thinkingFormat": "思考形式",
|
|
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 の範囲で指定してください",
|
|
212
|
+
"card.capabilities.failed": "保存に失敗しました:値が拒否されたか競合しています。確認してください。"
|
|
213
|
+
};
|
|
214
|
+
/** Korean dictionary (keys mirror zh). */
|
|
215
|
+
const ko = {
|
|
216
|
+
"card.title": "사고 수준",
|
|
217
|
+
"card.description": "모델 선택기에서 Auto(마스크)를 선택하면 도구 호출 기록을 기반으로 low / high / max 를 자동 스케줄링하여 API에 제출합니다. 여기서 기본 수준, 스케줄러 경계, 모델 기능(수준 → 게이트웨이 전송 값 매핑)을 구성합니다.",
|
|
218
|
+
"card.level": "기본 수준",
|
|
219
|
+
"card.level.off": "off — 사고 비활성화(수동 전용, 자동 선택 안 됨)",
|
|
220
|
+
"card.level.on": "on — 사고 활성화(토글 전용 모델용. enable_thinking만 전송, effort는 전송하지 않음)",
|
|
221
|
+
"card.level.minimal": "minimal — 최소(매우 가벼운 작업)",
|
|
222
|
+
"card.level.low": "low — 낮음(가벼운 라운드는 가볍게 유지)",
|
|
223
|
+
"card.level.medium": "medium — 중간",
|
|
224
|
+
"card.level.high": "high — 높음(공식 기본값)",
|
|
225
|
+
"card.level.xhigh": "xhigh — 특별히 높음",
|
|
226
|
+
"card.level.max": "max — 최대(무거운 작업)",
|
|
227
|
+
"card.level.auto": "auto — 도구 기록에서 자동 스케줄링(기본값)",
|
|
228
|
+
"card.enabled": "활성화",
|
|
229
|
+
"card.allowDowngrade": "다운그레이드 허용(auto가 low까지 내릴 수 있음)",
|
|
230
|
+
"card.allowUpgrade": "업그레이드 허용(auto가 max까지 올릴 수 있음)",
|
|
231
|
+
"card.unavailable": "설정 네임스페이스를 사용할 수 없습니다: dsh-thinking-levels가 이 profile에 조립되었는지 확인하세요.",
|
|
232
|
+
"card.readonly": "읽기 전용",
|
|
233
|
+
"card.capabilities": "모델 기능(llm-pi-ai 사용자 지정 제공자)",
|
|
234
|
+
"card.capabilities.hint": "llm-pi-ai 설정을 직접 읽고 씁니다: 수준을 체크하고 게이트웨이에 보낼 값을 입력(예: high → ultra). off를 비워 두면 전송하지 않습니다. 시각은 이미지 입력을 결정하고, 사고 토글은 enable_thinking을 제어하며, thinkingFormat은 wire 직렬화 형식을 선택합니다.",
|
|
235
|
+
"card.capabilities.empty": "llm-pi-ai에 모델이 구성된 사용자 지정 제공자가 없습니다. 먼저 「설정 → 모델」에서 제공자와 모델을 추가하세요.",
|
|
236
|
+
"card.capabilities.unavailable": "llm-pi-ai 설정 네임스페이스를 사용할 수 없습니다.",
|
|
237
|
+
"card.capabilities.none": "(모델 없음)",
|
|
238
|
+
"card.capabilities.search": "모델 이름 또는 ID로 검색…",
|
|
239
|
+
"card.capabilities.noMatches": "일치하는 모델이 없습니다",
|
|
240
|
+
"card.capabilities.quickSettings": "빠른 설정",
|
|
241
|
+
"card.capabilities.presetOfficial": "전체에 적용: Off / High / Max(공식 DeepSeek 방식)",
|
|
242
|
+
"card.capabilities.presetGeneric": "전체에 적용: Off / Low / Medium / High(일반 방식)",
|
|
243
|
+
"card.capabilities.vendor": "제공자",
|
|
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 을 수정. 체크 해제 시 필드를 삭제하고 상속을 복원합니다.",
|
|
246
|
+
"card.capabilities.expandProvider": "제공자 펼치기",
|
|
247
|
+
"card.capabilities.collapseProvider": "제공자 접기",
|
|
248
|
+
"card.capabilities.openModelSettings": "모델 설정 열기",
|
|
249
|
+
"card.capabilities.closeModelSettings": "모델 설정 접기",
|
|
250
|
+
"card.capabilities.vision": "시각 모델",
|
|
251
|
+
"card.capabilities.thinking": "사고 모델",
|
|
252
|
+
"card.capabilities.supportsEffort": "think effort 지원",
|
|
253
|
+
"card.capabilities.efforts": "사고 수준(체크 후 전송 값 입력)",
|
|
254
|
+
"card.capabilities.wirePlaceholder": "전송 값(예: ultra)",
|
|
255
|
+
"card.capabilities.offPlaceholder": "비워 둠 = 전송하지 않음",
|
|
256
|
+
"card.capabilities.atLeastThinking": "사고 수준을 하나 이상 선택하세요(off 제외)",
|
|
257
|
+
"card.capabilities.applyLevel": "수준 적용",
|
|
258
|
+
"card.capabilities.restoreDefault": "기본값 복원",
|
|
259
|
+
"card.capabilities.unsaved": "저장되지 않음",
|
|
260
|
+
"card.capabilities.saveChanges": "변경 사항 저장",
|
|
261
|
+
"card.capabilities.saved": "저장됨",
|
|
262
|
+
"card.capabilities.thinkingFormat": "사고 형식",
|
|
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 사이여야 합니다",
|
|
279
|
+
"card.capabilities.failed": "저장 실패: 값이 거부되었거나 충돌합니다. 확인하세요."
|
|
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
|
+
}
|
|
45
342
|
//#endregion
|
|
46
343
|
//#region src/client/card.tsx
|
|
47
344
|
/**
|
|
@@ -49,25 +346,82 @@ window.__ModuleLoader__.load({
|
|
|
49
346
|
* dsh-thinking-levels plugin.
|
|
50
347
|
*
|
|
51
348
|
* The card binds the `thinking-levels` settings namespace through the
|
|
52
|
-
* `settingsScope` cordis service and renders its
|
|
53
|
-
* (off / low / high / max / auto) plus the
|
|
54
|
-
* change commits immediately through the scope (no
|
|
55
|
-
* is read per model request, so a committed change
|
|
56
|
-
* without a restart.
|
|
349
|
+
* `settingsScope` cordis service and renders its fields: the level picker
|
|
350
|
+
* (off / on / minimal / low / medium / high / xhigh / max / auto) plus the
|
|
351
|
+
* scheduler toggles. Every change commits immediately through the scope (no
|
|
352
|
+
* staged form): the decision is read per model request, so a committed change
|
|
353
|
+
* applies to the next request without a restart.
|
|
354
|
+
*
|
|
355
|
+
* Below the scheduler rows, a "model capabilities" block edits the
|
|
356
|
+
* `llm-pi-ai` namespace directly (read + write through the same settings
|
|
357
|
+
* transport), borrowing dsh-thinking-effort's presentation: providers group
|
|
358
|
+
* their models, each model row shows capability badges and expands into a
|
|
359
|
+
* per-level editor where a level is ticked and its gateway wire value entered
|
|
360
|
+
* (e.g. `high` → `ultra`); `off` left empty means "do not send". A search box
|
|
361
|
+
* filters models and one-click presets apply official/generic level sets to
|
|
362
|
+
* every thinking model.
|
|
57
363
|
*
|
|
58
|
-
* Kept dependency-free beyond react: the
|
|
364
|
+
* Kept dependency-free beyond react: the scopes are subscribed with
|
|
59
365
|
* `useSyncExternalStore`, and the controls are plain HTML so the client bundle
|
|
60
366
|
* needs no CSS modules and no primitives value import.
|
|
61
367
|
*/
|
|
62
|
-
/** The
|
|
368
|
+
/** The user-facing levels, in picker order: eight standard levels plus the auto scheduler sentinel. */
|
|
63
369
|
const EFFORT_OPTIONS = [
|
|
64
370
|
"off",
|
|
371
|
+
"on",
|
|
372
|
+
"minimal",
|
|
65
373
|
"low",
|
|
374
|
+
"medium",
|
|
66
375
|
"high",
|
|
376
|
+
"xhigh",
|
|
67
377
|
"max",
|
|
68
378
|
"auto"
|
|
69
379
|
];
|
|
70
|
-
/**
|
|
380
|
+
/**
|
|
381
|
+
* The levels the capability editor offers. This is the llm-pi-ai
|
|
382
|
+
* `reasoningEfforts` table-key space — pi-ai's fixed seven levels (schema
|
|
383
|
+
* rejects any other key). `on` (the enable-thinking toggle) is a selector /
|
|
384
|
+
* injection-level concept, expressed here by the `off` + `high` pair
|
|
385
|
+
* (enable_thinking false/true), so it has no table key of its own.
|
|
386
|
+
*/
|
|
387
|
+
const CAPABILITY_LEVELS = [
|
|
388
|
+
"off",
|
|
389
|
+
"minimal",
|
|
390
|
+
"low",
|
|
391
|
+
"medium",
|
|
392
|
+
"high",
|
|
393
|
+
"xhigh",
|
|
394
|
+
"max"
|
|
395
|
+
];
|
|
396
|
+
/** One-click presets, mirroring dsh-thinking-effort: official DeepSeek style and a generic set. */
|
|
397
|
+
const PRESETS = [{
|
|
398
|
+
key: "official",
|
|
399
|
+
levels: {
|
|
400
|
+
off: null,
|
|
401
|
+
high: "high",
|
|
402
|
+
max: "max"
|
|
403
|
+
}
|
|
404
|
+
}, {
|
|
405
|
+
key: "generic",
|
|
406
|
+
levels: {
|
|
407
|
+
off: null,
|
|
408
|
+
low: "low",
|
|
409
|
+
medium: "medium",
|
|
410
|
+
high: "high"
|
|
411
|
+
}
|
|
412
|
+
}];
|
|
413
|
+
/** The wire thinking formats offered (llm-pi-ai's nameable set, incl. qwen-chat-template). */
|
|
414
|
+
const THINKING_FORMATS = [
|
|
415
|
+
"openai",
|
|
416
|
+
"deepseek",
|
|
417
|
+
"openrouter",
|
|
418
|
+
"together",
|
|
419
|
+
"zai",
|
|
420
|
+
"qwen",
|
|
421
|
+
"qwen-chat-template",
|
|
422
|
+
"string-thinking",
|
|
423
|
+
"ant-ling"
|
|
424
|
+
];
|
|
71
425
|
const rowStyle = {
|
|
72
426
|
display: "flex",
|
|
73
427
|
alignItems: "center",
|
|
@@ -77,7 +431,7 @@ window.__ModuleLoader__.load({
|
|
|
77
431
|
fontSize: "13px",
|
|
78
432
|
lineHeight: "20px"
|
|
79
433
|
};
|
|
80
|
-
const labelStyle = {
|
|
434
|
+
const labelStyle$1 = {
|
|
81
435
|
margin: 0,
|
|
82
436
|
color: "var(--dsw-alias-label-primary)"
|
|
83
437
|
};
|
|
@@ -89,101 +443,1436 @@ window.__ModuleLoader__.load({
|
|
|
89
443
|
padding: "3px 8px",
|
|
90
444
|
fontSize: "13px"
|
|
91
445
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
446
|
+
const sectionStyle = {
|
|
447
|
+
marginTop: "14px",
|
|
448
|
+
paddingTop: "12px",
|
|
449
|
+
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
450
|
+
};
|
|
451
|
+
const fieldStyle = {
|
|
452
|
+
display: "flex",
|
|
453
|
+
flexDirection: "column",
|
|
454
|
+
gap: "4px"
|
|
455
|
+
};
|
|
456
|
+
const fieldLabelStyle = {
|
|
457
|
+
margin: 0,
|
|
458
|
+
fontSize: "12px",
|
|
459
|
+
lineHeight: "18px",
|
|
460
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
461
|
+
};
|
|
462
|
+
const hintStyle$1 = {
|
|
463
|
+
margin: "6px 0 0",
|
|
464
|
+
fontSize: "12px",
|
|
465
|
+
lineHeight: "18px",
|
|
466
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
467
|
+
};
|
|
468
|
+
/** Provider group shell: an outlined row grouping its models. */
|
|
469
|
+
const providerStyle = {
|
|
470
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
471
|
+
borderRadius: "8px",
|
|
472
|
+
margin: "8px 0 0",
|
|
473
|
+
overflow: "hidden"
|
|
474
|
+
};
|
|
475
|
+
const providerHeadStyle = {
|
|
476
|
+
display: "flex",
|
|
477
|
+
alignItems: "center",
|
|
478
|
+
gap: "8px",
|
|
479
|
+
padding: "7px 10px",
|
|
480
|
+
background: "var(--dsw-alias-bg-layer-2, rgba(127,127,127,0.06))"
|
|
481
|
+
};
|
|
482
|
+
const providerNameStyle = {
|
|
483
|
+
margin: 0,
|
|
484
|
+
flex: "1 1 auto",
|
|
485
|
+
minWidth: 0,
|
|
486
|
+
fontFamily: "var(--ds-font-family-code, monospace)",
|
|
487
|
+
fontSize: "12px",
|
|
488
|
+
lineHeight: "18px",
|
|
489
|
+
fontWeight: 600,
|
|
490
|
+
color: "var(--dsw-alias-label-primary)",
|
|
491
|
+
overflowWrap: "anywhere"
|
|
492
|
+
};
|
|
493
|
+
const providerBadgeStyle = {
|
|
494
|
+
margin: 0,
|
|
495
|
+
fontSize: "10px",
|
|
496
|
+
lineHeight: "16px",
|
|
497
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
498
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
499
|
+
borderRadius: "4px",
|
|
500
|
+
padding: "0 5px",
|
|
501
|
+
whiteSpace: "nowrap"
|
|
502
|
+
};
|
|
503
|
+
const iconButtonStyle = {
|
|
504
|
+
background: "none",
|
|
505
|
+
border: "none",
|
|
506
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
507
|
+
cursor: "pointer",
|
|
508
|
+
padding: "2px 4px",
|
|
509
|
+
display: "inline-flex",
|
|
510
|
+
alignItems: "center"
|
|
511
|
+
};
|
|
512
|
+
/** One model row inside a provider group. */
|
|
513
|
+
const modelRowStyle = {
|
|
514
|
+
display: "flex",
|
|
515
|
+
alignItems: "center",
|
|
516
|
+
gap: "8px",
|
|
517
|
+
padding: "7px 10px",
|
|
518
|
+
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
519
|
+
};
|
|
520
|
+
const modelIdStyle = {
|
|
521
|
+
margin: 0,
|
|
522
|
+
flex: "1 1 auto",
|
|
523
|
+
minWidth: 0,
|
|
524
|
+
fontFamily: "var(--ds-font-family-code, monospace)",
|
|
525
|
+
fontSize: "12px",
|
|
526
|
+
lineHeight: "18px",
|
|
527
|
+
color: "var(--dsw-alias-label-secondary)",
|
|
528
|
+
overflowWrap: "anywhere"
|
|
529
|
+
};
|
|
530
|
+
/** Capability badge chips (text / image / context). */
|
|
531
|
+
const badgeStyle = {
|
|
532
|
+
fontSize: "10px",
|
|
533
|
+
lineHeight: "16px",
|
|
534
|
+
color: "var(--dsw-alias-label-tertiary)",
|
|
535
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
536
|
+
borderRadius: "4px",
|
|
537
|
+
padding: "0 5px",
|
|
538
|
+
whiteSpace: "nowrap"
|
|
539
|
+
};
|
|
540
|
+
/** The per-level editor grid: one row per level with a toggle, a label and a wire input. */
|
|
541
|
+
const levelRowStyle = {
|
|
542
|
+
display: "grid",
|
|
543
|
+
gridTemplateColumns: "auto 92px minmax(0, 1fr)",
|
|
544
|
+
alignItems: "center",
|
|
545
|
+
gap: "8px",
|
|
546
|
+
padding: "4px 0",
|
|
547
|
+
fontSize: "13px"
|
|
548
|
+
};
|
|
549
|
+
const levelNameStyle = {
|
|
550
|
+
margin: 0,
|
|
551
|
+
fontSize: "12px",
|
|
552
|
+
lineHeight: "18px",
|
|
553
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
554
|
+
};
|
|
555
|
+
const wireInputStyle = {
|
|
556
|
+
background: "var(--dsw-alias-bg-surface, #fff)",
|
|
557
|
+
color: "var(--dsw-alias-label-primary)",
|
|
558
|
+
border: "1px solid var(--dsw-alias-border-l2)",
|
|
559
|
+
borderRadius: "4px",
|
|
560
|
+
padding: "3px 8px",
|
|
561
|
+
fontSize: "12px",
|
|
562
|
+
width: "100%",
|
|
563
|
+
boxSizing: "border-box"
|
|
564
|
+
};
|
|
565
|
+
/** A row's `reasoningEfforts` as stored in the user layer. */
|
|
566
|
+
function effortsOf(model) {
|
|
567
|
+
const value = model["reasoningEfforts"];
|
|
568
|
+
if (value === false) return false;
|
|
569
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) return value;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* Build a `reasoningEfforts` table from a level→wire draft. `off` maps to
|
|
573
|
+
* `null` (omit the reasoning option → enable_thinking false) unless the user
|
|
574
|
+
* typed a wire value; every other ticked level keeps its typed wire value.
|
|
575
|
+
* pi-ai rejects a table offering nothing beyond `off`, so a selection of only
|
|
576
|
+
* `off` falls back to the default `high` level.
|
|
577
|
+
*/
|
|
578
|
+
function effortTableOf(draft) {
|
|
579
|
+
const table = {};
|
|
580
|
+
for (const level of CAPABILITY_LEVELS) {
|
|
581
|
+
const wire = draft[level];
|
|
582
|
+
if (wire === void 0 || wire === null) continue;
|
|
583
|
+
const trimmed = typeof wire === "string" ? wire.trim() : "";
|
|
584
|
+
if (level === "off") table[level] = trimmed === "" ? null : trimmed;
|
|
585
|
+
else if (trimmed !== "") table[level] = trimmed;
|
|
586
|
+
}
|
|
587
|
+
if (Object.keys(table).length === 0 || Object.keys(table).every((level) => table[level] === null)) return {
|
|
588
|
+
...table,
|
|
589
|
+
high: "high"
|
|
590
|
+
};
|
|
591
|
+
return table;
|
|
592
|
+
}
|
|
593
|
+
/** Whether a row declares `compat.supportsReasoningEffort` (the wire sends reasoning_effort). */
|
|
594
|
+
function supportsEffortOf(model) {
|
|
595
|
+
const compat = model["compat"];
|
|
596
|
+
if (typeof compat !== "object" || compat === null || Array.isArray(compat)) return false;
|
|
597
|
+
return compat["supportsReasoningEffort"] === true;
|
|
598
|
+
}
|
|
599
|
+
/** Patch one row's `compat` object, merging rather than replacing sibling fields. */
|
|
600
|
+
function patchCompat(row, patch) {
|
|
601
|
+
const compat = typeof row["compat"] === "object" && row["compat"] !== null && !Array.isArray(row["compat"]) ? { ...row["compat"] } : {};
|
|
602
|
+
patch(compat);
|
|
603
|
+
if (Object.keys(compat).length === 0) delete row["compat"];
|
|
604
|
+
else row["compat"] = compat;
|
|
605
|
+
}
|
|
606
|
+
/** The user-layer `providers` value of the llm-pi-ai namespace, when present. */
|
|
607
|
+
function providersOf$1(snapshot) {
|
|
608
|
+
if (typeof snapshot !== "object" || snapshot === null) return {};
|
|
609
|
+
const user = snapshot.user;
|
|
610
|
+
if (typeof user !== "object" || user === null || Array.isArray(user)) return {};
|
|
611
|
+
const providers = user["providers"];
|
|
612
|
+
return typeof providers === "object" && providers !== null && !Array.isArray(providers) ? providers : {};
|
|
613
|
+
}
|
|
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;
|
|
629
|
+
}
|
|
630
|
+
/** Flatten the user-layer providers into capability entries (models arrays only). */
|
|
631
|
+
function entriesOf(providers) {
|
|
632
|
+
return Object.entries(providers).flatMap(([providerId, profile]) => {
|
|
633
|
+
const raw = profile;
|
|
634
|
+
const models = raw["models"];
|
|
635
|
+
if (!Array.isArray(models)) return [];
|
|
636
|
+
const providerCompat = raw["compat"];
|
|
637
|
+
const providerInput = Array.isArray(raw["defaultInput"]) ? raw["defaultInput"] : void 0;
|
|
638
|
+
return models.map((model, index) => ({
|
|
639
|
+
providerId,
|
|
640
|
+
index,
|
|
641
|
+
model: typeof model === "object" && model !== null && !Array.isArray(model) ? model : {},
|
|
642
|
+
modelId: typeof model === "object" && model !== null && typeof model["id"] === "string" ? model["id"] : `#${index + 1}`,
|
|
643
|
+
providerCompat,
|
|
644
|
+
providerInput
|
|
645
|
+
}));
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
/** Human-readable capability summary of one entry (input modalities + declared context window). */
|
|
649
|
+
function summaryOf(entry) {
|
|
650
|
+
const input = Array.isArray(entry.model["input"]) ? entry.model["input"] : entry.providerInput;
|
|
651
|
+
const text = !Array.isArray(input) || input.length === 0 || input.includes("text");
|
|
652
|
+
const image = Array.isArray(input) && input.includes("image");
|
|
653
|
+
const contextWindow = entry.model["contextWindow"];
|
|
654
|
+
return {
|
|
655
|
+
text,
|
|
656
|
+
image,
|
|
657
|
+
context: typeof contextWindow === "number" && Number.isFinite(contextWindow) && contextWindow > 0 ? formatContextWindow(contextWindow) : null
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
/** A tiny inline chevron icon (no CSS modules). */
|
|
661
|
+
function ChevronIcon({ open }) {
|
|
662
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
663
|
+
width: "12",
|
|
664
|
+
height: "12",
|
|
665
|
+
viewBox: "0 0 16 16",
|
|
666
|
+
"aria-hidden": true,
|
|
667
|
+
style: {
|
|
668
|
+
transform: open ? "rotate(180deg)" : "none",
|
|
669
|
+
transition: "transform 0.16s"
|
|
670
|
+
},
|
|
671
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
672
|
+
d: "M4 6l4 4 4-4",
|
|
673
|
+
fill: "none",
|
|
674
|
+
stroke: "currentColor",
|
|
675
|
+
strokeWidth: "1.5",
|
|
676
|
+
strokeLinecap: "round",
|
|
677
|
+
strokeLinejoin: "round"
|
|
678
|
+
})
|
|
108
679
|
});
|
|
109
680
|
}
|
|
110
681
|
/**
|
|
111
|
-
* The
|
|
112
|
-
*
|
|
682
|
+
* The llm-pi-ai model-capability editor block (dsh-thinking-effort style:
|
|
683
|
+
* provider groups, model rows with badges, per-level wire editors, search and
|
|
684
|
+
* one-click presets).
|
|
685
|
+
* @param scope - the `llm-pi-ai` namespace scope.
|
|
686
|
+
* @param t - copy lookup.
|
|
687
|
+
* @param readonly - whether writes are forbidden.
|
|
688
|
+
* @returns the capabilities block, or a placeholder when nothing is configured.
|
|
113
689
|
*/
|
|
114
|
-
function
|
|
690
|
+
function ModelCapabilities(props) {
|
|
691
|
+
const { scope, t, readonly } = props;
|
|
115
692
|
const snapshot = (0, react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
|
|
116
693
|
const unavailable = snapshot.status === "unavailable";
|
|
117
|
-
const
|
|
118
|
-
const
|
|
119
|
-
const
|
|
694
|
+
const providers = snapshot.status === "ready" ? providersOf$1(snapshot) : {};
|
|
695
|
+
const allEntries = entriesOf(providers);
|
|
696
|
+
const [query, setQuery] = (0, react.useState)("");
|
|
697
|
+
const [expandedProviders, setExpandedProviders] = (0, react.useState)({});
|
|
698
|
+
const [expandedModels, setExpandedModels] = (0, react.useState)({});
|
|
699
|
+
const [drafts, setDrafts] = (0, react.useState)({});
|
|
700
|
+
const [busy, setBusy] = (0, react.useState)(false);
|
|
701
|
+
const [contextRaw, setContextRaw] = (0, react.useState)({});
|
|
702
|
+
const [contextError, setContextError] = (0, react.useState)({});
|
|
703
|
+
const entryKey = (entry) => `${entry.providerId}\u0000${entry.index}`;
|
|
704
|
+
/** Commit one patch over the user-layer providers. */
|
|
705
|
+
const commitProviders = (mutate) => {
|
|
706
|
+
if (snapshot.status !== "ready" || readonly) return;
|
|
707
|
+
setBusy(true);
|
|
708
|
+
scope.set("providers", mutate(structuredClone(providers))).then(() => {
|
|
709
|
+
setBusy(false);
|
|
710
|
+
}).catch(() => {
|
|
711
|
+
setBusy(false);
|
|
712
|
+
});
|
|
713
|
+
};
|
|
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;
|
|
725
|
+
});
|
|
726
|
+
};
|
|
727
|
+
/** Patch one model row of one provider. */
|
|
728
|
+
const patchModel = (providerId, index, patch) => {
|
|
729
|
+
commitProviders((current) => {
|
|
730
|
+
const profile = current[providerId];
|
|
731
|
+
if (profile === void 0 || !Array.isArray(profile.models)) return current;
|
|
732
|
+
const model = profile.models[index];
|
|
733
|
+
if (typeof model !== "object" || model === null) return current;
|
|
734
|
+
patch(model);
|
|
735
|
+
return current;
|
|
736
|
+
});
|
|
737
|
+
};
|
|
738
|
+
/** Toggle whether a model is a thinking model (reasoningEfforts table vs false). */
|
|
739
|
+
const toggleThinking = (entry, next) => {
|
|
740
|
+
patchModel(entry.providerId, entry.index, (row) => {
|
|
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;
|
|
751
|
+
});
|
|
752
|
+
};
|
|
753
|
+
/** Toggle whether a model accepts reasoning_effort levels. */
|
|
754
|
+
const toggleEffortCapable = (entry, next) => {
|
|
755
|
+
patchModel(entry.providerId, entry.index, (row) => {
|
|
756
|
+
patchCompat(row, (compat) => {
|
|
757
|
+
compat["supportsReasoningEffort"] = next;
|
|
758
|
+
if (next && compat["thinkingFormat"] === "qwen-chat-template") delete compat["thinkingFormat"];
|
|
759
|
+
});
|
|
760
|
+
});
|
|
761
|
+
};
|
|
762
|
+
/** Apply one model's wire draft as its `reasoningEfforts` table. */
|
|
763
|
+
const applyDraft = (entry) => {
|
|
764
|
+
const key = entryKey(entry);
|
|
765
|
+
const draft = drafts[key];
|
|
766
|
+
if (draft === void 0) return;
|
|
767
|
+
const table = effortTableOf(draft);
|
|
768
|
+
patchModel(entry.providerId, entry.index, (row) => {
|
|
769
|
+
row["reasoningEfforts"] = table;
|
|
770
|
+
const extended = Object.keys(table).some((level) => level !== "off" && level !== "on" && level !== "high");
|
|
771
|
+
if (supportsEffortOf(row) || extended) patchCompat(row, (compat) => {
|
|
772
|
+
compat["supportsReasoningEffort"] = true;
|
|
773
|
+
});
|
|
774
|
+
});
|
|
775
|
+
};
|
|
776
|
+
/** Reset a model's draft to its persisted table (or the default high set). */
|
|
777
|
+
const resetDraft = (entry) => {
|
|
778
|
+
const key = entryKey(entry);
|
|
779
|
+
setDrafts((current) => {
|
|
780
|
+
const next = { ...current };
|
|
781
|
+
const table = effortsOf(entry.model);
|
|
782
|
+
if (typeof table === "object" && table !== null) next[key] = Object.fromEntries(CAPABILITY_LEVELS.map((level) => [level, table[level] === void 0 ? null : table[level] === null ? "" : String(table[level])]));
|
|
783
|
+
else next[key] = {
|
|
784
|
+
off: "",
|
|
785
|
+
high: "high"
|
|
786
|
+
};
|
|
787
|
+
return next;
|
|
788
|
+
});
|
|
789
|
+
};
|
|
790
|
+
/** Seed a model's draft when it is first expanded. */
|
|
791
|
+
const ensureDraft = (entry) => {
|
|
792
|
+
const key = entryKey(entry);
|
|
793
|
+
setDrafts((current) => {
|
|
794
|
+
if (current[key] !== void 0) return current;
|
|
795
|
+
const next = { ...current };
|
|
796
|
+
const table = effortsOf(entry.model);
|
|
797
|
+
if (typeof table === "object" && table !== null) next[key] = Object.fromEntries(CAPABILITY_LEVELS.map((level) => [level, table[level] === void 0 ? null : table[level] === null ? "" : String(table[level])]));
|
|
798
|
+
else next[key] = {
|
|
799
|
+
off: "",
|
|
800
|
+
high: "high"
|
|
801
|
+
};
|
|
802
|
+
return next;
|
|
803
|
+
});
|
|
804
|
+
};
|
|
805
|
+
/** Apply a one-click preset to every thinking model. */
|
|
806
|
+
const applyPreset = (levels) => {
|
|
807
|
+
commitProviders((current) => {
|
|
808
|
+
for (const entry of entriesOf(current)) {
|
|
809
|
+
const profile = current[entry.providerId];
|
|
810
|
+
if (profile === void 0 || !Array.isArray(profile.models)) continue;
|
|
811
|
+
const model = profile.models[entry.index];
|
|
812
|
+
if (typeof model !== "object" || model === null) continue;
|
|
813
|
+
const row = model;
|
|
814
|
+
if (effortsOf(row) === void 0) continue;
|
|
815
|
+
row["reasoningEfforts"] = levels;
|
|
816
|
+
}
|
|
817
|
+
return current;
|
|
818
|
+
});
|
|
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
|
+
};
|
|
120
881
|
if (unavailable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
121
|
-
style:
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
children: t("card.unavailable")
|
|
882
|
+
style: sectionStyle,
|
|
883
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
884
|
+
style: hintStyle$1,
|
|
885
|
+
children: t("card.capabilities.unavailable")
|
|
886
|
+
})
|
|
127
887
|
});
|
|
888
|
+
if (allEntries.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
889
|
+
style: sectionStyle,
|
|
890
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
891
|
+
style: fieldLabelStyle,
|
|
892
|
+
children: t("card.capabilities")
|
|
893
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
894
|
+
style: hintStyle$1,
|
|
895
|
+
children: t("card.capabilities.empty")
|
|
896
|
+
})]
|
|
897
|
+
});
|
|
898
|
+
const needle = query.trim().toLowerCase();
|
|
899
|
+
const visible = needle === "" ? allEntries : allEntries.filter((entry) => entry.modelId.toLowerCase().includes(needle) || entry.providerId.toLowerCase().includes(needle));
|
|
900
|
+
const providerIds = [...new Set(visible.map((entry) => entry.providerId))];
|
|
128
901
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
129
|
-
style:
|
|
902
|
+
style: sectionStyle,
|
|
130
903
|
children: [
|
|
131
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
132
|
-
style:
|
|
133
|
-
children:
|
|
134
|
-
htmlFor: "plugin-config-thinking-levels-level",
|
|
135
|
-
style: labelStyle,
|
|
136
|
-
children: t("card.level")
|
|
137
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
138
|
-
id: "plugin-config-thinking-levels-level",
|
|
139
|
-
value: level,
|
|
140
|
-
disabled: readonly,
|
|
141
|
-
style: controlStyle,
|
|
142
|
-
onChange: (event) => {
|
|
143
|
-
scope.set("level", event.currentTarget.value);
|
|
144
|
-
},
|
|
145
|
-
children: EFFORT_OPTIONS.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
146
|
-
value: option,
|
|
147
|
-
children: t(`card.level.${option}`)
|
|
148
|
-
}, option))
|
|
149
|
-
})]
|
|
904
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
905
|
+
style: fieldLabelStyle,
|
|
906
|
+
children: t("card.capabilities")
|
|
150
907
|
}),
|
|
151
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
checked: value.enabled ?? true,
|
|
155
|
-
disabled: readonly,
|
|
156
|
-
onChange: (next) => {
|
|
157
|
-
scope.set("enabled", next);
|
|
158
|
-
}
|
|
908
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
909
|
+
style: hintStyle$1,
|
|
910
|
+
children: t("card.capabilities.hint")
|
|
159
911
|
}),
|
|
160
|
-
/* @__PURE__ */ (0, react_jsx_runtime.
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
912
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
913
|
+
style: {
|
|
914
|
+
display: "flex",
|
|
915
|
+
gap: "8px",
|
|
916
|
+
flexWrap: "wrap",
|
|
917
|
+
alignItems: "center",
|
|
918
|
+
margin: "8px 0 2px"
|
|
919
|
+
},
|
|
920
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
921
|
+
type: "text",
|
|
922
|
+
value: query,
|
|
923
|
+
placeholder: t("card.capabilities.search"),
|
|
924
|
+
disabled: readonly || busy,
|
|
925
|
+
style: {
|
|
926
|
+
...controlStyle,
|
|
927
|
+
flex: "1 1 160px",
|
|
928
|
+
minWidth: "140px"
|
|
929
|
+
},
|
|
930
|
+
onChange: (event) => setQuery(event.currentTarget.value)
|
|
931
|
+
}), PRESETS.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
932
|
+
type: "button",
|
|
933
|
+
disabled: readonly || busy,
|
|
934
|
+
onClick: () => applyPreset(preset.levels),
|
|
935
|
+
style: {
|
|
936
|
+
...controlStyle,
|
|
937
|
+
cursor: readonly || busy ? "default" : "pointer",
|
|
938
|
+
opacity: readonly || busy ? .5 : 1
|
|
939
|
+
},
|
|
940
|
+
children: t(`card.capabilities.preset${preset.key === "official" ? "Official" : "Generic"}`)
|
|
941
|
+
}, preset.key))]
|
|
168
942
|
}),
|
|
169
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
943
|
+
visible.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
944
|
+
style: hintStyle$1,
|
|
945
|
+
children: t("card.capabilities.noMatches")
|
|
946
|
+
}) : providerIds.map((providerId) => {
|
|
947
|
+
const providerEntries = visible.filter((entry) => entry.providerId === providerId);
|
|
948
|
+
const providerOpen = expandedProviders[providerId] === true || needle !== "";
|
|
949
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
950
|
+
style: providerStyle,
|
|
951
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
952
|
+
style: providerHeadStyle,
|
|
953
|
+
children: [
|
|
954
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
955
|
+
type: "button",
|
|
956
|
+
"aria-expanded": providerOpen,
|
|
957
|
+
disabled: readonly || busy,
|
|
958
|
+
onClick: () => setExpandedProviders((current) => ({
|
|
959
|
+
...current,
|
|
960
|
+
[providerId]: current[providerId] !== true
|
|
961
|
+
})),
|
|
962
|
+
style: {
|
|
963
|
+
...iconButtonStyle,
|
|
964
|
+
cursor: readonly || busy ? "default" : "pointer"
|
|
965
|
+
},
|
|
966
|
+
title: providerOpen ? t("card.capabilities.collapseProvider") : t("card.capabilities.expandProvider"),
|
|
967
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChevronIcon, { open: providerOpen })
|
|
968
|
+
}),
|
|
969
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
970
|
+
style: providerNameStyle,
|
|
971
|
+
children: providerId
|
|
972
|
+
}),
|
|
973
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
974
|
+
style: {
|
|
975
|
+
display: "inline-flex",
|
|
976
|
+
alignItems: "center",
|
|
977
|
+
gap: "5px",
|
|
978
|
+
fontSize: "11px",
|
|
979
|
+
whiteSpace: "nowrap",
|
|
980
|
+
color: "var(--dsw-alias-label-secondary)"
|
|
981
|
+
},
|
|
982
|
+
title: t("card.capabilities.developerRoleHint"),
|
|
983
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
984
|
+
type: "checkbox",
|
|
985
|
+
checked: developerRoleDisabledOf(providers[providerId]),
|
|
986
|
+
disabled: readonly || busy,
|
|
987
|
+
onChange: (event) => toggleDeveloperRole(providerId, event.currentTarget.checked)
|
|
988
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.developerRole") })]
|
|
989
|
+
}),
|
|
990
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
991
|
+
style: providerBadgeStyle,
|
|
992
|
+
children: providerEntries.length
|
|
993
|
+
})
|
|
994
|
+
]
|
|
995
|
+
}), providerOpen ? providerEntries.map((entry) => {
|
|
996
|
+
const key = entryKey(entry);
|
|
997
|
+
const modelOpen = expandedModels[key] === true;
|
|
998
|
+
const thinking = typeof effortsOf(entry.model) === "object";
|
|
999
|
+
const compat = compatOf(entry);
|
|
1000
|
+
const supportsEffort = compat["supportsReasoningEffort"] === true;
|
|
1001
|
+
const meta = summaryOf(entry);
|
|
1002
|
+
const format = typeof compat["thinkingFormat"] === "string" ? compat["thinkingFormat"] : void 0;
|
|
1003
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1004
|
+
style: modelRowStyle,
|
|
1005
|
+
children: [
|
|
1006
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1007
|
+
type: "button",
|
|
1008
|
+
"aria-expanded": modelOpen,
|
|
1009
|
+
disabled: readonly || busy,
|
|
1010
|
+
onClick: () => {
|
|
1011
|
+
const next = expandedModels[key] !== true;
|
|
1012
|
+
setExpandedModels((current) => ({
|
|
1013
|
+
...current,
|
|
1014
|
+
[key]: next
|
|
1015
|
+
}));
|
|
1016
|
+
if (next) {
|
|
1017
|
+
ensureDraft(entry);
|
|
1018
|
+
seedContext(entry);
|
|
1019
|
+
}
|
|
1020
|
+
},
|
|
1021
|
+
style: {
|
|
1022
|
+
...iconButtonStyle,
|
|
1023
|
+
cursor: readonly || busy ? "default" : "pointer"
|
|
1024
|
+
},
|
|
1025
|
+
title: modelOpen ? t("card.capabilities.closeModelSettings") : t("card.capabilities.openModelSettings"),
|
|
1026
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChevronIcon, { open: modelOpen })
|
|
1027
|
+
}),
|
|
1028
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1029
|
+
style: modelIdStyle,
|
|
1030
|
+
children: entry.modelId
|
|
1031
|
+
}),
|
|
1032
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1033
|
+
style: badgeStyle,
|
|
1034
|
+
title: "text",
|
|
1035
|
+
children: meta.text ? "T" : "–"
|
|
1036
|
+
}),
|
|
1037
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1038
|
+
style: badgeStyle,
|
|
1039
|
+
title: "image",
|
|
1040
|
+
children: meta.image ? "IMG" : "–"
|
|
1041
|
+
}),
|
|
1042
|
+
meta.context !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1043
|
+
style: badgeStyle,
|
|
1044
|
+
children: meta.context
|
|
1045
|
+
}),
|
|
1046
|
+
thinking && !supportsEffort && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1047
|
+
style: badgeStyle,
|
|
1048
|
+
children: "On/Off"
|
|
1049
|
+
})
|
|
1050
|
+
]
|
|
1051
|
+
}), modelOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1052
|
+
style: {
|
|
1053
|
+
padding: "4px 10px 10px",
|
|
1054
|
+
borderTop: "1px solid var(--dsw-alias-border-l2)"
|
|
1055
|
+
},
|
|
1056
|
+
children: [
|
|
1057
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1058
|
+
style: {
|
|
1059
|
+
display: "flex",
|
|
1060
|
+
gap: "16px",
|
|
1061
|
+
flexWrap: "wrap",
|
|
1062
|
+
margin: "2px 0 8px"
|
|
1063
|
+
},
|
|
1064
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1065
|
+
style: {
|
|
1066
|
+
display: "inline-flex",
|
|
1067
|
+
alignItems: "center",
|
|
1068
|
+
gap: "6px",
|
|
1069
|
+
fontSize: "12px"
|
|
1070
|
+
},
|
|
1071
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1072
|
+
type: "checkbox",
|
|
1073
|
+
checked: thinking,
|
|
1074
|
+
disabled: readonly || busy,
|
|
1075
|
+
onChange: (event) => toggleThinking(entry, event.currentTarget.checked)
|
|
1076
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.thinking") })]
|
|
1077
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1078
|
+
style: {
|
|
1079
|
+
display: "inline-flex",
|
|
1080
|
+
alignItems: "center",
|
|
1081
|
+
gap: "6px",
|
|
1082
|
+
fontSize: "12px"
|
|
1083
|
+
},
|
|
1084
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1085
|
+
type: "checkbox",
|
|
1086
|
+
checked: meta.image,
|
|
1087
|
+
disabled: readonly || busy,
|
|
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
|
+
})]
|
|
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,
|
|
1111
|
+
thinking && supportsEffort ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1112
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1113
|
+
style: fieldLabelStyle,
|
|
1114
|
+
children: t("card.capabilities.efforts")
|
|
1115
|
+
}),
|
|
1116
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1117
|
+
style: { margin: "4px 0 6px" },
|
|
1118
|
+
children: CAPABILITY_LEVELS.map((level) => {
|
|
1119
|
+
const wire = drafts[key]?.[level];
|
|
1120
|
+
const on = wire !== void 0 && wire !== null;
|
|
1121
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1122
|
+
style: levelRowStyle,
|
|
1123
|
+
children: [
|
|
1124
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1125
|
+
style: {
|
|
1126
|
+
display: "inline-flex",
|
|
1127
|
+
alignItems: "center",
|
|
1128
|
+
gap: "6px",
|
|
1129
|
+
fontSize: "12px"
|
|
1130
|
+
},
|
|
1131
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1132
|
+
type: "checkbox",
|
|
1133
|
+
checked: on,
|
|
1134
|
+
disabled: readonly || busy,
|
|
1135
|
+
onChange: (event) => {
|
|
1136
|
+
const checked = event.currentTarget.checked;
|
|
1137
|
+
setDrafts((current) => {
|
|
1138
|
+
const draft = { ...current[key] ?? {} };
|
|
1139
|
+
draft[level] = checked ? level === "off" ? "" : level : null;
|
|
1140
|
+
return {
|
|
1141
|
+
...current,
|
|
1142
|
+
[key]: draft
|
|
1143
|
+
};
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: level })]
|
|
1147
|
+
}),
|
|
1148
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1149
|
+
style: levelNameStyle,
|
|
1150
|
+
children: level === "off" ? t("card.capabilities.offPlaceholder") : "→"
|
|
1151
|
+
}),
|
|
1152
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1153
|
+
type: "text",
|
|
1154
|
+
value: wire ?? "",
|
|
1155
|
+
disabled: readonly || busy || !on,
|
|
1156
|
+
placeholder: t("card.capabilities.wirePlaceholder"),
|
|
1157
|
+
style: wireInputStyle,
|
|
1158
|
+
onChange: (event) => {
|
|
1159
|
+
setDrafts((current) => {
|
|
1160
|
+
const draft = { ...current[key] ?? {} };
|
|
1161
|
+
draft[level] = event.currentTarget.value;
|
|
1162
|
+
return {
|
|
1163
|
+
...current,
|
|
1164
|
+
[key]: draft
|
|
1165
|
+
};
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
})
|
|
1169
|
+
]
|
|
1170
|
+
}, level);
|
|
1171
|
+
})
|
|
1172
|
+
}),
|
|
1173
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1174
|
+
style: {
|
|
1175
|
+
display: "flex",
|
|
1176
|
+
gap: "8px",
|
|
1177
|
+
flexWrap: "wrap"
|
|
1178
|
+
},
|
|
1179
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1180
|
+
type: "button",
|
|
1181
|
+
disabled: readonly || busy,
|
|
1182
|
+
onClick: () => applyDraft(entry),
|
|
1183
|
+
style: {
|
|
1184
|
+
...controlStyle,
|
|
1185
|
+
cursor: readonly || busy ? "default" : "pointer",
|
|
1186
|
+
opacity: readonly || busy ? .5 : 1
|
|
1187
|
+
},
|
|
1188
|
+
children: t("card.capabilities.applyLevel")
|
|
1189
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1190
|
+
type: "button",
|
|
1191
|
+
disabled: readonly || busy,
|
|
1192
|
+
onClick: () => resetDraft(entry),
|
|
1193
|
+
style: {
|
|
1194
|
+
...controlStyle,
|
|
1195
|
+
cursor: readonly || busy ? "default" : "pointer",
|
|
1196
|
+
opacity: readonly || busy ? .5 : 1
|
|
1197
|
+
},
|
|
1198
|
+
children: t("card.capabilities.restoreDefault")
|
|
1199
|
+
})]
|
|
1200
|
+
})
|
|
1201
|
+
] }) : null,
|
|
1202
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1203
|
+
style: {
|
|
1204
|
+
display: "flex",
|
|
1205
|
+
gap: "16px",
|
|
1206
|
+
flexWrap: "wrap",
|
|
1207
|
+
marginTop: "10px"
|
|
1208
|
+
},
|
|
1209
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
1210
|
+
style: fieldStyle,
|
|
1211
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1212
|
+
style: fieldLabelStyle,
|
|
1213
|
+
children: t("card.capabilities.thinkingFormat")
|
|
1214
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
1215
|
+
style: controlStyle,
|
|
1216
|
+
value: format ?? "inherit",
|
|
1217
|
+
disabled: readonly || busy,
|
|
1218
|
+
onChange: (event) => {
|
|
1219
|
+
const next = event.currentTarget.value;
|
|
1220
|
+
patchModel(entry.providerId, entry.index, (row) => {
|
|
1221
|
+
patchCompat(row, (compat) => {
|
|
1222
|
+
if (next === "inherit") delete compat["thinkingFormat"];
|
|
1223
|
+
else compat["thinkingFormat"] = next;
|
|
1224
|
+
});
|
|
1225
|
+
});
|
|
1226
|
+
},
|
|
1227
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1228
|
+
value: "inherit",
|
|
1229
|
+
children: t("card.capabilities.thinkingFormat.inherit")
|
|
1230
|
+
}), THINKING_FORMATS.map((formatOption) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1231
|
+
value: formatOption,
|
|
1232
|
+
children: formatOption
|
|
1233
|
+
}, formatOption))]
|
|
1234
|
+
})]
|
|
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
|
+
})
|
|
1316
|
+
})
|
|
1317
|
+
]
|
|
1318
|
+
}) : null] }, key);
|
|
1319
|
+
}) : null]
|
|
1320
|
+
}, providerId);
|
|
177
1321
|
}),
|
|
178
|
-
|
|
1322
|
+
readonly ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1323
|
+
style: hintStyle$1,
|
|
1324
|
+
children: t("card.readonly")
|
|
1325
|
+
}) : null
|
|
1326
|
+
]
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
/**
|
|
1330
|
+
* The card body, wrapped in a disclosure shell like every peer settings card:
|
|
1331
|
+
* a header (name + description + chevron) that toggles the body, collapsed by
|
|
1332
|
+
* default so the plugin tab stays a tidy list of drawers.
|
|
1333
|
+
* @param props - locale copy and the injected scopes.
|
|
1334
|
+
*/
|
|
1335
|
+
function ThinkingLevelsCard({ t, scope, piAiScope }) {
|
|
1336
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
1337
|
+
const snapshot = (0, react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
|
|
1338
|
+
const unavailable = snapshot.status === "unavailable";
|
|
1339
|
+
const readonly = unavailable || !snapshot.writable;
|
|
1340
|
+
const value = snapshot.value ?? {};
|
|
1341
|
+
const level = EFFORT_OPTIONS.includes(value.level) ? value.level : "auto";
|
|
1342
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1343
|
+
style: {
|
|
1344
|
+
border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,0.35))",
|
|
1345
|
+
background: "var(--dsw-alias-bg-layer-3, rgba(127,127,127,0.05))",
|
|
1346
|
+
borderRadius: "12px",
|
|
1347
|
+
transition: "border-color 0.16s, background 0.16s"
|
|
1348
|
+
},
|
|
1349
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1350
|
+
type: "button",
|
|
1351
|
+
"aria-expanded": open,
|
|
1352
|
+
style: {
|
|
1353
|
+
appearance: "none",
|
|
1354
|
+
width: "100%",
|
|
1355
|
+
font: "inherit",
|
|
1356
|
+
color: "inherit",
|
|
1357
|
+
textAlign: "left",
|
|
1358
|
+
cursor: "pointer",
|
|
1359
|
+
background: "none",
|
|
1360
|
+
border: 0,
|
|
1361
|
+
borderRadius: "12px",
|
|
1362
|
+
display: "flex",
|
|
1363
|
+
alignItems: "center",
|
|
1364
|
+
gap: "12px",
|
|
1365
|
+
padding: "14px 16px"
|
|
1366
|
+
},
|
|
1367
|
+
onClick: () => {
|
|
1368
|
+
setOpen((current) => !current);
|
|
1369
|
+
},
|
|
1370
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
179
1371
|
style: {
|
|
180
|
-
|
|
181
|
-
|
|
1372
|
+
flex: "1 1 0%",
|
|
1373
|
+
minWidth: 0
|
|
1374
|
+
},
|
|
1375
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1376
|
+
style: {
|
|
1377
|
+
fontSize: "14px",
|
|
1378
|
+
fontWeight: 600,
|
|
1379
|
+
color: "var(--dsw-alias-label-primary)"
|
|
1380
|
+
},
|
|
1381
|
+
children: t("card.title")
|
|
1382
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1383
|
+
style: {
|
|
1384
|
+
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,0.8))",
|
|
1385
|
+
fontSize: "13px",
|
|
1386
|
+
lineHeight: 1.5
|
|
1387
|
+
},
|
|
1388
|
+
children: t("card.description")
|
|
1389
|
+
})]
|
|
1390
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
1391
|
+
width: "16",
|
|
1392
|
+
height: "16",
|
|
1393
|
+
viewBox: "0 0 16 16",
|
|
1394
|
+
"aria-hidden": true,
|
|
1395
|
+
style: {
|
|
1396
|
+
color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,0.8))",
|
|
1397
|
+
flex: "0 0 auto",
|
|
1398
|
+
transition: "transform 0.16s",
|
|
1399
|
+
transform: open ? "rotate(180deg)" : "none"
|
|
1400
|
+
},
|
|
1401
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1402
|
+
d: "M4 6l4 4 4-4",
|
|
1403
|
+
fill: "none",
|
|
1404
|
+
stroke: "currentColor",
|
|
1405
|
+
strokeWidth: "1.5",
|
|
1406
|
+
strokeLinecap: "round",
|
|
1407
|
+
strokeLinejoin: "round"
|
|
1408
|
+
})
|
|
1409
|
+
})]
|
|
1410
|
+
}), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1411
|
+
style: { padding: "12px 16px" },
|
|
1412
|
+
children: unavailable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1413
|
+
style: {
|
|
1414
|
+
fontSize: "13px",
|
|
182
1415
|
color: "var(--dsw-alias-label-tertiary)"
|
|
183
1416
|
},
|
|
184
|
-
children: t("card.
|
|
185
|
-
})
|
|
186
|
-
|
|
1417
|
+
children: t("card.unavailable")
|
|
1418
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
1419
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1420
|
+
style: rowStyle,
|
|
1421
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1422
|
+
htmlFor: "plugin-config-thinking-levels-level",
|
|
1423
|
+
style: labelStyle$1,
|
|
1424
|
+
children: t("card.level")
|
|
1425
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
|
|
1426
|
+
id: "plugin-config-thinking-levels-level",
|
|
1427
|
+
value: level,
|
|
1428
|
+
disabled: readonly,
|
|
1429
|
+
style: controlStyle,
|
|
1430
|
+
onChange: (event) => {
|
|
1431
|
+
scope.set("level", event.currentTarget.value);
|
|
1432
|
+
},
|
|
1433
|
+
children: EFFORT_OPTIONS.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
1434
|
+
value: option,
|
|
1435
|
+
children: t(`card.level.${option}`)
|
|
1436
|
+
}, option))
|
|
1437
|
+
})]
|
|
1438
|
+
}),
|
|
1439
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1440
|
+
style: rowStyle,
|
|
1441
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1442
|
+
htmlFor: "plugin-config-thinking-levels-enabled",
|
|
1443
|
+
style: labelStyle$1,
|
|
1444
|
+
children: t("card.enabled")
|
|
1445
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1446
|
+
id: "plugin-config-thinking-levels-enabled",
|
|
1447
|
+
type: "checkbox",
|
|
1448
|
+
checked: value.enabled ?? true,
|
|
1449
|
+
disabled: readonly,
|
|
1450
|
+
onChange: (event) => {
|
|
1451
|
+
scope.set("enabled", event.currentTarget.checked);
|
|
1452
|
+
}
|
|
1453
|
+
})]
|
|
1454
|
+
}),
|
|
1455
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1456
|
+
style: rowStyle,
|
|
1457
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1458
|
+
htmlFor: "plugin-config-thinking-levels-downgrade",
|
|
1459
|
+
style: labelStyle$1,
|
|
1460
|
+
children: t("card.allowDowngrade")
|
|
1461
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1462
|
+
id: "plugin-config-thinking-levels-downgrade",
|
|
1463
|
+
type: "checkbox",
|
|
1464
|
+
checked: value.allowDowngrade ?? true,
|
|
1465
|
+
disabled: readonly || value.level !== "auto",
|
|
1466
|
+
onChange: (event) => {
|
|
1467
|
+
scope.set("allowDowngrade", event.currentTarget.checked);
|
|
1468
|
+
}
|
|
1469
|
+
})]
|
|
1470
|
+
}),
|
|
1471
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1472
|
+
style: rowStyle,
|
|
1473
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1474
|
+
htmlFor: "plugin-config-thinking-levels-upgrade",
|
|
1475
|
+
style: labelStyle$1,
|
|
1476
|
+
children: t("card.allowUpgrade")
|
|
1477
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
|
|
1478
|
+
id: "plugin-config-thinking-levels-upgrade",
|
|
1479
|
+
type: "checkbox",
|
|
1480
|
+
checked: value.allowUpgrade ?? false,
|
|
1481
|
+
disabled: readonly || value.level !== "auto",
|
|
1482
|
+
onChange: (event) => {
|
|
1483
|
+
scope.set("allowUpgrade", event.currentTarget.checked);
|
|
1484
|
+
}
|
|
1485
|
+
})]
|
|
1486
|
+
}),
|
|
1487
|
+
!snapshot.writable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
1488
|
+
style: {
|
|
1489
|
+
margin: "8px 0 0",
|
|
1490
|
+
fontSize: "12px",
|
|
1491
|
+
color: "var(--dsw-alias-label-tertiary)"
|
|
1492
|
+
},
|
|
1493
|
+
children: t("card.readonly")
|
|
1494
|
+
}),
|
|
1495
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelCapabilities, {
|
|
1496
|
+
scope: piAiScope,
|
|
1497
|
+
t,
|
|
1498
|
+
readonly
|
|
1499
|
+
})
|
|
1500
|
+
] })
|
|
1501
|
+
}) : null]
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
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]
|
|
187
1876
|
});
|
|
188
1877
|
}
|
|
189
1878
|
//#endregion
|
|
@@ -203,7 +1892,9 @@ window.__ModuleLoader__.load({
|
|
|
203
1892
|
function apply(ctx) {
|
|
204
1893
|
ctx.effect(() => ctx.locale.register(NS, {
|
|
205
1894
|
zh,
|
|
206
|
-
en
|
|
1895
|
+
en,
|
|
1896
|
+
ja,
|
|
1897
|
+
ko
|
|
207
1898
|
}), "dsh-thinking-levels: dictionaries");
|
|
208
1899
|
ctx.slots.inject("settings.plugin.item", function* () {
|
|
209
1900
|
yield ctx.slots.register({
|
|
@@ -212,10 +1903,26 @@ window.__ModuleLoader__.load({
|
|
|
212
1903
|
key: THINKING_LEVELS_NS,
|
|
213
1904
|
locale: NS,
|
|
214
1905
|
inject: () => {
|
|
215
|
-
return {
|
|
1906
|
+
return {
|
|
1907
|
+
scope: ctx.settingsScope.bind({ namespace: THINKING_LEVELS_NS }),
|
|
1908
|
+
piAiScope: ctx.settingsScope.bind({ namespace: "llm-pi-ai" })
|
|
1909
|
+
};
|
|
216
1910
|
}
|
|
217
1911
|
}, ThinkingLevelsCard);
|
|
218
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
|
+
});
|
|
219
1926
|
}
|
|
220
1927
|
//#endregion
|
|
221
1928
|
exports.apply = apply;
|