@dsmm/dsmm 0.3.11 → 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.
Files changed (59) hide show
  1. package/README.md +2 -2
  2. package/docs/agent-presets.md +4 -4
  3. package/docs/compatibility.md +16 -4
  4. package/docs/deferred-native-approval-risk.md +1 -1
  5. package/docs/design.md +15 -5
  6. package/docs/lsp.md +1 -1
  7. package/docs/maintenance.md +9 -3
  8. package/docs/model-routing.md +6 -6
  9. package/docs/native-permissions.md +1 -1
  10. package/docs/profiles.md +46 -5
  11. package/docs/roadmap.md +3 -3
  12. package/docs/runtime-recovery.md +5 -5
  13. package/docs/safety-guards.md +1 -1
  14. package/docs/settings-status.md +3 -3
  15. package/docs/testing.md +85 -0
  16. package/lib/child-capture.d.ts +9 -0
  17. package/lib/child-capture.js +24 -1
  18. package/lib/client/ProfileModelsDialog.d.ts +23 -0
  19. package/lib/client/ProfileModelsDialog.js +318 -0
  20. package/lib/client/ProfilesSection.js +228 -34
  21. package/lib/client/RoleToolView-data.d.ts +11 -4
  22. package/lib/client/RoleToolView-data.js +48 -1
  23. package/lib/client/RoleToolView-locales.d.ts +12 -4
  24. package/lib/client/RoleToolView-locales.js +12 -6
  25. package/lib/client/RoleToolView.js +49 -9
  26. package/lib/client/SessionProfiles.d.ts +5 -1
  27. package/lib/client/SessionProfiles.js +13 -9
  28. package/lib/client/StructuredEditor.d.ts +60 -0
  29. package/lib/client/StructuredEditor.js +73 -49
  30. package/lib/client/controller.d.ts +10 -0
  31. package/lib/client/controller.js +44 -14
  32. package/lib/client/diagnostics.d.ts +1 -0
  33. package/lib/client/diagnostics.js +9 -0
  34. package/lib/client/locales.d.ts +57 -0
  35. package/lib/client/locales.js +89 -17
  36. package/lib/client/session-labels.js +4 -1
  37. package/lib/client/structured.d.ts +4 -0
  38. package/lib/client/structured.js +16 -1
  39. package/lib/client/styles.d.ts +1 -1
  40. package/lib/client/styles.js +107 -30
  41. package/lib/client.js +2424 -1049
  42. package/lib/host-llm.js +3 -3
  43. package/lib/index.js +1 -1
  44. package/lib/model-routing.d.ts +3 -2
  45. package/lib/model-routing.js +28 -7
  46. package/lib/native-admission.d.ts +2 -0
  47. package/lib/native-admission.js +106 -34
  48. package/lib/profile-runtime.d.ts +11 -0
  49. package/lib/profile-runtime.js +48 -13
  50. package/lib/profile-store.d.ts +4 -1
  51. package/lib/profile-store.js +37 -14
  52. package/lib/role-control-rpc.js +18 -5
  53. package/lib/role-llm-runtime.js +10 -1
  54. package/lib/role-policy.d.ts +4 -3
  55. package/lib/role-policy.js +6 -6
  56. package/lib/role-providers.js +1 -0
  57. package/lib/runtime-recovery.d.ts +2 -2
  58. package/lib/runtime-recovery.js +7 -4
  59. package/package.json +7 -2
@@ -1,17 +1,37 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { Button, CodeBlock, DisclosureRow, StateDot } from "@deepseek-ai/dsh-client-ui-primitives";
3
- import { actualRoleTool, preparingRoleTool, requestedRoleTool, roleToolDisplay, roleToolKeys } from "./RoleToolView-data.js";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Button, CodeBlock, DisclosureRow, IconAgentPresetOutlineRegular, SegmentedControl, StateDot, TextShimmer } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { actualRoleTool, preparingRoleTool, requestedRoleTool, roleToolDisplay, roleToolKeys, technicalJsonData, technicalTableRows } from "./RoleToolView-data.js";
4
5
  import { ROLE_TOOL_NS, roleToolEn, roleToolZh } from "./RoleToolView-locales.js";
5
6
  const styles = `
6
7
  .dsmm-role-tool{min-width:0;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);font-size:14px;line-height:22px}
7
8
  .dsmm-role-tool .dsmm-role-heading{color:var(--dsw-alias-label-primary);height:auto;min-height:32px}
8
- .dsmm-role-tool .dsmm-role-title{white-space:normal;overflow-wrap:anywhere;min-width:0;max-width:100%;color:inherit;font-size:inherit;line-height:inherit}
9
- .dsmm-role-tool .dsmm-role-text{flex:1;min-width:0}
10
- .dsmm-role-tool .dsmm-role-body{display:flex;flex-direction:column;gap:12px;min-width:0;padding:8px 0}
9
+ .dsmm-role-tool .dsmm-role-title{white-space:nowrap;flex:none;color:inherit;font-size:inherit;line-height:inherit}
10
+ .dsmm-role-tool .dsmm-role-text{display:inline-flex;align-items:center;min-width:0;flex:1;overflow:hidden}
11
+ .dsmm-role-tool .dsmm-role-sep{background:var(--dsw-alias-label-caption);border-radius:1px;flex:none;width:2px;height:2px;margin:0 8px}
12
+ .dsmm-role-tool .dsmm-role-summary{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:var(--dsh-content-font-size-secondary,13px);line-height:calc(24px + var(--dsh-content-font-delta,0px));flex:auto;overflow:hidden;color:var(--dsw-alias-label-secondary)}
13
+ .dsmm-role-tool .dsmm-role-icon{flex:none;color:inherit}
14
+ .dsmm-role-tool .dsmm-role-body{display:flex;flex-direction:column;gap:8px;min-width:0;padding:8px 0}
11
15
  .dsmm-role-tool p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}
12
16
  .dsmm-role-tool .dsmm-role-status{color:var(--dsw-alias-label-secondary)}
13
17
  .dsmm-role-tool .dsmm-role-actions{display:flex;flex-wrap:wrap;align-items:center;gap:8px}
14
- .dsmm-role-tool :is(button,[role=button]):focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
18
+ .dsmm-role-tool .dsmm-role-identity{color:var(--dsw-alias-label-secondary);font-size:13px;line-height:20px}
19
+ .dsmm-role-tool .dsmm-role-task{color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px}
20
+ .dsmm-role-tool .dsmm-role-dim{color:var(--dsw-alias-label-tertiary)}
21
+ .dsmm-role-tool .dsmm-role-section-title{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;margin-bottom:4px}
22
+ .dsmm-role-tool .dsmm-role-details{border-top:1px solid var(--dsw-alias-border-l2);padding-top:8px;margin-top:4px}
23
+ .dsmm-role-tool .dsmm-role-details summary{cursor:pointer;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;user-select:none}
24
+ .dsmm-role-tool .dsmm-role-details-body{display:flex;flex-direction:column;gap:8px;margin-top:8px;padding-left:8px}
25
+ .dsmm-role-tool .dsmm-role-details-header{display:flex;align-items:center;margin-bottom:4px}
26
+ .dsmm-role-tool .dsmm-role-view-switch{margin-bottom:4px}
27
+ .dsmm-role-tool .dsmm-role-table{width:100%;border-collapse:collapse;font-size:12px;line-height:18px;margin-top:4px}
28
+ .dsmm-role-tool .dsmm-role-table th,.dsmm-role-tool .dsmm-role-table td{padding:4px 8px;text-align:left;vertical-align:top;border-bottom:1px solid var(--dsw-alias-border-l1)}
29
+ .dsmm-role-tool .dsmm-role-table th{color:var(--dsw-alias-label-secondary);font-weight:500;border-bottom:1px solid var(--dsw-alias-border-l2)}
30
+ .dsmm-role-tool .dsmm-role-prop-cell{color:var(--dsw-alias-label-secondary);font-family:var(--dsw-font-family-code,monospace);word-break:break-all;width:35%;max-width:180px}
31
+ .dsmm-role-tool .dsmm-role-val-cell{color:var(--dsw-alias-label-primary);word-break:break-word}
32
+ .dsmm-role-tool .dsmm-role-cell-text{white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}
33
+ .dsmm-role-tool .dsmm-role-cell-code{margin:0;font-family:var(--dsw-font-family-code,monospace);font-size:11px;line-height:16px;white-space:pre-wrap;word-break:break-all;background:var(--dsw-alias-bg-layer-2,rgba(0,0,0,0.04));padding:4px 6px;border-radius:4px}
34
+ .dsmm-role-tool :is(button,[role=button],summary):focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
15
35
  `;
