dsh-thinking-levels 3.1.1 → 3.2.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/lib/client.js CHANGED
@@ -13,6 +13,7 @@ window.__ModuleLoader__.load({
13
13
  /** Simplified Chinese dictionary (the key-set source of truth). */
14
14
  const zh = {
15
15
  "card.title": "思考档位",
16
+ "family.title": "起子插件设置",
16
17
  "card.description": "在模型选择器中可选 Auto(mask):按工具调用历史自动在 low / high / max 间调度后提交 API。此处配置默认档位、调度边界与模型能力(档位 → 网关线上值映射)。",
17
18
  "card.level": "默认档位",
18
19
  "card.level.off": "off — 关闭思考(仅手动,永不自动选择)",
@@ -81,6 +82,7 @@ window.__ModuleLoader__.load({
81
82
  /** English dictionary (keys mirror zh). */
82
83
  const en = {
83
84
  "card.title": "Thinking Levels",
85
+ "family.title": "Qizi Plugin Settings",
84
86
  "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).",
85
87
  "card.level": "Default level",
86
88
  "card.level.off": "off — disable thinking (manual only, never auto-picked)",
@@ -149,6 +151,7 @@ window.__ModuleLoader__.load({
149
151
  /** Japanese dictionary (keys mirror zh). */
150
152
  const ja = {
151
153
  "card.title": "思考レベル",
154
+ "family.title": "起子プラグイン設定",
152
155
  "card.description": "モデルセレクターで Auto(マスク)を選択すると、ツール呼び出し履歴から low / high / max を自動スケジュールして API に送信します。ここでは既定レベル、スケジューラーの境界、モデル能力(レベル → ゲートウェイ送信値のマッピング)を設定します。",
153
156
  "card.level": "既定レベル",
154
157
  "card.level.off": "off — 思考を無効化(手動のみ、自動選択はされません)",
@@ -217,6 +220,7 @@ window.__ModuleLoader__.load({
217
220
  /** Korean dictionary (keys mirror zh). */
218
221
  const ko = {
219
222
  "card.title": "사고 수준",
223
+ "family.title": "起子 플러그인 설정",
220
224
  "card.description": "모델 선택기에서 Auto(마스크)를 선택하면 도구 호출 기록을 기반으로 low / high / max 를 자동 스케줄링하여 API에 제출합니다. 여기서 기본 수준, 스케줄러 경계, 모델 기능(수준 → 게이트웨이 전송 값 매핑)을 구성합니다.",
221
225
  "card.level": "기본 수준",
222
226
  "card.level.off": "off — 사고 비활성화(수동 전용, 자동 선택 안 됨)",
@@ -426,7 +430,7 @@ window.__ModuleLoader__.load({
426
430
  inset: 0,
427
431
  zIndex: 1199
428
432
  };
429
- const rowStyle = {
433
+ const rowStyle$1 = {
430
434
  display: "flex",
431
435
  alignItems: "center",
432
436
  gap: "8px",
@@ -434,7 +438,7 @@ window.__ModuleLoader__.load({
434
438
  lineHeight: "18px",
435
439
  color: "var(--dsw-alias-label-secondary)"
436
440
  };
437
- const labelStyle = {
441
+ const labelStyle$1 = {
438
442
  flex: "0 0 auto",
439
443
  minWidth: "0",
440
444
  overflow: "hidden",
@@ -501,7 +505,7 @@ window.__ModuleLoader__.load({
501
505
  color: "var(--dsw-alias-danger, #e5484d)"
502
506
  };
503
507
  /** The user-layer `providers` value of the llm-pi-ai namespace, when present. */
504
- function providersOf(snapshot) {
508
+ function providersOf$1(snapshot) {
505
509
  if (typeof snapshot !== "object" || snapshot === null) return {};
506
510
  const user = snapshot.user;
507
511
  if (typeof user !== "object" || user === null || Array.isArray(user)) return {};
@@ -630,7 +634,7 @@ window.__ModuleLoader__.load({
630
634
  const dsSnapshot = (0, react.useSyncExternalStore)((listener) => deepseekScope.subscribe(listener), () => deepseekScope.getSnapshot());
631
635
  const snapshot = official ? dsSnapshot : piSnapshot;
632
636
  const readonly = snapshot.status === "unavailable" || !snapshot.writable;
633
- const providers = official ? {} : providersOf(piSnapshot);
637
+ const providers = official ? {} : providersOf$1(piSnapshot);
634
638
  const dsSection = official ? deepseekSectionOf(dsSnapshot) : void 0;
635
639
  let currentWindow;
636
640
  let writableTarget = false;
@@ -752,10 +756,10 @@ window.__ModuleLoader__.load({
752
756
  role: "group",
753
757
  "aria-label": t("input.context.title"),
754
758
  children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
755
- style: rowStyle,
759
+ style: rowStyle$1,
756
760
  children: [
757
761
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
758
- style: labelStyle,
762
+ style: labelStyle$1,
759
763
  title: t("input.context.globalHint"),
760
764
  children: t("input.context.title")
761
765
  }),
@@ -856,6 +860,1180 @@ window.__ModuleLoader__.load({
856
860
  });
857
861
  }
858
862
  //#endregion
863
+ //#region src/client/card.tsx
864
+ /**
865
+ * Thinking-levels settings card — the family settings tab face of the
866
+ * dsh-thinking-levels plugin.
867
+ *
868
+ * The card binds this plugin's entry config through the `configForms` cordis
869
+ * service and renders its fields: the level picker
870
+ * (off / on / minimal / low / medium / high / xhigh / max / auto) plus the
871
+ * scheduler toggles. Every change commits immediately through the scope (no
872
+ * staged form): the decision is read per model request, so a committed change
873
+ * applies to the next request without a restart.
874
+ *
875
+ * Below the scheduler rows, a "model capabilities" block edits the
876
+ * `llm-pi-ai` namespace directly (read + write through the same settings
877
+ * transport), borrowing dsh-thinking-effort's presentation: providers group
878
+ * their models, each model row shows capability badges and expands into a
879
+ * per-level editor where a level is ticked and its gateway wire value entered
880
+ * (e.g. `high` → `ultra`); `off` left empty means "do not send". A search box
881
+ * filters models and one-click presets apply official/generic level sets to
882
+ * every thinking model.
883
+ *
884
+ * Kept dependency-free beyond react: the scopes are subscribed with
885
+ * `useSyncExternalStore`, and the controls are plain HTML so the client bundle
886
+ * needs no CSS modules and no primitives value import.
887
+ */
888
+ /** The user-facing levels, in picker order: eight standard levels plus the auto scheduler sentinel. */
889
+ const EFFORT_OPTIONS = [
890
+ "off",
891
+ "on",
892
+ "minimal",
893
+ "low",
894
+ "medium",
895
+ "high",
896
+ "xhigh",
897
+ "max",
898
+ "auto"
899
+ ];
900
+ /**
901
+ * The levels the capability editor offers. This is the llm-pi-ai
902
+ * `reasoningEfforts` table-key space — pi-ai's fixed seven levels (schema
903
+ * rejects any other key). `on` (the enable-thinking toggle) is a selector /
904
+ * injection-level concept, expressed here by the `off` + `high` pair
905
+ * (enable_thinking false/true), so it has no table key of its own.
906
+ */
907
+ const CAPABILITY_LEVELS = [
908
+ "off",
909
+ "minimal",
910
+ "low",
911
+ "medium",
912
+ "high",
913
+ "xhigh",
914
+ "max"
915
+ ];
916
+ /** One-click presets, mirroring dsh-thinking-effort: official DeepSeek style and a generic set. */
917
+ const PRESETS = [{
918
+ key: "official",
919
+ levels: {
920
+ off: null,
921
+ high: "high",
922
+ max: "max"
923
+ }
924
+ }, {
925
+ key: "generic",
926
+ levels: {
927
+ off: null,
928
+ low: "low",
929
+ medium: "medium",
930
+ high: "high"
931
+ }
932
+ }];
933
+ /** The wire thinking formats offered (llm-pi-ai's nameable set, incl. qwen-chat-template). */
934
+ const THINKING_FORMATS = [
935
+ "openai",
936
+ "deepseek",
937
+ "openrouter",
938
+ "together",
939
+ "zai",
940
+ "qwen",
941
+ "qwen-chat-template",
942
+ "string-thinking",
943
+ "ant-ling"
944
+ ];
945
+ const rowStyle = {
946
+ display: "flex",
947
+ alignItems: "center",
948
+ justifyContent: "space-between",
949
+ gap: "12px",
950
+ padding: "6px 0",
951
+ fontSize: "13px",
952
+ lineHeight: "20px"
953
+ };
954
+ const labelStyle = {
955
+ margin: 0,
956
+ color: "var(--dsw-alias-label-primary)"
957
+ };
958
+ const controlStyle = {
959
+ background: "var(--dsw-alias-bg-surface, #fff)",
960
+ color: "var(--dsw-alias-label-primary)",
961
+ border: "1px solid var(--dsw-alias-border-l2)",
962
+ borderRadius: "4px",
963
+ padding: "3px 8px",
964
+ fontSize: "13px"
965
+ };
966
+ const sectionStyle = {
967
+ marginTop: "14px",
968
+ paddingTop: "12px",
969
+ borderTop: "1px solid var(--dsw-alias-border-l2)"
970
+ };
971
+ const fieldStyle = {
972
+ display: "flex",
973
+ flexDirection: "column",
974
+ gap: "4px"
975
+ };
976
+ const fieldLabelStyle = {
977
+ margin: 0,
978
+ fontSize: "12px",
979
+ lineHeight: "18px",
980
+ color: "var(--dsw-alias-label-tertiary)"
981
+ };
982
+ const hintStyle = {
983
+ margin: "6px 0 0",
984
+ fontSize: "12px",
985
+ lineHeight: "18px",
986
+ color: "var(--dsw-alias-label-tertiary)"
987
+ };
988
+ /** Provider group shell: an outlined row grouping its models. */
989
+ const providerStyle = {
990
+ border: "1px solid var(--dsw-alias-border-l2)",
991
+ borderRadius: "8px",
992
+ margin: "8px 0 0",
993
+ overflow: "hidden"
994
+ };
995
+ const providerHeadStyle = {
996
+ display: "flex",
997
+ alignItems: "center",
998
+ gap: "8px",
999
+ padding: "7px 10px",
1000
+ background: "var(--dsw-alias-bg-layer-2, rgba(127,127,127,0.06))"
1001
+ };
1002
+ const providerNameStyle = {
1003
+ margin: 0,
1004
+ flex: "1 1 auto",
1005
+ minWidth: 0,
1006
+ fontFamily: "var(--ds-font-family-code, monospace)",
1007
+ fontSize: "12px",
1008
+ lineHeight: "18px",
1009
+ fontWeight: 600,
1010
+ color: "var(--dsw-alias-label-primary)",
1011
+ overflowWrap: "anywhere"
1012
+ };
1013
+ const providerBadgeStyle = {
1014
+ margin: 0,
1015
+ fontSize: "10px",
1016
+ lineHeight: "16px",
1017
+ color: "var(--dsw-alias-label-tertiary)",
1018
+ border: "1px solid var(--dsw-alias-border-l2)",
1019
+ borderRadius: "4px",
1020
+ padding: "0 5px",
1021
+ whiteSpace: "nowrap"
1022
+ };
1023
+ const iconButtonStyle = {
1024
+ background: "none",
1025
+ border: "none",
1026
+ color: "var(--dsw-alias-label-tertiary)",
1027
+ cursor: "pointer",
1028
+ padding: "2px 4px",
1029
+ display: "inline-flex",
1030
+ alignItems: "center"
1031
+ };
1032
+ /** One model row inside a provider group. */
1033
+ const modelRowStyle = {
1034
+ display: "flex",
1035
+ alignItems: "center",
1036
+ gap: "8px",
1037
+ padding: "7px 10px",
1038
+ borderTop: "1px solid var(--dsw-alias-border-l2)"
1039
+ };
1040
+ const modelIdStyle = {
1041
+ margin: 0,
1042
+ flex: "1 1 auto",
1043
+ minWidth: 0,
1044
+ fontFamily: "var(--ds-font-family-code, monospace)",
1045
+ fontSize: "12px",
1046
+ lineHeight: "18px",
1047
+ color: "var(--dsw-alias-label-secondary)",
1048
+ overflowWrap: "anywhere"
1049
+ };
1050
+ /** Capability badge chips (text / image / context). */
1051
+ const badgeStyle = {
1052
+ fontSize: "10px",
1053
+ lineHeight: "16px",
1054
+ color: "var(--dsw-alias-label-tertiary)",
1055
+ border: "1px solid var(--dsw-alias-border-l2)",
1056
+ borderRadius: "4px",
1057
+ padding: "0 5px",
1058
+ whiteSpace: "nowrap"
1059
+ };
1060
+ /** The per-level editor grid: one row per level with a toggle, a label and a wire input. */
1061
+ const levelRowStyle = {
1062
+ display: "grid",
1063
+ gridTemplateColumns: "auto 92px minmax(0, 1fr)",
1064
+ alignItems: "center",
1065
+ gap: "8px",
1066
+ padding: "4px 0",
1067
+ fontSize: "13px"
1068
+ };
1069
+ const levelNameStyle = {
1070
+ margin: 0,
1071
+ fontSize: "12px",
1072
+ lineHeight: "18px",
1073
+ color: "var(--dsw-alias-label-secondary)"
1074
+ };
1075
+ const wireInputStyle = {
1076
+ background: "var(--dsw-alias-bg-surface, #fff)",
1077
+ color: "var(--dsw-alias-label-primary)",
1078
+ border: "1px solid var(--dsw-alias-border-l2)",
1079
+ borderRadius: "4px",
1080
+ padding: "3px 8px",
1081
+ fontSize: "12px",
1082
+ width: "100%",
1083
+ boxSizing: "border-box"
1084
+ };
1085
+ /** A row's `reasoningEfforts` as stored in the user layer. */
1086
+ function effortsOf(model) {
1087
+ const value = model["reasoningEfforts"];
1088
+ if (value === false) return false;
1089
+ if (typeof value === "object" && value !== null && !Array.isArray(value)) return value;
1090
+ }
1091
+ /**
1092
+ * Build a `reasoningEfforts` table from a level→wire draft. `off` maps to
1093
+ * `null` (omit the reasoning option → enable_thinking false) unless the user
1094
+ * typed a wire value; every other ticked level keeps its typed wire value.
1095
+ * pi-ai rejects a table offering nothing beyond `off`, so a selection of only
1096
+ * `off` falls back to the default `high` level.
1097
+ */
1098
+ function effortTableOf(draft) {
1099
+ const table = {};
1100
+ for (const level of CAPABILITY_LEVELS) {
1101
+ const wire = draft[level];
1102
+ if (wire === void 0 || wire === null) continue;
1103
+ const trimmed = typeof wire === "string" ? wire.trim() : "";
1104
+ if (level === "off") table[level] = trimmed === "" ? null : trimmed;
1105
+ else if (trimmed !== "") table[level] = trimmed;
1106
+ }
1107
+ if (Object.keys(table).length === 0 || Object.keys(table).every((level) => table[level] === null)) return {
1108
+ ...table,
1109
+ high: "high"
1110
+ };
1111
+ return table;
1112
+ }
1113
+ /** Whether a row declares `compat.supportsReasoningEffort` (the wire sends reasoning_effort). */
1114
+ function supportsEffortOf(model) {
1115
+ const compat = model["compat"];
1116
+ if (typeof compat !== "object" || compat === null || Array.isArray(compat)) return false;
1117
+ return compat["supportsReasoningEffort"] === true;
1118
+ }
1119
+ /** Patch one row's `compat` object, merging rather than replacing sibling fields. */
1120
+ function patchCompat(row, patch) {
1121
+ const compat = typeof row["compat"] === "object" && row["compat"] !== null && !Array.isArray(row["compat"]) ? { ...row["compat"] } : {};
1122
+ patch(compat);
1123
+ if (Object.keys(compat).length === 0) delete row["compat"];
1124
+ else row["compat"] = compat;
1125
+ }
1126
+ /** The user-layer `providers` value of the llm-pi-ai namespace, when present. */
1127
+ function providersOf(snapshot) {
1128
+ if (typeof snapshot !== "object" || snapshot === null) return {};
1129
+ const user = snapshot.user;
1130
+ if (typeof user !== "object" || user === null || Array.isArray(user)) return {};
1131
+ const providers = user["providers"];
1132
+ return typeof providers === "object" && providers !== null && !Array.isArray(providers) ? providers : {};
1133
+ }
1134
+ /** Whether a route-level profile declares `compat.supportsDeveloperRole: false`. */
1135
+ function developerRoleDisabledOf(profile) {
1136
+ if (typeof profile !== "object" || profile === null) return false;
1137
+ const compat = profile["compat"];
1138
+ if (typeof compat !== "object" || compat === null || Array.isArray(compat)) return false;
1139
+ return compat["supportsDeveloperRole"] === false;
1140
+ }
1141
+ /** The effective `compat` of an entry: its own `compat` merged over the provider-level `compat`. */
1142
+ function compatOf(entry) {
1143
+ const base = typeof entry.providerCompat === "object" && entry.providerCompat !== null ? entry.providerCompat : {};
1144
+ const own = entry.model["compat"];
1145
+ return typeof own === "object" && own !== null && !Array.isArray(own) ? {
1146
+ ...base,
1147
+ ...own
1148
+ } : base;
1149
+ }
1150
+ /** Flatten the user-layer providers into capability entries (models arrays only). */
1151
+ function entriesOf(providers) {
1152
+ return Object.entries(providers).flatMap(([providerId, profile]) => {
1153
+ const raw = profile;
1154
+ const models = raw["models"];
1155
+ if (!Array.isArray(models)) return [];
1156
+ const providerCompat = raw["compat"];
1157
+ const providerInput = Array.isArray(raw["defaultInput"]) ? raw["defaultInput"] : void 0;
1158
+ return models.map((model, index) => ({
1159
+ providerId,
1160
+ index,
1161
+ model: typeof model === "object" && model !== null && !Array.isArray(model) ? model : {},
1162
+ modelId: typeof model === "object" && model !== null && typeof model["id"] === "string" ? model["id"] : `#${index + 1}`,
1163
+ providerCompat,
1164
+ providerInput
1165
+ }));
1166
+ });
1167
+ }
1168
+ /** Human-readable capability summary of one entry (input modalities + declared context window). */
1169
+ function summaryOf(entry) {
1170
+ const input = Array.isArray(entry.model["input"]) ? entry.model["input"] : entry.providerInput;
1171
+ const text = !Array.isArray(input) || input.length === 0 || input.includes("text");
1172
+ const image = Array.isArray(input) && input.includes("image");
1173
+ const contextWindow = entry.model["contextWindow"];
1174
+ return {
1175
+ text,
1176
+ image,
1177
+ context: typeof contextWindow === "number" && Number.isFinite(contextWindow) && contextWindow > 0 ? formatContextWindow(contextWindow) : null
1178
+ };
1179
+ }
1180
+ /** A tiny inline chevron icon (no CSS modules). */
1181
+ function ChevronIcon({ open }) {
1182
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1183
+ width: "12",
1184
+ height: "12",
1185
+ viewBox: "0 0 16 16",
1186
+ "aria-hidden": true,
1187
+ style: {
1188
+ transform: open ? "rotate(180deg)" : "none",
1189
+ transition: "transform 0.16s"
1190
+ },
1191
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1192
+ d: "M4 6l4 4 4-4",
1193
+ fill: "none",
1194
+ stroke: "currentColor",
1195
+ strokeWidth: "1.5",
1196
+ strokeLinecap: "round",
1197
+ strokeLinejoin: "round"
1198
+ })
1199
+ });
1200
+ }
1201
+ /**
1202
+ * The llm-pi-ai model-capability editor block (dsh-thinking-effort style:
1203
+ * provider groups, model rows with badges, per-level wire editors, search and
1204
+ * one-click presets).
1205
+ * @param scope - the `llm-pi-ai` namespace scope.
1206
+ * @param t - copy lookup.
1207
+ * @param readonly - whether writes are forbidden.
1208
+ * @returns the capabilities block, or a placeholder when nothing is configured.
1209
+ */
1210
+ function ModelCapabilities(props) {
1211
+ const { scope, t, readonly } = props;
1212
+ const snapshot = (0, react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
1213
+ const unavailable = snapshot.status === "unavailable";
1214
+ const providers = snapshot.status === "ready" ? providersOf(snapshot) : {};
1215
+ const allEntries = entriesOf(providers);
1216
+ const [query, setQuery] = (0, react.useState)("");
1217
+ const [expandedProviders, setExpandedProviders] = (0, react.useState)({});
1218
+ const [expandedModels, setExpandedModels] = (0, react.useState)({});
1219
+ const [drafts, setDrafts] = (0, react.useState)({});
1220
+ const [busy, setBusy] = (0, react.useState)(false);
1221
+ const [contextRaw, setContextRaw] = (0, react.useState)({});
1222
+ const [contextError, setContextError] = (0, react.useState)({});
1223
+ const entryKey = (entry) => `${entry.providerId}\u0000${entry.index}`;
1224
+ /** Commit one patch over the user-layer providers. */
1225
+ const commitProviders = (mutate) => {
1226
+ if (snapshot.status !== "ready" || readonly) return;
1227
+ setBusy(true);
1228
+ scope.set("providers", mutate(structuredClone(providers))).then(() => {
1229
+ setBusy(false);
1230
+ }).catch(() => {
1231
+ setBusy(false);
1232
+ });
1233
+ };
1234
+ /** Toggle the route-level official compat flag: unchecked = inherit (unset). */
1235
+ const toggleDeveloperRole = (providerId, next) => {
1236
+ commitProviders((current) => {
1237
+ const profile = current[providerId];
1238
+ if (profile === void 0) return current;
1239
+ const compat = typeof profile["compat"] === "object" && profile["compat"] !== null && !Array.isArray(profile["compat"]) ? { ...profile["compat"] } : {};
1240
+ if (next) compat["supportsDeveloperRole"] = false;
1241
+ else delete compat["supportsDeveloperRole"];
1242
+ if (Object.keys(compat).length === 0) delete profile["compat"];
1243
+ else profile["compat"] = compat;
1244
+ return current;
1245
+ });
1246
+ };
1247
+ /** Patch one model row of one provider. */
1248
+ const patchModel = (providerId, index, patch) => {
1249
+ commitProviders((current) => {
1250
+ const profile = current[providerId];
1251
+ if (profile === void 0 || !Array.isArray(profile.models)) return current;
1252
+ const model = profile.models[index];
1253
+ if (typeof model !== "object" || model === null) return current;
1254
+ patch(model);
1255
+ return current;
1256
+ });
1257
+ };
1258
+ /** Toggle whether a model is a thinking model (reasoningEfforts table vs false). */
1259
+ const toggleThinking = (entry, next) => {
1260
+ patchModel(entry.providerId, entry.index, (row) => {
1261
+ if (next) {
1262
+ const effortCapable = supportsEffortOf(row);
1263
+ row["reasoningEfforts"] = effortCapable ? effortTableOf({ high: "high" }) : {
1264
+ off: null,
1265
+ high: "high"
1266
+ };
1267
+ if (!effortCapable) patchCompat(row, (compat) => {
1268
+ if (compat["thinkingFormat"] === void 0) compat["thinkingFormat"] = "qwen-chat-template";
1269
+ });
1270
+ } else row["reasoningEfforts"] = false;
1271
+ });
1272
+ };
1273
+ /** Toggle whether a model accepts reasoning_effort levels. */
1274
+ const toggleEffortCapable = (entry, next) => {
1275
+ patchModel(entry.providerId, entry.index, (row) => {
1276
+ patchCompat(row, (compat) => {
1277
+ compat["supportsReasoningEffort"] = next;
1278
+ if (next && compat["thinkingFormat"] === "qwen-chat-template") delete compat["thinkingFormat"];
1279
+ });
1280
+ });
1281
+ };
1282
+ /** Apply one model's wire draft as its `reasoningEfforts` table. */
1283
+ const applyDraft = (entry) => {
1284
+ const key = entryKey(entry);
1285
+ const draft = drafts[key];
1286
+ if (draft === void 0) return;
1287
+ const table = effortTableOf(draft);
1288
+ patchModel(entry.providerId, entry.index, (row) => {
1289
+ row["reasoningEfforts"] = table;
1290
+ const extended = Object.keys(table).some((level) => level !== "off" && level !== "on" && level !== "high");
1291
+ if (supportsEffortOf(row) || extended) patchCompat(row, (compat) => {
1292
+ compat["supportsReasoningEffort"] = true;
1293
+ });
1294
+ });
1295
+ };
1296
+ /** Reset a model's draft to its persisted table (or the default high set). */
1297
+ const resetDraft = (entry) => {
1298
+ const key = entryKey(entry);
1299
+ setDrafts((current) => {
1300
+ const next = { ...current };
1301
+ const table = effortsOf(entry.model);
1302
+ 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])]));
1303
+ else next[key] = {
1304
+ off: "",
1305
+ high: "high"
1306
+ };
1307
+ return next;
1308
+ });
1309
+ };
1310
+ /** Seed a model's draft when it is first expanded. */
1311
+ const ensureDraft = (entry) => {
1312
+ const key = entryKey(entry);
1313
+ setDrafts((current) => {
1314
+ if (current[key] !== void 0) return current;
1315
+ const next = { ...current };
1316
+ const table = effortsOf(entry.model);
1317
+ 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])]));
1318
+ else next[key] = {
1319
+ off: "",
1320
+ high: "high"
1321
+ };
1322
+ return next;
1323
+ });
1324
+ };
1325
+ /** Apply a one-click preset to every thinking model. */
1326
+ const applyPreset = (levels) => {
1327
+ commitProviders((current) => {
1328
+ for (const entry of entriesOf(current)) {
1329
+ const profile = current[entry.providerId];
1330
+ if (profile === void 0 || !Array.isArray(profile.models)) continue;
1331
+ const model = profile.models[entry.index];
1332
+ if (typeof model !== "object" || model === null) continue;
1333
+ const row = model;
1334
+ if (effortsOf(row) === void 0) continue;
1335
+ row["reasoningEfforts"] = levels;
1336
+ }
1337
+ return current;
1338
+ });
1339
+ };
1340
+ /** Seed a model's context-window input when it is first expanded. */
1341
+ const seedContext = (entry) => {
1342
+ const key = entryKey(entry);
1343
+ setContextRaw((current) => {
1344
+ if (current[key] !== void 0) return current;
1345
+ const value = entry.model["contextWindow"];
1346
+ return {
1347
+ ...current,
1348
+ [key]: typeof value === "number" && Number.isFinite(value) ? String(value) : ""
1349
+ };
1350
+ });
1351
+ };
1352
+ /** Write (or delete) a model's `contextWindow` in the llm-pi-ai entry. */
1353
+ const commitContextWindow = (entry, value) => {
1354
+ const key = entryKey(entry);
1355
+ patchModel(entry.providerId, entry.index, (row) => {
1356
+ if (value === void 0) delete row["contextWindow"];
1357
+ else row["contextWindow"] = value;
1358
+ });
1359
+ setContextError((current) => {
1360
+ const next = { ...current };
1361
+ delete next[key];
1362
+ return next;
1363
+ });
1364
+ };
1365
+ /** Apply one preset immediately. */
1366
+ const applyContextPreset = (entry, value) => {
1367
+ const key = entryKey(entry);
1368
+ setContextRaw((current) => ({
1369
+ ...current,
1370
+ [key]: String(value)
1371
+ }));
1372
+ commitContextWindow(entry, value);
1373
+ };
1374
+ /** Validate and commit the custom input (blur / Enter); empty clears it. */
1375
+ const applyContextInput = (entry) => {
1376
+ const key = entryKey(entry);
1377
+ const raw = (contextRaw[key] ?? "").trim();
1378
+ if (raw === "") {
1379
+ commitContextWindow(entry, void 0);
1380
+ return;
1381
+ }
1382
+ const validation = validateContextWindow(raw);
1383
+ if (!validation.ok) {
1384
+ setContextError((current) => ({
1385
+ ...current,
1386
+ [key]: t(validation.reason === "integer" ? "card.capabilities.contextInteger" : "card.capabilities.contextRange")
1387
+ }));
1388
+ return;
1389
+ }
1390
+ commitContextWindow(entry, validation.value);
1391
+ };
1392
+ /** Clear the model's context-window declaration (delete the field). */
1393
+ const clearContext = (entry) => {
1394
+ const key = entryKey(entry);
1395
+ setContextRaw((current) => ({
1396
+ ...current,
1397
+ [key]: ""
1398
+ }));
1399
+ commitContextWindow(entry, void 0);
1400
+ };
1401
+ if (unavailable) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1402
+ style: sectionStyle,
1403
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1404
+ style: hintStyle,
1405
+ children: t("card.capabilities.unavailable")
1406
+ })
1407
+ });
1408
+ if (allEntries.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1409
+ style: sectionStyle,
1410
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1411
+ style: fieldLabelStyle,
1412
+ children: t("card.capabilities")
1413
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1414
+ style: hintStyle,
1415
+ children: t("card.capabilities.empty")
1416
+ })]
1417
+ });
1418
+ const needle = query.trim().toLowerCase();
1419
+ const visible = needle === "" ? allEntries : allEntries.filter((entry) => entry.modelId.toLowerCase().includes(needle) || entry.providerId.toLowerCase().includes(needle));
1420
+ const providerIds = [...new Set(visible.map((entry) => entry.providerId))];
1421
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1422
+ style: sectionStyle,
1423
+ children: [
1424
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1425
+ style: fieldLabelStyle,
1426
+ children: t("card.capabilities")
1427
+ }),
1428
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1429
+ style: hintStyle,
1430
+ children: t("card.capabilities.hint")
1431
+ }),
1432
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1433
+ style: {
1434
+ display: "flex",
1435
+ gap: "8px",
1436
+ flexWrap: "wrap",
1437
+ alignItems: "center",
1438
+ margin: "8px 0 2px"
1439
+ },
1440
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1441
+ type: "text",
1442
+ value: query,
1443
+ placeholder: t("card.capabilities.search"),
1444
+ disabled: readonly || busy,
1445
+ style: {
1446
+ ...controlStyle,
1447
+ flex: "1 1 160px",
1448
+ minWidth: "140px"
1449
+ },
1450
+ onChange: (event) => setQuery(event.currentTarget.value)
1451
+ }), PRESETS.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1452
+ type: "button",
1453
+ disabled: readonly || busy,
1454
+ onClick: () => applyPreset(preset.levels),
1455
+ style: {
1456
+ ...controlStyle,
1457
+ cursor: readonly || busy ? "default" : "pointer",
1458
+ opacity: readonly || busy ? .5 : 1
1459
+ },
1460
+ children: t(`card.capabilities.preset${preset.key === "official" ? "Official" : "Generic"}`)
1461
+ }, preset.key))]
1462
+ }),
1463
+ visible.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1464
+ style: hintStyle,
1465
+ children: t("card.capabilities.noMatches")
1466
+ }) : providerIds.map((providerId) => {
1467
+ const providerEntries = visible.filter((entry) => entry.providerId === providerId);
1468
+ const providerOpen = expandedProviders[providerId] === true || needle !== "";
1469
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1470
+ style: providerStyle,
1471
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1472
+ style: providerHeadStyle,
1473
+ children: [
1474
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1475
+ type: "button",
1476
+ "aria-expanded": providerOpen,
1477
+ disabled: readonly || busy,
1478
+ onClick: () => setExpandedProviders((current) => ({
1479
+ ...current,
1480
+ [providerId]: current[providerId] !== true
1481
+ })),
1482
+ style: {
1483
+ ...iconButtonStyle,
1484
+ cursor: readonly || busy ? "default" : "pointer"
1485
+ },
1486
+ title: providerOpen ? t("card.capabilities.collapseProvider") : t("card.capabilities.expandProvider"),
1487
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChevronIcon, { open: providerOpen })
1488
+ }),
1489
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1490
+ style: providerNameStyle,
1491
+ children: providerId
1492
+ }),
1493
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1494
+ style: {
1495
+ display: "inline-flex",
1496
+ alignItems: "center",
1497
+ gap: "5px",
1498
+ fontSize: "11px",
1499
+ whiteSpace: "nowrap",
1500
+ color: "var(--dsw-alias-label-secondary)"
1501
+ },
1502
+ title: t("card.capabilities.developerRoleHint"),
1503
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1504
+ type: "checkbox",
1505
+ checked: developerRoleDisabledOf(providers[providerId]),
1506
+ disabled: readonly || busy,
1507
+ onChange: (event) => toggleDeveloperRole(providerId, event.currentTarget.checked)
1508
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.developerRole") })]
1509
+ }),
1510
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1511
+ style: providerBadgeStyle,
1512
+ children: providerEntries.length
1513
+ })
1514
+ ]
1515
+ }), providerOpen ? providerEntries.map((entry) => {
1516
+ const key = entryKey(entry);
1517
+ const modelOpen = expandedModels[key] === true;
1518
+ const thinking = typeof effortsOf(entry.model) === "object";
1519
+ const compat = compatOf(entry);
1520
+ const supportsEffort = compat["supportsReasoningEffort"] === true;
1521
+ const meta = summaryOf(entry);
1522
+ const format = typeof compat["thinkingFormat"] === "string" ? compat["thinkingFormat"] : void 0;
1523
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1524
+ style: modelRowStyle,
1525
+ children: [
1526
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1527
+ type: "button",
1528
+ "aria-expanded": modelOpen,
1529
+ disabled: readonly || busy,
1530
+ onClick: () => {
1531
+ const next = expandedModels[key] !== true;
1532
+ setExpandedModels((current) => ({
1533
+ ...current,
1534
+ [key]: next
1535
+ }));
1536
+ if (next) {
1537
+ ensureDraft(entry);
1538
+ seedContext(entry);
1539
+ }
1540
+ },
1541
+ style: {
1542
+ ...iconButtonStyle,
1543
+ cursor: readonly || busy ? "default" : "pointer"
1544
+ },
1545
+ title: modelOpen ? t("card.capabilities.closeModelSettings") : t("card.capabilities.openModelSettings"),
1546
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChevronIcon, { open: modelOpen })
1547
+ }),
1548
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1549
+ style: modelIdStyle,
1550
+ children: entry.modelId
1551
+ }),
1552
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1553
+ style: badgeStyle,
1554
+ title: "text",
1555
+ children: meta.text ? "T" : "–"
1556
+ }),
1557
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1558
+ style: badgeStyle,
1559
+ title: "image",
1560
+ children: meta.image ? "IMG" : "–"
1561
+ }),
1562
+ meta.context !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1563
+ style: badgeStyle,
1564
+ children: meta.context
1565
+ }),
1566
+ thinking && !supportsEffort && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1567
+ style: badgeStyle,
1568
+ children: "On/Off"
1569
+ })
1570
+ ]
1571
+ }), modelOpen ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1572
+ style: {
1573
+ padding: "4px 10px 10px",
1574
+ borderTop: "1px solid var(--dsw-alias-border-l2)"
1575
+ },
1576
+ children: [
1577
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1578
+ style: {
1579
+ display: "flex",
1580
+ gap: "16px",
1581
+ flexWrap: "wrap",
1582
+ margin: "2px 0 8px"
1583
+ },
1584
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1585
+ style: {
1586
+ display: "inline-flex",
1587
+ alignItems: "center",
1588
+ gap: "6px",
1589
+ fontSize: "12px"
1590
+ },
1591
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1592
+ type: "checkbox",
1593
+ checked: thinking,
1594
+ disabled: readonly || busy,
1595
+ onChange: (event) => toggleThinking(entry, event.currentTarget.checked)
1596
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.thinking") })]
1597
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1598
+ style: {
1599
+ display: "inline-flex",
1600
+ alignItems: "center",
1601
+ gap: "6px",
1602
+ fontSize: "12px"
1603
+ },
1604
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1605
+ type: "checkbox",
1606
+ checked: meta.image,
1607
+ disabled: readonly || busy,
1608
+ onChange: (event) => {
1609
+ patchModel(entry.providerId, entry.index, (row) => {
1610
+ row["input"] = event.currentTarget.checked ? ["text", "image"] : ["text"];
1611
+ });
1612
+ }
1613
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.vision") })]
1614
+ })]
1615
+ }),
1616
+ thinking ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1617
+ style: {
1618
+ display: "inline-flex",
1619
+ alignItems: "center",
1620
+ gap: "6px",
1621
+ fontSize: "12px",
1622
+ margin: "0 0 8px"
1623
+ },
1624
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1625
+ type: "checkbox",
1626
+ checked: supportsEffort,
1627
+ disabled: readonly || busy,
1628
+ onChange: (event) => toggleEffortCapable(entry, event.currentTarget.checked)
1629
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: t("card.capabilities.supportsEffort") })]
1630
+ }) : null,
1631
+ thinking && supportsEffort ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1632
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1633
+ style: fieldLabelStyle,
1634
+ children: t("card.capabilities.efforts")
1635
+ }),
1636
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1637
+ style: { margin: "4px 0 6px" },
1638
+ children: CAPABILITY_LEVELS.map((level) => {
1639
+ const wire = drafts[key]?.[level];
1640
+ const on = wire !== void 0 && wire !== null;
1641
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1642
+ style: levelRowStyle,
1643
+ children: [
1644
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1645
+ style: {
1646
+ display: "inline-flex",
1647
+ alignItems: "center",
1648
+ gap: "6px",
1649
+ fontSize: "12px"
1650
+ },
1651
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1652
+ type: "checkbox",
1653
+ checked: on,
1654
+ disabled: readonly || busy,
1655
+ onChange: (event) => {
1656
+ const checked = event.currentTarget.checked;
1657
+ setDrafts((current) => {
1658
+ const draft = { ...current[key] ?? {} };
1659
+ draft[level] = checked ? level === "off" ? "" : level : null;
1660
+ return {
1661
+ ...current,
1662
+ [key]: draft
1663
+ };
1664
+ });
1665
+ }
1666
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children: level })]
1667
+ }),
1668
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1669
+ style: levelNameStyle,
1670
+ children: level === "off" ? t("card.capabilities.offPlaceholder") : "→"
1671
+ }),
1672
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1673
+ type: "text",
1674
+ value: wire ?? "",
1675
+ disabled: readonly || busy || !on,
1676
+ placeholder: t("card.capabilities.wirePlaceholder"),
1677
+ style: wireInputStyle,
1678
+ onChange: (event) => {
1679
+ setDrafts((current) => {
1680
+ const draft = { ...current[key] ?? {} };
1681
+ draft[level] = event.currentTarget.value;
1682
+ return {
1683
+ ...current,
1684
+ [key]: draft
1685
+ };
1686
+ });
1687
+ }
1688
+ })
1689
+ ]
1690
+ }, level);
1691
+ })
1692
+ }),
1693
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1694
+ style: {
1695
+ display: "flex",
1696
+ gap: "8px",
1697
+ flexWrap: "wrap"
1698
+ },
1699
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1700
+ type: "button",
1701
+ disabled: readonly || busy,
1702
+ onClick: () => applyDraft(entry),
1703
+ style: {
1704
+ ...controlStyle,
1705
+ cursor: readonly || busy ? "default" : "pointer",
1706
+ opacity: readonly || busy ? .5 : 1
1707
+ },
1708
+ children: t("card.capabilities.applyLevel")
1709
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1710
+ type: "button",
1711
+ disabled: readonly || busy,
1712
+ onClick: () => resetDraft(entry),
1713
+ style: {
1714
+ ...controlStyle,
1715
+ cursor: readonly || busy ? "default" : "pointer",
1716
+ opacity: readonly || busy ? .5 : 1
1717
+ },
1718
+ children: t("card.capabilities.restoreDefault")
1719
+ })]
1720
+ })
1721
+ ] }) : null,
1722
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1723
+ style: {
1724
+ display: "flex",
1725
+ gap: "16px",
1726
+ flexWrap: "wrap",
1727
+ marginTop: "10px"
1728
+ },
1729
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1730
+ style: fieldStyle,
1731
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1732
+ style: fieldLabelStyle,
1733
+ children: t("card.capabilities.thinkingFormat")
1734
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
1735
+ style: controlStyle,
1736
+ value: format ?? "inherit",
1737
+ disabled: readonly || busy,
1738
+ onChange: (event) => {
1739
+ const next = event.currentTarget.value;
1740
+ patchModel(entry.providerId, entry.index, (row) => {
1741
+ patchCompat(row, (compat) => {
1742
+ if (next === "inherit") delete compat["thinkingFormat"];
1743
+ else compat["thinkingFormat"] = next;
1744
+ });
1745
+ });
1746
+ },
1747
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1748
+ value: "inherit",
1749
+ children: t("card.capabilities.thinkingFormat.inherit")
1750
+ }), THINKING_FORMATS.map((formatOption) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1751
+ value: formatOption,
1752
+ children: formatOption
1753
+ }, formatOption))]
1754
+ })]
1755
+ })
1756
+ }),
1757
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1758
+ style: {
1759
+ display: "flex",
1760
+ gap: "16px",
1761
+ flexWrap: "wrap",
1762
+ marginTop: "10px"
1763
+ },
1764
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
1765
+ style: fieldStyle,
1766
+ children: [
1767
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1768
+ style: fieldLabelStyle,
1769
+ children: t("card.capabilities.contextWindow")
1770
+ }),
1771
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1772
+ style: {
1773
+ display: "flex",
1774
+ gap: "6px",
1775
+ flexWrap: "wrap",
1776
+ alignItems: "center"
1777
+ },
1778
+ children: [
1779
+ CONTEXT_WINDOW_PRESETS.map((preset) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1780
+ type: "button",
1781
+ disabled: readonly || busy,
1782
+ onClick: () => applyContextPreset(entry, preset.value),
1783
+ style: {
1784
+ ...controlStyle,
1785
+ padding: "2px 8px",
1786
+ cursor: readonly || busy ? "default" : "pointer",
1787
+ opacity: readonly || busy ? .5 : 1
1788
+ },
1789
+ children: preset.label
1790
+ }, preset.value)),
1791
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1792
+ type: "text",
1793
+ value: contextRaw[key] ?? "",
1794
+ disabled: readonly || busy,
1795
+ placeholder: t("card.capabilities.contextCustomPlaceholder"),
1796
+ style: {
1797
+ ...controlStyle,
1798
+ width: "120px"
1799
+ },
1800
+ onChange: (event) => {
1801
+ const next = event.currentTarget.value;
1802
+ setContextRaw((current) => ({
1803
+ ...current,
1804
+ [key]: next
1805
+ }));
1806
+ },
1807
+ onBlur: () => applyContextInput(entry),
1808
+ onKeyDown: (event) => {
1809
+ if (event.key === "Enter") event.currentTarget.blur();
1810
+ }
1811
+ }),
1812
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
1813
+ type: "button",
1814
+ disabled: readonly || busy,
1815
+ onClick: () => clearContext(entry),
1816
+ style: {
1817
+ ...controlStyle,
1818
+ cursor: readonly || busy ? "default" : "pointer",
1819
+ opacity: readonly || busy ? .5 : 1
1820
+ },
1821
+ children: t("card.capabilities.contextClear")
1822
+ })
1823
+ ]
1824
+ }),
1825
+ contextError[key] !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
1826
+ style: {
1827
+ margin: 0,
1828
+ fontSize: "12px",
1829
+ lineHeight: "18px",
1830
+ color: "var(--dsw-alias-danger, #e5484d)"
1831
+ },
1832
+ children: contextError[key]
1833
+ }) : null
1834
+ ]
1835
+ })
1836
+ })
1837
+ ]
1838
+ }) : null] }, key);
1839
+ }) : null]
1840
+ }, providerId);
1841
+ }),
1842
+ readonly ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
1843
+ style: hintStyle,
1844
+ children: t("card.readonly")
1845
+ }) : null
1846
+ ]
1847
+ });
1848
+ }
1849
+ /**
1850
+ * The card body, wrapped in a disclosure shell like every peer settings card:
1851
+ * a header (name + description + chevron) that toggles the body, collapsed by
1852
+ * default so the plugin tab stays a tidy list of drawers.
1853
+ * @param props - locale copy and the injected scopes.
1854
+ */
1855
+ function ThinkingLevelsCard({ t, scope, piAiScope }) {
1856
+ const [open, setOpen] = (0, react.useState)(false);
1857
+ const snapshot = (0, react.useSyncExternalStore)((listener) => scope.subscribe(listener), () => scope.getSnapshot());
1858
+ const unavailable = snapshot.status === "unavailable";
1859
+ const readonly = unavailable || !snapshot.writable;
1860
+ const value = snapshot.value ?? {};
1861
+ const level = EFFORT_OPTIONS.includes(value.level) ? value.level : "auto";
1862
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1863
+ style: {
1864
+ border: "1px solid var(--dsw-alias-border-l2, rgba(127,127,127,0.35))",
1865
+ background: "var(--dsw-alias-bg-layer-3, rgba(127,127,127,0.05))",
1866
+ borderRadius: "12px",
1867
+ transition: "border-color 0.16s, background 0.16s"
1868
+ },
1869
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
1870
+ type: "button",
1871
+ "aria-expanded": open,
1872
+ style: {
1873
+ appearance: "none",
1874
+ width: "100%",
1875
+ font: "inherit",
1876
+ color: "inherit",
1877
+ textAlign: "left",
1878
+ cursor: "pointer",
1879
+ background: "none",
1880
+ border: 0,
1881
+ borderRadius: "12px",
1882
+ display: "flex",
1883
+ alignItems: "center",
1884
+ gap: "12px",
1885
+ padding: "14px 16px"
1886
+ },
1887
+ onClick: () => {
1888
+ setOpen((current) => !current);
1889
+ },
1890
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
1891
+ style: {
1892
+ flex: "1 1 0%",
1893
+ minWidth: 0
1894
+ },
1895
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1896
+ style: {
1897
+ fontSize: "14px",
1898
+ fontWeight: 600,
1899
+ color: "var(--dsw-alias-label-primary)"
1900
+ },
1901
+ children: t("card.title")
1902
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1903
+ style: {
1904
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,0.8))",
1905
+ fontSize: "13px",
1906
+ lineHeight: 1.5
1907
+ },
1908
+ children: t("card.description")
1909
+ })]
1910
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
1911
+ width: "16",
1912
+ height: "16",
1913
+ viewBox: "0 0 16 16",
1914
+ "aria-hidden": true,
1915
+ style: {
1916
+ color: "var(--dsw-alias-label-tertiary, rgba(127,127,127,0.8))",
1917
+ flex: "0 0 auto",
1918
+ transition: "transform 0.16s",
1919
+ transform: open ? "rotate(180deg)" : "none"
1920
+ },
1921
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
1922
+ d: "M4 6l4 4 4-4",
1923
+ fill: "none",
1924
+ stroke: "currentColor",
1925
+ strokeWidth: "1.5",
1926
+ strokeLinecap: "round",
1927
+ strokeLinejoin: "round"
1928
+ })
1929
+ })]
1930
+ }), open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1931
+ style: { padding: "12px 16px" },
1932
+ children: unavailable ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
1933
+ style: {
1934
+ fontSize: "13px",
1935
+ color: "var(--dsw-alias-label-tertiary)"
1936
+ },
1937
+ children: t("card.unavailable")
1938
+ }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
1939
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1940
+ style: rowStyle,
1941
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1942
+ htmlFor: "plugin-config-thinking-levels-level",
1943
+ style: labelStyle,
1944
+ children: t("card.level")
1945
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("select", {
1946
+ id: "plugin-config-thinking-levels-level",
1947
+ value: level,
1948
+ disabled: readonly,
1949
+ style: controlStyle,
1950
+ onChange: (event) => {
1951
+ scope.set("level", event.currentTarget.value);
1952
+ },
1953
+ children: EFFORT_OPTIONS.map((option) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
1954
+ value: option,
1955
+ children: t(`card.level.${option}`)
1956
+ }, option))
1957
+ })]
1958
+ }),
1959
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1960
+ style: rowStyle,
1961
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1962
+ htmlFor: "plugin-config-thinking-levels-enabled",
1963
+ style: labelStyle,
1964
+ children: t("card.enabled")
1965
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1966
+ id: "plugin-config-thinking-levels-enabled",
1967
+ type: "checkbox",
1968
+ checked: value.enabled ?? true,
1969
+ disabled: readonly,
1970
+ onChange: (event) => {
1971
+ scope.set("enabled", event.currentTarget.checked);
1972
+ }
1973
+ })]
1974
+ }),
1975
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1976
+ style: rowStyle,
1977
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1978
+ htmlFor: "plugin-config-thinking-levels-downgrade",
1979
+ style: labelStyle,
1980
+ children: t("card.allowDowngrade")
1981
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1982
+ id: "plugin-config-thinking-levels-downgrade",
1983
+ type: "checkbox",
1984
+ checked: value.allowDowngrade ?? true,
1985
+ disabled: readonly || value.level !== "auto",
1986
+ onChange: (event) => {
1987
+ scope.set("allowDowngrade", event.currentTarget.checked);
1988
+ }
1989
+ })]
1990
+ }),
1991
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
1992
+ style: rowStyle,
1993
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
1994
+ htmlFor: "plugin-config-thinking-levels-upgrade",
1995
+ style: labelStyle,
1996
+ children: t("card.allowUpgrade")
1997
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
1998
+ id: "plugin-config-thinking-levels-upgrade",
1999
+ type: "checkbox",
2000
+ checked: value.allowUpgrade ?? false,
2001
+ disabled: readonly || value.level !== "auto",
2002
+ onChange: (event) => {
2003
+ scope.set("allowUpgrade", event.currentTarget.checked);
2004
+ }
2005
+ })]
2006
+ }),
2007
+ !snapshot.writable && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
2008
+ style: {
2009
+ margin: "8px 0 0",
2010
+ fontSize: "12px",
2011
+ color: "var(--dsw-alias-label-tertiary)"
2012
+ },
2013
+ children: t("card.readonly")
2014
+ }),
2015
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ModelCapabilities, {
2016
+ scope: piAiScope,
2017
+ t,
2018
+ readonly
2019
+ })
2020
+ ] })
2021
+ }) : null]
2022
+ });
2023
+ }
2024
+ //#endregion
2025
+ //#region src/client/family-tab.tsx
2026
+ function FamilySettingsTab(props) {
2027
+ const { renderSlot } = props;
2028
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
2029
+ style: {
2030
+ display: "grid",
2031
+ gap: "10px"
2032
+ },
2033
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThinkingLevelsCard, { ...props }), renderSlot("dsh-family.tab", {}, { fallback: null })]
2034
+ });
2035
+ }
2036
+ //#endregion
859
2037
  //#region src/client/index.ts
