@dsmm/dsmm 0.3.12 → 0.3.13
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/README.md +2 -2
- package/docs/agent-presets.md +1 -1
- package/docs/compatibility.md +8 -2
- package/docs/deferred-native-approval-risk.md +1 -1
- package/docs/design.md +1 -1
- package/docs/lsp.md +1 -1
- package/docs/maintenance.md +9 -3
- package/docs/model-routing.md +1 -1
- package/docs/native-permissions.md +1 -1
- package/docs/profiles.md +21 -11
- package/docs/roadmap.md +2 -2
- package/docs/runtime-recovery.md +1 -1
- package/docs/safety-guards.md +1 -1
- package/docs/settings-status.md +1 -1
- package/docs/testing.md +85 -0
- package/lib/client/ProfileModelsDialog.d.ts +23 -0
- package/lib/client/ProfileModelsDialog.js +318 -0
- package/lib/client/ProfilesSection.js +178 -36
- package/lib/client/RoleToolView-data.d.ts +7 -0
- package/lib/client/RoleToolView-data.js +45 -0
- package/lib/client/RoleToolView-locales.d.ts +5 -0
- package/lib/client/RoleToolView-locales.js +2 -0
- package/lib/client/RoleToolView.js +33 -8
- package/lib/client/StructuredEditor.d.ts +32 -4
- package/lib/client/StructuredEditor.js +12 -40
- package/lib/client/diagnostics.d.ts +1 -0
- package/lib/client/diagnostics.js +9 -0
- package/lib/client/locales.d.ts +21 -0
- package/lib/client/locales.js +42 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +89 -30
- package/lib/client.js +1940 -1024
- package/package.json +7 -2
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
3
|
+
import { Button, Input, Modal } from "@deepseek-ai/dsh-client-ui-primitives";
|
|
4
|
+
import { DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimitPolicy } from "../routing-policy.js";
|
|
5
|
+
import { LevelFields, PolicyFields, RouteFields } from "./StructuredEditor.js";
|
|
6
|
+
import { RoleAvailability, roleAvailability } from "./RoleAvailability.js";
|
|
7
|
+
import { IssueDetails, issueKey } from "./diagnostics.js";
|
|
8
|
+
function locateFieldInsideRole(roleCard, field) {
|
|
9
|
+
if (!field)
|
|
10
|
+
return null;
|
|
11
|
+
const roleId = roleCard.dataset.dsmmRole;
|
|
12
|
+
if (field === `settings.roles.${roleId}` || field === `roles.${roleId}`) {
|
|
13
|
+
const details = roleCard.querySelector("details[data-dsmm-details='non-model']");
|
|
14
|
+
if (details)
|
|
15
|
+
details.open = true;
|
|
16
|
+
return roleCard.querySelector("select[id$='-role-enabled']");
|
|
17
|
+
}
|
|
18
|
+
const roleMatch = /^(?:settings\.)?roleRouting\.([a-zA-Z0-9_-]+)\.(.+)$/.exec(field);
|
|
19
|
+
if (roleMatch === null || roleMatch[1] !== roleId)
|
|
20
|
+
return null;
|
|
21
|
+
const path = roleMatch[2].replace(/\[(\d+)\]/g, ".$1");
|
|
22
|
+
const routeInput = (container, prop) => {
|
|
23
|
+
const suffix = prop === "reasoningEffort" ? "effort" : prop;
|
|
24
|
+
return container?.querySelector(`input[id$='-${suffix}'], select[id$='-${suffix}']`) ?? null;
|
|
25
|
+
};
|
|
26
|
+
const levelMatch = /^levels\.(low|high|max)(?:\.(provider|model|reasoningEffort))?$/.exec(path);
|
|
27
|
+
if (levelMatch) {
|
|
28
|
+
const level = levelMatch[1];
|
|
29
|
+
const prop = levelMatch[2];
|
|
30
|
+
const details = roleCard.querySelector("details[data-dsmm-details='levels']");
|
|
31
|
+
if (details)
|
|
32
|
+
details.open = true;
|
|
33
|
+
const fieldset = roleCard.querySelector(`fieldset[data-dsmm-level='${level}']`);
|
|
34
|
+
return routeInput(fieldset, prop ?? "mode");
|
|
35
|
+
}
|
|
36
|
+
const fallbackMatch = /^fallbackRoutes\.(0|[1-9]\d*)\.(provider|model|reasoningEffort)$/.exec(path);
|
|
37
|
+
if (fallbackMatch) {
|
|
38
|
+
const index = fallbackMatch[1];
|
|
39
|
+
const prop = fallbackMatch[2];
|
|
40
|
+
const details = roleCard.querySelector("details[data-dsmm-details='fallback']");
|
|
41
|
+
if (details)
|
|
42
|
+
details.open = true;
|
|
43
|
+
const fieldset = roleCard.querySelector(`fieldset[data-dsmm-fallback-index='${index}']`);
|
|
44
|
+
return routeInput(fieldset, prop);
|
|
45
|
+
}
|
|
46
|
+
if (path === "fallbackRoutes") {
|
|
47
|
+
const details = roleCard.querySelector("details[data-dsmm-details='fallback']");
|
|
48
|
+
if (details)
|
|
49
|
+
details.open = true;
|
|
50
|
+
return roleCard.querySelector("select[id$='-fallback-mode']");
|
|
51
|
+
}
|
|
52
|
+
const primaryMatch = /^primary(?:\.(provider|model|reasoningEffort))?$/.exec(path);
|
|
53
|
+
if (primaryMatch) {
|
|
54
|
+
const primaryContainer = roleCard.querySelector(".dsmm-role-primary-route");
|
|
55
|
+
return routeInput(primaryContainer, primaryMatch[1] ?? "primary-mode");
|
|
56
|
+
}
|
|
57
|
+
const rateLimitMatch = /^rateLimit\.([a-zA-Z]+)$/.exec(path);
|
|
58
|
+
const selector = path === "strategy" ? "select[id$='-strategy']"
|
|
59
|
+
: rateLimitMatch && Object.hasOwn(DSMM_RATE_LIMIT_BOUNDS, rateLimitMatch[1])
|
|
60
|
+
? `input[data-dsmm-policy-field='${rateLimitMatch[1]}']` : null;
|
|
61
|
+
if (selector === null)
|
|
62
|
+
return null;
|
|
63
|
+
const details = roleCard.querySelector("details[data-dsmm-details='non-model']");
|
|
64
|
+
if (details)
|
|
65
|
+
details.open = true;
|
|
66
|
+
return details?.querySelector(selector) ?? null;
|
|
67
|
+
}
|
|
68
|
+
export function hasExplicitModelOverride(roleId, doc) {
|
|
69
|
+
if (doc === null)
|
|
70
|
+
return false;
|
|
71
|
+
const policy = doc.roleRouting[roleId];
|
|
72
|
+
if (!policy)
|
|
73
|
+
return false;
|
|
74
|
+
if (policy.primary !== undefined)
|
|
75
|
+
return true;
|
|
76
|
+
if (policy.levels !== undefined && Object.keys(policy.levels).length > 0)
|
|
77
|
+
return true;
|
|
78
|
+
if (policy.fallbackRoutes !== undefined)
|
|
79
|
+
return true;
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
export function ProfileModelsDialog({ open, onClose, state, actions, disabled, document: doc, isInvalidProjection, triggerRef, targetRoleId, targetField, onTargetLocated, onJumpToJsonc, t, }) {
|
|
83
|
+
const prefix = useId();
|
|
84
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
85
|
+
const [filterExplicitOnly, setFilterExplicitOnly] = useState(false);
|
|
86
|
+
const pendingFallbackFocusRef = useRef(null);
|
|
87
|
+
const wasOpenRef = useRef(open);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
if (wasOpenRef.current && !open) {
|
|
90
|
+
if (triggerRef?.current && triggerRef.current.isConnected) {
|
|
91
|
+
triggerRef.current.focus();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
wasOpenRef.current = open;
|
|
95
|
+
}, [open, triggerRef]);
|
|
96
|
+
// Background inert on document.body siblings while modal is open
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (!open)
|
|
99
|
+
return;
|
|
100
|
+
const elementsToRestore = [];
|
|
101
|
+
const timer = setTimeout(() => {
|
|
102
|
+
const dialogElement = document.querySelector(".dsmm-profile-models-dialog");
|
|
103
|
+
for (const child of Array.from(document.body.children)) {
|
|
104
|
+
if (child instanceof HTMLElement && (!dialogElement || !child.contains(dialogElement))) {
|
|
105
|
+
const prev = child.getAttribute("inert");
|
|
106
|
+
child.setAttribute("inert", "");
|
|
107
|
+
elementsToRestore.push({ el: child, prevInert: prev });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}, 0);
|
|
111
|
+
return () => {
|
|
112
|
+
clearTimeout(timer);
|
|
113
|
+
for (const { el, prevInert } of elementsToRestore) {
|
|
114
|
+
if (prevInert !== null) {
|
|
115
|
+
el.setAttribute("inert", prevInert);
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
el.removeAttribute("inert");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}, [open]);
|
|
123
|
+
// Target role locating effect
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (!open || !targetRoleId)
|
|
126
|
+
return;
|
|
127
|
+
setSearchQuery("");
|
|
128
|
+
setFilterExplicitOnly(false);
|
|
129
|
+
const rafId = requestAnimationFrame(() => {
|
|
130
|
+
const roleCard = document.querySelector(`[data-dsmm-role='${targetRoleId}']`);
|
|
131
|
+
if (!roleCard) {
|
|
132
|
+
onJumpToJsonc?.();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
const targetInput = locateFieldInsideRole(roleCard, targetField);
|
|
136
|
+
if (!targetInput) {
|
|
137
|
+
onJumpToJsonc?.();
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
141
|
+
const scrollOpt = { behavior: reducedMotion ? "auto" : "smooth", block: "nearest" };
|
|
142
|
+
if (typeof targetInput.scrollIntoView === "function") {
|
|
143
|
+
targetInput.scrollIntoView(scrollOpt);
|
|
144
|
+
}
|
|
145
|
+
targetInput.focus();
|
|
146
|
+
if (document.activeElement === targetInput)
|
|
147
|
+
onTargetLocated?.();
|
|
148
|
+
else
|
|
149
|
+
onJumpToJsonc?.();
|
|
150
|
+
});
|
|
151
|
+
return () => cancelAnimationFrame(rafId);
|
|
152
|
+
}, [open, targetRoleId, targetField, onTargetLocated, onJumpToJsonc]);
|
|
153
|
+
// Safe fallback focus preservation after add, move, or remove
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!pendingFallbackFocusRef.current)
|
|
156
|
+
return;
|
|
157
|
+
const { roleId, index, action } = pendingFallbackFocusRef.current;
|
|
158
|
+
pendingFallbackFocusRef.current = null;
|
|
159
|
+
const roleCard = document.querySelector(`[data-dsmm-role='${roleId}']`);
|
|
160
|
+
if (!roleCard)
|
|
161
|
+
return;
|
|
162
|
+
if (action === "add") {
|
|
163
|
+
const item = roleCard.querySelector(`[data-dsmm-fallback-index='${index}']`);
|
|
164
|
+
const providerInput = item?.querySelector("input[id$='-provider'], select[id$='-provider'], input, select");
|
|
165
|
+
providerInput?.focus();
|
|
166
|
+
}
|
|
167
|
+
else if (action === "moveUp" || action === "moveDown") {
|
|
168
|
+
const item = roleCard.querySelector(`[data-dsmm-fallback-index='${index}']`);
|
|
169
|
+
if (item) {
|
|
170
|
+
const targetBtn = item.querySelector(`button[data-dsmm-action='${action}']:not([disabled])`) ??
|
|
171
|
+
item.querySelector("button[data-dsmm-action='moveUp']:not([disabled])") ??
|
|
172
|
+
item.querySelector("button[data-dsmm-action='moveDown']:not([disabled])") ??
|
|
173
|
+
item.querySelector("button[data-dsmm-action='remove']:not([disabled])") ??
|
|
174
|
+
item.querySelector("input:not([disabled]), select:not([disabled])");
|
|
175
|
+
targetBtn?.focus();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else if (action === "remove") {
|
|
179
|
+
const nextRemoveBtn = roleCard.querySelector(`[data-dsmm-fallback-index='${index}'] button[data-dsmm-action='remove']`) ??
|
|
180
|
+
roleCard.querySelector(`[data-dsmm-fallback-index='${Math.max(0, index - 1)}'] button[data-dsmm-action='remove']`) ??
|
|
181
|
+
roleCard.querySelector("button[data-dsmm-action='add-fallback']");
|
|
182
|
+
nextRemoveBtn?.focus();
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
const handleKeyDownCapture = (event) => {
|
|
186
|
+
if (event.key === "Tab") {
|
|
187
|
+
const dialog = (event.currentTarget.classList.contains("dsmm-profile-models-dialog")
|
|
188
|
+
? event.currentTarget
|
|
189
|
+
: event.currentTarget.querySelector(".dsmm-profile-models-dialog") ?? event.currentTarget);
|
|
190
|
+
const candidates = Array.from(dialog.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])')).filter((el) => {
|
|
191
|
+
const closedDetails = el.closest("details:not([open])");
|
|
192
|
+
if (closedDetails && el !== closedDetails.querySelector("summary"))
|
|
193
|
+
return false;
|
|
194
|
+
if (el.getAttribute("tabindex") === "-1")
|
|
195
|
+
return false;
|
|
196
|
+
if (el.hasAttribute("disabled") || el.getAttribute("aria-disabled") === "true")
|
|
197
|
+
return false;
|
|
198
|
+
if (el.closest("[inert]") || el.closest("[hidden]"))
|
|
199
|
+
return false;
|
|
200
|
+
if (el.offsetWidth === 0 && el.offsetHeight === 0 && el.getClientRects().length === 0)
|
|
201
|
+
return false;
|
|
202
|
+
return true;
|
|
203
|
+
});
|
|
204
|
+
if (candidates.length === 0) {
|
|
205
|
+
event.preventDefault();
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const first = candidates[0];
|
|
209
|
+
const last = candidates[candidates.length - 1];
|
|
210
|
+
if (event.shiftKey) {
|
|
211
|
+
if (document.activeElement === first || !dialog.contains(document.activeElement)) {
|
|
212
|
+
event.preventDefault();
|
|
213
|
+
event.stopPropagation();
|
|
214
|
+
last.focus();
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
if (document.activeElement === last || !dialog.contains(document.activeElement)) {
|
|
219
|
+
event.preventDefault();
|
|
220
|
+
event.stopPropagation();
|
|
221
|
+
first.focus();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
const roles = state.snapshot?.roles ?? [];
|
|
227
|
+
const effectiveDisabled = disabled || isInvalidProjection || doc === null;
|
|
228
|
+
const baseline = state.snapshot?.editorDefaults;
|
|
229
|
+
const filteredRoles = roles.filter((role) => {
|
|
230
|
+
if (searchQuery.trim()) {
|
|
231
|
+
const q = searchQuery.trim().toLowerCase();
|
|
232
|
+
const matchesId = role.id.toLowerCase().includes(q);
|
|
233
|
+
const matchesLabel = role.label.toLowerCase().includes(q);
|
|
234
|
+
if (!matchesId && !matchesLabel)
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
if (filterExplicitOnly) {
|
|
238
|
+
if (!hasExplicitModelOverride(role.id, doc))
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
return true;
|
|
242
|
+
});
|
|
243
|
+
return (_jsxs(Modal, { open: open, onClose: onClose, title: t("modelsDialogTitle"), description: t("modelsDialogDesc"), closeLabel: t("cancel"), className: "dsmm-profile-models-dialog", contentClassName: "dsmm-profile-models-dialog-content", onKeyDownCapture: handleKeyDownCapture, children: [_jsxs("div", { className: "dsmm-models-filter-bar dsmm-dialog-filter-bar", children: [_jsx("div", { className: "dsmm-field dsmm-filter-search", children: _jsx(Input, { id: `${prefix}-role-search`, className: "dsmm-input", type: "search", value: searchQuery, placeholder: t("searchRolesPlaceholder"), disabled: effectiveDisabled, onChange: (e) => setSearchQuery(e.currentTarget.value), "data-dsmm-role-search": true, "data-modal-autofocus": true }) }), _jsxs("label", { className: "dsmm-filter-label dsmm-filter-override-toggle", children: [_jsx("input", { type: "checkbox", checked: filterExplicitOnly, disabled: effectiveDisabled, onChange: (e) => setFilterExplicitOnly(e.currentTarget.checked), "data-dsmm-filter-overrides": true }), _jsx("span", { children: t("filterExplicitOverrides") })] })] }), state.issue !== null && (_jsxs("div", { className: "dsmm-issue dsmm-dialog-issue", role: "region", "aria-label": t("savedInventory"), children: [_jsx("p", { className: "dsmm-dialog-issue-title", children: t(issueKey(state.issue)) }), _jsx(IssueDetails, { issue: state.issue, t: t }), onJumpToJsonc && (_jsx("div", { className: "dsmm-dialog-issue-action", children: _jsx(Button, { type: "button", variant: "outline", size: "sm", onClick: onJumpToJsonc, children: t("jumpToJsonc") }) }))] })), doc === null && (_jsxs("div", { className: "dsmm-structured-invalid", "data-dsmm-structured-invalid": true, children: [_jsx("p", { children: t("rawInvalid") }), _jsx("p", { className: "dsmm-hint", children: t("rawInvalidFormDisabled") }), onJumpToJsonc && (_jsx(Button, { type: "button", variant: "outline", onClick: onJumpToJsonc, children: t("viewConfiguration") }))] })), doc !== null && (_jsxs("div", { className: "dsmm-roles-list dsmm-dialog-roles-list", children: [filteredRoles.length === 0 && (_jsx("p", { className: "dsmm-hint dsmm-no-roles", children: t("noMatchingRoles") })), filteredRoles.map((role) => {
|
|
244
|
+
const policy = doc.roleRouting[role.id] ?? {};
|
|
245
|
+
const rolePath = ["settings", "roleRouting", role.id];
|
|
246
|
+
const isOrchestrator = role.id === "dsmm-orchestrator";
|
|
247
|
+
const explicitOverride = hasExplicitModelOverride(role.id, doc);
|
|
248
|
+
// Compute inheritance for policy retry
|
|
249
|
+
let inherited;
|
|
250
|
+
try {
|
|
251
|
+
if (baseline !== undefined) {
|
|
252
|
+
const profileDefaults = {
|
|
253
|
+
strategy: doc.runtimePolicy.strategy ?? baseline.strategy,
|
|
254
|
+
rateLimit: normalizeRateLimitPolicy(doc.runtimePolicy.rateLimit, baseline.rateLimit),
|
|
255
|
+
};
|
|
256
|
+
inherited = {
|
|
257
|
+
strategy: role.runtimePolicy?.strategy ?? profileDefaults.strategy,
|
|
258
|
+
rateLimit: normalizeRateLimitPolicy(role.runtimePolicy?.rateLimit, profileDefaults.rateLimit),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
// Leave inherited undefined if invalid
|
|
264
|
+
}
|
|
265
|
+
const availability = roleAvailability(role.availability);
|
|
266
|
+
const namedRoles = doc.settings.roles;
|
|
267
|
+
// Calling levels summary
|
|
268
|
+
const configuredLevels = ["low", "high", "max"].filter((lvl) => policy.levels?.[lvl] !== undefined);
|
|
269
|
+
const levelsSummary = configuredLevels.length > 0
|
|
270
|
+
? t("levelsSummary", { levels: configuredLevels.join(", ") })
|
|
271
|
+
: t("levelsInherited");
|
|
272
|
+
// Fallback chain summary
|
|
273
|
+
const fallbackSummary = policy.fallbackRoutes === undefined
|
|
274
|
+
? t("fallbackInherited")
|
|
275
|
+
: policy.fallbackRoutes.length === 0
|
|
276
|
+
? t("fallbackExplicitEmptySummary")
|
|
277
|
+
: t("fallbackCountSummary", { count: policy.fallbackRoutes.length });
|
|
278
|
+
// Non-model settings summary
|
|
279
|
+
const statusSummary = namedRoles?.[role.id] !== undefined
|
|
280
|
+
? (namedRoles[role.id] ? t("enabled") : t("disabled"))
|
|
281
|
+
: t("roleSettingsInherited");
|
|
282
|
+
const retrySummary = policy.strategy !== undefined || (policy.rateLimit !== undefined && Object.keys(policy.rateLimit).length > 0)
|
|
283
|
+
? t("roleSettingsOverridden")
|
|
284
|
+
: t("roleSettingsInherited");
|
|
285
|
+
const nonModelSummary = t("roleSettingsSummary", { status: statusSummary, retry: retrySummary });
|
|
286
|
+
return (_jsxs("div", { className: "dsmm-role-card dsmm-dialog-role-card", "data-dsmm-role": role.id, children: [_jsxs("div", { className: "dsmm-role-main-row", children: [_jsx("div", { className: "dsmm-dialog-role-header", children: _jsxs("div", { className: "dsmm-role-title-group", children: [_jsx("span", { className: "dsmm-role-title", children: role.label }), _jsx("code", { className: "dsmm-role-id-badge", children: role.id }), explicitOverride && (_jsx("span", { className: "dsmm-override-badge", children: t("roleSettingsOverridden") }))] }) }), _jsxs("div", { className: "dsmm-role-primary-route", children: [_jsxs("div", { className: "dsmm-field dsmm-primary-mode-field", children: [_jsx("label", { htmlFor: `${prefix}-${role.id}-primary-mode`, children: t("primaryMode", { name: role.label }) }), _jsxs("select", { id: `${prefix}-${role.id}-primary-mode`, disabled: effectiveDisabled, value: policy.primary === undefined ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "primary"], event.currentTarget.value === "inherit" ? undefined : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("inheritRoute") }), _jsx("option", { value: "explicit", children: t("configuredRoute") })] })] }), policy.primary !== undefined ? (_jsx(RouteFields, { t: t, value: policy.primary, path: [...rolePath, "primary"], name: t("primaryName", { name: role.label }), catalog: state.catalog, disabled: effectiveDisabled, edit: actions.editPath, editRoute: actions.editRoute, naturalLabels: true })) : (_jsx("div", { className: "dsmm-route-inherited-hint", children: _jsx("span", { children: t("inheritRouteDesc") }) })), isOrchestrator && (_jsx("span", { className: "dsmm-orchestrator-tag", children: t("orchestratorNoLevelsHint") }))] })] }), _jsxs("div", { className: "dsmm-role-details-bar", children: [!isOrchestrator && (_jsxs("details", { className: "dsmm-role-levels-details dsmm-compact-details", "data-dsmm-details": "levels", children: [_jsxs("summary", { className: "dsmm-details-summary dsmm-details-pill", children: [_jsxs("span", { className: "dsmm-pill-label", children: [t("callingLevels"), ":"] }), _jsx("span", { className: "dsmm-pill-val", children: levelsSummary })] }), _jsxs("div", { className: "dsmm-details-content", children: [_jsx("p", { className: "dsmm-hint", children: t("levelsHint") }), ["low", "high", "max"].map((level) => (_jsx(LevelFields, { level: level, value: policy.levels?.[level], path: [...rolePath, "levels", level], catalog: state.catalog, disabled: effectiveDisabled, actions: actions, t: t }, level)))] })] })), _jsxs("details", { className: "dsmm-role-fallback-details dsmm-compact-details", "data-dsmm-details": "fallback", children: [_jsxs("summary", { className: "dsmm-details-summary dsmm-details-pill", children: [_jsxs("span", { className: "dsmm-pill-label", children: [t("fallbackRoutes"), ":"] }), _jsx("span", { className: "dsmm-pill-val", children: fallbackSummary })] }), _jsxs("div", { className: "dsmm-details-content", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-${role.id}-fallback-mode`, children: t("fallbackMode", { name: role.label }) }), _jsxs("select", { id: `${prefix}-${role.id}-fallback-mode`, disabled: effectiveDisabled, value: policy.fallbackRoutes === undefined ? "inherit" : "explicit", onChange: (event) => actions.editPath([...rolePath, "fallbackRoutes"], event.currentTarget.value === "inherit" ? undefined : []), children: [_jsx("option", { value: "inherit", children: t("inheritChain") }), _jsx("option", { value: "explicit", children: t("configuredChain") })] })] }), policy.fallbackRoutes?.length === 0 && (_jsx("p", { className: "dsmm-hint", children: t("emptyChain") })), policy.fallbackRoutes?.map((candidate, index) => {
|
|
287
|
+
const name = t("fallbackName", { name: role.label, index: index + 1 });
|
|
288
|
+
return (_jsxs("fieldset", { className: "dsmm-fallback-item", "data-dsmm-fallback-index": index, children: [_jsx("legend", { children: name }), _jsx(RouteFields, { t: t, value: candidate, path: [...rolePath, "fallbackRoutes", index], name: name, catalog: state.catalog, disabled: effectiveDisabled, edit: actions.editPath, editRoute: actions.editRoute, naturalLabels: true }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", "data-dsmm-action": "moveUp", disabled: effectiveDisabled || index === 0, onClick: () => {
|
|
289
|
+
pendingFallbackFocusRef.current = { roleId: role.id, index: index - 1, action: "moveUp" };
|
|
290
|
+
actions.moveFallback(role.id, index, index - 1);
|
|
291
|
+
}, children: t("moveUp", { name }) }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-action": "moveDown", disabled: effectiveDisabled || index === policy.fallbackRoutes.length - 1, onClick: () => {
|
|
292
|
+
pendingFallbackFocusRef.current = { roleId: role.id, index: index + 1, action: "moveDown" };
|
|
293
|
+
actions.moveFallback(role.id, index, index + 1);
|
|
294
|
+
}, children: t("moveDown", { name }) }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-action": "remove", disabled: effectiveDisabled, onClick: () => {
|
|
295
|
+
const newLen = policy.fallbackRoutes.length - 1;
|
|
296
|
+
const nextIdx = Math.min(index, Math.max(0, newLen - 1));
|
|
297
|
+
pendingFallbackFocusRef.current = { roleId: role.id, index: nextIdx, action: "remove" };
|
|
298
|
+
actions.editPath([...rolePath, "fallbackRoutes", index], undefined);
|
|
299
|
+
}, children: t("removeFallback", { name }) })] })] }, index));
|
|
300
|
+
}), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-action": "add-fallback", disabled: effectiveDisabled || (policy.fallbackRoutes?.length ?? 0) >= 32, onClick: (e) => {
|
|
301
|
+
const currentDetails = e.currentTarget.closest("details");
|
|
302
|
+
if (currentDetails)
|
|
303
|
+
currentDetails.open = true;
|
|
304
|
+
const newIndex = policy.fallbackRoutes?.length ?? 0;
|
|
305
|
+
pendingFallbackFocusRef.current = { roleId: role.id, index: newIndex, action: "add" };
|
|
306
|
+
if (policy.fallbackRoutes === undefined) {
|
|
307
|
+
actions.editPath([...rolePath, "fallbackRoutes"], [{ provider: "", model: "" }]);
|
|
308
|
+
}
|
|
309
|
+
else {
|
|
310
|
+
actions.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
|
|
311
|
+
}
|
|
312
|
+
}, children: t("addFallback", { name: role.label }) })] })] }), _jsxs("details", { className: "dsmm-role-nonmodel-details dsmm-compact-details", "data-dsmm-details": "non-model", children: [_jsxs("summary", { className: "dsmm-details-summary dsmm-details-pill", children: [_jsxs("span", { className: "dsmm-pill-label", children: [t("roleNonModelSettings"), ":"] }), _jsx("span", { className: "dsmm-pill-val", children: nonModelSummary })] }), _jsxs("div", { className: "dsmm-details-content", children: [_jsx(RoleAvailability, { value: role.availability, t: t }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-${role.id}-role-enabled`, children: t("namedRole", { name: role.label }) }), _jsxs("select", { id: `${prefix}-${role.id}-role-enabled`, value: namedRoles?.[role.id] === undefined ? "" : String(namedRoles[role.id]), disabled: effectiveDisabled, "aria-describedby": `${prefix}-${role.id}-role-hint`, onChange: (event) => actions.editPath(["settings", "roles", role.id], event.currentTarget.value === "" ? undefined : event.currentTarget.value === "true"), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "true", disabled: availability === undefined ||
|
|
313
|
+
!availability.startupAvailable ||
|
|
314
|
+
!availability.deploymentEnabled ||
|
|
315
|
+
availability.reason === "module-off", children: t("enabled") }), _jsx("option", { value: "false", disabled: availability === undefined || availability.required, children: t("disabled") })] }), _jsx("p", { id: `${prefix}-${role.id}-role-hint`, className: "dsmm-hint", children: t("namedRoleHint") })] }), _jsx(PolicyFields, { t: t, value: policy, inherited: inherited, path: rolePath, name: role.label, disabled: effectiveDisabled, actions: actions })] })] })] })] }, role.id));
|
|
316
|
+
})] }))] }));
|
|
317
|
+
}
|
|
318
|
+
//# sourceMappingURL=ProfileModelsDialog.js.map
|