16
36
  export function RoleToolView(props) {
17
37
  const { expanded, toggle } = props.useDisclosure();
@@ -23,10 +43,30 @@ export function RoleToolView(props) {
23
43
  const failed = result !== undefined && (result.isError || result.error != null);
24
44
  const actual = result === undefined ? undefined : actualRoleTool(props.toolName, result.meta, failed);
25
45
  const target = actual?.role ?? requested.target;
26
- const title = `${t("call")} ${target === undefined ? t("unknownTarget") : roleToolDisplay(target)}${(actual?.level ?? requested.level) === undefined ? "" : ` · ${actual?.level ?? requested.level}`}`;
46
+ const action = props.phase === "preparing" ? t("calling") : t("call");
47
+ const targetLabel = target === undefined ? t("unknownTarget") : roleToolDisplay(target);
48
+ const rawDesc = requested.description?.trim();
49
+ const singleLineDesc = rawDesc ? rawDesc.replace(/\s+/gu, " ") : undefined;
50
+ const title = `${action} ${targetLabel}`;
27
51
  const state = result?.error?.code === "interrupted" ? "stopped" : failed ? "error" : result === undefined ? props.phase === "preparing" ? "preparing" : "running" : actual?.jobId !== undefined || actual?.mode === "continuable" ? "background" : "result";
52
+ const isOngoing = state === "running" || props.phase === "preparing";
28
53
  const code = (value) => _jsx(CodeBlock, { code: value, copyLabel: t("copy"), copiedLabel: t("copied") });
29
- return _jsxs("div", { className: "dsmm-role-tool", "data-dsmm-role-tool": props.toolName, "data-identity": actual === undefined ? "requested" : "actual", "data-state": state, children: [_jsx(DisclosureRow, { title: title, titleClassName: "dsmm-role-title", rowClassName: "dsmm-role-heading", contentClassName: "dsmm-role-text", icon: _jsx(StateDot, { state: state === "error" ? "error" : state === "stopped" ? "warning" : result === undefined ? "ongoing" : state === "background" ? "idle" : "done" }), open: expanded, expandable: true, onToggle: toggle, expandOnRowClick: true, children: _jsxs("div", { className: "dsmm-role-body", children: [_jsxs("p", { children: [props.toolName, " \u00B7 ", props.callId] }), _jsxs("p", { className: "dsmm-role-status", children: [t("requested"), " ", t(requested.kind), ": ", requested.target === undefined ? t("unknown") : roleToolDisplay(requested.target)] }), requested.description !== undefined && _jsx("p", { className: "dsmm-role-status", children: requested.description }), actual !== undefined && _jsxs(_Fragment, { children: [_jsxs("p", { children: [t("actual"), " ", t(requested.kind), ": ", roleToolDisplay(actual.role), " \u00B7 ", t("level"), ": ", actual.level] }), _jsxs("p", { children: [t("routeSource"), ": ", actual.routeSource, " \u00B7 ", t("route"), ": ", actual.route === undefined ? t("unknown") : `${actual.route.provider}/${actual.route.model}${actual.route.reasoningEffort === undefined ? "" : ` · ${actual.route.reasoningEffort}`}`] })] }), _jsxs("div", { children: [_jsx("p", { children: t(props.phase === "preparing" ? "preparingArgs" : "args") }), raw === "" ? _jsx("p", { children: t("emptyArgs") }) : code(raw)] }), result !== undefined && _jsxs(_Fragment, { children: [actual === undefined && _jsx("p", { children: t("unavailable") }), _jsxs("div", { children: [_jsx("p", { children: t("output") }), code(JSON.stringify(result.content, null, 2))] }), result.error != null && _jsxs("div", { children: [_jsx("p", { children: t("failure") }), code(JSON.stringify(result.error, null, 2))] }), result.meta != null && _jsxs("div", { children: [_jsx("p", { children: t("metadata") }), code(JSON.stringify(result.meta, null, 2))] })] })] }) }), _jsxs("div", { className: "dsmm-role-actions", children: [_jsx("p", { className: "dsmm-role-status", role: "status", children: t(state) }), props.inspect !== undefined && _jsx(Button, { variant: "ghost", size: "sm", onClick: props.inspect, children: t("inspect") })] })] });
54
+ const [viewMode, setViewMode] = useState("table");
55
+ const controlId = `dsmm-tech-${props.callId || "call"}`;
56
+ const viewOptions = [
57
+ { value: "table", label: t("table") },
58
+ { value: "json", label: t("json") },
59
+ ];
60
+ const tableRows = technicalTableRows(props.toolName, props.callId, raw, result?.meta, actual?.routeSource);
61
+ const jsonData = technicalJsonData(props.toolName, props.callId, raw, result?.meta, actual?.routeSource);
62
+ const roleDiffers = requested.target !== undefined && actual !== undefined && actual.role !== requested.target;
63
+ const levelDiffers = requested.level !== undefined && actual !== undefined && actual.level !== requested.level;
64
+ const showRequestedVsActual = roleDiffers || levelDiffers;
65
+ const collapsedContent = singleLineDesc ? _jsxs(_Fragment, { children: [_jsx("span", { className: "dsmm-role-sep", "aria-hidden": "true" }), _jsx("span", { className: "dsmm-role-summary", children: _jsx(TextShimmer, { active: isOngoing, children: singleLineDesc }) })] }) : undefined;
66
+ const stateDotState = state === "error" ? "error" : state === "stopped" ? "warning" : result === undefined ? "ongoing" : state === "background" ? "idle" : "done";
67
+ return _jsxs("div", { className: "dsmm-role-tool", "data-dsmm-role-tool": props.toolName, "data-identity": actual === undefined ? "requested" : "actual", "data-state": state, "data-expanded": expanded ? "true" : "false", children: [_jsx(DisclosureRow, { title: title, titleClassName: "dsmm-role-title", rowClassName: "dsmm-role-heading", contentClassName: "dsmm-role-text", icon: _jsx(IconAgentPresetOutlineRegular, { size: 14, className: "dsmm-role-icon" }), collapsedContent: collapsedContent, keepContentWhenOpen: true, running: isOngoing, open: expanded, expandable: true, onToggle: toggle, expandOnRowClick: true, children: _jsxs("div", { className: "dsmm-role-body", children: [_jsxs("p", { className: "dsmm-role-identity", children: [showRequestedVsActual ? _jsxs(_Fragment, { children: [_jsxs("span", { className: "dsmm-role-dim", children: [t("requested"), ": "] }), _jsxs("span", { children: [requested.target === undefined ? t("unknown") : roleToolDisplay(requested.target), requested.level ? ` (${requested.level})` : ""] }), _jsx("span", { className: "dsmm-role-dim", children: " \u2192 " }), _jsxs("span", { className: "dsmm-role-dim", children: [t("actual"), ": "] }), _jsxs("span", { children: [roleToolDisplay(actual.role), " (", actual.level, ")"] })] }) : _jsxs("span", { children: [actual !== undefined ? roleToolDisplay(actual.role) : requested.target === undefined ? t("unknownTarget") : roleToolDisplay(requested.target), (actual?.level ?? requested.level) !== undefined && ` · ${actual?.level ?? requested.level}`, result !== undefined && actual === undefined && _jsxs("span", { className: "dsmm-role-dim", children: [" \u00B7 ", t("actualUnknown")] })] }), actual?.route !== undefined && _jsxs("span", { className: "dsmm-role-model", children: [" · ", actual.route.provider, "/", actual.route.model, actual.route.reasoningEffort ? ` · ${actual.route.reasoningEffort}` : ""] })] }), requested.description !== undefined && _jsx("p", { className: "dsmm-role-task", children: requested.description }), result?.error != null && _jsxs("div", { className: "dsmm-role-failure", children: [_jsx("p", { className: "dsmm-role-section-title", children: t("failure") }), code(JSON.stringify(result.error, null, 2))] }), _jsxs("details", { className: "dsmm-role-details", children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-role-details-body", children: [_jsx("div", { className: "dsmm-role-details-header", children: _jsx(SegmentedControl, { id: controlId, value: viewMode, options: viewOptions, onChange: setViewMode, label: t("viewMode"), className: "dsmm-role-view-switch" }) }), _jsx("div", { id: `${controlId}-table-panel`, role: "tabpanel", "aria-labelledby": `${controlId}-table`, hidden: viewMode !== "table", tabIndex: 0, children: viewMode === "table" && _jsxs("table", { className: "dsmm-role-table", children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: t("property") }), _jsx("th", { scope: "col", children: t("value") })] }) }), _jsx("tbody", { children: tableRows.map(row => _jsxs("tr", { children: [_jsx("td", { className: "dsmm-role-prop-cell", children: row.property }), _jsx("td", { className: "dsmm-role-val-cell", children: row.isComplex ? _jsx("pre", { className: "dsmm-role-cell-code", children: JSON.stringify(row.value, null, 2) })
68
+ : typeof row.value === "string" ? _jsx("span", { className: "dsmm-role-cell-text", children: row.value })
69
+ : _jsx("span", { children: row.value === null ? "null" : row.value === undefined ? "undefined" : String(row.value) }) })] }, row.property)) })] }) }), _jsx("div", { id: `${controlId}-json-panel`, role: "tabpanel", "aria-labelledby": `${controlId}-json`, hidden: viewMode !== "json", tabIndex: 0, children: viewMode === "json" && code(JSON.stringify(jsonData, null, 2)) })] })] })] }) }), _jsxs("div", { className: "dsmm-role-actions", children: [_jsx(StateDot, { state: stateDotState }), _jsx("p", { className: "dsmm-role-status", role: "status", children: t(state) }), props.inspect !== undefined && _jsx(Button, { variant: "ghost", size: "sm", onClick: props.inspect, children: t("inspect") })] })] });
30
70
  }