860
2038
  /** Services required by the browser half. */
861
2039
  const inject = [
@@ -868,6 +2046,7 @@ window.__ModuleLoader__.load({
868
2046
  * @param ctx - client root context.
869
2047
  */
870
2048
  function apply(ctx) {
2049
+ const t = ctx.locale.bind(NS);
871
2050
  ctx.effect(() => {
872
2051
  const disposers = [
873
2052
  ctx.locale.register(NS, {
@@ -894,6 +2073,23 @@ window.__ModuleLoader__.load({
894
2073
  }
895
2074
  }, ContextQuick);
896
2075
  });
2076
+ ctx.slots.inject("settings.plugins.tab", function* () {
2077
+ yield ctx.slots.register({
2078
+ name: "settings.plugins.tab",
2079
+ id: "dsh-family",
2080
+ order: 40,
2081
+ label: () => t("family.title"),
2082
+ locale: NS,
2083
+ inject: () => ({
2084
+ scope: ctx.configForms.get("dsh-thinking-levels"),
2085
+ piAiScope: ctx.configForms.get("llm-pi-ai")
2086
+ }),
2087
+ children: { "dsh-family.tab": {
2088
+ kind: "list",
2089
+ scope: "root"
2090
+ } }
2091
+ }, FamilySettingsTab);
2092
+ });
897
2093
  }
898
2094
  //#endregion
899
2095
  exports.apply = apply;