@dsmm/dsmm 0.3.12 → 0.3.14

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 (48) hide show
  1. package/README.md +2 -2
  2. package/docs/agent-presets.md +1 -1
  3. package/docs/compatibility.md +8 -2
  4. package/docs/deferred-native-approval-risk.md +4 -4
  5. package/docs/design.md +1 -1
  6. package/docs/lsp.md +1 -1
  7. package/docs/maintenance.md +9 -3
  8. package/docs/model-routing.md +1 -1
  9. package/docs/native-permissions.md +12 -2
  10. package/docs/profiles.md +32 -13
  11. package/docs/roadmap.md +67 -30
  12. package/docs/runtime-recovery.md +1 -1
  13. package/docs/safety-guards.md +1 -1
  14. package/docs/settings-status.md +1 -1
  15. package/docs/testing.md +85 -0
  16. package/lib/client/DeploymentPage.js +31 -2
  17. package/lib/client/PermissionsPanel.js +1 -1
  18. package/lib/client/ProfileModelsDialog.d.ts +24 -0
  19. package/lib/client/ProfileModelsDialog.js +353 -0
  20. package/lib/client/ProfilesSection.js +209 -37
  21. package/lib/client/RoleToolView-data.d.ts +7 -0
  22. package/lib/client/RoleToolView-data.js +45 -0
  23. package/lib/client/RoleToolView-locales.d.ts +5 -0
  24. package/lib/client/RoleToolView-locales.js +2 -0
  25. package/lib/client/RoleToolView.js +33 -8
  26. package/lib/client/SessionProfiles.js +24 -6
  27. package/lib/client/StructuredEditor.d.ts +32 -4
  28. package/lib/client/StructuredEditor.js +12 -40
  29. package/lib/client/children-locales.d.ts +1 -1
  30. package/lib/client/controller.d.ts +23 -1
  31. package/lib/client/controller.js +289 -8
  32. package/lib/client/diagnostics.d.ts +1 -0
  33. package/lib/client/diagnostics.js +9 -0
  34. package/lib/client/index.js +10 -2
  35. package/lib/client/locales.d.ts +29 -0
  36. package/lib/client/locales.js +54 -2
  37. package/lib/client/profile-blank.d.ts +43 -0
  38. package/lib/client/profile-blank.js +19 -0
  39. package/lib/client/styles.d.ts +1 -1
  40. package/lib/client/styles.js +96 -32
  41. package/lib/client.js +2411 -1040
  42. package/lib/command-approval.d.ts +2 -0
  43. package/lib/command-approval.js +4 -1
  44. package/lib/index.js +2 -1
  45. package/lib/native-admission.d.ts +10 -3
  46. package/lib/native-admission.js +129 -28
  47. package/lib/profile-runtime.js +3 -5
  48. package/package.json +7 -2
@@ -11,7 +11,36 @@ import { permissionEn } from "./permission-locales.js";
11
11
  export function ScopeSave({ controller, workspace, refreshOnly = false, t }) {
12
12
  const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot);
13
13
  const pending = [...new Set(controller.pendingPaths().map(moduleFor))];