31
71
  /** Called once by the parent client apply(ctx), alongside the other slot registrations. */
32
72
  export function registerRoleToolViews(ctx) {
@@ -9,10 +9,14 @@ type Injected = ProfilesActions & {
9
9
  export type SessionProfilesProps = InjectFace<Injected> & PropsLocale<"settings.dsmm-profiles"> & {
10
10
  sessionId?: string;
11
11
  };
12
- export declare function SessionScope({ state, actions, t, compact }: PropsLocale<"settings.dsmm-profiles"> & {
12
+ export declare function SessionScopeFeedback({ state, t }: PropsLocale<"settings.dsmm-profiles"> & {
13
+ state: ProfilesViewSnapshot;
14
+ }): import("react").JSX.Element;
15
+ export declare function SessionScope({ state, actions, t, compact, showFeedback }: PropsLocale<"settings.dsmm-profiles"> & {
13
16
  state: ProfilesViewSnapshot;
14
17
  actions: ProfilesActions;
15
18
  compact?: boolean;
19
+ showFeedback?: boolean;
16
20
  }): import("react").JSX.Element;
17
21
  /** Root-scoped native menu; an explicitly scoped foreign occurrence still refuses. */
18
22
  export declare function SessionProfiles(props: SessionProfilesProps): import("react").JSX.Element | null;
@@ -28,7 +28,15 @@ function menuIssue(issue) {
28
28
  // arbitrary wire fields, provider identifiers, credentials or file paths.
29
29
  return { code, ...(isSafeDiagnosticField(field) ? { field } : {}) };
30
30
  }
31
- export function SessionScope({ state, actions, t, compact = false }) {
31
+ export function SessionScopeFeedback({ state, t }) {
32
+ const session = state.session;
33
+ const status = state.sessionNotice === null ? "" : t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "sessionAppliedWithModel" : state.sessionNotice === "applied" ? "sessionApplied" : "sessionResetDone");
34
+ return _jsxs("div", { "data-dsmm-session-feedback": true, children: [session?.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("admissionWarnings") }), _jsx(ProfileWarnings, { warnings: session.warnings, t: t })] }) : null, state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), (session?.refreshRequired || session?.selection.refreshRequired) && _jsx("p", { role: "status", children: t("sessionCommittedRefresh") }), state.sessionUnconfirmed && _jsx("p", { role: "status", children: t("sessionUnconfirmedRefresh") }), state.sessionIssue !== null && _jsxs(_Fragment, { children: [_jsx("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed")
35
+ : state.sessionIssue.code === "conflict" ? t("sessionConflict")
36
+ : ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code })
37
+ : t(state.sessionIssue.code === "validation" ? "validation" : "sessionUnavailable") }), _jsx(IssueDetails, { issue: state.sessionIssue, t: t })] }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.sessionBusy === "read" ? t("reading") : status })] });
38
+ }
39
+ export function SessionScope({ state, actions, t, compact = false, showFeedback = true }) {
32
40
  const prefix = useId();
33
41
  const session = state.session;
34
42
  const labels = session === null ? null : sessionProfileLabels(session, t);
@@ -38,7 +46,6 @@ export function SessionScope({ state, actions, t, compact = false }) {
38
46
  const ready = session !== null && !state.sessionUnconfirmed && !session.refreshRequired && !session.selection.refreshRequired && writableSelectionVersion(session.selection.selectionRevision);
39
47
  const allowed = ready && session.canApplyOverlay === true && session.applyOverlayUnavailableReason !== "new-session-required";
40
48
  const modelAllowed = ready && session.canSelectModel === true && session.profileModel !== undefined;
41
- const status = state.sessionNotice === null ? "" : t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "sessionAppliedWithModel" : state.sessionNotice === "applied" ? "sessionApplied" : "sessionResetDone");
42
49
  let binding = session?.subagentRuntime;
43
50
  try {
44
51
  if (binding !== undefined)
@@ -47,15 +54,12 @@ export function SessionScope({ state, actions, t, compact = false }) {
47
54
  catch {
48
55
  binding = undefined;
49
56
  }
50
- return _jsxs("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [!compact && _jsx("h3", { children: t("sessionScope") }), state.currentSessionId === null ? _jsx("p", { className: "dsmm-hint", children: t("sessionChooseWorkspace") }) : _jsxs(_Fragment, { children: [labels !== null && _jsx("p", { "data-dsmm-session-state": true, children: labels.admitted }), labels !== null && !compact && _jsx("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }), session === null && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: t("sessionUnavailable") }), session?.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("admissionWarnings") }), _jsx(ProfileWarnings, { warnings: session.warnings, t: t })] }) : null, session !== null && !allowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: capabilityReason(session.applyOverlayUnavailableReason, t) }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onChange: (event) => { if (current())
51
- actions.chooseSessionProfile(event.currentTarget.value || null); }, children: [_jsx("option", { value: "", children: t("sessionBaseline") }), state.sessionChoice !== null && selected === undefined && _jsx("option", { value: state.sessionChoice, children: state.sessionChoice }), state.snapshot?.profiles.map((profile) => _jsxs("option", { value: profile.id, disabled: !isConfigRevision(profile.revision) || profile.error !== undefined, children: [profile.label?.trim() || profile.id, profileWarnings(profile.warnings).length ? ` — ${t("warningProfile")}` : ""] }, profile.id))] })] }), !compact && _jsxs(_Fragment, { children: [_jsx("p", { className: "dsmm-hint", children: t("sessionModelHint") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !modelAllowed, "aria-describedby": !modelAllowed ? `${prefix}-model-reason` : undefined, onClick: () => { if (current())
52
- void actions.useSessionProfileModel(); }, children: t("headerUseCurrentModel") }), !modelAllowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-model-reason`, children: capabilityReason(session?.selectModelUnavailableReason, t) }), session !== null && _jsxs("details", { children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: binding === undefined ? t("bindingUnknown") : t("bindingState", { binding: binding.binding, ready: t(binding.deliveryFenceReady ? "enabled" : "disabled"), restart: t(binding.restartRequired ? "enabled" : "disabled") }) }), binding?.reason !== undefined && _jsx("p", { children: t("bindingReason", { reason: binding.reason }) })] }), session.roles !== undefined && _jsxs("details", { children: [_jsx("summary", { children: t("admittedRoles") }), session.roles.map(role => _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: role.id }), _jsx(RoleAvailability, { value: role, t: t })] }, role.id))] }), session.rolePolicy !== undefined && _jsx("p", { "data-dsmm-session-policy": true, children: t("roleState", { route: session.rolePolicy.route === undefined ? t("inheritRoute") : `${session.rolePolicy.route.provider}/${session.rolePolicy.route.model}${session.rolePolicy.route.reasoningEffort === undefined ? "" : ` (${session.rolePolicy.route.reasoningEffort})`}`, strategy: session.rolePolicy.strategy, retries: session.rolePolicy.retries, failures: session.rolePolicy.rateLimitFailures, switches: session.rolePolicy.switches, delay: session.rolePolicy.totalDelayMs }) })] })] }), state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), (session?.refreshRequired || session?.selection.refreshRequired) && _jsx("p", { role: "status", children: t("sessionCommittedRefresh") }), state.sessionUnconfirmed && _jsx("p", { role: "status", children: t("sessionUnconfirmedRefresh") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed || (state.sessionChoice !== null && !isConfigRevision(selected?.revision)), "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onClick: () => { if (current())
57
+ return _jsxs("div", { className: "dsmm-session-scope", "aria-busy": state.sessionBusy !== null, "data-dsmm-session-scope": true, children: [!compact && _jsx("h3", { children: t("sessionScope") }), state.currentSessionId === null ? _jsx("p", { className: "dsmm-hint", children: t("sessionChooseWorkspace") }) : _jsxs(_Fragment, { children: [labels !== null && _jsx("p", { "data-dsmm-session-state": true, children: labels.admitted }), labels !== null && !compact && _jsx("p", { className: "dsmm-hint", "data-dsmm-session-future-default": true, children: labels.futureDefault }), session === null && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: t("sessionUnavailable") }), session !== null && !allowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-overlay-reason`, children: capabilityReason(session.applyOverlayUnavailableReason, t) }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }), _jsxs("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onChange: (event) => { if (current())
58
+ actions.chooseSessionProfile(event.currentTarget.value || null); }, children: [_jsx("option", { value: "", children: t("sessionBaseline") }), state.sessionChoice !== null && selected === undefined && _jsx("option", { value: state.sessionChoice, children: state.sessionChoice }), state.snapshot?.profiles.map((profile) => _jsxs("option", { value: profile.id, disabled: !isConfigRevision(profile.revision) || profile.error !== undefined, children: [profile.label?.trim() || profile.id, profileWarnings(profile.warnings).length ? ` — ${t("warningProfile")}` : ""] }, profile.id))] })] }), !compact && _jsxs(_Fragment, { children: [_jsx("p", { className: "dsmm-hint", id: `${prefix}-model-hint`, children: t("useSessionProfileModelDesc") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !modelAllowed, "aria-describedby": `${prefix}-model-hint${!modelAllowed ? ` ${prefix}-model-reason` : ""}`, onClick: () => { if (current())
59
+ void actions.useSessionProfileModel(); }, children: t("headerUseCurrentModel") }), !modelAllowed && _jsx("p", { className: "dsmm-hint", id: `${prefix}-model-reason`, children: capabilityReason(session?.selectModelUnavailableReason, t) }), session !== null && _jsxs("details", { children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: binding === undefined ? t("bindingUnknown") : t("bindingState", { binding: binding.binding, ready: t(binding.deliveryFenceReady ? "enabled" : "disabled"), restart: t(binding.restartRequired ? "enabled" : "disabled") }) }), binding?.reason !== undefined && _jsx("p", { children: t("bindingReason", { reason: binding.reason }) })] }), session.roles !== undefined && _jsxs("details", { children: [_jsx("summary", { children: t("admittedRoles") }), session.roles.map(role => _jsxs("div", { className: "dsmm-availability", children: [_jsx("p", { children: role.id }), _jsx(RoleAvailability, { value: role, t: t })] }, role.id))] }), session.rolePolicy !== undefined && _jsx("p", { "data-dsmm-session-policy": true, children: t("roleState", { route: session.rolePolicy.route === undefined ? t("inheritRoute") : `${session.rolePolicy.route.provider}/${session.rolePolicy.route.model}${session.rolePolicy.route.reasoningEffort === undefined ? "" : ` (${session.rolePolicy.route.reasoningEffort})`}`, strategy: session.rolePolicy.strategy, retries: session.rolePolicy.retries, failures: session.rolePolicy.rateLimitFailures, switches: session.rolePolicy.switches, delay: session.rolePolicy.totalDelayMs }) })] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed || (state.sessionChoice !== null && !isConfigRevision(selected?.revision)), "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onClick: () => { if (current())
53
60
  void actions.applySession(); }, children: t(state.sessionBusy === "apply" ? "sessionApplying" : "sessionApply") }), !compact && _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : undefined, onClick: () => { if (current())
54
61
  void actions.resetSession(); }, children: t(state.sessionBusy === "reset" ? "sessionResetting" : "sessionReset") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.sessionBusy !== null || state.busy !== null || state.pendingEditor !== null, onClick: () => { if (current())
55
- void actions.refreshSession(); }, children: t("sessionRefresh") })] })] }), state.sessionIssue !== null && _jsx("p", { role: "alert", children: state.sessionIssue.source === "profile-model" ? t(state.sessionIssue.code === "model-unconfigured" ? "headerNoProfileModel" : state.sessionIssue.code === "model-choice-changed" ? "headerModelChoiceChanged" : "headerModelUnconfirmed")
56
- : state.sessionIssue.code === "conflict" ? t("sessionConflict")
57
- : ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code })
58
- : t(state.sessionIssue.code === "validation" ? "validation" : "sessionUnavailable") }), state.sessionIssue !== null && _jsx(IssueDetails, { issue: state.sessionIssue, t: t }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.sessionBusy === "read" ? t("reading") : status })] });
62
+ void actions.refreshSession(); }, children: t("sessionRefresh") })] })] }), showFeedback && _jsx(SessionScopeFeedback, { state: state, t: t })] });
59
63
  }
