@dsmm/dsmm 0.3.10 → 0.3.12

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 (99) hide show
  1. package/README.md +1 -1
  2. package/agent-presets/dsmm-builder/agent.cordis.yml +0 -4
  3. package/agent-presets/dsmm-clarifier/agent.cordis.yml +0 -4
  4. package/agent-presets/dsmm-code-search/agent.cordis.yml +0 -4
  5. package/agent-presets/dsmm-coding/agent.cordis.yml +0 -4
  6. package/agent-presets/dsmm-complex/agent.cordis.yml +0 -4
  7. package/agent-presets/dsmm-creative/agent.cordis.yml +0 -4
  8. package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +0 -4
  9. package/agent-presets/dsmm-deep/agent.cordis.yml +0 -4
  10. package/agent-presets/dsmm-doc-search/agent.cordis.yml +0 -4
  11. package/agent-presets/dsmm-documenting/agent.cordis.yml +0 -4
  12. package/agent-presets/dsmm-frontend/agent.cordis.yml +0 -4
  13. package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +0 -4
  14. package/agent-presets/dsmm-media-reader/agent.cordis.yml +0 -4
  15. package/agent-presets/dsmm-normal-task/agent.cordis.yml +0 -4
  16. package/agent-presets/dsmm-oracle/agent.cordis.yml +0 -4
  17. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +0 -4
  18. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +0 -4
  19. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +0 -4
  20. package/agent-presets/dsmm-planner/agent.cordis.yml +0 -4
  21. package/agent-presets/dsmm-quick/agent.cordis.yml +0 -4
  22. package/agent-presets/dsmm-research/agent.cordis.yml +0 -4
  23. package/agent-presets/dsmm-reviewer/agent.cordis.yml +0 -4
  24. package/docs/agent-presets.md +5 -5
  25. package/docs/compatibility.md +10 -4
  26. package/docs/deferred-native-approval-risk.md +11 -1
  27. package/docs/design.md +15 -5
  28. package/docs/lsp.md +1 -1
  29. package/docs/model-routing.md +6 -6
  30. package/docs/native-permissions.md +5 -1
  31. package/docs/profiles.md +36 -5
  32. package/docs/roadmap.md +3 -3
  33. package/docs/runtime-recovery.md +5 -5
  34. package/docs/safety-guards.md +23 -5
  35. package/docs/settings-status.md +3 -3
  36. package/lib/child-capture.d.ts +9 -0
  37. package/lib/child-capture.js +29 -2
  38. package/lib/client/ProfilesSection.js +65 -13
  39. package/lib/client/RoleToolView-data.d.ts +4 -4
  40. package/lib/client/RoleToolView-data.js +3 -1
  41. package/lib/client/RoleToolView-locales.d.ts +7 -4
  42. package/lib/client/RoleToolView-locales.js +10 -6
  43. package/lib/client/RoleToolView.js +20 -5
  44. package/lib/client/SessionProfiles.d.ts +5 -1
  45. package/lib/client/SessionProfiles.js +13 -9
  46. package/lib/client/StructuredEditor.d.ts +32 -0
  47. package/lib/client/StructuredEditor.js +75 -23
  48. package/lib/client/controller.d.ts +10 -0
  49. package/lib/client/controller.js +44 -14
  50. package/lib/client/deployment-locales.js +1 -0
  51. package/lib/client/locales.d.ts +36 -0
  52. package/lib/client/locales.js +47 -17
  53. package/lib/client/permission-locales.js +8 -8
  54. package/lib/client/session-labels.js +4 -1
  55. package/lib/client/structured.d.ts +4 -0
  56. package/lib/client/structured.js +16 -1
  57. package/lib/client/styles.d.ts +1 -1
  58. package/lib/client/styles.js +19 -1
  59. package/lib/client.js +772 -312
  60. package/lib/command-approval.d.ts +50 -0
  61. package/lib/command-approval.js +148 -0
  62. package/lib/core-permissions.d.ts +2 -1
  63. package/lib/core-permissions.js +6 -3
  64. package/lib/guards.d.ts +2 -1
  65. package/lib/guards.js +45 -8
  66. package/lib/host-llm.js +3 -3
  67. package/lib/index.d.ts +1 -1
  68. package/lib/index.js +5 -3
  69. package/lib/model-routing.d.ts +3 -2
  70. package/lib/model-routing.js +28 -7
  71. package/lib/native-admission.d.ts +2 -0
  72. package/lib/native-admission.js +106 -34
  73. package/lib/permission-control.d.ts +5 -2
  74. package/lib/permission-control.js +46 -24
  75. package/lib/permission-controller.d.ts +2 -0
  76. package/lib/permission-controller.js +13 -8
  77. package/lib/permission-native-command.d.ts +2 -0
  78. package/lib/permission-native-command.js +9 -4
  79. package/lib/permission-native-rules.d.ts +2 -2
  80. package/lib/permission-native-rules.js +12 -10
  81. package/lib/profile-diagnostics.js +1 -1
  82. package/lib/profile-runtime.d.ts +11 -0
  83. package/lib/profile-runtime.js +48 -13
  84. package/lib/profile-store.d.ts +4 -1
  85. package/lib/profile-store.js +37 -14
  86. package/lib/profiles.js +2 -1
  87. package/lib/prompt-content.js +2 -2
  88. package/lib/role-control-rpc.js +18 -5
  89. package/lib/role-llm-runtime.js +10 -1
  90. package/lib/role-policy.d.ts +4 -3
  91. package/lib/role-policy.js +6 -6
  92. package/lib/role-providers.js +1 -0
  93. package/lib/runtime-recovery.d.ts +2 -2
  94. package/lib/runtime-recovery.js +7 -4
  95. package/lib/settings.d.ts +2 -0
  96. package/lib/settings.js +10 -0
  97. package/lib/shell-command.d.ts +16 -0
  98. package/lib/shell-command.js +443 -119
  99. package/package.json +1 -1