14
- return _jsxs("section", { className: "dsmm-scope-save", "aria-label": t("saveScope"), children: [_jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: refreshOnly ? state.busy ? t("loading") : "" : state.busy ? t("saving") : state.refreshRequired ? t("savedRefreshRequired") : state.saved ? t("saved") : state.dirty ? t("dirty") : "" }), !refreshOnly && pending.length > 0 && _jsxs("p", { children: [t("pendingModules"), ": ", pending.map(module => t(moduleTitle(module))).join(" · ")] }), state.issue !== null && _jsx("p", { className: "dsmm-issue", role: "alert", children: t(state.issue) }), !refreshOnly && state.invalidFields.length > 0 && _jsx("p", { className: "dsmm-issue", role: "alert", children: t("invalid") }), controller.layer === "profile" && !controller.canWriteProfile() && _jsx("p", { className: "dsmm-hint", children: t("unavailableForm") }), _jsxs("div", { className: "dsmm-actions", children: [!refreshOnly && _jsx(Button, { type: "button", variant: "primary", disabled: !controller.canSave(), onClick: () => void (workspace?.save() ?? controller.save()), children: t(controller.layer === "global" ? "saveGlobal" : "saveProfile") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void controller.refresh(), children: t("refresh") }), !refreshOnly && _jsx(Button, { type: "button", variant: "outline", disabled: state.busy || !state.dirty && state.issue === null && !state.refreshRequired, onClick: () => void controller.refresh(true), children: t("discard") })] })] });
14
+ const ref = useRef(null);
15
+ useEffect(() => {
16
+ const el = ref.current;
17
+ if (!el)
18
+ return;
19
+ const parent = el.closest(".dsmm-section-panel");
20
+ const update = () => {
21
+ const height = el.offsetHeight;
22
+ if (parent) {
23
+ parent.style.setProperty("--dsmm-scope-save-offset", `${height}px`);
24
+ }
25
+ };
26
+ update();
27
+ if (typeof ResizeObserver !== "undefined") {
28
+ const ro = new ResizeObserver(update);
29
+ ro.observe(el);
30
+ return () => {
31
+ ro.disconnect();
32
+ if (parent) {
33
+ parent.style.removeProperty("--dsmm-scope-save-offset");
34
+ }
35
+ };
36
+ }
37
+ return () => {
38
+ if (parent) {
39
+ parent.style.removeProperty("--dsmm-scope-save-offset");
40
+ }
41
+ };
42
+ }, []);
43
+ return _jsxs("section", { ref: ref, className: "dsmm-scope-save", "aria-label": t("saveScope"), children: [_jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: refreshOnly ? state.busy ? t("loading") : "" : state.busy ? t("saving") : state.refreshRequired ? t("savedRefreshRequired") : state.saved ? t("saved") : state.dirty ? t("dirty") : "" }), !refreshOnly && pending.length > 0 && _jsxs("p", { children: [t("pendingModules"), ": ", pending.map(module => t(moduleTitle(module))).join(" · ")] }), state.issue !== null && _jsx("p", { className: "dsmm-issue", role: "alert", children: t(state.issue) }), !refreshOnly && state.invalidFields.length > 0 && _jsx("p", { className: "dsmm-issue", role: "alert", children: t("invalid") }), controller.layer === "profile" && !controller.canWriteProfile() && _jsx("p", { className: "dsmm-hint", children: t("unavailableForm") }), _jsxs("div", { className: "dsmm-actions", children: [!refreshOnly && _jsx(Button, { type: "button", variant: "primary", disabled: !controller.canSave(), onClick: () => void (workspace?.save() ?? controller.save()), children: t(controller.layer === "global" ? "saveGlobal" : "saveProfile") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void controller.refresh(), children: t("refresh") }), !refreshOnly && _jsx(Button, { type: "button", variant: "outline", disabled: state.busy || !state.dirty && state.issue === null && !state.refreshRequired, onClick: () => void controller.refresh(true), children: t("discard") })] })] });
15
44
  }