60
64
  /** Root-scoped native menu; an explicitly scoped foreign occurrence still refuses. */
61
65
  export function SessionProfiles(props) {
@@ -1,6 +1,66 @@
1
+ import type { Ref } from "react";
1
2
  import type { PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
3
+ import type { ModelCatalog } from "@deepseek-ai/dsh-api-session-controller";
4
+ import type { DsmmInvocationLevel, DsmmLevelOverride, DsmmModelRoute } from "../settings.js";
5
+ import type { DsmmRateLimitPolicy, DsmmRuntimePolicyConfig, DsmmRuntimePolicySettings } from "../routing-policy.js";
2
6
  import type { ProfilesActions, ProfilesViewSnapshot } from "./controller.js";
7
+ import type { JsonPath, StructuredDocument } from "./structured.js";
3
8
  type Locale = PropsLocale<"settings.dsmm-profiles">;
9
+ type Edit = ProfilesActions["editPath"];
10
+ export declare function RetryNumber({ id, name, field, value, inherited, path, disabled, actions, t }: Locale & {
11
+ id: string;
12
+ name: string;
13
+ field: keyof DsmmRateLimitPolicy;
14
+ value: number | undefined;
15
+ inherited: number | undefined;
16
+ path: JsonPath;
17
+ disabled: boolean;
18
+ actions: ProfilesActions;
19
+ }): import("react").JSX.Element;
20
+ export declare function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t, naturalLabels }: Locale & {
21
+ value: DsmmModelRoute;
22
+ path: JsonPath;
23
+ name?: string;
24
+ catalog: ModelCatalog | null;
25
+ disabled: boolean;
26
+ edit: Edit;
27
+ editRoute: ProfilesActions["editRoute"];
28
+ naturalLabels?: boolean;
29
+ }): import("react").JSX.Element;
30
+ export declare function PolicyFields({ value, inherited, path, name, disabled, actions, t }: Locale & {
31
+ value: DsmmRuntimePolicyConfig;
32
+ inherited: DsmmRuntimePolicySettings | undefined;
33
+ path: JsonPath;
34
+ name: string;
35
+ disabled: boolean;
36
+ actions: ProfilesActions;
37
+ }): import("react").JSX.Element;
38
+ export declare function LevelFields({ level, value, path, catalog, disabled, actions, t }: Locale & {
39
+ level: Exclude<DsmmInvocationLevel, "normal">;
40
+ value?: DsmmLevelOverride;
41
+ path: JsonPath;
42
+ catalog: ModelCatalog | null;
43
+ disabled: boolean;
44
+ actions: ProfilesActions;
45
+ }): import("react").JSX.Element;
46
+ export type BasicSettingsProps = Locale & {
47
+ state: ProfilesViewSnapshot;
48
+ actions: ProfilesActions;
49
+ disabled: boolean;
50
+ inputRef?: Ref<HTMLInputElement>;
51
+ idInvalid?: boolean;
52
+ orchestratorRef?: Ref<HTMLDivElement>;
53
+ onJumpToJsonc?: () => void;
54
+ };
55
+ export declare function BasicSettings({ state, actions, disabled, inputRef, idInvalid, orchestratorRef, onJumpToJsonc, t }: BasicSettingsProps): import("react").JSX.Element | null;
56
+ export type AdvancedSettingsProps = Locale & {
57
+ state: ProfilesViewSnapshot;
58
+ actions: ProfilesActions;
59
+ disabled: boolean;
60
+ document?: StructuredDocument | null;
61
+ isInvalidProjection?: boolean;
62
+ };
63
+ export declare function AdvancedSettings({ state, actions, disabled, document: propDoc, isInvalidProjection: propInvalid, t }: AdvancedSettingsProps): import("react").JSX.Element | null;
4
64
  /** The same raw draft drives every control; there is no form-to-document rewrite. */