@@ -1,18 +1,22 @@
1
1
  export const ROLE_TOOL_NS = "conversation.dsmm-role-tool";
2
2
  export const roleToolEn = {
3
- call: "Call", unknownTarget: "DSMM agent · target pending",
3
+ call: "Call", calling: "Calling", unknownTarget: "DSMM agent · target pending",
4
4
  requested: "Requested", actual: "Actual", role: "Role", category: "Category", unknown: "Unknown",
5
- preparing: "Preparing", running: "Running", result: "Tool returned · child completion not inferred",
6
- background: "Started / handed off · child completion not confirmed", error: "Tool error", stopped: "Interrupted",
5
+ actualUnknown: "Actual unknown",
6
+ preparing: "Preparing", running: "Calling", result: "Returned",
7
+ background: "Background", error: "Failed", stopped: "Interrupted",
8
+ technicalDetails: "Technical details",
7
9
  args: "Original arguments", preparingArgs: "Arguments received so far", output: "Complete result content", failure: "Error details", metadata: "Invocation metadata",
8
10
  inspect: "Inspect tool call", copy: "Copy", copied: "Copied", emptyArgs: "Arguments not available yet",
9
11
  unavailable: "Actual identity unavailable; requested identity only", level: "Level", route: "Reported route", routeSource: "Route source",
10
12
  };