16
45
  export function NativeRuntimeState({ value, t }) {
17
46
  return _jsxs("details", { className: "dsmm-availability", children: [_jsx("summary", { children: t("nativeRuntimeState") }), _jsxs("p", { children: [t("nativeRuntimeBinding"), ": ", t(value?.binding === "stock" ? "nativeRuntimeStock" : value?.binding === "unavailable" ? "nativeRuntimeUnavailable" : "unknown")] }), _jsxs("p", { children: [t("nativeRuntimeFence"), ": ", value === undefined ? t("unknown") : t(value.deliveryFenceReady ? "on" : "off"), " \u00B7 ", t("nativeRuntimeRestart"), ": ", value === undefined ? t("unknown") : t(value.restartRequired ? "on" : "off")] }), value?.reason !== undefined && _jsx("p", { children: t(`nativeRuntimeReason-${value.reason}`) })] });
@@ -99,7 +128,7 @@ export function DeploymentPage(props) {
99
128
  }, children: [_jsx("option", { value: "global", children: t("global") }), _jsx("option", { value: "profile", children: t("profile") })] })] }), _jsx("p", { className: "dsmm-hint", children: t(navigation.scope === "global" ? "globalHint" : "profileHint") }), navigation.scope === "profile" && (navigation.native === null || !navigation.native.canWriteProfile()) && _jsx("p", { className: "dsmm-hint", children: t("unavailableForm") }), _jsx("div", { className: "dsmm-section-tabs", role: "tablist", "aria-label": t("modules"), children: tabs.map((module, index) => _jsx(Button, { ref: element => { if (element !== null)
100
129
  triggers.current.set(module, element);
101
130
  else
102
- triggers.current.delete(module); }, role: "tab", type: "button", id: `${id}-tab-${module}`, "aria-selected": active === module, "aria-controls": `${id}-panel`, tabIndex: active === module ? 0 : -1, "data-dsmm-tab": module, onKeyDown: event => onTabKey(event, index), onClick: () => select(module), children: t(moduleTitle(module)) }, module)) }), active !== null && _jsxs("section", { id: `${id}-panel`, role: "tabpanel", className: "dsmm-section-panel", "aria-labelledby": `${id}-tab-${active}`, "data-dsmm-module": active, children: [_jsx("div", { className: "dsmm-panel-heading", children: _jsx("h2", { id: `${id}-heading`, ref: heading, tabIndex: -1, children: t(moduleTitle(active)) }) }), active === "state" ? _jsxs(_Fragment, { children: [_jsx(StateInspector, { controller: props.core, t: t }), scopeActions] }) : _jsxs(_Fragment, { children: [navigation.scope === "profile" && navigation.native === null ? _jsx("p", { children: t("unavailableForm") }) : state.snapshot === null ? _jsx("p", { children: t(state.busy ? "loading" : "unavailable") }) : _jsxs("div", { "data-dsmm-layer": controller.layer, "aria-busy": state.busy, className: "dsmm-structured", children: [fields.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("noModuleFields") }), fields.map(([key, schema]) => _jsx(Field, { schema: schema, path: [key], controller: controller, initiallyOpen: fields.length === 1 && active !== "permissions", disclosures: disclosures.current[navigation.scope], t: t }, `${navigation.scope}:${key}`)), active === "run" && controller.layer === "profile" && _jsx(NativeRuntimeState, { value: state.snapshot.subagentRuntime, t: t })] }), scopeActions, active === "permissions" && _jsx("section", { className: "dsmm-zone dsmm-rules-transaction", "aria-label": t("rootRules"), children: workspace.permissions === undefined ? _jsx("p", { children: t("rootRulesUnavailable") }) : _jsx(PermissionsPanel, { controller: workspace.permissions, t: props.permissionsT ?? (key => Object.hasOwn(permissionEn, key) ? permissionText(t)(key) : key) }) })] })] }), navigation.pending !== null && _jsxs("section", { className: "dsmm-confirm", role: "group", "aria-label": t("leaveDraft"), onKeyDown: event => { if (event.key === "Escape" && !event.defaultPrevented) {
131
+ triggers.current.delete(module); }, role: "tab", type: "button", id: `${id}-tab-${module}`, "aria-selected": active === module, "aria-controls": `${id}-panel`, tabIndex: active === module ? 0 : -1, "data-dsmm-tab": module, onKeyDown: event => onTabKey(event, index), onClick: () => select(module), children: t(moduleTitle(module)) }, module)) }), active !== null && _jsxs("section", { id: `${id}-panel`, role: "tabpanel", className: "dsmm-section-panel", "aria-labelledby": `${id}-tab-${active}`, "data-dsmm-module": active, children: [_jsx("div", { className: "dsmm-panel-heading", children: _jsx("h2", { id: `${id}-heading`, ref: heading, tabIndex: -1, children: t(moduleTitle(active)) }) }), scopeActions, active === "state" ? _jsx(StateInspector, { controller: props.core, t: t }) : _jsxs(_Fragment, { children: [navigation.scope === "profile" && navigation.native === null ? _jsx("p", { children: t("unavailableForm") }) : state.snapshot === null ? _jsx("p", { children: t(state.busy ? "loading" : "unavailable") }) : _jsxs("div", { "data-dsmm-layer": controller.layer, "aria-busy": state.busy, className: "dsmm-structured", children: [fields.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("noModuleFields") }), fields.map(([key, schema]) => _jsx(Field, { schema: schema, path: [key], controller: controller, initiallyOpen: fields.length === 1 && active !== "permissions", disclosures: disclosures.current[navigation.scope], t: t }, `${navigation.scope}:${key}`)), active === "run" && controller.layer === "profile" && _jsx(NativeRuntimeState, { value: state.snapshot.subagentRuntime, t: t })] }), active === "permissions" && _jsx("section", { className: "dsmm-zone dsmm-rules-transaction", "aria-label": t("rootRules"), children: workspace.permissions === undefined ? _jsx("p", { children: t("rootRulesUnavailable") }) : _jsx(PermissionsPanel, { controller: workspace.permissions, t: props.permissionsT ?? (key => Object.hasOwn(permissionEn, key) ? permissionText(t)(key) : key) }) })] })] }), navigation.pending !== null && _jsxs("section", { className: "dsmm-confirm", role: "group", "aria-label": t("leaveDraft"), onKeyDown: event => { if (event.key === "Escape" && !event.defaultPrevented) {
103
132
  event.preventDefault();
104
133
  workspace.continueEditing();
105
134
  } }, children: [_jsx("p", { children: t("leaveDraft") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { ref: confirmation, type: "button", variant: "primary", onClick: () => workspace.continueEditing(), children: t("continueEditing") }), _jsx(Button, { type: "button", variant: "outline", onClick: () => workspace.keepAndNavigate(), children: t("keepDraft") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void workspace.discardAndNavigate(), children: t("discardDraft") })] })] })] });
