dsh-coding-subscription-oauth 0.6.2 → 0.6.3

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.
Files changed (121) hide show
  1. package/CHANGELOG.md +222 -206
  2. package/CONTRIBUTING.md +129 -120
  3. package/INSTALL.md +218 -218
  4. package/LICENSE +19 -19
  5. package/NOTICE +11 -11
  6. package/README.de.md +289 -289
  7. package/README.es.md +290 -290
  8. package/README.fr.md +290 -290
  9. package/README.ja.md +290 -290
  10. package/README.ko.md +290 -290
  11. package/README.md +304 -304
  12. package/README.pt-BR.md +290 -290
  13. package/README.ru.md +290 -290
  14. package/README.zh-CN.md +302 -302
  15. package/compatibility/dsh-bom.json +0 -0
  16. package/cordis.patch.yml +13 -13
  17. package/docs/00-project-rules.md +212 -195
  18. package/docs/02-architecture.md +130 -130
  19. package/docs/02-architecture.zh-CN.md +130 -130
  20. package/lib/bin.js.map +1 -1
  21. package/lib/capability-settings.d.ts +8 -2
  22. package/lib/capability-settings.d.ts.map +1 -1
  23. package/lib/capability-tools.d.ts +7 -2
  24. package/lib/capability-tools.d.ts.map +1 -1
  25. package/lib/client.js +3 -3
  26. package/lib/client.js.map +2 -2
  27. package/lib/codex-images.d.ts +8 -0
  28. package/lib/codex-images.d.ts.map +1 -1
  29. package/lib/index.js +32 -7
  30. package/lib/index.js.map +2 -2
  31. package/lib/invariant.js.map +1 -1
  32. package/media/en/settings_accounts.png +0 -0
  33. package/media/en/settings_capabilities.png +0 -0
  34. package/media/en/settings_gateway.png +0 -0
  35. package/media/settings_accounts.png +0 -0
  36. package/media/settings_capabilities.png +0 -0
  37. package/media/settings_gateway.png +0 -0
  38. package/media/settings_overview.png +0 -0
  39. package/media/zh-CN/settings_accounts.png +0 -0
  40. package/media/zh-CN/settings_capabilities.png +0 -0
  41. package/media/zh-CN/settings_gateway.png +0 -0
  42. package/package.json +148 -148
  43. package/patches/dsh-agy@0.1.2.patch +25 -25
  44. package/scripts/release.mjs +186 -186
  45. package/scripts/smoke-deployed-routes.mjs +146 -146
  46. package/scripts/verify-deployed-catalog.mjs +87 -87
  47. package/src/adapter.ts +273 -273
  48. package/src/alias-adapter.ts +130 -130
  49. package/src/auth-routes.ts +921 -921
  50. package/src/auth.ts +67 -67
  51. package/src/bin.ts +350 -350
  52. package/src/capability-routes.ts +279 -279
  53. package/src/capability-runtime.ts +314 -313
  54. package/src/capability-settings.ts +671 -658
  55. package/src/capability-tools.ts +685 -666
  56. package/src/catalog.ts +271 -271
  57. package/src/client/GrokBuildSettings.tsx +771 -770
  58. package/src/client/api.ts +88 -88
  59. package/src/client/components/AboutTab.tsx +30 -30
  60. package/src/client/components/AccountsTab.tsx +241 -241
  61. package/src/client/components/Badge.tsx +33 -33
  62. package/src/client/components/CapabilitiesTab.tsx +265 -265
  63. package/src/client/components/CliPullPreview.tsx +116 -116
  64. package/src/client/components/CopyButton.tsx +57 -57
  65. package/src/client/components/GatewayTab.tsx +469 -469
  66. package/src/client/components/NoticeBanner.tsx +46 -46
  67. package/src/client/components/ProgressBar.tsx +53 -53
  68. package/src/client/components/ProviderCard.tsx +606 -606
  69. package/src/client/components/SettingsTabs.tsx +75 -75
  70. package/src/client/components/ToggleSwitch.tsx +71 -71
  71. package/src/client/constants.ts +230 -224
  72. package/src/client/display.ts +61 -61
  73. package/src/client/dshClientAdapter.ts +127 -127
  74. package/src/client/gatewaySnippets.ts +37 -37
  75. package/src/client/index.tsx +156 -156
  76. package/src/client/locales.ts +540 -535
  77. package/src/client/microStyles.ts +52 -52
  78. package/src/client/parsers.ts +398 -396
  79. package/src/client/styles.ts +325 -325
  80. package/src/client/types.ts +199 -197
  81. package/src/codex-http.ts +447 -447
  82. package/src/codex-images.ts +503 -485
  83. package/src/codex-model-capabilities.ts +320 -320
  84. package/src/codex-search.ts +245 -245
  85. package/src/codex-usage.ts +263 -263
  86. package/src/compatibility.ts +41 -41
  87. package/src/dsh-host-adapter.ts +173 -173
  88. package/src/gateway-anthropic-messages.ts +84 -84
  89. package/src/gateway-auth.ts +102 -102
  90. package/src/gateway-backend.ts +274 -274
  91. package/src/gateway-body.ts +49 -49
  92. package/src/gateway-config.ts +76 -76
  93. package/src/gateway-http.ts +104 -104
  94. package/src/gateway-openai-chat.ts +124 -124
  95. package/src/gateway-openai-responses.ts +53 -53
  96. package/src/gateway-parse.ts +224 -224
  97. package/src/gateway-protocol.ts +52 -52
  98. package/src/gateway-routes.ts +158 -158
  99. package/src/gateway.ts +258 -258
  100. package/src/grok-errors.ts +24 -24
  101. package/src/grok-imagine.ts +1627 -1627
  102. package/src/grok-import.ts +151 -151
  103. package/src/http-json.ts +82 -82
  104. package/src/ids.ts +59 -59
  105. package/src/imagine-routes.ts +463 -463
  106. package/src/index.ts +709 -709
  107. package/src/invariant.ts +17 -17
  108. package/src/kimi-errors.ts +26 -26
  109. package/src/media-store.ts +927 -927
  110. package/src/oauth-import-routes.ts +324 -324
  111. package/src/oauth-providers.ts +152 -152
  112. package/src/oauth-session.ts +183 -183
  113. package/src/oauth-sources.ts +1104 -1104
  114. package/src/oauth.ts +620 -620
  115. package/src/provider.ts +128 -128
  116. package/src/proxy.ts +11 -11
  117. package/src/redact.ts +72 -72
  118. package/src/session.ts +218 -218
  119. package/src/store.ts +217 -217
  120. package/src/web-origin.ts +296 -296
  121. package/src/web-routes.ts +38 -38