11
13
  export const roleToolZh = {
12
- call: "调用", unknownTarget: "DSMM 代理 · 目标待确定",
14
+ call: "调用", calling: "正在调用", unknownTarget: "DSMM 代理 · 目标待确定",
13
15
  requested: "请求", actual: "实际", role: "角色", category: "类别", unknown: "未知",
14
- preparing: "准备中", running: "运行中", result: "工具已返回 · 不推断子任务完成",
15
- background: "已启动/移交 · 尚未确认子任务完成", error: "工具错误", stopped: "已中断",
16
+ actualUnknown: "实际未知",
17
+ preparing: "准备中", running: "调用中", result: "已返回",
18
+ background: "后台调用", error: "失败", stopped: "已中断",
19
+ technicalDetails: "技术详情",
16
20
  args: "原始参数", preparingArgs: "目前已收到的参数", output: "完整结果内容", failure: "错误详情", metadata: "调用元数据",
17
21
  inspect: "检查工具调用", copy: "复制", copied: "已复制", emptyArgs: "参数尚不可用",
18
22
  unavailable: "实际身份不可用,仅显示请求身份", level: "等级", route: "报告的路由", routeSource: "路由来源",
@@ -5,13 +5,21 @@ import { ROLE_TOOL_NS, roleToolEn, roleToolZh } from "./RoleToolView-locales.js"
5
5
  const styles = `
6
6
  .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
7
  .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}
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;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;overflow:hidden;text-overflow:ellipsis}
9
+ .dsmm-role-tool[data-expanded="true"] .dsmm-role-title{display:block;-webkit-line-clamp:unset;overflow:visible}
9
10
  .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}
11
+ .dsmm-role-tool .dsmm-role-body{display:flex;flex-direction:column;gap:8px;min-width:0;padding:8px 0}
11
12
  .dsmm-role-tool p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere}
12
13
  .dsmm-role-tool .dsmm-role-status{color:var(--dsw-alias-label-secondary)}
13
14
  .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}
15
+ .dsmm-role-tool .dsmm-role-identity{color:var(--dsw-alias-label-secondary);font-size:13px;line-height:20px}
16
+ .dsmm-role-tool .dsmm-role-task{color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px}
17
+ .dsmm-role-tool .dsmm-role-dim{color:var(--dsw-alias-label-tertiary)}
18
+ .dsmm-role-tool .dsmm-role-section-title{color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;margin-bottom:4px}
19
+ .dsmm-role-tool .dsmm-role-details{border-top:1px solid var(--dsw-alias-border-l2);padding-top:8px;margin-top:4px}
20
+ .dsmm-role-tool .dsmm-role-details summary{cursor:pointer;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:18px;user-select:none}
21
+ .dsmm-role-tool .dsmm-role-details-body{display:flex;flex-direction:column;gap:8px;margin-top:8px;padding-left:8px}
22
+ .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
23
  `;
16
24
  export function RoleToolView(props) {
17
25
  const { expanded, toggle } = props.useDisclosure();
@@ -23,10 +31,17 @@ export function RoleToolView(props) {
23
31
  const failed = result !== undefined && (result.isError || result.error != null);
24
32
  const actual = result === undefined ? undefined : actualRoleTool(props.toolName, result.meta, failed);
25
33
  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}`}`;
34
+ const action = props.phase === "preparing" ? t("calling") : t("call");
35
+ const targetLabel = target === undefined ? t("unknownTarget") : roleToolDisplay(target);
36
+ const rawDesc = requested.description?.trim();
37
+ const singleLineDesc = rawDesc ? rawDesc.replace(/\s+/gu, " ") : undefined;
38
+ const title = singleLineDesc ? `${action} ${targetLabel}: ${singleLineDesc}` : `${action} ${targetLabel}`;
27
39
  const state = result?.error?.code === "interrupted" ? "stopped" : failed ? "error" : result === undefined ? props.phase === "preparing" ? "preparing" : "running" : actual?.jobId !== undefined || actual?.mode === "continuable" ? "background" : "result";
28
40
  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") })] })] });
41
+ const roleDiffers = requested.target !== undefined && actual !== undefined && actual.role !== requested.target;
42
+ const levelDiffers = requested.level !== undefined && actual !== undefined && actual.level !== requested.level;
43
+ const showRequestedVsActual = roleDiffers || levelDiffers;
44
+ 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(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", { 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))] }), result?.content !== undefined && (result.error == null || result.content.length > 0) && _jsxs("div", { className: "dsmm-role-output", children: [_jsx("p", { className: "dsmm-role-section-title", children: t("output") }), code(JSON.stringify(result.content, null, 2))] }), _jsxs("details", { className: "dsmm-role-details", children: [_jsx("summary", { children: t("technicalDetails") }), _jsxs("div", { className: "dsmm-role-details-body", children: [_jsxs("p", { children: [props.toolName, " \u00B7 ", props.callId] }), actual?.routeSource !== undefined && _jsxs("p", { children: [t("routeSource"), ": ", actual.routeSource] }), _jsxs("div", { children: [_jsx("p", { className: "dsmm-role-section-title", children: t(props.phase === "preparing" ? "preparingArgs" : "args") }), raw === "" ? _jsx("p", { className: "dsmm-role-empty", children: t("emptyArgs") }) : code(raw)] }), result?.meta != null && _jsxs("div", { children: [_jsx("p", { className: "dsmm-role-section-title", 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") })] })] });
30
45
  }