@@ -36,7 +36,7 @@ function PermissionCoverage({ state, t }) {
36
36
  export function PermissionRulesEditor({ controller, state, t }) {
37
37
  const id = useId(), draft = state.draft, disabled = !controller.canEdit(state.generation), value = observedRules(state), observedPolicy = value?.snapshot ?? null;
38
38
  const writable = state.scope === "root" && state.connected;
39
- return _jsxs("section", { className: "dsmm-zone", "aria-label": t("rules"), children: [_jsx("h3", { children: t("rules") }), _jsx("p", { className: "dsmm-hint", children: t("rulesHint") }), _jsx(Issue, { value: state.rulesIssue, t: t }), displayUnconfirmed(state) && _jsx("p", { className: "dsmm-hint", children: t("unconfirmedObservation") }), _jsx("p", { className: "dsmm-hint", children: t("observedPolicy") }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("profileOverrideState") }), _jsx("dd", { children: t("profileOverrideUnknown") })] }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("runtime") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.state) }), _jsx("dt", { children: t("mounted") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.mounted ? "on" : "off") })] }), value?.runtime.restartRequired && _jsx("p", { children: t("restart") }), disabled && !state.reading && !displayUnconfirmed(state) && _jsx("p", { className: "dsmm-hint", children: t("rulesUnavailable") }), observedPolicy !== null && _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: "permissionControl.enabled" }), _jsxs("dd", { children: [t(observedPolicy.policy.enabled ? "on" : "off"), " \u00B7 ", t("coldHint")] }), _jsx("dt", { children: "permissionControl.nativeCommands.enabled" }), _jsx("dd", { children: t(observedPolicy.policy.nativeCommands.enabled ? "on" : "off") })] }), _jsxs("details", { className: "dsmm-deployment-group", children: [_jsx("summary", { children: t("coverageDetails") }), _jsx(PermissionCoverage, { state: state, t: t })] }), draft !== null && _jsxs(_Fragment, { children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-outside`, children: t("outsideReads") }), _jsx(ActionSelect, { id: `${id}-outside`, value: draft.outsideReads, disabled: disabled, t: t, onChange: outsideReads => controller.edit(state.generation, { outsideReads }) })] }), ["webSearch", "webFetch"].map(key => _jsxs("fieldset", { children: [_jsx("legend", { children: t(key) }), _jsxs("label", { className: "dsmm-actions", htmlFor: `${id}-${key}-enabled`, children: [_jsx("input", { type: "checkbox", id: `${id}-${key}-enabled`, checked: draft[key].enabled, disabled: disabled, onChange: event => controller.edit(state.generation, { [key]: { ...draft[key], enabled: event.currentTarget.checked } }) }), t("enabled")] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-${key}-rule`, children: t("rule") }), _jsx(ActionSelect, { id: `${id}-${key}-rule`, value: draft[key].rule, disabled: disabled, t: t, onChange: rule => controller.edit(state.generation, { [key]: { ...draft[key], rule } }) })] })] }, key)), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || draft.editor !== null, onClick: () => controller.edit(state.generation, { editor: { id: "", action: "ask", match: newMatch("outside-read") } }), children: t("newRule") }), _jsx(RuleEditor, { controller: controller, state: state, t: t }), (draft.upsert.length > 0 || draft.revoke.length > 0) && _jsxs("div", { className: "dsmm-structured", children: [_jsx("h3", { children: t("staged") }), draft.upsert.map(row => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [row.id, " \u00B7 ", t(`kind:${row.match.kind}`), " \u00B7 ", t(`action:${row.action}`)] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { upsert: draft.upsert.filter(rule => rule.id !== row.id) }), children: [t("unstage"), ": ", row.id] })] }, row.id)), draft.revoke.map(ruleId => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [t("stageRevoke"), ": ", ruleId] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { revoke: draft.revoke.filter(id => id !== ruleId) }), children: [t("unstage"), ": ", ruleId] })] }, ruleId))] })] }), _jsx(RuleRecords, { state: state, controller: controller, t: t }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !controller.canSave(state.generation), onClick: () => void controller.save(state.generation), children: t("save") }), _jsx(Button, { type: "button", variant: "outline", disabled: !writable || state.reading || state.busy !== null, onClick: () => void controller.refresh(state.generation), children: t("refresh") }), _jsx(Button, { type: "button", variant: "outline", disabled: !writable || state.reading || state.busy !== null || !state.dirty && state.rulesIssue === null, onClick: () => void controller.refresh(state.generation, true), children: t("discard") })] }), state.dirty && _jsx("p", { children: t("dirty") })] });
39
+ return _jsxs("section", { className: "dsmm-zone", "aria-label": t("rules"), children: [_jsxs("div", { className: "dsmm-rules-save-bar", children: [_jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !controller.canSave(state.generation), onClick: () => void controller.save(state.generation), children: t("save") }), _jsx(Button, { type: "button", variant: "outline", disabled: !writable || state.reading || state.busy !== null, onClick: () => void controller.refresh(state.generation), children: t("refresh") }), _jsx(Button, { type: "button", variant: "outline", disabled: !writable || state.reading || state.busy !== null || !state.dirty && state.rulesIssue === null, onClick: () => void controller.refresh(state.generation, true), children: t("discard") })] }), state.dirty && _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: t("dirty") })] }), _jsx("h3", { children: t("rules") }), _jsx("p", { className: "dsmm-hint", children: t("rulesHint") }), _jsx(Issue, { value: state.rulesIssue, t: t }), displayUnconfirmed(state) && _jsx("p", { className: "dsmm-hint", children: t("unconfirmedObservation") }), _jsx("p", { className: "dsmm-hint", children: t("observedPolicy") }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("profileOverrideState") }), _jsx("dd", { children: t("profileOverrideUnknown") })] }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("runtime") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.state) }), _jsx("dt", { children: t("mounted") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.mounted ? "on" : "off") })] }), value?.runtime.restartRequired && _jsx("p", { children: t("restart") }), disabled && !state.reading && !displayUnconfirmed(state) && _jsx("p", { className: "dsmm-hint", children: t("rulesUnavailable") }), observedPolicy !== null && _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: "permissionControl.enabled" }), _jsxs("dd", { children: [t(observedPolicy.policy.enabled ? "on" : "off"), " \u00B7 ", t("coldHint")] }), _jsx("dt", { children: "permissionControl.nativeCommands.enabled" }), _jsx("dd", { children: t(observedPolicy.policy.nativeCommands.enabled ? "on" : "off") })] }), _jsxs("details", { className: "dsmm-deployment-group", children: [_jsx("summary", { children: t("coverageDetails") }), _jsx(PermissionCoverage, { state: state, t: t })] }), draft !== null && _jsxs(_Fragment, { children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-outside`, children: t("outsideReads") }), _jsx(ActionSelect, { id: `${id}-outside`, value: draft.outsideReads, disabled: disabled, t: t, onChange: outsideReads => controller.edit(state.generation, { outsideReads }) })] }), ["webSearch", "webFetch"].map(key => _jsxs("fieldset", { children: [_jsx("legend", { children: t(key) }), _jsxs("label", { className: "dsmm-actions", htmlFor: `${id}-${key}-enabled`, children: [_jsx("input", { type: "checkbox", id: `${id}-${key}-enabled`, checked: draft[key].enabled, disabled: disabled, onChange: event => controller.edit(state.generation, { [key]: { ...draft[key], enabled: event.currentTarget.checked } }) }), t("enabled")] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-${key}-rule`, children: t("rule") }), _jsx(ActionSelect, { id: `${id}-${key}-rule`, value: draft[key].rule, disabled: disabled, t: t, onChange: rule => controller.edit(state.generation, { [key]: { ...draft[key], rule } }) })] })] }, key)), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || draft.editor !== null, onClick: () => controller.edit(state.generation, { editor: { id: "", action: "ask", match: newMatch("outside-read") } }), children: t("newRule") }), _jsx(RuleEditor, { controller: controller, state: state, t: t }), (draft.upsert.length > 0 || draft.revoke.length > 0) && _jsxs("div", { className: "dsmm-structured", children: [_jsx("h3", { children: t("staged") }), draft.upsert.map(row => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [row.id, " \u00B7 ", t(`kind:${row.match.kind}`), " \u00B7 ", t(`action:${row.action}`)] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { upsert: draft.upsert.filter(rule => rule.id !== row.id) }), children: [t("unstage"), ": ", row.id] })] }, row.id)), draft.revoke.map(ruleId => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [t("stageRevoke"), ": ", ruleId] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { revoke: draft.revoke.filter(id => id !== ruleId) }), children: [t("unstage"), ": ", ruleId] })] }, ruleId))] })] }), _jsx(RuleRecords, { state: state, controller: controller, t: t })] });
40
40
  }