5
65
  export declare function StructuredEditor({ state, actions, disabled, t }: Locale & {
6
66
  state: ProfilesViewSnapshot;
@@ -1,30 +1,49 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useState } from "react";
3
3
  import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
4
4
  import { DSMM_LOCALES } from "../profile-locale.js";
5
- import { DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimitPolicy } from "../routing-policy.js";
5
+ import { DSMM_RATE_LIMIT_BOUNDS } from "../routing-policy.js";
6
6
  import { structuredDocument } from "./structured.js";
7
7
  import { RETRY_FIELD_LABEL_KEYS } from "./locales.js";
8
- import { RoleAvailability, roleAvailability } from "./RoleAvailability.js";
9
8
  import { EditableChoice } from "./EditableChoice.js";
10
- function RetryNumber({ id, name, field, value, inherited, path, disabled, actions, t }) {
11
- const [draft, setDraft] = useState(value === undefined ? "" : String(value));
12
- const [invalid, setInvalid] = useState(false);
13
- const [min, max] = DSMM_RATE_LIMIT_BOUNDS[field];
9
+ export function RetryNumber({ id, name, field, value, inherited, path, disabled, actions, t }) {
14
10
  const key = path.join(".");
15
- useEffect(() => { setDraft(value === undefined ? "" : String(value)); setInvalid(false); }, [value]);
16
- useEffect(() => { actions.setFieldInvalid(key, invalid); return () => actions.setFieldInvalid(key, false); }, [actions.setFieldInvalid, key, invalid]);
17
- return _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: id, children: t("retryField", { name, field: t(RETRY_FIELD_LABEL_KEYS[field]) }) }), _jsx(Input, { id: id, "data-dsmm-policy-field": field, className: "dsmm-input", type: "number", inputMode: "numeric", min: min, max: max, step: 1, disabled: disabled, value: draft, placeholder: inherited === undefined ? t("unknownDefault") : t("inheritNumber", { value: inherited }), "aria-invalid": invalid || undefined, "aria-describedby": `${id}-hint${invalid ? ` ${id}-invalid` : ""}`, onChange: (event) => {
11
+ const stored = actions.getNumberDraft?.(key);
12
+ const sourceChanged = stored !== undefined && value !== stored.sourceValue;
13
+ const [draft, setDraft] = useState(stored && !sourceChanged ? stored.draft : (value === undefined ? "" : String(value)));
14
+ const [invalid, setInvalid] = useState(stored && !sourceChanged ? stored.invalid : false);
15
+ const [min, max] = DSMM_RATE_LIMIT_BOUNDS[field];
16
+ useEffect(() => {
17
+ const currentStored = actions.getNumberDraft?.(key);
18
+ if (currentStored && value !== currentStored.sourceValue) {
19
+ setDraft(value === undefined ? "" : String(value));
20
+ setInvalid(false);
21
+ }
22
+ else if (!currentStored) {
23
+ setDraft(value === undefined ? "" : String(value));
24
+ setInvalid(false);
25
+ }
26
+ }, [value, key, actions]);
27
+ const displayDraft = sourceChanged ? (value === undefined ? "" : String(value)) : draft;
28
+ const isInvalid = sourceChanged ? false : invalid;
29
+ return _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: id, children: t("retryField", { name, field: t(RETRY_FIELD_LABEL_KEYS[field]) }) }), _jsx(Input, { id: id, "data-dsmm-policy-field": field, className: "dsmm-input", type: "number", inputMode: "numeric", min: min, max: max, step: 1, disabled: disabled, value: displayDraft, placeholder: inherited === undefined ? t("unknownDefault") : t("inheritNumber", { value: inherited }), "aria-invalid": isInvalid || undefined, "aria-describedby": `${id}-hint${isInvalid ? ` ${id}-invalid` : ""}`, onChange: (event) => {
18
30
  const input = event.currentTarget;
19
- setDraft(input.value);
20
- const valid = input.validity.valid && (input.value === "" || Number.isSafeInteger(input.valueAsNumber));
31
+ const valStr = input.value;
32
+ const valid = input.validity.valid && (valStr === "" || Number.isSafeInteger(input.valueAsNumber));
33
+ setDraft(valStr);
21
34
  setInvalid(!valid);
22
- actions.setFieldInvalid(key, !valid);
23
- if (valid)
24
- actions.editPath(path, input.value === "" ? undefined : input.valueAsNumber);
25
- } }), _jsx("p", { className: "dsmm-hint", id: `${id}-hint`, children: t("retryBounds", { min, max, value: inherited ?? t("unknownDefault") }) }), invalid && _jsx("p", { id: `${id}-invalid`, children: t("invalidNumber") })] });
35
+ if (!valid) {
36
+ actions.setNumberDraft?.(key, { draft: valStr, invalid: true, sourceValue: value });
37
+ actions.setFieldInvalid(key, true);
38
+ }
39
+ else {
40
+ actions.setNumberDraft?.(key, null);
41
+ actions.setFieldInvalid(key, false);
42
+ actions.editPath(path, valStr === "" ? undefined : input.valueAsNumber);
43
+ }
44
+ } }), _jsx("p", { className: "dsmm-hint", id: `${id}-hint`, children: t("retryBounds", { min, max, value: inherited ?? t("unknownDefault") }) }), isInvalid && _jsx("p", { id: `${id}-invalid`, children: t("invalidNumber") })] });
26
45
  }