31
46
  /** Called once by the parent client apply(ctx), alongside the other slot registrations. */
32
47
  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,38 @@
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 { DsmmModelRoute } from "../settings.js";
2
5
  import type { ProfilesActions, ProfilesViewSnapshot } from "./controller.js";
6
+ import type { JsonPath } from "./structured.js";
3
7
  type Locale = PropsLocale<"settings.dsmm-profiles">;
8
+ type Edit = ProfilesActions["editPath"];
9
+ export declare function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t, naturalLabels }: Locale & {
10
+ value: DsmmModelRoute;
11
+ path: JsonPath;
12
+ name?: string;
13
+ catalog: ModelCatalog | null;
14
+ disabled: boolean;
15
+ edit: Edit;
16
+ editRoute: ProfilesActions["editRoute"];
17
+ naturalLabels?: boolean;
18
+ }): import("react").JSX.Element;
19
+ export type BasicSettingsProps = Locale & {
20
+ state: ProfilesViewSnapshot;
21
+ actions: ProfilesActions;
22
+ disabled: boolean;
23
+ inputRef?: Ref<HTMLInputElement>;
24
+ idInvalid?: boolean;
25
+ orchestratorRef?: Ref<HTMLDivElement>;
26
+ onJumpToJsonc?: () => void;
27
+ };
28
+ export declare function BasicSettings({ state, actions, disabled, inputRef, idInvalid, orchestratorRef, onJumpToJsonc, t }: BasicSettingsProps): import("react").JSX.Element | null;
29
+ export type AdvancedSettingsProps = Locale & {
30
+ state: ProfilesViewSnapshot;
31
+ actions: ProfilesActions;
32
+ disabled: boolean;
33
+ onJumpToOrchestrator?: () => void;
34
+ };
35
+ export declare function AdvancedSettings({ state, actions, disabled, onJumpToOrchestrator, t }: AdvancedSettingsProps): import("react").JSX.Element | null;
4
36
  /** The same raw draft drives every control; there is no form-to-document rewrite. */