41
41
  export function PermissionsPanel({ controller, t, sessionId }) {
42
42
  const state = useSyncExternalStore(controller.store.subscribe, controller.store.getSnapshot);
@@ -0,0 +1,24 @@
1
+ import type { RefObject } from "react";
2
+ import type { PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
3
+ import type { ProfilesActions, ProfilesViewSnapshot } from "./controller.js";
4
+ import type { StructuredDocument } from "./structured.js";
5
+ type Locale = PropsLocale<"settings.dsmm-profiles">;
6
+ export declare function hasExplicitModelOverride(roleId: string, doc: StructuredDocument | null): boolean;
7
+ export interface ProfileModelsDialogProps extends Locale {
8
+ open: boolean;
9
+ onClose: () => void;
10
+ state: ProfilesViewSnapshot;
11
+ actions: ProfilesActions;
12
+ disabled: boolean;
13
+ document: StructuredDocument | null;
14
+ isInvalidProjection?: boolean;
15
+ triggerRef?: RefObject<HTMLElement | null>;
16
+ targetRoleId?: string | null;
17
+ targetField?: string | null;
18
+ onTargetLocated?: () => void;
19
+ onJumpToJsonc?: () => void;
20
+ canSave?: boolean;
21
+ }
22
+ export declare function ProfileModelsDialog({ open, onClose, state, actions, disabled, document: doc, isInvalidProjection, triggerRef, targetRoleId, targetField, onTargetLocated, onJumpToJsonc, canSave: canSaveProp, t, }: ProfileModelsDialogProps): import("react").JSX.Element;
23
+ export {};
24
+ //# sourceMappingURL=ProfileModelsDialog.d.ts.map
@@ -0,0 +1,353 @@
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, canSave: canSaveProp, t, }) {
83
+ const prefix = useId();
84
+ const [searchQuery, setSearchQuery] = useState("");
85
+ const [filterExplicitOnly, setFilterExplicitOnly] = useState(false);
86
+ const pendingFallbackFocusRef = useRef(null);
87
+ const dialogTopBarRef = useRef(null);
88
+ const wasOpenRef = useRef(open);
89
+ useEffect(() => {
90
+ if (wasOpenRef.current && !open) {
91
+ if (triggerRef?.current && triggerRef.current.isConnected) {
92
+ triggerRef.current.focus();
93
+ }
94
+ }
95
+ wasOpenRef.current = open;
96
+ }, [open, triggerRef]);
97
+ // Background inert on document.body siblings while modal is open
98
+ useEffect(() => {
99
+ if (!open)
100
+ return;
101
+ const elementsToRestore = [];
102
+ const timer = setTimeout(() => {
103
+ const dialogElement = document.querySelector(".dsmm-profile-models-dialog");
104
+ for (const child of Array.from(document.body.children)) {
105
+ if (child instanceof HTMLElement && (!dialogElement || !child.contains(dialogElement))) {
106
+ const prev = child.getAttribute("inert");
107
+ child.setAttribute("inert", "");
108
+ elementsToRestore.push({ el: child, prevInert: prev });
109
+ }
110
+ }
111
+ }, 0);
112
+ return () => {
113
+ clearTimeout(timer);
114
+ for (const { el, prevInert } of elementsToRestore) {
115
+ if (prevInert !== null) {
116
+ el.setAttribute("inert", prevInert);
117
+ }
118
+ else {
119
+ el.removeAttribute("inert");
120
+ }
121
+ }
122
+ };
123
+ }, [open]);
124
+ // Target role locating effect
125
+ useEffect(() => {
126
+ if (!open || !targetRoleId)
127
+ return;
128
+ setSearchQuery("");
129
+ setFilterExplicitOnly(false);
130
+ const rafId = requestAnimationFrame(() => {
131
+ const roleCard = document.querySelector(`[data-dsmm-role='${targetRoleId}']`);
132
+ if (!roleCard) {
133
+ onJumpToJsonc?.();
134
+ return;
135
+ }
136
+ const targetInput = locateFieldInsideRole(roleCard, targetField);
137
+ if (!targetInput) {
138
+ onJumpToJsonc?.();
139
+ return;
140
+ }
141
+ const reducedMotion = typeof window !== "undefined" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
142
+ const scrollOpt = { behavior: reducedMotion ? "auto" : "smooth", block: "nearest" };
143
+ if (typeof targetInput.scrollIntoView === "function") {
144
+ targetInput.scrollIntoView(scrollOpt);
145
+ }
146
+ targetInput.focus();
147
+ if (document.activeElement === targetInput)
148
+ onTargetLocated?.();
149
+ else
150
+ onJumpToJsonc?.();
151
+ });
152
+ return () => cancelAnimationFrame(rafId);
153
+ }, [open, targetRoleId, targetField, onTargetLocated, onJumpToJsonc]);
154
+ // Safe fallback focus preservation after add, move, or remove
155
+ useEffect(() => {
156
+ if (!pendingFallbackFocusRef.current)
157
+ return;
158
+ const { roleId, index, action } = pendingFallbackFocusRef.current;
159
+ pendingFallbackFocusRef.current = null;
160
+ const roleCard = document.querySelector(`[data-dsmm-role='${roleId}']`);
161
+ if (!roleCard)
162
+ return;
163
+ if (action === "add") {
164
+ const item = roleCard.querySelector(`[data-dsmm-fallback-index='${index}']`);
165
+ const providerInput = item?.querySelector("input[id$='-provider'], select[id$='-provider'], input, select");
166
+ providerInput?.focus();
167
+ }
168
+ else if (action === "moveUp" || action === "moveDown") {
169
+ const item = roleCard.querySelector(`[data-dsmm-fallback-index='${index}']`);
170
+ if (item) {
171
+ const targetBtn = item.querySelector(`button[data-dsmm-action='${action}']:not([disabled])`) ??
172
+ item.querySelector("button[data-dsmm-action='moveUp']:not([disabled])") ??
173
+ item.querySelector("button[data-dsmm-action='moveDown']:not([disabled])") ??
174
+ item.querySelector("button[data-dsmm-action='remove']:not([disabled])") ??
175
+ item.querySelector("input:not([disabled]), select:not([disabled])");
176
+ targetBtn?.focus();
177
+ }
178
+ }
179
+ else if (action === "remove") {
180
+ const nextRemoveBtn = roleCard.querySelector(`[data-dsmm-fallback-index='${index}'] button[data-dsmm-action='remove']`) ??
181
+ roleCard.querySelector(`[data-dsmm-fallback-index='${Math.max(0, index - 1)}'] button[data-dsmm-action='remove']`) ??
182
+ roleCard.querySelector("button[data-dsmm-action='add-fallback']");
183
+ nextRemoveBtn?.focus();
184
+ }
185
+ });
186
+ const handleKeyDownCapture = (event) => {
187
+ if (event.key === "Tab") {
188
+ const dialog = (event.currentTarget.classList.contains("dsmm-profile-models-dialog")
189
+ ? event.currentTarget
190
+ : event.currentTarget.querySelector(".dsmm-profile-models-dialog") ?? event.currentTarget);
191
+ 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) => {
192
+ const closedDetails = el.closest("details:not([open])");
193
+ if (closedDetails && el !== closedDetails.querySelector("summary"))
194
+ return false;
195
+ if (el.getAttribute("tabindex") === "-1")
196
+ return false;
197
+ if (el.hasAttribute("disabled") || el.getAttribute("aria-disabled") === "true")
198
+ return false;
199
+ if (el.closest("[inert]") || el.closest("[hidden]"))
200
+ return false;
201
+ if (el.offsetWidth === 0 && el.offsetHeight === 0 && el.getClientRects().length === 0)
202
+ return false;
203
+ return true;
204
+ });
205
+ if (candidates.length === 0) {
206
+ event.preventDefault();
207
+ return;
208
+ }
209
+ const first = candidates[0];
210
+ const last = candidates[candidates.length - 1];
211
+ if (event.shiftKey) {
212
+ if (document.activeElement === first || !dialog.contains(document.activeElement)) {
213
+ event.preventDefault();
214
+ event.stopPropagation();
215
+ last.focus();
216
+ }
217
+ }
218
+ else {
219
+ if (document.activeElement === last || !dialog.contains(document.activeElement)) {
220
+ event.preventDefault();
221
+ event.stopPropagation();
222
+ first.focus();
223
+ }
224
+ }
225
+ }
226
+ };
227
+ const roles = state.snapshot?.roles ?? [];
228
+ const effectiveDisabled = disabled || isInvalidProjection || doc === null;
229
+ const baseline = state.snapshot?.editorDefaults;
230
+ const canSave = canSaveProp ?? (!disabled && !isInvalidProjection && doc !== null && state.dirty && state.snapshot !== null && state.invalidFields.length === 0);
231
+ const isSaveLocked = (state.dirty || state.invalidFields.length > 0) && !disabled && doc !== null && state.snapshot !== null && (state.invalidFields.length > 0 || Boolean(isInvalidProjection));
232
+ const filteredRoles = roles.filter((role) => {
233
+ if (searchQuery.trim()) {
234
+ const q = searchQuery.trim().toLowerCase();
235
+ const matchesId = role.id.toLowerCase().includes(q);
236
+ const matchesLabel = role.label.toLowerCase().includes(q);
237
+ if (!matchesId && !matchesLabel)
238
+ return false;
239
+ }
240
+ if (filterExplicitOnly) {
241
+ if (!hasExplicitModelOverride(role.id, doc))
242
+ return false;
243
+ }
244
+ return true;
245
+ });
246
+ useEffect(() => {
247
+ if (!open)
248
+ return;
249
+ const el = dialogTopBarRef.current;
250
+ if (!el)
251
+ return;
252
+ const parent = el.closest(".dsmm-profile-models-dialog-content");
253
+ const update = () => {
254
+ const height = el.offsetHeight;
255
+ if (parent) {
256
+ parent.style.setProperty("--dsmm-dialog-bar-offset", `${height}px`);
257
+ }
258
+ };
259
+ update();
260
+ if (typeof ResizeObserver !== "undefined") {
261
+ const ro = new ResizeObserver(update);
262
+ ro.observe(el);
263
+ return () => {
264
+ ro.disconnect();
265
+ if (parent) {
266
+ parent.style.removeProperty("--dsmm-dialog-bar-offset");
267
+ }
268
+ };
269
+ }
270
+ return () => {
271
+ if (parent) {
272
+ parent.style.removeProperty("--dsmm-dialog-bar-offset");
273
+ }
274
+ };
275
+ }, [open, state.dirty, isSaveLocked, state.busy]);
276
+ 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", { ref: dialogTopBarRef, className: "dsmm-dialog-top-bar", children: [_jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !canSave, onClick: () => { void actions.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), _jsx(Button, { type: "button", variant: "outline", onClick: onClose, children: t("cancel") })] }), state.busy === "save" ? (_jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: t("saving") })) : state.dirty ? (_jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: t("dirty") })) : null, isSaveLocked && (_jsx("div", { className: "dsmm-save-lock-reason", role: "status", children: _jsx("span", { className: "dsmm-save-lock-text", children: isInvalidProjection
277
+ ? t("rawInvalid")
278
+ : t("saveLockedReason", { count: state.invalidFields.length }) }) }))] }), _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) => {
279
+ const policy = doc.roleRouting[role.id] ?? {};
280
+ const rolePath = ["settings", "roleRouting", role.id];
281
+ const isOrchestrator = role.id === "dsmm-orchestrator";
282
+ const explicitOverride = hasExplicitModelOverride(role.id, doc);
283
+ // Compute inheritance for policy retry
284
+ let inherited;
285
+ try {
286
+ if (baseline !== undefined) {
287
+ const profileDefaults = {
288
+ strategy: doc.runtimePolicy.strategy ?? baseline.strategy,
289
+ rateLimit: normalizeRateLimitPolicy(doc.runtimePolicy.rateLimit, baseline.rateLimit),
290
+ };
291
+ inherited = {
292
+ strategy: role.runtimePolicy?.strategy ?? profileDefaults.strategy,
293
+ rateLimit: normalizeRateLimitPolicy(role.runtimePolicy?.rateLimit, profileDefaults.rateLimit),
294
+ };
295
+ }
296
+ }
297
+ catch {
298
+ // Leave inherited undefined if invalid
299
+ }
300
+ const availability = roleAvailability(role.availability);
301
+ const namedRoles = doc.settings.roles;
302
+ // Calling levels summary
303
+ const configuredLevels = ["low", "high", "max"].filter((lvl) => policy.levels?.[lvl] !== undefined);
304
+ const levelsSummary = configuredLevels.length > 0
305
+ ? t("levelsSummary", { levels: configuredLevels.join(", ") })
306
+ : t("levelsInherited");
307
+ // Fallback chain summary
308
+ const fallbackSummary = policy.fallbackRoutes === undefined
309
+ ? t("fallbackInherited")
310
+ : policy.fallbackRoutes.length === 0
311
+ ? t("fallbackExplicitEmptySummary")
312
+ : t("fallbackCountSummary", { count: policy.fallbackRoutes.length });
313
+ // Non-model settings summary
314
+ const statusSummary = namedRoles?.[role.id] !== undefined
315
+ ? (namedRoles[role.id] ? t("enabled") : t("disabled"))
316
+ : t("roleSettingsInherited");
317
+ const retrySummary = policy.strategy !== undefined || (policy.rateLimit !== undefined && Object.keys(policy.rateLimit).length > 0)
318
+ ? t("roleSettingsOverridden")
319
+ : t("roleSettingsInherited");
320
+ const nonModelSummary = t("roleSettingsSummary", { status: statusSummary, retry: retrySummary });
321
+ 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) => {
322
+ const name = t("fallbackName", { name: role.label, index: index + 1 });
323
+ 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: () => {
324
+ pendingFallbackFocusRef.current = { roleId: role.id, index: index - 1, action: "moveUp" };
325
+ actions.moveFallback(role.id, index, index - 1);
326
+ }, children: t("moveUp", { name }) }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-action": "moveDown", disabled: effectiveDisabled || index === policy.fallbackRoutes.length - 1, onClick: () => {
327
+ pendingFallbackFocusRef.current = { roleId: role.id, index: index + 1, action: "moveDown" };
328
+ actions.moveFallback(role.id, index, index + 1);
329
+ }, children: t("moveDown", { name }) }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-action": "remove", disabled: effectiveDisabled, onClick: () => {
330
+ const newLen = policy.fallbackRoutes.length - 1;
331
+ const nextIdx = Math.min(index, Math.max(0, newLen - 1));
332
+ pendingFallbackFocusRef.current = { roleId: role.id, index: nextIdx, action: "remove" };
333
+ actions.editPath([...rolePath, "fallbackRoutes", index], undefined);
334
+ }, children: t("removeFallback", { name }) })] })] }, index));
335
+ }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-action": "add-fallback", disabled: effectiveDisabled || (policy.fallbackRoutes?.length ?? 0) >= 32, onClick: (e) => {
336
+ const currentDetails = e.currentTarget.closest("details");
337
+ if (currentDetails)
338
+ currentDetails.open = true;
339
+ const newIndex = policy.fallbackRoutes?.length ?? 0;
340
+ pendingFallbackFocusRef.current = { roleId: role.id, index: newIndex, action: "add" };
341
+ if (policy.fallbackRoutes === undefined) {
342
+ actions.editPath([...rolePath, "fallbackRoutes"], [{ provider: "", model: "" }]);
343
+ }
344
+ else {
345
+ actions.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
346
+ }
347
+ }, 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 ||
348
+ !availability.startupAvailable ||
349
+ !availability.deploymentEnabled ||
350
+ 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));
351
+ })] }))] }));
352
+ }
353
+ //# sourceMappingURL=ProfileModelsDialog.js.map