27
- function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t }) {
46
+ export function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t, naturalLabels }) {
28
47
  const prefix = useId();
29
48
  const providers = catalog?.groups ?? [];
30
49
  const group = providers.find((candidate) => candidate.id === value.provider);
@@ -35,48 +54,53 @@ function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t
35
54
  // route's adapter-owned effort; do not save or touch the native model default.
36
55
  editRoute(path, provider, modelId);
37
56
  };
38
- return _jsxs("div", { className: "dsmm-route-fields", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-provider`, children: t("routeProvider", { name }) }), _jsx(EditableChoice, { id: `${prefix}-provider`, label: t("routeProvider", { name }), value: value.provider, options: providers, disabled: disabled, onChange: provider => updateModel(provider, value.model), onSelect: provider => updateModel(provider, "") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-model`, children: t("routeModel", { name }) }), _jsx(EditableChoice, { id: `${prefix}-model`, label: t("routeModel", { name }), value: value.model, options: group?.models ?? [], disabled: disabled, onChange: modelId => updateModel(value.provider, modelId) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-effort`, children: t("routeEffort", { name }) }), _jsx(EditableChoice, { id: `${prefix}-effort`, label: t("routeEffort", { name }), value: value.reasoningEffort ?? "", options: efforts, disabled: disabled, placeholder: t("effortDefault"), onChange: effort => edit([...path, "reasoningEffort"], effort || undefined) })] })] });
57
+ const providerLabel = naturalLabels ? t("naturalProvider") : t("routeProvider", { name: name ?? "" });
58
+ const modelLabel = naturalLabels ? t("naturalModel") : t("routeModel", { name: name ?? "" });
59
+ const effortLabel = naturalLabels ? t("naturalEffort") : t("routeEffort", { name: name ?? "" });
60
+ return _jsxs("div", { className: "dsmm-route-fields", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-provider`, children: providerLabel }), _jsx(EditableChoice, { id: `${prefix}-provider`, label: providerLabel, value: value.provider, options: providers, disabled: disabled, onChange: provider => updateModel(provider, value.model), onSelect: provider => updateModel(provider, "") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-model`, children: modelLabel }), _jsx(EditableChoice, { id: `${prefix}-model`, label: modelLabel, value: value.model, options: group?.models ?? [], disabled: disabled, onChange: modelId => updateModel(value.provider, modelId) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-effort`, children: effortLabel }), _jsx(EditableChoice, { id: `${prefix}-effort`, label: effortLabel, value: value.reasoningEffort ?? "", options: efforts, disabled: disabled, placeholder: t("effortDefault"), onChange: effort => edit([...path, "reasoningEffort"], effort || undefined) })] })] });
39
61
  }