5
37
  export declare function StructuredEditor({ state, actions, disabled, t }: Locale & {
6
38
  state: ProfilesViewSnapshot;
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- import { useEffect, useId, useState } from "react";
2
+ import { useEffect, useId, useRef, 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
5
  import { DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimitPolicy } from "../routing-policy.js";
@@ -8,23 +8,43 @@ import { RETRY_FIELD_LABEL_KEYS } from "./locales.js";
8
8
  import { RoleAvailability, roleAvailability } from "./RoleAvailability.js";
9
9
  import { EditableChoice } from "./EditableChoice.js";
10
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];
14
11
  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) => {
12
+ const stored = actions.getNumberDraft?.(key);
13
+ const sourceChanged = stored !== undefined && value !== stored.sourceValue;
14
+ const [draft, setDraft] = useState(stored && !sourceChanged ? stored.draft : (value === undefined ? "" : String(value)));
15
+ const [invalid, setInvalid] = useState(stored && !sourceChanged ? stored.invalid : false);
16
+ const [min, max] = DSMM_RATE_LIMIT_BOUNDS[field];
17
+ useEffect(() => {
18
+ const currentStored = actions.getNumberDraft?.(key);
19
+ if (currentStored && value !== currentStored.sourceValue) {
20
+ setDraft(value === undefined ? "" : String(value));
21
+ setInvalid(false);
22
+ }
23
+ else if (!currentStored) {
24
+ setDraft(value === undefined ? "" : String(value));
25
+ setInvalid(false);
26
+ }
27
+ }, [value, key, actions]);
28
+ const displayDraft = sourceChanged ? (value === undefined ? "" : String(value)) : draft;
29
+ const isInvalid = sourceChanged ? false : invalid;
30
+ 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
31
  const input = event.currentTarget;
19
- setDraft(input.value);
20
- const valid = input.validity.valid && (input.value === "" || Number.isSafeInteger(input.valueAsNumber));
32
+ const valStr = input.value;
33
+ const valid = input.validity.valid && (valStr === "" || Number.isSafeInteger(input.valueAsNumber));
34
+ setDraft(valStr);
21
35
  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") })] });
36
+ if (!valid) {
37
+ actions.setNumberDraft?.(key, { draft: valStr, invalid: true, sourceValue: value });
38
+ actions.setFieldInvalid(key, true);
39
+ }
40
+ else {
41
+ actions.setNumberDraft?.(key, null);
42
+ actions.setFieldInvalid(key, false);
43
+ actions.editPath(path, valStr === "" ? undefined : input.valueAsNumber);
44
+ }
45
+ } }), _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
46
  }
27
- function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t }) {
47
+ export function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t, naturalLabels }) {
28
48
  const prefix = useId();
29
49
  const providers = catalog?.groups ?? [];
30
50
  const group = providers.find((candidate) => candidate.id === value.provider);
@@ -35,24 +55,49 @@ function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t
35
55
  // route's adapter-owned effort; do not save or touch the native model default.
36
56
  editRoute(path, provider, modelId);
37
57
  };
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) })] })] });
58
+ const providerLabel = naturalLabels ? t("naturalProvider") : t("routeProvider", { name: name ?? "" });
59
+ const modelLabel = naturalLabels ? t("naturalModel") : t("routeModel", { name: name ?? "" });
60
+ const effortLabel = naturalLabels ? t("naturalEffort") : t("routeEffort", { name: name ?? "" });
61
+ 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
62
  }
40
63
  function PolicyFields({ value, inherited, path, name, disabled, actions, t }) {
41
64
  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)) })] });
65
+ 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
66
  }
44
67
  function LevelFields({ level, value, path, catalog, disabled, actions, t }) {
45
68
  const prefix = useId();
46
69
  const mode = value === undefined ? "inherit" : value.provider === undefined ? "effort" : "route";
47
70
  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
71
  }