@@ -1,265 +1,265 @@
1
- /** Capabilities tab: Codex toggles, Grok Imagine, and limits. */
2
-
3
- import { CAPABILITY_LIMITS, CAPABILITY_TOGGLES } from "../constants.ts";
4
- import { imagineSourceLabel } from "../parsers.ts";
5
- import {
6
- bodyStyle,
7
- buttonStyle,
8
- cardStyle,
9
- dotStyle,
10
- errorStyle,
11
- hintStyle,
12
- inputStyle,
13
- listStyle,
14
- nestedStyle,
15
- rowStyle,
16
- skeletonStyle,
17
- statusStyle,
18
- titleStyle,
19
- } from "../styles.ts";
20
- import type {
21
- CapabilitySettingKey,
22
- CapabilitySnapshot,
23
- GrokBuildSettingsInjected,
24
- ImagineCredentialView,
25
- } from "../types.ts";
26
- import { Badge } from "./Badge.tsx";
27
- import { ToggleSwitch } from "./ToggleSwitch.tsx";
28
-
29
- export interface CapabilitiesTabProps {
30
- t: GrokBuildSettingsInjected["t"];
31
- capabilities: CapabilitySnapshot | undefined;
32
- capabilitiesError: string | undefined;
33
- capabilitiesBusy: boolean;
34
- imagine: ImagineCredentialView | undefined;
35
- imagineError: string | undefined;
36
- codexSignedIn: boolean;
37
- onRetry: () => void;
38
- onOpenAccounts: (provider: "codex") => void;
39
- onFocusDependency: (target: "codexImages" | "imagineCredential") => void;
40
- onPatchCapability: (key: CapabilitySettingKey, value: boolean | number) => Promise<boolean | undefined> | undefined;
41
- }
42
-
43
- export function CapabilitiesTab({
44
- t,
45
- capabilities,
46
- capabilitiesError,
47
- capabilitiesBusy,
48
- imagine,
49
- imagineError,
50
- codexSignedIn,
51
- onRetry,
52
- onOpenAccounts,
53
- onFocusDependency,
54
- onPatchCapability,
55
- }: CapabilitiesTabProps) {
56
- const codexToggles = CAPABILITY_TOGGLES.filter((item) => !item.key.startsWith("grokImagine"));
57
- const imagineToggles = CAPABILITY_TOGGLES.filter((item) => item.key.startsWith("grokImagine"));
58
-
59
- return (
60
- <section style={cardStyle} aria-labelledby="coding-oauth-capabilities-title">
61
- <div>
62
- <h3 id="coding-oauth-capabilities-title" style={{ ...titleStyle, fontSize: 16 }}>
63
- {t("capabilitiesTitle")}
64
- </h3>
65
- <p style={{ ...bodyStyle, marginTop: 4 }}>{t("capabilitiesIntro")}</p>
66
- </div>
67
- {imagineError === undefined ? null : (
68
- <div style={nestedStyle} role="alert">
69
- <p style={errorStyle}>{imagineError}</p>
70
- <button type="button" style={buttonStyle} onClick={onRetry}>
71
- {t("retry")}
72
- </button>
73
- </div>
74
- )}
75
- {imagine === undefined && imagineError === undefined ? (
76
- <div style={skeletonStyle} role="status" aria-busy="true">
77
- <div style={statusStyle}>
78
- <span aria-hidden="true" style={dotStyle("loading")} />
79
- {t("imagineLoading")}
80
- </div>
81
- </div>
82
- ) : imagine === undefined ? null : (
83
- <div id="coding-oauth-imagine-credential" style={nestedStyle} tabIndex={-1}>
84
- <Badge
85
- label={imagine.configured ? t("imagineConfigured") : t("imagineNotConfigured")}
86
- tone={imagine.configured ? "success" : "neutral"}
87
- />
88
- <p style={hintStyle}>{t("imagineSource", { source: imagineSourceLabel(imagine.source, t) })}</p>
89
- </div>
90
- )}
91
- {capabilitiesError === undefined ? null : (
92
- <div style={nestedStyle} role="alert">
93
- <p style={errorStyle}>{capabilitiesError}</p>
94
- <button type="button" style={buttonStyle} onClick={onRetry}>
95
- {t("retry")}
96
- </button>
97
- </div>
98
- )}
99
- {capabilities === undefined && capabilitiesError === undefined ? (
100
- <div style={skeletonStyle} role="status" aria-busy="true">
101
- <div style={statusStyle}>
102
- <span aria-hidden="true" style={dotStyle("loading")} />
103
- {t("capabilitiesLoading")}
104
- </div>
105
- </div>
106
- ) : capabilities === undefined ? null : (
107
- <fieldset style={{ border: 0, margin: 0, padding: 0, minWidth: 0 }}>
108
- <legend style={{ ...bodyStyle, position: "absolute", width: 1, height: 1, overflow: "hidden" }}>
109
- {t("capabilitiesTitle")}
110
- </legend>
111
- {capabilities.writable ? null : <p style={hintStyle}>{t("capabilitiesReadOnly")}</p>}
112
- <ul style={listStyle}>
113
- {codexToggles.map((item) => {
114
- const checked = capabilities.value[item.key];
115
- const imagesOff = item.requiresImages === true && !capabilities.value.codexImages;
116
- const dependencyReason = !codexSignedIn
117
- ? t("requiresCodexSignIn")
118
- : imagesOff
119
- ? t("requiresCodexImages")
120
- : undefined;
121
- const disabled = capabilitiesBusy || !capabilities.writable || dependencyReason !== undefined;
122
- const switchId = `cap-switch-${item.key}`;
123
- const repairAction = !codexSignedIn
124
- ? { label: t("openCodexAccount"), action: () => onOpenAccounts("codex") }
125
- : imagesOff
126
- ? { label: t("focusCodexImages"), action: () => onFocusDependency("codexImages") }
127
- : undefined;
128
- return (
129
- <li
130
- key={item.key}
131
- style={{
132
- opacity: dependencyReason === undefined ? 1 : 0.65,
133
- transition: "opacity 0.15s ease",
134
- }}
135
- >
136
- <div style={{ ...rowStyle, alignItems: "flex-start" }}>
137
- <label htmlFor={switchId} style={{ flex: "1 1 360px", cursor: disabled ? "default" : "pointer" }}>
138
- <span style={{ display: "block", fontSize: 14, color: "var(--dsw-alias-label-primary)" }}>
139
- {t(item.label)}
140
- </span>
141
- <span id={`cap-hint-${item.key}`} style={{ display: "block", ...hintStyle }}>
142
- {dependencyReason ?? t(item.hint)}
143
- </span>
144
- </label>
145
- {repairAction === undefined ? null : (
146
- <button type="button" style={buttonStyle} onClick={repairAction.action}>
147
- {repairAction.label}
148
- </button>
149
- )}
150
- <ToggleSwitch
151
- id={switchId}
152
- checked={checked}
153
- disabled={disabled}
154
- ariaLabel={t(item.label)}
155
- ariaDescribedBy={`cap-hint-${item.key}`}
156
- onChange={(next) => {
157
- void onPatchCapability(item.key, next);
158
- }}
159
- />
160
- </div>
161
- </li>
162
- );
163
- })}
164
- </ul>
165
- <h4 style={{ ...titleStyle, fontSize: 14 }}>{t("imagineTitle")}</h4>
166
- <ul style={listStyle}>
167
- {imagineToggles.map((item) => {
168
- const checked = capabilities.value[item.key];
169
- const dependencyReason = imagine?.configured === true ? undefined : t("requiresImagineCredential");
170
- const disabled = capabilitiesBusy || !capabilities.writable || dependencyReason !== undefined;
171
- const switchId = `cap-switch-${item.key}`;
172
- return (
173
- <li key={item.key}>
174
- <div style={{ ...rowStyle, alignItems: "flex-start" }}>
175
- <label htmlFor={switchId} style={{ flex: "1 1 360px", cursor: disabled ? "default" : "pointer" }}>
176
- <span style={{ display: "block", fontSize: 14, color: "var(--dsw-alias-label-primary)" }}>
177
- {t(item.label)}
178
- </span>
179
- <span id={`cap-hint-${item.key}`} style={{ display: "block", ...hintStyle }}>
180
- {dependencyReason ?? t(item.hint)}
181
- </span>
182
- </label>
183
- {dependencyReason === undefined ? null : (
184
- <button type="button" style={buttonStyle} onClick={() => onFocusDependency("imagineCredential")}>
185
- {t("focusImagineCredential")}
186
- </button>
187
- )}
188
- <ToggleSwitch
189
- id={switchId}
190
- checked={checked}
191
- disabled={disabled}
192
- ariaLabel={t(item.label)}
193
- ariaDescribedBy={`cap-hint-${item.key}`}
194
- onChange={(next) => {
195
- void onPatchCapability(item.key, next);
196
- }}
197
- />
198
- </div>
199
- </li>
200
- );
201
- })}
202
- </ul>
203
- <div style={nestedStyle}>
204
- <h4 style={{ ...titleStyle, fontSize: 14 }}>{t("capabilityLimitsTitle")}</h4>
205
- <p style={hintStyle}>{t("capabilityLimitsHint")}</p>
206
- <ul style={listStyle}>
207
- {CAPABILITY_LIMITS.map((item) => {
208
- const displayValue = capabilities.value[item.key] / item.scale;
209
- const inputId = `cap-limit-${item.key}`;
210
- return (
211
- <li key={item.key} style={rowStyle}>
212
- <label htmlFor={inputId} style={{ ...bodyStyle, flex: "1 1 360px" }}>
213
- <span style={{ display: "block", color: "var(--dsw-alias-label-primary)" }}>{t(item.label)}</span>
214
- <span id={`${inputId}-hint`} style={{ display: "block", ...hintStyle }}>
215
- {t(item.hint)}
216
- </span>
217
- </label>
218
- <input
219
- key={`${item.key}-${String(capabilities.revision)}-${String(displayValue)}`}
220
- id={inputId}
221
- type="number"
222
- inputMode="numeric"
223
- min={item.min}
224
- max={item.max}
225
- step={1}
226
- defaultValue={displayValue}
227
- disabled={capabilitiesBusy || !capabilities.writable}
228
- aria-describedby={`${inputId}-hint`}
229
- style={{ ...inputStyle, width: 112, flex: "0 0 112px" }}
230
- onInput={(event) => {
231
- event.currentTarget.setCustomValidity("");
232
- }}
233
- onKeyDown={(event) => {
234
- if (event.key === "Enter") event.currentTarget.blur();
235
- if (event.key === "Escape") {
236
- event.currentTarget.value = String(displayValue);
237
- event.currentTarget.setCustomValidity("");
238
- }
239
- }}
240
- onBlur={(event) => {
241
- const target = event.currentTarget;
242
- const next = Number(target.value);
243
- if (!Number.isInteger(next) || next < item.min || next > item.max) {
244
- target.setCustomValidity(t("capabilityLimitInvalid", { min: item.min, max: item.max }));
245
- target.reportValidity();
246
- return;
247
- }
248
- target.setCustomValidity("");
249
- const apiValue = next * item.scale;
250
- if (apiValue === capabilities.value[item.key]) return;
251
- void Promise.resolve(onPatchCapability(item.key, apiValue)).then((saved) => {
252
- if (saved === false && target.isConnected) target.value = String(displayValue);
253
- });
254
- }}
255
- />
256
- </li>
257
- );
258
- })}
259
- </ul>
260
- </div>
261
- </fieldset>
262
- )}
263
- </section>
264
- );
265
- }
1
+ /** Capabilities tab: Codex toggles, Grok Imagine, and limits. */
2
+
3
+ import { CAPABILITY_LIMITS, CAPABILITY_TOGGLES } from "../constants.ts";
4
+ import { imagineSourceLabel } from "../parsers.ts";
5
+ import {
6
+ bodyStyle,
7
+ buttonStyle,
8
+ cardStyle,
9
+ dotStyle,
10
+ errorStyle,
11
+ hintStyle,
12
+ inputStyle,
13
+ listStyle,
14
+ nestedStyle,
15
+ rowStyle,
16
+ skeletonStyle,
17
+ statusStyle,
18
+ titleStyle,
19
+ } from "../styles.ts";
20
+ import type {
21
+ CapabilitySettingKey,
22
+ CapabilitySnapshot,
23
+ GrokBuildSettingsInjected,
24
+ ImagineCredentialView,
25
+ } from "../types.ts";
26
+ import { Badge } from "./Badge.tsx";
27
+ import { ToggleSwitch } from "./ToggleSwitch.tsx";
28
+
29
+ export interface CapabilitiesTabProps {
30
+ t: GrokBuildSettingsInjected["t"];
31
+ capabilities: CapabilitySnapshot | undefined;
32
+ capabilitiesError: string | undefined;
33
+ capabilitiesBusy: boolean;
34
+ imagine: ImagineCredentialView | undefined;
35
+ imagineError: string | undefined;
36
+ codexSignedIn: boolean;
37
+ onRetry: () => void;
38
+ onOpenAccounts: (provider: "codex") => void;
39
+ onFocusDependency: (target: "codexImages" | "imagineCredential") => void;
40
+ onPatchCapability: (key: CapabilitySettingKey, value: boolean | number) => Promise<boolean | undefined> | undefined;
41
+ }
42
+
43
+ export function CapabilitiesTab({
44
+ t,
45
+ capabilities,
46
+ capabilitiesError,
47
+ capabilitiesBusy,
48
+ imagine,
49
+ imagineError,
50
+ codexSignedIn,
51
+ onRetry,
52
+ onOpenAccounts,
53
+ onFocusDependency,
54
+ onPatchCapability,
55
+ }: CapabilitiesTabProps) {
56
+ const codexToggles = CAPABILITY_TOGGLES.filter((item) => !item.key.startsWith("grokImagine"));
57
+ const imagineToggles = CAPABILITY_TOGGLES.filter((item) => item.key.startsWith("grokImagine"));
58
+
59
+ return (
60
+ <section style={cardStyle} aria-labelledby="coding-oauth-capabilities-title">
61
+ <div>
62
+ <h3 id="coding-oauth-capabilities-title" style={{ ...titleStyle, fontSize: 16 }}>
63
+ {t("capabilitiesTitle")}
64
+ </h3>
65
+ <p style={{ ...bodyStyle, marginTop: 4 }}>{t("capabilitiesIntro")}</p>
66
+ </div>
67
+ {imagineError === undefined ? null : (
68
+ <div style={nestedStyle} role="alert">
69
+ <p style={errorStyle}>{imagineError}</p>
70
+ <button type="button" style={buttonStyle} onClick={onRetry}>
71
+ {t("retry")}
72
+ </button>
73
+ </div>
74
+ )}
75
+ {imagine === undefined && imagineError === undefined ? (
76
+ <div style={skeletonStyle} role="status" aria-busy="true">
77
+ <div style={statusStyle}>
78
+ <span aria-hidden="true" style={dotStyle("loading")} />
79
+ {t("imagineLoading")}
80
+ </div>
81
+ </div>
82
+ ) : imagine === undefined ? null : (
83
+ <div id="coding-oauth-imagine-credential" style={nestedStyle} tabIndex={-1}>
84
+ <Badge
85
+ label={imagine.configured ? t("imagineConfigured") : t("imagineNotConfigured")}
86
+ tone={imagine.configured ? "success" : "neutral"}
87
+ />
88
+ <p style={hintStyle}>{t("imagineSource", { source: imagineSourceLabel(imagine.source, t) })}</p>
89
+ </div>
90
+ )}
91
+ {capabilitiesError === undefined ? null : (
92
+ <div style={nestedStyle} role="alert">
93
+ <p style={errorStyle}>{capabilitiesError}</p>
94
+ <button type="button" style={buttonStyle} onClick={onRetry}>
95
+ {t("retry")}
96
+ </button>
97
+ </div>
98
+ )}
99
+ {capabilities === undefined && capabilitiesError === undefined ? (
100
+ <div style={skeletonStyle} role="status" aria-busy="true">
101
+ <div style={statusStyle}>
102
+ <span aria-hidden="true" style={dotStyle("loading")} />
103
+ {t("capabilitiesLoading")}
104
+ </div>
105
+ </div>
106
+ ) : capabilities === undefined ? null : (
107
+ <fieldset style={{ border: 0, margin: 0, padding: 0, minWidth: 0 }}>
108
+ <legend style={{ ...bodyStyle, position: "absolute", width: 1, height: 1, overflow: "hidden" }}>
109
+ {t("capabilitiesTitle")}
110
+ </legend>
111
+ {capabilities.writable ? null : <p style={hintStyle}>{t("capabilitiesReadOnly")}</p>}
112
+ <ul style={listStyle}>
113
+ {codexToggles.map((item) => {
114
+ const checked = capabilities.value[item.key];
115
+ const imagesOff = item.requiresImages === true && !capabilities.value.codexImages;
116
+ const dependencyReason = !codexSignedIn
117
+ ? t("requiresCodexSignIn")
118
+ : imagesOff
119
+ ? t("requiresCodexImages")
120
+ : undefined;
121
+ const disabled = capabilitiesBusy || !capabilities.writable || dependencyReason !== undefined;
122
+ const switchId = `cap-switch-${item.key}`;
123
+ const repairAction = !codexSignedIn
124
+ ? { label: t("openCodexAccount"), action: () => onOpenAccounts("codex") }
125
+ : imagesOff
126
+ ? { label: t("focusCodexImages"), action: () => onFocusDependency("codexImages") }
127
+ : undefined;
128
+ return (
129
+ <li
130
+ key={item.key}
131
+ style={{
132
+ opacity: dependencyReason === undefined ? 1 : 0.65,
133
+ transition: "opacity 0.15s ease",
134
+ }}
135
+ >
136
+ <div style={{ ...rowStyle, alignItems: "flex-start" }}>
137
+ <label htmlFor={switchId} style={{ flex: "1 1 360px", cursor: disabled ? "default" : "pointer" }}>
138
+ <span style={{ display: "block", fontSize: 14, color: "var(--dsw-alias-label-primary)" }}>
139
+ {t(item.label)}
140
+ </span>
141
+ <span id={`cap-hint-${item.key}`} style={{ display: "block", ...hintStyle }}>
142
+ {dependencyReason ?? t(item.hint)}
143
+ </span>
144
+ </label>
145
+ {repairAction === undefined ? null : (
146
+ <button type="button" style={buttonStyle} onClick={repairAction.action}>
147
+ {repairAction.label}
148
+ </button>
149
+ )}
150
+ <ToggleSwitch
151
+ id={switchId}
152
+ checked={checked}
153
+ disabled={disabled}
154
+ ariaLabel={t(item.label)}
155
+ ariaDescribedBy={`cap-hint-${item.key}`}
156
+ onChange={(next) => {
157
+ void onPatchCapability(item.key, next);
158
+ }}
159
+ />
160
+ </div>
161
+ </li>
162
+ );
163
+ })}
164
+ </ul>
165
+ <h4 style={{ ...titleStyle, fontSize: 14 }}>{t("imagineTitle")}</h4>
166
+ <ul style={listStyle}>
167
+ {imagineToggles.map((item) => {
168
+ const checked = capabilities.value[item.key];
169
+ const dependencyReason = imagine?.configured === true ? undefined : t("requiresImagineCredential");
170
+ const disabled = capabilitiesBusy || !capabilities.writable || dependencyReason !== undefined;
171
+ const switchId = `cap-switch-${item.key}`;
172
+ return (
173
+ <li key={item.key}>
174
+ <div style={{ ...rowStyle, alignItems: "flex-start" }}>
175
+ <label htmlFor={switchId} style={{ flex: "1 1 360px", cursor: disabled ? "default" : "pointer" }}>
176
+ <span style={{ display: "block", fontSize: 14, color: "var(--dsw-alias-label-primary)" }}>
177
+ {t(item.label)}
178
+ </span>
179
+ <span id={`cap-hint-${item.key}`} style={{ display: "block", ...hintStyle }}>
180
+ {dependencyReason ?? t(item.hint)}
181
+ </span>
182
+ </label>
183
+ {dependencyReason === undefined ? null : (
184
+ <button type="button" style={buttonStyle} onClick={() => onFocusDependency("imagineCredential")}>
185
+ {t("focusImagineCredential")}
186
+ </button>
187
+ )}
188
+ <ToggleSwitch
189
+ id={switchId}
190
+ checked={checked}
191
+ disabled={disabled}
192
+ ariaLabel={t(item.label)}
193
+ ariaDescribedBy={`cap-hint-${item.key}`}
194
+ onChange={(next) => {
195
+ void onPatchCapability(item.key, next);
196
+ }}
197
+ />
198
+ </div>
199
+ </li>
200
+ );
201
+ })}
202
+ </ul>
203
+ <div style={nestedStyle}>
204
+ <h4 style={{ ...titleStyle, fontSize: 14 }}>{t("capabilityLimitsTitle")}</h4>
205
+ <p style={hintStyle}>{t("capabilityLimitsHint")}</p>
206
+ <ul style={listStyle}>
207
+ {CAPABILITY_LIMITS.map((item) => {
208
+ const displayValue = capabilities.value[item.key] / item.scale;
209
+ const inputId = `cap-limit-${item.key}`;
210
+ return (
211
+ <li key={item.key} style={rowStyle}>
212
+ <label htmlFor={inputId} style={{ ...bodyStyle, flex: "1 1 360px" }}>
213
+ <span style={{ display: "block", color: "var(--dsw-alias-label-primary)" }}>{t(item.label)}</span>
214
+ <span id={`${inputId}-hint`} style={{ display: "block", ...hintStyle }}>
215
+ {t(item.hint)}
216
+ </span>
217
+ </label>
218
+ <input
219
+ key={`${item.key}-${String(capabilities.revision)}-${String(displayValue)}`}
220
+ id={inputId}
221
+ type="number"
222
+ inputMode="numeric"
223
+ min={item.min}
224
+ max={item.max}
225
+ step={1}
226
+ defaultValue={displayValue}
227
+ disabled={capabilitiesBusy || !capabilities.writable}
228
+ aria-describedby={`${inputId}-hint`}
229
+ style={{ ...inputStyle, width: 112, flex: "0 0 112px" }}
230
+ onInput={(event) => {
231
+ event.currentTarget.setCustomValidity("");
232
+ }}
233
+ onKeyDown={(event) => {
234
+ if (event.key === "Enter") event.currentTarget.blur();
235
+ if (event.key === "Escape") {
236
+ event.currentTarget.value = String(displayValue);
237
+ event.currentTarget.setCustomValidity("");
238
+ }
239
+ }}
240
+ onBlur={(event) => {
241
+ const target = event.currentTarget;
242
+ const next = Number(target.value);
243
+ if (!Number.isInteger(next) || next < item.min || next > item.max) {
244
+ target.setCustomValidity(t("capabilityLimitInvalid", { min: item.min, max: item.max }));
245
+ target.reportValidity();
246
+ return;
247
+ }
248
+ target.setCustomValidity("");
249
+ const apiValue = next * item.scale;
250
+ if (apiValue === capabilities.value[item.key]) return;
251
+ void Promise.resolve(onPatchCapability(item.key, apiValue)).then((saved) => {
252
+ if (saved === false && target.isConnected) target.value = String(displayValue);
253
+ });
254
+ }}
255
+ />
256
+ </li>
257
+ );
258
+ })}
259
+ </ul>
260
+ </div>
261
+ </fieldset>
262
+ )}
263
+ </section>
264
+ );
265
+ }