40
- function PolicyFields({ value, inherited, path, name, disabled, actions, t }) {
62
+ export function PolicyFields({ value, inherited, path, name, disabled, actions, t }) {
41
63
  const prefix = useId();
42
- return _jsxs("div", { className: "dsmm-policy-fields", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-strategy`, children: t("strategy", { name }) }), _jsxs("select", { id: `${prefix}-strategy`, disabled: disabled, value: value.strategy ?? "", onChange: (event) => actions.editPath([...path, "strategy"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inheritStrategy", { value: inherited?.strategy ?? t("unknownDefault") }) }), _jsx("option", { value: "startup-lock", children: t("startupLock") }), _jsx("option", { value: "rate-limit-fallback", children: t("rateFallback") })] })] }), _jsx("p", { className: "dsmm-hint", children: t("strategyHint") }), _jsx("div", { className: "dsmm-route-fields", children: Object.keys(DSMM_RATE_LIMIT_BOUNDS).map((field) => _jsx(RetryNumber, { id: `${prefix}-${field}`, t: t, name: name, field: field, value: value.rateLimit?.[field], inherited: inherited?.rateLimit[field], path: [...path, "rateLimit", field], disabled: disabled, actions: actions }, field)) })] });
64
+ return _jsxs("div", { className: "dsmm-policy-fields", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-strategy`, children: t("strategy", { name }) }), _jsxs("select", { id: `${prefix}-strategy`, disabled: disabled, value: value.strategy ?? "", onChange: (event) => actions.editPath([...path, "strategy"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inheritStrategy", { value: inherited?.strategy ?? t("unknownDefault") }) }), _jsx("option", { value: "startup-lock", children: t("startupLock") }), _jsx("option", { value: "rate-limit-fallback", children: t("rateFallback") })] })] }), _jsx("p", { className: "dsmm-hint", children: t("strategyHint") }), _jsx("div", { className: "dsmm-route-fields", children: Object.keys(DSMM_RATE_LIMIT_BOUNDS).map((field) => (_jsx(RetryNumber, { id: `${prefix}-${field}`, t: t, name: name, field: field, value: value.rateLimit?.[field], inherited: inherited?.rateLimit[field], path: [...path, "rateLimit", field], disabled: disabled, actions: actions }, field))) })] });
43
65
  }
44
- function LevelFields({ level, value, path, catalog, disabled, actions, t }) {
66
+ export function LevelFields({ level, value, path, catalog, disabled, actions, t }) {
45
67
  const prefix = useId();
46
68
  const mode = value === undefined ? "inherit" : value.provider === undefined ? "effort" : "route";
47
69
  return _jsxs("fieldset", { "data-dsmm-level": level, children: [_jsx("legend", { children: t("levelName", { level }) }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-mode`, children: t("levelMode", { level }) }), _jsxs("select", { id: `${prefix}-mode`, value: mode, disabled: disabled, onChange: event => actions.editPath(path, event.currentTarget.value === "inherit" ? undefined : event.currentTarget.value === "effort" ? { reasoningEffort: "" } : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("levelUnconfigured") }), _jsx("option", { value: "effort", children: t("levelEffortOnly") }), _jsx("option", { value: "route", children: t("levelFullRoute") })] })] }), mode === "effort" && _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-effort`, children: t("routeEffort", { name: level }) }), _jsx(EditableChoice, { id: `${prefix}-effort`, label: t("routeEffort", { name: level }), value: value?.reasoningEffort ?? "", options: [], disabled: disabled, onChange: effort => actions.editPath([...path, "reasoningEffort"], effort) })] }), value?.provider !== undefined && _jsx(RouteFields, { value: value, path: path, name: t("levelName", { level }), catalog: catalog, disabled: disabled, edit: actions.editPath, editRoute: actions.editRoute, t: t })] });
48
70
  }
49
- /** The same raw draft drives every control; there is no form-to-document rewrite. */
50
- export function StructuredEditor({ state, actions, disabled, t }) {
71
+ export function BasicSettings({ state, actions, disabled, inputRef, idInvalid, orchestratorRef, onJumpToJsonc, t }) {
72
+ const prefix = useId();
73
+ const editor = state.editor;
74
+ if (editor === null)
75
+ return null;
76
+ const document = structuredDocument(editor.content);
77
+ if (document === null) {
78
+ return _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") })] });
79
+ }
80
+ const orchPolicy = document.roleRouting["dsmm-orchestrator"] ?? {};
81
+ const orchPath = ["settings", "roleRouting", "dsmm-orchestrator"];
82
+ return _jsxs("div", { className: "dsmm-basic-settings", "data-dsmm-basic-settings": true, children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-label`, children: t("profileLabel") }), _jsx(Input, { id: `${prefix}-label`, className: "dsmm-input", value: document.label ?? "", disabled: disabled, onChange: (event) => actions.editPath(["label"], event.currentTarget.value) }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || document.label === undefined, onClick: () => actions.editPath(["label"], undefined), children: t("omitLabel") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-id`, children: t("profileId") }), _jsx(Input, { ref: inputRef, id: `${prefix}-id`, className: "dsmm-input", value: editor.id, disabled: disabled || editor.revision !== null, "aria-invalid": idInvalid || undefined, "aria-describedby": `${prefix}-id-hint${idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => actions.editId(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })] }), _jsxs("div", { ref: orchestratorRef, className: "dsmm-field", id: `${prefix}-orchestrator-primary`, children: [_jsx("label", { htmlFor: `${prefix}-orch-mode`, children: t("orchestratorModel") }), _jsx("p", { className: "dsmm-hint", children: t("orchestratorModelDesc") }), _jsxs("select", { id: `${prefix}-orch-mode`, disabled: disabled, value: orchPolicy.primary === undefined ? "inherit" : "explicit", onChange: (event) => actions.editPath([...orchPath, "primary"], event.currentTarget.value === "inherit" ? undefined : { provider: "", model: "" }), children: [_jsx("option", { value: "inherit", children: t("inheritRoute") }), _jsx("option", { value: "explicit", children: t("configuredRoute") })] }), orchPolicy.primary !== undefined && _jsx(RouteFields, { t: t, value: orchPolicy.primary, path: [...orchPath, "primary"], naturalLabels: true, catalog: state.catalog, disabled: disabled, edit: actions.editPath, editRoute: actions.editRoute }), _jsx("p", { className: "dsmm-hint", children: t("effortChangeHint") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-locale`, children: t("businessLocale") }), _jsxs("select", { id: `${prefix}-locale`, value: String(document.settings.locale ?? ""), disabled: disabled, "aria-describedby": `${prefix}-locale-hint`, onChange: event => actions.editPath(["settings", "locale"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inheritLocale") }), typeof document.settings.locale === "string" && !DSMM_LOCALES.includes(document.settings.locale) && _jsx("option", { value: document.settings.locale, children: t("unsupportedLocale") }), DSMM_LOCALES.map(locale => _jsx("option", { value: locale, children: locale }, locale))] }), _jsx("p", { id: `${prefix}-locale-hint`, className: "dsmm-hint", children: t("localeHint") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-active`, children: t("defaultActive") }), _jsxs("select", { id: `${prefix}-active`, disabled: disabled, value: document.settings.defaultActive === undefined ? "" : String(document.settings.defaultActive), onChange: (event) => actions.editPath(["settings", "defaultActive"], event.currentTarget.value === "" ? undefined : event.currentTarget.value === "true"), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "true", children: t("enabled") }), _jsx("option", { value: "false", children: t("disabled") })] }), _jsx("p", { className: "dsmm-hint", children: t("activeHint") })] })] });
83
+ }
84
+ export function AdvancedSettings({ state, actions, disabled, document: propDoc, isInvalidProjection: propInvalid, t }) {
51
85
  const prefix = useId();
52
- const [selectedRole, setSelectedRole] = useState("dsmm-orchestrator");
53
- const document = state.editor === null ? null : structuredDocument(state.editor.content);
54
- if (document === null)
86
+ const editor = state.editor;
87
+ if (editor === null)
88
+ return null;
89
+ const rawDoc = propDoc !== undefined ? propDoc : structuredDocument(editor.content);
90
+ const isInvalidProjection = propInvalid !== undefined ? propInvalid : (rawDoc === null);
91
+ if (rawDoc === null)
55
92
  return _jsx("p", { className: "dsmm-hint", "data-dsmm-structured-invalid": true, children: t("rawInvalid") });
56
- const roles = state.snapshot?.roles ?? [];
57
- const role = roles.find((candidate) => candidate.id === selectedRole) ?? roles[0];
58
- const policy = role === undefined ? undefined : document.roleRouting[role.id] ?? {};
93
+ const document = rawDoc;
94
+ const effectiveDisabled = disabled || isInvalidProjection;
59
95
  const baseline = state.snapshot?.editorDefaults;
60
- let inherited;
61
- try {
62
- if (baseline !== undefined) {
63
- const profileDefaults = { strategy: document.runtimePolicy.strategy ?? baseline.strategy, rateLimit: normalizeRateLimitPolicy(document.runtimePolicy.rateLimit, baseline.rateLimit) };
64
- inherited = { strategy: role?.runtimePolicy?.strategy ?? profileDefaults.strategy, rateLimit: normalizeRateLimitPolicy(role?.runtimePolicy?.rateLimit, profileDefaults.rateLimit) };
65
- }
66
- }
67
- catch { /* Invalid effective values remain a raw/Host validation error. */ }
68
- const rolePath = ["settings", "roleRouting", role?.id ?? ""];
69
- const availability = roleAvailability(role?.availability);
70
- const namedRoles = document.settings.roles;
71
96
  const topology = document.settings.subagents?.toolTopology;
72
- return _jsxs("div", { className: "dsmm-structured", "data-dsmm-structured": true, children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-label`, children: t("profileLabel") }), _jsx(Input, { id: `${prefix}-label`, className: "dsmm-input", value: document.label ?? "", disabled: disabled, onChange: (event) => actions.editPath(["label"], event.currentTarget.value) }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || document.label === undefined, onClick: () => actions.editPath(["label"], undefined), children: t("omitLabel") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-locale`, children: t("businessLocale") }), _jsxs("select", { id: `${prefix}-locale`, value: String(document.settings.locale ?? ""), disabled: disabled, "aria-describedby": `${prefix}-locale-hint`, onChange: event => actions.editPath(["settings", "locale"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inheritLocale") }), typeof document.settings.locale === "string" && !DSMM_LOCALES.includes(document.settings.locale) && _jsx("option", { value: document.settings.locale, children: t("unsupportedLocale") }), DSMM_LOCALES.map(locale => _jsx("option", { value: locale, children: locale }, locale))] }), _jsx("p", { id: `${prefix}-locale-hint`, className: "dsmm-hint", children: t("localeHint") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-topology`, children: t("toolTopology") }), _jsxs("select", { id: `${prefix}-topology`, value: topology ?? "", disabled: disabled, "aria-describedby": `${prefix}-topology-hint`, onChange: event => actions.editPath(["settings", "subagents", "toolTopology"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "per-role", children: "per-role" }), _jsx("option", { value: "parameterized", children: "parameterized" })] }), _jsx("p", { id: `${prefix}-topology-hint`, className: "dsmm-hint", children: t("topologyHint") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-active`, children: t("defaultActive") }), _jsxs("select", { id: `${prefix}-active`, disabled: disabled, value: document.settings.defaultActive === undefined ? "" : String(document.settings.defaultActive), onChange: (event) => actions.editPath(["settings", "defaultActive"], event.currentTarget.value === "" ? undefined : event.currentTarget.value === "true"), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "true", children: t("enabled") }), _jsx("option", { value: "false", children: t("disabled") })] }), _jsx("p", { className: "dsmm-hint", children: t("activeHint") })] }), _jsxs("fieldset", { children: [_jsx("legend", { children: t("profileDefaults") }), _jsx(PolicyFields, { t: t, value: document.runtimePolicy, inherited: baseline, path: ["settings", "runtimePolicy"], name: t("profileDefaults"), disabled: disabled, actions: actions })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-role`, children: t("roleSelect") }), _jsxs("select", { id: `${prefix}-role`, disabled: disabled || roles.length === 0 || state.invalidFields.length > 0, value: role?.id ?? "", onChange: (event) => setSelectedRole(event.currentTarget.value), children: [roles.length === 0 && _jsx("option", { value: "", children: t("rolesUnavailable") }), roles.map((candidate) => _jsxs("option", { value: candidate.id, children: [candidate.label, candidate.enabled ? "" : ` — ${t("roleDisabled")}`] }, candidate.id))] })] }), role !== undefined && policy !== undefined && _jsxs("fieldset", { "data-dsmm-role": role.id, children: [_jsx("legend", { children: role.label }), _jsx(RoleAvailability, { value: role.availability, t: t }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-role-enabled`, children: t("namedRole", { name: role.label }) }), _jsxs("select", { id: `${prefix}-role-enabled`, value: namedRoles?.[role.id] === undefined ? "" : String(namedRoles[role.id]), disabled: disabled, "aria-describedby": `${prefix}-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 || !availability.startupAvailable || !availability.deploymentEnabled || availability.reason === "module-off", children: t("enabled") }), _jsx("option", { value: "false", disabled: availability === undefined || availability.required, children: t("disabled") })] }), _jsx("p", { id: `${prefix}-role-hint`, className: "dsmm-hint", children: t("namedRoleHint") })] }), _jsx(PolicyFields, { t: t, value: policy, inherited: inherited, path: rolePath, name: role.label, disabled: disabled, actions: actions }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-primary-mode`, children: t("primaryMode", { name: role.label }) }), _jsxs("select", { id: `${prefix}-primary-mode`, disabled: disabled, 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: disabled, edit: actions.editPath, editRoute: actions.editRoute }), _jsx("p", { className: "dsmm-hint", children: t("effortChangeHint") }), _jsx("p", { className: "dsmm-hint", children: t("normalLevel") }), role.id === "dsmm-orchestrator" ? _jsx("p", { className: "dsmm-hint", children: t("orchestratorLevels") }) : _jsxs(_Fragment, { 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: disabled, actions: actions, t: t }, level))] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-fallback-mode`, children: t("fallbackMode", { name: role.label }) }), _jsxs("select", { id: `${prefix}-fallback-mode`, disabled: disabled, 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) => {
73
- const name = t("fallbackName", { name: role.label, index: index + 1 });
74
- return _jsxs("fieldset", { children: [_jsx("legend", { children: name }), _jsx(RouteFields, { t: t, value: candidate, path: [...rolePath, "fallbackRoutes", index], name: name, catalog: state.catalog, disabled: disabled, edit: actions.editPath, editRoute: actions.editRoute }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || index === 0, onClick: () => actions.moveFallback(role.id, index, index - 1), children: t("moveUp", { name }) }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || index === policy.fallbackRoutes.length - 1, onClick: () => actions.moveFallback(role.id, index, index + 1), children: t("moveDown", { name }) }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => actions.editPath([...rolePath, "fallbackRoutes", index], undefined), children: t("removeFallback", { name }) })] })] }, index);
75
- }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || (policy.fallbackRoutes?.length ?? 0) >= 32, onClick: () => {
76
- if (policy.fallbackRoutes === undefined)
77
- actions.editPath([...rolePath, "fallbackRoutes"], [{ provider: "", model: "" }]);
78
- else
79
- actions.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
80
- }, children: t("addFallback", { name: role.label }) })] }, role.id)] });
97
+ const gitGuard = document.guards?.gitWriteGuard;
98
+ const gitScope = document.guards?.gitWriteScope;
99
+ const isGuardOff = gitGuard === "off";
100
+ return _jsxs("div", { className: "dsmm-structured", "data-dsmm-structured": true, children: [isInvalidProjection && _jsx("p", { className: "dsmm-hint", "data-dsmm-structured-invalid": true, children: t("rawInvalid") }), _jsxs("fieldset", { children: [_jsx("legend", { children: t("profileDefaults") }), _jsx(PolicyFields, { t: t, value: document.runtimePolicy, inherited: baseline, path: ["settings", "runtimePolicy"], name: t("profileDefaults"), disabled: effectiveDisabled, actions: actions })] }), _jsxs("fieldset", { className: "dsmm-git-guard", children: [_jsx("legend", { children: t("gitWriteGuard") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-git-guard`, children: t("gitWriteGuard") }), _jsxs("select", { id: `${prefix}-git-guard`, disabled: effectiveDisabled, value: gitGuard ?? "", "aria-describedby": `${prefix}-git-guard-hint`, onChange: event => actions.editPath(["settings", "guards", "gitWriteGuard"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "ask", children: t("gitWriteAsk") }), _jsx("option", { value: "deny", children: t("gitWriteDeny") }), _jsx("option", { value: "off", children: t("gitWriteOff") })] }), _jsx("p", { id: `${prefix}-git-guard-hint`, className: "dsmm-hint", children: t("gitWriteGuardHint") })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-git-scope`, children: t("gitWriteScope") }), _jsxs("select", { id: `${prefix}-git-scope`, disabled: effectiveDisabled, value: gitScope ?? "", "aria-describedby": `${prefix}-git-scope-hint`, onChange: event => actions.editPath(["settings", "guards", "gitWriteScope"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "all-writes", disabled: isGuardOff, children: t("gitWriteAllWrites") }), _jsx("option", { value: "high-risk", disabled: isGuardOff, children: t("gitWriteHighRisk") })] }), isGuardOff && _jsx("p", { id: `${prefix}-git-scope-hint`, className: "dsmm-hint", children: t("gitWriteScopeDisabledHint") })] })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-topology`, children: t("toolTopology") }), _jsxs("select", { id: `${prefix}-topology`, value: topology ?? "", disabled: effectiveDisabled, "aria-describedby": `${prefix}-topology-hint`, onChange: event => actions.editPath(["settings", "subagents", "toolTopology"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("inherit") }), _jsx("option", { value: "per-role", children: t("topologyPerRole") }), _jsx("option", { value: "parameterized", children: t("topologyParameterized") })] }), _jsx("p", { id: `${prefix}-topology-hint`, className: "dsmm-hint", children: t("topologyHint") })] })] });
101
+ }
102
+ /** The same raw draft drives every control; there is no form-to-document rewrite. */
103
+ export function StructuredEditor({ state, actions, disabled, t }) {
104
+ return _jsxs("div", { className: "dsmm-structured", "data-dsmm-structured": true, children: [_jsx(BasicSettings, { state: state, actions: actions, disabled: disabled, t: t }), _jsx(AdvancedSettings, { state: state, actions: actions, disabled: disabled, t: t })] });
81
105
  }
82
106
  //# sourceMappingURL=StructuredEditor.js.map
@@ -66,6 +66,7 @@ export interface ProfilesActions {
66
66
  save(): Promise<void>;
67
67
  apply(): Promise<void>;
68
68
  reset(): Promise<void>;
69
+ discard(): void;
69
70
  discardAndOpen(): Promise<void>;
70
71
  cancelDiscard(): void;
71
72
  editPath(path: JsonPath, value: unknown): void;
@@ -79,6 +80,13 @@ export interface ProfilesActions {
79
80
  setDeepwork(active: boolean): Promise<void>;
80
81
  useSessionProfileModel(): Promise<void>;
81
82
  setFieldInvalid(field: string, invalid: boolean): void;
83
+ setNumberDraft(key: string, entry: NumberDraftState | null): void;
84
+ getNumberDraft(key: string): NumberDraftState | undefined;
85
+ }
86
+ export interface NumberDraftState {
87
+ draft: string;
88
+ invalid: boolean;
89
+ sourceValue: number | undefined;
82
90
  }
83
91
  export interface ModelCatalogRemote {
84
92
  modelCatalog(): Promise<RemoteResult<ModelCatalog>>;
@@ -131,6 +139,7 @@ export declare class ProfilesController {
131
139
  subscribe: (listener: () => void) => (() => void);
132
140
  };
133
141
  readonly actions: ProfilesActions;
142
+ private numberDrafts;
134
143
  constructor(remote: DsmmProfilesRemote);
135
144
  dispose(): void;
136
145
  bindConnection(source: ConnectionGenerationState | null): void;
@@ -157,6 +166,7 @@ export declare class ProfilesController {
157
166
  refresh(): Promise<void>;
158
167
  open(id: string): Promise<void>;
159
168
  reload(): Promise<void>;
169
+ discard(): void;
160
170
  private loadEditor;
161
171
  discardAndOpen(): Promise<void>;
162
172
  private editId;