49
- /** The same raw draft drives every control; there is no form-to-document rewrite. */
50
- export function StructuredEditor({ state, actions, disabled, t }) {
72
+ export function BasicSettings({ state, actions, disabled, inputRef, idInvalid, orchestratorRef, onJumpToJsonc, t }) {
73
+ const prefix = useId();
74
+ const editor = state.editor;
75
+ if (editor === null)
76
+ return null;
77
+ const document = structuredDocument(editor.content);
78
+ if (document === null) {
79
+ 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") })] });
80
+ }
81
+ const orchPolicy = document.roleRouting["dsmm-orchestrator"] ?? {};
82
+ const orchPath = ["settings", "roleRouting", "dsmm-orchestrator"];
83
+ 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") })] })] });
84
+ }
85
+ export function AdvancedSettings({ state, actions, disabled, onJumpToOrchestrator, t }) {
51
86
  const prefix = useId();
52
87
  const [selectedRole, setSelectedRole] = useState("dsmm-orchestrator");
53
- const document = state.editor === null ? null : structuredDocument(state.editor.content);
88
+ const editor = state.editor;
89
+ if (editor === null)
90
+ return null;
91
+ const rawDoc = structuredDocument(editor.content);
92
+ const lastValidDocRef = useRef(null);
93
+ if (rawDoc !== null) {
94
+ lastValidDocRef.current = rawDoc;
95
+ }
96
+ const document = rawDoc ?? lastValidDocRef.current;
97
+ const isInvalidProjection = rawDoc === null;
54
98
  if (document === null)
55
99
  return _jsx("p", { className: "dsmm-hint", "data-dsmm-structured-invalid": true, children: t("rawInvalid") });
100
+ const effectiveDisabled = disabled || isInvalidProjection;
56
101
  const roles = state.snapshot?.roles ?? [];
57
102
  const role = roles.find((candidate) => candidate.id === selectedRole) ?? roles[0];
58
103
  const policy = role === undefined ? undefined : document.roleRouting[role.id] ?? {};
@@ -69,14 +114,21 @@ export function StructuredEditor({ state, actions, disabled, t }) {
69
114
  const availability = roleAvailability(role?.availability);
70
115
  const namedRoles = document.settings.roles;
71
116
  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) => {
117
+ const gitGuard = document.guards?.gitWriteGuard;
118
+ const gitScope = document.guards?.gitWriteScope;
119
+ const isGuardOff = gitGuard === "off";
120
+ 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("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-role`, children: t("roleSelect") }), _jsxs("select", { id: `${prefix}-role`, disabled: effectiveDisabled || roles.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: effectiveDisabled, "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: effectiveDisabled, actions: actions }), role.id === "dsmm-orchestrator" ? _jsxs("div", { className: "dsmm-field", children: [_jsx("p", { className: "dsmm-hint", children: t("orchestratorInBasicNotice") }), onJumpToOrchestrator && _jsx(Button, { type: "button", variant: "outline", onClick: onJumpToOrchestrator, children: t("orchestratorJumpToBasic") }), _jsx("p", { className: "dsmm-hint", children: t("orchestratorLevels") })] }) : _jsxs(_Fragment, { children: [_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: 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 }), _jsx("p", { className: "dsmm-hint", children: t("effortChangeHint") }), _jsx("p", { className: "dsmm-hint", children: t("normalLevel") }), _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("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-fallback-mode`, children: t("fallbackMode", { name: role.label }) }), _jsxs("select", { id: `${prefix}-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) => {
73
121
  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: () => {
122
+ return _jsxs("fieldset", { 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 }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: effectiveDisabled || index === 0, onClick: () => actions.moveFallback(role.id, index, index - 1), children: t("moveUp", { name }) }), _jsx(Button, { type: "button", variant: "outline", disabled: effectiveDisabled || index === policy.fallbackRoutes.length - 1, onClick: () => actions.moveFallback(role.id, index, index + 1), children: t("moveDown", { name }) }), _jsx(Button, { type: "button", variant: "outline", disabled: effectiveDisabled, onClick: () => actions.editPath([...rolePath, "fallbackRoutes", index], undefined), children: t("removeFallback", { name }) })] })] }, index);
123
+ }), _jsx(Button, { type: "button", variant: "outline", disabled: effectiveDisabled || (policy.fallbackRoutes?.length ?? 0) >= 32, onClick: () => {
76
124
  if (policy.fallbackRoutes === undefined)
77
125
  actions.editPath([...rolePath, "fallbackRoutes"], [{ provider: "", model: "" }]);
78
126
  else
79
127
  actions.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
80
- }, children: t("addFallback", { name: role.label }) })] }, role.id)] });
128
+ }, children: t("addFallback", { name: role.label }) })] }, role.id), _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") })] })] });
129
+ }
130
+ /** The same raw draft drives every control; there is no form-to-document rewrite. */
131
+ export function StructuredEditor({ state, actions, disabled, t }) {
132
+ 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
133
  }
82
134
  //# 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;
@@ -2,7 +2,7 @@ import { isProfileId } from "../profile-remote.js";
2
2
  import { safeIssue } from "./diagnostics.js";
3
3
  import { isConfigRevision } from "../config-revision.js";
4
4
  import { writableSelectionVersion } from "./configuration-display.js";
5
- import { editStructuredPath, moveFallback } from "./structured.js";
5
+ import { editStructuredPath, moveFallback, structuredDocument } from "./structured.js";
6
6
  function modelSelectionWatermark(window) {
7
7
  let watermark = -1;
8
8
  for (const entry of window.entries)
@@ -73,6 +73,7 @@ export class ProfilesController {
73
73
  refresh: () => this.refresh(), open: (id) => this.open(id), create: () => this.open(NEW_EDITOR), reload: () => this.reload(),
74
74
  editId: (id) => this.editId(id), editContent: (content) => this.editContent(content),
75
75
  save: () => this.save(), apply: () => this.apply(), reset: () => this.reset(),
76
+ discard: () => this.discard(),
76
77
  discardAndOpen: () => this.discardAndOpen(), cancelDiscard: () => this.publish({ pendingEditor: null }),
77
78
  editPath: (path, value) => this.editPath(path, value), moveFallback: (role, from, to) => this.editFallbackOrder(role, from, to),
78
79
  editRoute: (path, provider, model) => this.editRoute(path, provider, model),
@@ -90,11 +91,23 @@ export class ProfilesController {
90
91
  if (invalidFields.join("\n") !== this.current.invalidFields.join("\n"))
91
92
  this.publish({ invalidFields, ...(invalid ? { dirty: true } : {}) });
92
93
  },
94
+ setNumberDraft: (key, entry) => {
95
+ if (this.disposed)
96
+ return;
97
+ if (entry === null) {
98
+ this.numberDrafts.delete(key);
99
+ }
100
+ else {
101
+ this.numberDrafts.set(key, entry);
102
+ }
103
+ },
104
+ getNumberDraft: (key) => this.numberDrafts.get(key),
93
105
  };
106
+ numberDrafts = new Map();
94
107
  constructor(remote) {
95
108
  this.remote = remote;
96
109
  }
97
- dispose() { this.releaseComposerBlock(); this.stopConnection?.(); this.disposed = true; this.generation += 1; this.sessionGeneration += 1; this.catalogGeneration += 1; this.modelSelectorGeneration += 1; this.modelSelectionGeneration += 1; this.stopModelSelection?.(); this.stopModelEvents?.(); this.stopModelInteraction?.(); this.stopModelSelection = null; this.stopModelEvents = null; this.stopModelInteraction = null; this.modelSelectionSource = null; this.modelEvents = null; this.modelInteraction = null; this.catalogRemote = null; this.modelSelector = null; this.listeners.clear(); }
110
+ dispose() { this.releaseComposerBlock(); this.numberDrafts.clear(); this.stopConnection?.(); this.disposed = true; this.generation += 1; this.sessionGeneration += 1; this.catalogGeneration += 1; this.modelSelectorGeneration += 1; this.modelSelectionGeneration += 1; this.stopModelSelection?.(); this.stopModelEvents?.(); this.stopModelInteraction?.(); this.stopModelSelection = null; this.stopModelEvents = null; this.stopModelInteraction = null; this.modelSelectionSource = null; this.modelEvents = null; this.modelInteraction = null; this.catalogRemote = null; this.modelSelector = null; this.listeners.clear(); }
98
111
  bindConnection(source) {
99
112
  if (this.disposed)
100
113
  return;
@@ -438,6 +451,7 @@ export class ProfilesController {
438
451
  listener();
439
452
  }
440
453
  accept(document) {
454
+ this.numberDrafts.clear();
441
455
  this.accepted = { ...document };
442
456
  this.publish({ editor: { ...document }, dirty: false, pendingEditor: null, invalidFields: [], editorEpoch: this.current.editorEpoch + 1 });
443
457
  }
@@ -490,7 +504,7 @@ export class ProfilesController {
490
504
  return;
491
505
  if (id !== NEW_EDITOR && this.current.editor?.id === id)
492
506
  return;
493
- if (this.current.dirty) {
507
+ if (this.current.dirty || this.current.invalidFields.length > 0) {
494
508
  this.publish({ pendingEditor: id });
495
509
  return;
496
510
  }
@@ -500,14 +514,23 @@ export class ProfilesController {
500
514
  const editor = this.current.editor;
501
515
  if (editor === null || editor.revision === null || this.current.busy !== null || this.current.pendingEditor !== null)
502
516
  return;
503
- if (this.current.dirty) {
517
+ if (this.current.dirty || this.current.invalidFields.length > 0) {
504
518
  this.publish({ pendingEditor: editor.id });
505
519
  return;
506
520
  }
507
521
  await this.loadEditor(editor.id);
508
522
  }
523
+ discard() {
524
+ const editor = this.current.editor;
525
+ if (this.disposed || editor === null || this.current.busy !== null || this.current.pendingEditor !== null)
526
+ return;
527
+ if (!this.current.dirty && this.current.invalidFields.length === 0)
528
+ return;
529
+ this.publish({ pendingEditor: editor.revision === null ? NEW_EDITOR : editor.id });
530
+ }
509
531
  async loadEditor(id) {
510
532
  if (id === NEW_EDITOR) {
533
+ this.numberDrafts.clear();
511
534
  this.accepted = null;
512
535
  this.publish({ editor: { id: "new-profile", content: NEW_PROFILE_CONTENT, revision: null }, dirty: true, issue: null, notice: null, pendingEditor: null, invalidFields: [], editorEpoch: this.current.editorEpoch + 1 });
513
536
  return;
@@ -523,14 +546,7 @@ export class ProfilesController {
523
546
  if (wanted === null || this.current.busy !== null)
524
547
  return;
525
548
  this.publish({ pendingEditor: null });
526
- // Only explicit confirmation clears a draft; a failed read restores it.
527
- const previous = this.current.editor;
528
- const accepted = this.accepted;
529
549
  await this.loadEditor(wanted);
530
- if (this.current.issue !== null && previous !== null) {
531
- this.accepted = accepted;
532
- this.publish({ editor: previous, dirty: true });
533
- }
534
550
  }
535
551
  editId(id) {
536
552
  const editor = this.current.editor;
@@ -547,7 +563,21 @@ export class ProfilesController {
547
563
  const editor = this.current.editor;
548
564
  if (editor === null || editor.refreshRequired || this.current.busy !== null || this.current.pendingEditor !== null)
549
565
  return;
550
- this.publish({ editor: { ...editor, content }, dirty: this.accepted === null || this.accepted.content !== content || this.accepted.id !== editor.id, issue: null, notice: null });
566
+ const document = structuredDocument(content);
567
+ let invalidFields = this.current.invalidFields;
568
+ if (document !== null) {
569
+ for (const [key, draft] of this.numberDrafts) {
570
+ let value = document;
571
+ for (const segment of key.split(".")) {
572
+ value = value !== null && typeof value === "object" && Object.hasOwn(value, segment) ? value[segment] : undefined;
573
+ }
574
+ if (value !== draft.sourceValue) {
575
+ this.numberDrafts.delete(key);
576
+ invalidFields = invalidFields.filter(field => field !== key);
577
+ }
578
+ }
579
+ }
580
+ this.publish({ editor: { ...editor, content }, invalidFields, dirty: this.accepted === null || this.accepted.content !== content || this.accepted.id !== editor.id, issue: null, notice: null });
551
581
  }
552
582
  editPath(path, value) {
553
583
  const editor = this.current.editor;
@@ -604,8 +634,8 @@ export class ProfilesController {
604
634
  });
605
635
  }
606
636
  async apply() {
607
- const { editor, snapshot, dirty } = this.current;
608
- if (editor?.refreshRequired || !isConfigRevision(editor?.revision) || !canReconcileSelection(snapshot) || dirty)
637
+ const { editor, snapshot, dirty, invalidFields } = this.current;
638
+ if (editor?.refreshRequired || !isConfigRevision(editor?.revision) || !canReconcileSelection(snapshot) || dirty || invalidFields.length > 0)
609
639
  return;
610
640
  await this.perform("apply", async (live) => {
611
641
  const accepted = await this.unwrap(this.remote.select({ id: editor.id, expectedRevision: editor.revision, expectedSelectionRevision: snapshot.selectionRevision }));