@dsmm/dsmm 0.2.0 → 0.2.2

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 (291) hide show
  1. package/README.md +38 -66
  2. package/agent-presets/dsmm-builder/agent.cordis.yml +10 -2015
  3. package/agent-presets/dsmm-clarifier/agent.cordis.yml +24 -343
  4. package/agent-presets/dsmm-code-search/agent.cordis.yml +19 -6
  5. package/agent-presets/dsmm-coding/agent.cordis.yml +19 -438
  6. package/agent-presets/dsmm-complex/agent.cordis.yml +23 -1009
  7. package/agent-presets/dsmm-creative/agent.cordis.yml +25 -442
  8. package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +29 -1013
  9. package/agent-presets/dsmm-deep/agent.cordis.yml +24 -1008
  10. package/agent-presets/dsmm-doc-search/agent.cordis.yml +19 -6
  11. package/agent-presets/dsmm-documenting/agent.cordis.yml +26 -439
  12. package/agent-presets/dsmm-frontend/agent.cordis.yml +21 -440
  13. package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +22 -441
  14. package/agent-presets/dsmm-media-reader/agent.cordis.yml +19 -6
  15. package/agent-presets/dsmm-normal-task/agent.cordis.yml +19 -438
  16. package/agent-presets/dsmm-oracle/agent.cordis.yml +25 -340
  17. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +25 -340
  18. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +29 -2025
  19. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +24 -341
  20. package/agent-presets/dsmm-planner/agent.cordis.yml +14 -344
  21. package/agent-presets/dsmm-quick/agent.cordis.yml +19 -6
  22. package/agent-presets/dsmm-research/agent.cordis.yml +23 -8
  23. package/agent-presets/dsmm-reviewer/agent.cordis.yml +25 -340
  24. package/docs/agent-presets.md +36 -52
  25. package/docs/compatibility.md +50 -108
  26. package/docs/deferred-native-approval-risk.md +19 -0
  27. package/docs/design.md +2 -2
  28. package/docs/lsp.md +11 -21
  29. package/docs/migration-from-ocmm.md +2 -2
  30. package/docs/model-routing.md +84 -59
  31. package/docs/native-permissions.md +35 -0
  32. package/docs/profiles.md +40 -87
  33. package/docs/releasing.md +83 -2
  34. package/docs/roadmap.md +71 -17
  35. package/docs/settings-status.md +34 -169
  36. package/docs/skill-sync.md +52 -15
  37. package/lib/child-admission-contract.d.ts +37 -0
  38. package/lib/child-admission-contract.js +2 -0
  39. package/lib/child-admission.d.ts +42 -0
  40. package/lib/child-admission.js +162 -0
  41. package/lib/child-capture.d.ts +81 -0
  42. package/lib/child-capture.js +203 -0
  43. package/lib/child-evidence.d.ts +17 -0
  44. package/lib/child-evidence.js +43 -0
  45. package/lib/client/ChildrenPanel.d.ts +43 -0
  46. package/lib/client/ChildrenPanel.js +82 -0
  47. package/lib/client/DeploymentPage.js +15 -8
  48. package/lib/client/EditableChoice.d.ts +17 -0
  49. package/lib/client/EditableChoice.js +49 -0
  50. package/lib/client/PermissionsPanel.d.ts +14 -0
  51. package/lib/client/PermissionsPanel.js +46 -0
  52. package/lib/client/ProfilesSection.js +30 -15
  53. package/lib/client/RoleAvailability.d.ts +7 -0
  54. package/lib/client/RoleAvailability.js +19 -0
  55. package/lib/client/SessionProfiles.js +27 -9
  56. package/lib/client/StructuredEditor.js +15 -7
  57. package/lib/client/children-controller.d.ts +98 -0
  58. package/lib/client/children-controller.js +296 -0
  59. package/lib/client/children-locales.d.ts +367 -0
  60. package/lib/client/children-locales.js +69 -0
  61. package/lib/client/controller.d.ts +6 -1
  62. package/lib/client/controller.js +14 -8
  63. package/lib/client/deployment-data.d.ts +2 -1
  64. package/lib/client/deployment-data.js +34 -5
  65. package/lib/client/deployment-locales.d.ts +4 -0
  66. package/lib/client/deployment-locales.js +11 -2
  67. package/lib/client/diagnostics.d.ts +14 -0
  68. package/lib/client/diagnostics.js +53 -0
  69. package/lib/client/index.d.ts +4 -0
  70. package/lib/client/index.js +96 -2
  71. package/lib/client/locales.d.ts +54 -0
  72. package/lib/client/locales.js +34 -16
  73. package/lib/client/permission-client.d.ts +16 -0
  74. package/lib/client/permission-client.js +38 -0
  75. package/lib/client/permission-controller.d.ts +62 -0
  76. package/lib/client/permission-controller.js +149 -0
  77. package/lib/client/permission-locales.d.ts +114 -0
  78. package/lib/client/permission-locales.js +75 -0
  79. package/lib/client/session-labels.js +4 -4
  80. package/lib/client/structured.js +19 -5
  81. package/lib/client/styles.d.ts +1 -1
  82. package/lib/client/styles.js +20 -0
  83. package/lib/client.js +5780 -1679
  84. package/lib/core-permission-authority.d.ts +18 -0
  85. package/lib/core-permission-authority.js +255 -0
  86. package/lib/core-permissions.d.ts +8 -0
  87. package/lib/core-permissions.js +33 -0
  88. package/lib/delivery-authority.d.ts +68 -0
  89. package/lib/delivery-authority.js +260 -0
  90. package/lib/deployment-config.d.ts +23 -0
  91. package/lib/deployment-config.js +61 -40
  92. package/lib/deployment-permission-rules.d.ts +55 -0
  93. package/lib/deployment-permission-rules.js +306 -0
  94. package/lib/dsh-types.d.ts +10 -4
  95. package/lib/guards.d.ts +1 -1
  96. package/lib/guards.js +29 -8
  97. package/lib/host-llm-startup.d.ts +41 -0
  98. package/lib/host-llm-startup.js +65 -0
  99. package/lib/host-llm.d.ts +92 -0
  100. package/lib/host-llm.js +325 -0
  101. package/lib/index.d.ts +15 -4
  102. package/lib/index.js +300 -47
  103. package/lib/legacy-child-policy.d.ts +51 -0
  104. package/lib/legacy-child-policy.js +123 -0
  105. package/lib/legacy-read-composition.d.ts +20 -0
  106. package/lib/legacy-read-composition.js +144 -0
  107. package/lib/legacy-read-contracts.d.ts +157 -0
  108. package/lib/legacy-read-contracts.js +39 -0
  109. package/lib/legacy-read-host.d.ts +19 -0
  110. package/lib/legacy-read-host.js +67 -0
  111. package/lib/legacy-read-integration.d.ts +121 -0
  112. package/lib/legacy-read-integration.js +522 -0
  113. package/lib/legacy-read-proxy.d.ts +26 -0
  114. package/lib/legacy-read-proxy.js +237 -0
  115. package/lib/live-pi-ai-owner.d.ts +18 -0
  116. package/lib/live-pi-ai-owner.js +144 -0
  117. package/lib/llm-runtime.d.ts +11 -0
  118. package/lib/llm-runtime.js +21 -0
  119. package/lib/managed-settings.d.ts +5 -0
  120. package/lib/managed-settings.js +14 -0
  121. package/lib/model-parameter-policy.d.ts +11 -0
  122. package/lib/model-parameter-policy.js +27 -0
  123. package/lib/model-routing.js +28 -17
  124. package/lib/modules.d.ts +13 -5
  125. package/lib/modules.js +17 -1
  126. package/lib/native-child-evidence.d.ts +42 -0
  127. package/lib/native-child-evidence.js +133 -0
  128. package/lib/native-pi-ai-wire.d.ts +37 -0
  129. package/lib/native-pi-ai-wire.js +261 -0
  130. package/lib/native-scope.js +1 -1
  131. package/lib/permission-bash.d.ts +6 -0
  132. package/lib/permission-bash.js +7 -0
  133. package/lib/permission-control.d.ts +73 -0
  134. package/lib/permission-control.js +205 -0
  135. package/lib/permission-controller.d.ts +68 -0
  136. package/lib/permission-controller.js +317 -0
  137. package/lib/permission-errors.d.ts +7 -0
  138. package/lib/permission-errors.js +21 -0
  139. package/lib/permission-fs-search.d.ts +5 -0
  140. package/lib/permission-fs-search.js +7 -0
  141. package/lib/permission-fs.d.ts +5 -0
  142. package/lib/permission-fs.js +7 -0
  143. package/lib/permission-native-access.d.ts +11 -0
  144. package/lib/permission-native-access.js +6 -0
  145. package/lib/permission-native-command.d.ts +10 -0
  146. package/lib/permission-native-command.js +93 -0
  147. package/lib/permission-native-rules.d.ts +75 -0
  148. package/lib/permission-native-rules.js +278 -0
  149. package/lib/permission-pwsh.d.ts +6 -0
  150. package/lib/permission-pwsh.js +7 -0
  151. package/lib/permission-remote.d.ts +26 -0
  152. package/lib/permission-remote.js +53 -0
  153. package/lib/permission-rpc.d.ts +29 -0
  154. package/lib/permission-rpc.js +152 -0
  155. package/lib/permission-rules.d.ts +115 -0
  156. package/lib/permission-rules.js +256 -0
  157. package/lib/permission-settings.d.ts +45 -0
  158. package/lib/permission-settings.js +48 -0
  159. package/lib/permission-shell.d.ts +38 -0
  160. package/lib/permission-shell.js +150 -0
  161. package/lib/permission-web.d.ts +5 -0
  162. package/lib/permission-web.js +7 -0
  163. package/lib/preset-registry.js +36 -25
  164. package/lib/profile-diagnostics.d.ts +45 -0
  165. package/lib/profile-diagnostics.js +148 -0
  166. package/lib/profile-locale.d.ts +3 -0
  167. package/lib/profile-locale.js +2 -0
  168. package/lib/profile-remote.d.ts +8 -0
  169. package/lib/profile-remote.js +163 -39
  170. package/lib/profile-rpc.d.ts +4 -3
  171. package/lib/profile-rpc.js +14 -12
  172. package/lib/profile-runtime.d.ts +40 -1
  173. package/lib/profile-runtime.js +368 -93
  174. package/lib/profile-store.d.ts +11 -0
  175. package/lib/profile-store.js +143 -11
  176. package/lib/profile-types.d.ts +70 -1
  177. package/lib/profile-types.js +1 -0
  178. package/lib/profiles.d.ts +16 -2
  179. package/lib/profiles.js +156 -79
  180. package/lib/prompt-content.js +1 -1
  181. package/lib/prompts.d.ts +37 -2
  182. package/lib/prompts.js +111 -9
  183. package/lib/recovery-policy.js +20 -7
  184. package/lib/role-control-remote.d.ts +38 -0
  185. package/lib/role-control-remote.js +211 -0
  186. package/lib/role-control-rpc.d.ts +51 -0
  187. package/lib/role-control-rpc.js +377 -0
  188. package/lib/role-control-types.d.ts +92 -0
  189. package/lib/role-control-types.js +8 -0
  190. package/lib/role-invocation.d.ts +47 -0
  191. package/lib/role-invocation.js +135 -0
  192. package/lib/role-llm-runtime.d.ts +17 -0
  193. package/lib/role-llm-runtime.js +62 -0
  194. package/lib/role-llm.d.ts +31 -0
  195. package/lib/role-llm.js +66 -0
  196. package/lib/role-policy.d.ts +49 -8
  197. package/lib/role-policy.js +437 -60
  198. package/lib/role-providers.d.ts +1 -1
  199. package/lib/role-providers.js +30 -35
  200. package/lib/role-routing.d.ts +11 -2
  201. package/lib/role-routing.js +42 -25
  202. package/lib/role-runs.d.ts +135 -0
  203. package/lib/role-runs.js +304 -0
  204. package/lib/role-subagents.d.ts +58 -3
  205. package/lib/role-subagents.js +169 -56
  206. package/lib/roles.d.ts +5 -6
  207. package/lib/roles.js +10 -39
  208. package/lib/route-json.d.ts +19 -0
  209. package/lib/route-json.js +129 -0
  210. package/lib/routing-policy.d.ts +2 -0
  211. package/lib/routing-policy.js +12 -2
  212. package/lib/runtime-integration.d.ts +112 -0
  213. package/lib/runtime-integration.js +784 -0
  214. package/lib/runtime-recovery.js +18 -8
  215. package/lib/settings.d.ts +47 -13
  216. package/lib/settings.js +217 -82
  217. package/lib/skills.js +2 -2
  218. package/lib/status.d.ts +10 -1
  219. package/lib/status.js +11 -8
  220. package/lib/subagent-runtime.d.ts +45 -0
  221. package/lib/subagent-runtime.js +131 -0
  222. package/package.json +106 -56
  223. package/patches/subagent-runtime.yml +15 -0
  224. package/prompts/deepseek-flash.md +1 -1
  225. package/prompts/deepseek-v4-pro.md +2 -2
  226. package/prompts/deepwork.md +27 -18
  227. package/prompts/source/agents/clarifier.md +5 -3
  228. package/prompts/source/agents/orchestrator.md +18 -9
  229. package/prompts/source/agents/plan-critic.md +5 -1
  230. package/prompts/source/agents/planner.md +4 -2
  231. package/prompts/source/agents/reviewer.md +6 -0
  232. package/prompts/source/category/complex.md +4 -4
  233. package/prompts/source/category/creative.md +6 -4
  234. package/prompts/source/category/cross-cutting.md +10 -8
  235. package/prompts/source/category/deep.md +5 -3
  236. package/prompts/source/category/documenting.md +7 -1
  237. package/prompts/source/category/frontend.md +2 -2
  238. package/prompts/source/category/hard-reasoning.md +3 -3
  239. package/prompts/source/category/research.md +4 -2
  240. package/prompts/source/deepwork/claude-opus-5.md +2 -2
  241. package/prompts/source/deepwork/codex.md +1 -1
  242. package/prompts/source/deepwork/default.md +22 -15
  243. package/prompts/source/deepwork/gemini.md +23 -16
  244. package/prompts/source/deepwork/glm.md +21 -14
  245. package/prompts/source/deepwork/gpt.md +12 -6
  246. package/prompts/source/deepwork/planner.md +8 -5
  247. package/prompts/source/manifest.json +178 -63
  248. package/prompts/source/shared/dsh-host-contract.md +5 -3
  249. package/prompts/source/shared/locale.md +2 -2
  250. package/prompts/source/terminal/orchestrator.md +1 -1
  251. package/scripts/cold-profile-composition.mjs +329 -0
  252. package/scripts/cold-profile-sources.mjs +238 -0
  253. package/scripts/migrate-cold-profile.mjs +315 -0
  254. package/skills/ast-grep/SKILL.md +7 -4
  255. package/skills/brainstorming/SKILL.md +43 -22
  256. package/skills/coding-agent-sessions/SKILL.md +7 -4
  257. package/skills/coding-agent-sessions/scripts/agent_sessions/pi_family.py +46 -46
  258. package/skills/coding-agent-sessions/scripts/tests/test_pi_family_scanners.py +130 -130
  259. package/skills/debugging/SKILL.md +14 -9
  260. package/skills/debugging/references/methodology/00-setup.md +14 -62
  261. package/skills/debugging/references/methodology/02-investigate.md +4 -4
  262. package/skills/debugging/references/methodology/03-flaky-triage.md +3 -3
  263. package/skills/debugging/references/methodology/04-hard-reasoning-escalation.md +2 -14
  264. package/skills/debugging/references/methodology/06-fix.md +6 -6
  265. package/skills/debugging/references/methodology/08-qa.md +5 -5
  266. package/skills/debugging/references/methodology/09-cleanup.md +15 -153
  267. package/skills/debugging/references/methodology/partial-runtime-evidence.md +3 -16
  268. package/skills/debugging/references/runtimes/bundled-js-binary.md +1 -16
  269. package/skills/debugging/references/runtimes/native-binary.md +9 -54
  270. package/skills/debugging/references/runtimes/node.md +4 -15
  271. package/skills/debugging/references/runtimes/python.md +3 -15
  272. package/skills/debugging/references/runtimes/rust.md +2 -18
  273. package/skills/debugging/references/tools/dap.md +1 -1
  274. package/skills/debugging/references/tools/ghidra.md +4 -15
  275. package/skills/debugging/references/tools/playwright-cli.md +3 -15
  276. package/skills/debugging/references/tools/pwntools.md +4 -16
  277. package/skills/dispatching-parallel-agents/SKILL.md +18 -16
  278. package/skills/frontend/SKILL.md +7 -4
  279. package/skills/frontend/references/design/react-dev-tooling-skill.md +1 -1
  280. package/skills/git-master/SKILL.md +7 -4
  281. package/skills/init-deep/SKILL.md +7 -4
  282. package/skills/receiving-code-review/SKILL.md +17 -12
  283. package/skills/remove-ai-slops/SKILL.md +39 -38
  284. package/skills/requesting-code-review/SKILL.md +19 -17
  285. package/skills/requesting-code-review/code-reviewer.md +13 -1
  286. package/skills/subagent-driven-development/SKILL.md +29 -26
  287. package/skills/subagent-driven-development/implementer-prompt.md +29 -11
  288. package/skills/subagent-driven-development/spec-reviewer-prompt.md +6 -1
  289. package/skills/using-git-worktrees/SKILL.md +7 -4
  290. package/skills/writing-plans/SKILL.md +29 -24
  291. package/skills/writing-plans/plan-document-reviewer-prompt.md +10 -1
@@ -0,0 +1,14 @@
1
+ import type { PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
2
+ import type { PermissionController, PermissionView } from "./permission-controller.js";
3
+ type Locale = PropsLocale<"settings.dsmm-permissions">;
4
+ export type PermissionsPanelProps = Locale & {
5
+ controller: PermissionController;
6
+ sessionId?: string;
7
+ };
8
+ export declare function PermissionRulesEditor({ controller, state, t }: Locale & {
9
+ controller: PermissionController;
10
+ state: PermissionView;
11
+ }): import("react").JSX.Element;
12
+ export declare function PermissionsPanel({ controller, t, sessionId }: PermissionsPanelProps): import("react").JSX.Element | null;
13
+ export {};
14
+ //# sourceMappingURL=PermissionsPanel.d.ts.map
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useId, useSyncExternalStore } from "react";
3
+ import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ const actions = ["inherit", "allow", "ask", "deny"];
5
+ const kinds = ["outside-read", "shell", "webSearch", "webFetch"];
6
+ const ruleDraft = (rule) => ({ id: rule.id, action: rule.action, match: structuredClone(rule.match) });
7
+ const newMatch = (kind) => kind === "outside-read" ? { kind, path: "", scope: "exact" } : kind === "shell" ? { kind, executable: "", command: "", workingDirectory: "" } : { kind };
8
+ function Issue({ value, t }) { return value === null ? null : _jsxs("p", { className: "dsmm-issue", role: "alert", children: [t(`issue:${value}`), " ", _jsx("code", { children: value })] }); }
9
+ function RootState({ state, t }) {
10
+ return _jsxs(_Fragment, { children: [_jsxs("p", { children: [t("root"), ": ", _jsx("code", { children: state.sessionId ?? "—" })] }), state.scope !== "root" && _jsx("p", { className: "dsmm-hint", children: t(state.scope === "child" ? "child" : "noRoot") }), !state.connected && _jsx("p", { className: "dsmm-hint", children: t("unknown") })] });
11
+ }
12
+ function ActionSelect({ id, value, inherit = true, onChange, disabled, t }) {
13
+ return _jsx("select", { id: id, value: value, disabled: disabled, onChange: event => { const choice = actions.find(value => value === event.currentTarget.value); if (choice !== undefined)
14
+ onChange(choice); }, children: actions.filter(value => inherit || value !== "inherit").map(value => _jsx("option", { value: value, children: t(value === "inherit" ? "inherit" : `action:${value}`) }, value)) });
15
+ }
16
+ function RuleEditor({ controller, state, t }) {
17
+ const id = useId(), editor = state.draft?.editor;
18
+ if (editor == null)
19
+ return null;
20
+ const disabled = state.busy !== null, change = (value) => controller.edit(state.generation, { editor: value });
21
+ const field = (key, label) => _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-${key}`, children: t(label) }), _jsx(Input, { className: "dsmm-input", id: `${id}-${key}`, required: true, maxLength: 32768, disabled: disabled, value: key in editor.match ? String(Reflect.get(editor.match, key)) : "", onChange: event => change({ ...editor, match: { ...editor.match, [key]: event.currentTarget.value } }) })] });
22
+ return _jsxs("form", { className: "dsmm-structured", "aria-label": t("editor"), onSubmit: event => { event.preventDefault(); controller.stageRule(state.generation); }, children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-id`, children: t("id") }), _jsx(Input, { className: "dsmm-input", id: `${id}-id`, required: true, maxLength: 256, value: editor.id, disabled: disabled, onChange: event => change({ ...editor, id: event.currentTarget.value }) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-action`, children: t("action") }), _jsx(ActionSelect, { id: `${id}-action`, value: editor.action, disabled: disabled, inherit: false, t: t, onChange: action => { if (action !== "inherit")
23
+ change({ ...editor, action }); } })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-kind`, children: t("match") }), _jsx("select", { id: `${id}-kind`, value: editor.match.kind, disabled: disabled, onChange: event => { const kind = kinds.find(value => value === event.currentTarget.value); if (kind !== undefined)
24
+ change({ ...editor, match: newMatch(kind) }); }, children: kinds.map(kind => _jsx("option", { value: kind, children: t(`kind:${kind}`) }, kind)) })] }), editor.match.kind === "outside-read" && _jsxs(_Fragment, { children: [field("path", "path"), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-path-scope`, children: t("pathScope") }), _jsxs("select", { id: `${id}-path-scope`, value: editor.match.scope, disabled: disabled, onChange: event => { const scope = event.currentTarget.value; if (editor.match.kind === "outside-read" && (scope === "exact" || scope === "tree"))
25
+ change({ ...editor, match: { ...editor.match, scope } }); }, children: [_jsx("option", { value: "exact", children: t("exact") }), _jsx("option", { value: "tree", children: t("tree") })] })] })] }), editor.match.kind === "shell" && _jsxs(_Fragment, { children: [field("executable", "executable"), field("command", "command"), field("workingDirectory", "cwd")] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "submit", variant: "outline", disabled: disabled, children: t("stage") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { editor: null }), children: t("cancel") })] })] });
26
+ }
27
+ function RuleRecords({ controller, state, t }) {
28
+ const records = state.rules?.snapshot.policy.rules ?? state.base?.policy.rules;
29
+ return _jsxs("div", { className: "dsmm-structured", children: [records?.length === 0 && _jsx("p", { children: t("noRules") }), records?.map(rule => _jsxs("fieldset", { children: [_jsx("legend", { children: rule.id }), _jsxs("p", { children: [t(rule.revoked ? "revoked" : "active"), " \u00B7 ", t(`action:${rule.action}`)] }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("match") }), _jsx("dd", { children: t(`kind:${rule.match.kind}`) }), rule.match.kind === "outside-read" && _jsxs(_Fragment, { children: [_jsx("dt", { children: t("path") }), _jsxs("dd", { children: [rule.match.path, " \u00B7 ", t(rule.match.scope)] })] }), rule.match.kind === "shell" && _jsxs(_Fragment, { children: [_jsx("dt", { children: t("executable") }), _jsx("dd", { children: rule.match.executable }), _jsx("dt", { children: t("command") }), _jsx("dd", { children: _jsx("code", { children: rule.match.command }) }), _jsx("dt", { children: t("cwd") }), _jsx("dd", { children: rule.match.workingDirectory })] }), _jsx("dt", { children: t("recordVersion") }), _jsx("dd", { children: rule.revision }), _jsx("dt", { children: t("source") }), _jsxs("dd", { children: [t(rule.source.kind === "operator" ? "operator" : "imported"), " \u00B7 ", rule.source.kind === "operator" ? rule.source.sessionId : rule.source.label] }), rule.source.kind === "operator" && _jsxs(_Fragment, { children: [_jsx("dt", { children: t("savedAt") }), _jsx("dd", { children: String(rule.source.savedAt) })] })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: state.busy !== null || state.draft === null, onClick: () => controller.edit(state.generation, { editor: ruleDraft(rule) }), children: t("editRule") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy !== null || state.draft === null || rule.revoked || state.draft.revoke.includes(rule.id), onClick: () => controller.stageRevoke(state.generation, rule.id), children: t("stageRevoke") })] })] }, rule.id))] });
30
+ }
31
+ function PermissionCoverage({ state, t }) {
32
+ const value = state.rules?.capabilities;
33
+ return _jsxs("section", { className: "dsmm-structured", "aria-label": t("coverageTitle"), children: [_jsx("h3", { children: t("coverageTitle") }), _jsx("p", { className: "dsmm-hint", children: t("coverage") }), value === undefined ? _jsx("p", { children: t("coverageUnavailable") }) : _jsxs(_Fragment, { children: [_jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("coverageRuntime") }), _jsxs("dd", { children: [t(value.runtime.state), " \u00B7 ", t("mounted"), ": ", t(value.runtime.mounted ? "on" : "off")] }), _jsx("dt", { children: t("coverageRevision") }), _jsx("dd", { children: _jsx("code", { children: value.runtime.runtimeRevision }) })] }), value.runtime.restartRequired && _jsx("p", { children: t("restart") }), value.tools.length === 0 ? _jsx("p", { children: t("coverageEmpty") }) : _jsx("ul", { className: "dsmm-profile-list", children: value.tools.map(tool => _jsx("li", { children: _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("toolName") }), _jsx("dd", { children: _jsx("code", { children: tool.name }) }), _jsx("dt", { children: t("toolKind") }), _jsx("dd", { children: _jsx("code", { children: tool.kind }) }), _jsx("dt", { children: t("toolApproval") }), _jsx("dd", { children: t("nativeOnce") }), _jsx("dt", { children: t("toolMemory") }), _jsx("dd", { children: t("notProvided") })] }) }, tool.name)) }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("outsideReads") }), _jsx("dd", { children: t("limit:outsideReads") }), _jsx("dt", { children: t("finalInode") }), _jsx("dd", { children: t("limit:finalInode") }), _jsx("dt", { children: t("toolMemory") }), _jsx("dd", { children: t("limit:scopedMemory") }), _jsx("dt", { children: t("webFetch") }), _jsx("dd", { children: t("limit:webFetch") }), _jsx("dt", { children: t("searchDestinations") }), _jsx("dd", { children: t("limit:webSearchDestinations") }), _jsx("dt", { children: t("proxyBinding") }), _jsx("dd", { children: t("limit:proxyAddressBinding") }), _jsx("dt", { children: t("shellSockets") }), _jsx("dd", { children: t("limit:shellSockets") }), _jsx("dt", { children: t("providerAuthMcp") }), _jsx("dd", { children: t("limit:providerAuthMcp") })] })] }), _jsx("p", { className: "dsmm-hint", children: t("pathEvidence") })] });
34
+ }
35
+ export function PermissionRulesEditor({ controller, state, t }) {
36
+ const id = useId(), draft = state.draft, disabled = state.busy !== null, value = state.rules;
37
+ return _jsxs("section", { className: "dsmm-zone", "aria-label": t("rules"), children: [_jsx("h3", { children: t("rules") }), _jsx("p", { className: "dsmm-hint", children: t("rulesHint") }), _jsx("p", { className: "dsmm-hint", children: t("networkLimit") }), _jsx("p", { className: "dsmm-hint", children: t("matchHint") }), _jsx(Issue, { value: state.rulesIssue, t: t }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("base") }), _jsx("dd", { children: _jsx("code", { children: state.base?.revision ?? t("unknown") }) }), _jsx("dt", { children: t("savedRevision") }), _jsx("dd", { children: _jsx("code", { children: value?.runtime.savedRevision ?? t("unknown") }) }), _jsx("dt", { children: t("runtimeRevision") }), _jsx("dd", { children: _jsx("code", { children: value?.runtime.runtimeRevision ?? t("unknown") }) }), _jsx("dt", { children: t("runtime") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.state) }), _jsx("dt", { children: t("mounted") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.mounted ? "on" : "off") })] }), value?.runtime.restartRequired && _jsx("p", { children: t("restart") }), _jsx(PermissionCoverage, { state: state, t: t }), draft !== null && _jsxs(_Fragment, { children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-outside`, children: t("outsideReads") }), _jsx(ActionSelect, { id: `${id}-outside`, value: draft.outsideReads, disabled: disabled, t: t, onChange: outsideReads => controller.edit(state.generation, { outsideReads }) })] }), ["webSearch", "webFetch"].map(key => _jsxs("fieldset", { children: [_jsx("legend", { children: t(key) }), _jsxs("label", { className: "dsmm-actions", htmlFor: `${id}-${key}-enabled`, children: [_jsx("input", { type: "checkbox", id: `${id}-${key}-enabled`, checked: draft[key].enabled, disabled: disabled, onChange: event => controller.edit(state.generation, { [key]: { ...draft[key], enabled: event.currentTarget.checked } }) }), t("enabled")] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-${key}-rule`, children: t("rule") }), _jsx(ActionSelect, { id: `${id}-${key}-rule`, value: draft[key].rule, disabled: disabled, t: t, onChange: rule => controller.edit(state.generation, { [key]: { ...draft[key], rule } }) })] })] }, key)), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || draft.editor !== null, onClick: () => controller.edit(state.generation, { editor: { id: "", action: "ask", match: newMatch("outside-read") } }), children: t("newRule") }), _jsx(RuleEditor, { controller: controller, state: state, t: t }), (draft.upsert.length > 0 || draft.revoke.length > 0) && _jsxs("div", { className: "dsmm-structured", children: [_jsx("h3", { children: t("staged") }), draft.upsert.map(row => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [row.id, " \u00B7 ", t(`kind:${row.match.kind}`), " \u00B7 ", t(`action:${row.action}`)] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { upsert: draft.upsert.filter(rule => rule.id !== row.id) }), children: [t("unstage"), ": ", row.id] })] }, row.id)), draft.revoke.map(ruleId => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [t("stageRevoke"), ": ", ruleId] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { revoke: draft.revoke.filter(id => id !== ruleId) }), children: [t("unstage"), ": ", ruleId] })] }, ruleId))] })] }), _jsx(RuleRecords, { state: state, controller: controller, t: t }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !controller.canSave(state.generation), onClick: () => void controller.save(state.generation), children: t("save") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.scope !== "root" || !state.connected || state.reading || disabled, onClick: () => void controller.refresh(state.generation, true), children: t("discard") })] }), state.dirty && _jsx("p", { children: t("dirty") })] });
38
+ }
39
+ export function PermissionsPanel({ controller, t, sessionId }) {
40
+ const state = useSyncExternalStore(controller.store.subscribe, controller.store.getSnapshot);
41
+ useEffect(() => controller.watch(), [controller]);
42
+ if (sessionId !== undefined && sessionId !== state.sessionId)
43
+ return null;
44
+ return _jsxs("section", { className: "dsmm-profiles dsmm-children dsmm-permissions", "data-dsmm-permissions": true, "aria-label": t("title"), "aria-busy": state.reading || state.busy !== null, children: [_jsx("h2", { children: t("title") }), _jsx(RootState, { state: state, t: t }), _jsx("p", { className: "dsmm-hint", children: t("nativeApproval") }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: state.busy !== null ? t("busy") : state.notice === null ? "" : t(state.notice) }), _jsx(PermissionRulesEditor, { controller: controller, state: state, t: t })] });
45
+ }
46
+ //# sourceMappingURL=PermissionsPanel.js.map
@@ -5,6 +5,7 @@ import { canReconcileSelection } from "./controller.js";
5
5
  import { StructuredEditor } from "./StructuredEditor.js";
6
6
  import { SessionScope } from "./SessionProfiles.js";
7
7
  import { structuredDocument } from "./structured.js";
8
+ import { draftWarnings, IssueDetails, ProfileWarnings } from "./diagnostics.js";
8
9
  function issueKey(issue) {
9
10
  if (issue.source === "selection")
10
11
  return issue.code === "conflict" ? "selectionConflict" : "appliedInvalid";
@@ -22,6 +23,8 @@ export function ProfilesSection(props) {
22
23
  const selectRef = useRef(null);
23
24
  const inputRef = useRef(null);
24
25
  const editorRef = useRef(null);
26
+ const advancedRef = useRef(null);
27
+ const handledValidation = useRef(0);
25
28
  const cancelRef = useRef(null);
26
29
  const hadConfirmation = useRef(false);
27
30
  const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy === "apply" || state.sessionBusy === "reset";
@@ -32,7 +35,7 @@ export function ProfilesSection(props) {
32
35
  const reconcilable = canReconcileSelection(snapshot);
33
36
  const selectionConflict = reconcilable && snapshot?.selectionError?.code === "conflict";
34
37
  const invalid = state.issue?.kind === "domain" && state.issue.code === "validation";
35
- const idInvalid = invalid && state.issue?.field === "id";
38
+ const idInvalid = invalid && state.issue?.field === "id" && state.issue.location === undefined && editor?.revision === null && !editorDisabled;
36
39
  const rawInvalid = editor !== null && structuredDocument(editor.content) === null;
37
40
  useEffect(() => {
38
41
  if (state.pendingEditor !== null) {
@@ -45,24 +48,36 @@ export function ProfilesSection(props) {
45
48
  }
46
49
  }, [state.pendingEditor]);
47
50
  useEffect(() => {
48
- if (state.issue?.kind === "domain" && state.issue.code === "validation") {
49
- if (state.issue.field === "id")
50
- inputRef.current?.focus();
51
- else
52
- editorRef.current?.focus();
51
+ if (state.busy === null && state.validationEpoch > handledValidation.current && state.issue?.kind === "domain" && state.issue.code === "validation") {
52
+ handledValidation.current = state.validationEpoch;
53
+ if (state.issue.location === undefined && state.issue.field === "id" && inputRef.current !== null
54
+ && !inputRef.current.disabled && !inputRef.current.readOnly)
55
+ inputRef.current.focus();
56
+ else {
57
+ if (advancedRef.current !== null)
58
+ advancedRef.current.open = true;
59
+ const input = editorRef.current;
60
+ if (input !== null) {
61
+ input.focus();
62
+ const location = state.issue.location;
63
+ if (location !== undefined && location.offset + location.length <= input.value.length)
64
+ input.setSelectionRange(location.offset, location.offset + location.length);
65
+ }
66
+ }
53
67
  }
54
- }, [state.issue]);
55
- const applied = editor?.revision !== null && editor?.id === snapshot?.selectedId && editor?.revision === snapshot?.appliedRevision;
56
- let selection = t("baseline");
68
+ }, [state.issue, state.busy, state.validationEpoch]);
69
+ const applied = editor?.revision != null && editor.id === snapshot?.selectedId && editor.revision === snapshot?.appliedRevision;
70
+ let selection = t(snapshot === null ? "unavailable" : "baseline");
57
71
  if (snapshot?.selectionError !== undefined && !selectionConflict)
58
72
  selection = t("appliedInvalid");
59
73
  else if (snapshot?.selectedId !== null && snapshot?.selectedId !== undefined)
60
- selection = t("appliedProfile", { id: snapshot.selectedId, revision: snapshot.appliedRevision?.slice(0, 12) ?? "—" });
74
+ selection = t("appliedProfile", { id: snapshot.selectedId, revision: snapshot.appliedRevision ?? "—" });
61
75
  const notice = state.notice === null ? "" : t(state.notice.key === "reset" ? "resetDone" : state.notice.key, { id: state.notice.id });
62
- return _jsxs("section", { className: "dsmm-profiles", "aria-labelledby": `${prefix}-title`, "aria-busy": state.busy !== null, children: [_jsx("h2", { id: `${prefix}-title`, children: t("title") }), _jsx("p", { children: t("description") }), snapshot?.origin !== undefined && _jsx("p", { className: "dsmm-hint", children: t(snapshot.origin === "legacy" ? "legacyOrigin" : snapshot.origin === "central" ? "centralOrigin" : "explicitOrigin") }), readOnly && _jsx("p", { role: "status", className: "dsmm-hint", children: t("readOnlyOrigin") }), _jsx("h3", { id: `${prefix}-global`, children: t("globalScope") }), _jsx("p", { className: "dsmm-hint", children: t("newSessions") }), _jsx("p", { "data-dsmm-selection": true, children: selection }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || snapshot === null, onClick: () => { void props.create(); }, children: t("new") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => { void props.refresh(); }, children: t(state.busy === "refresh" ? "refreshing" : "refresh") }), _jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || !reconcilable || (snapshot?.selectedId === null && !selectionConflict), onClick: () => { void props.reset(); }, children: t(state.busy === "reset" ? "resetting" : "reset") })] }), snapshot !== null && _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-select`, children: t("editorSelect") }), _jsxs("select", { ref: selectRef, id: `${prefix}-select`, disabled: disabled, value: editor?.revision == null ? "" : editor.id, onChange: (event) => { if (event.currentTarget.value)
63
- void props.open(event.currentTarget.value); }, children: [_jsx("option", { value: "", children: t(editor?.revision === null ? "newDraft" : "choose") }), snapshot.profiles.map((profile, index) => _jsxs("option", { value: profile.id, children: [profile.label === undefined ? profile.id : `${profile.label} (${profile.id})`, profile.error === undefined ? "" : ` — ${t("invalidProfile", { id: profile.id })}`] }, `${index}:${profile.id}`))] }), snapshot.profiles.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("empty") })] }), state.pendingEditor !== null && _jsxs("div", { className: "dsmm-confirm", role: "group", "aria-labelledby": `${prefix}-confirm`, onKeyDown: (event) => { if (event.key === "Escape") {
64
- event.preventDefault();
65
- props.cancelDiscard();
66
- } }, children: [_jsx("p", { id: `${prefix}-confirm`, children: t("discardPrompt") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => { void props.discardAndOpen(); }, children: t("discard") }), _jsx(Button, { ref: cancelRef, type: "button", variant: "primary", onClick: props.cancelDiscard, children: t("cancel") })] })] }), _jsx(SessionScope, { state: state, actions: props, t: t }), _jsxs("div", { className: "dsmm-catalog", children: [_jsx("h3", { children: t("catalogTitle") }), _jsx("p", { className: "dsmm-hint", children: t("catalogHint") }), state.catalogUnavailable && _jsx("p", { className: "dsmm-hint", children: t("catalogUnavailable") }), state.catalog?.failures.map((failure) => _jsx("p", { className: "dsmm-hint", children: t("catalogFailure", { name: failure.name, id: failure.id }) }, failure.id)), _jsx(Button, { type: "button", variant: "outline", disabled: state.catalogBusy, onClick: () => { void props.refreshCatalog(); }, children: t(state.catalogBusy ? "catalogRefreshing" : "catalogRefresh") })] }), editor !== null && _jsxs("div", { className: "dsmm-editor", children: [_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) => props.editId(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })] }), _jsx(StructuredEditor, { state: state, actions: props, disabled: editorDisabled, t: t }, state.editorEpoch), _jsxs("details", { className: "dsmm-advanced", open: true, children: [_jsx("summary", { children: t("advanced") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-content`, children: t("configuration") }), _jsx("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, readOnly: readOnly, disabled: disabled, "aria-invalid": rawInvalid || (invalid && !idInvalid) || undefined, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-content-hint`, className: "dsmm-hint", children: t("configurationHint") }), _jsx("p", { id: `${prefix}-structural-hint`, className: "dsmm-hint", children: t("structuralHint") })] })] }), _jsx("p", { "data-dsmm-editor-state": true, children: t(state.dirty ? "dirty" : applied ? "savedApplied" : "savedNotApplied") }), _jsx("p", { id: `${prefix}-global-action`, className: "dsmm-hint", children: t("globalActionHint") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: editorDisabled || !state.dirty || snapshot === null || state.invalidFields.length > 0, onClick: () => { void props.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), _jsx(Button, { type: "button", variant: "outline", "aria-describedby": `${prefix}-global-action`, disabled: editorDisabled || state.dirty || editor.revision === null || !reconcilable || (applied && !selectionConflict), onClick: () => { void props.apply(); }, children: t(state.busy === "apply" ? "applying" : "apply") }), editor.revision !== null && _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => { void props.reload(); }, children: t("reload") })] })] }), state.issue !== null && _jsx("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: _jsx("p", { children: t(issueKey(state.issue)) }) }), snapshot?.selectionError !== undefined && _jsx("div", { className: "dsmm-issue", children: _jsx("p", { children: t(selectionConflict ? "selectionConflict" : "retry") }) }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot === null ? t("loading") : state.busy === "read" ? t("reading") : notice })] });
76
+ const warnings = editor === null ? [] : draftWarnings(editor.content);
77
+ return _jsxs("section", { className: "dsmm-profiles", "aria-labelledby": `${prefix}-title`, "aria-busy": state.busy !== null, children: [_jsx("h2", { id: `${prefix}-title`, children: t("title") }), _jsx("p", { children: t("description") }), snapshot?.origin !== undefined && _jsx("p", { className: "dsmm-hint", children: t(snapshot.origin === "legacy" ? "legacyOrigin" : snapshot.origin === "central" ? "centralOrigin" : "explicitOrigin") }), readOnly && _jsx("p", { role: "status", className: "dsmm-hint", children: t("readOnlyOrigin") }), _jsxs("section", { className: "dsmm-zone", "aria-labelledby": `${prefix}-browse`, "data-dsmm-zone": "browse", children: [_jsx("h3", { id: `${prefix}-browse`, children: t("browseZone") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || snapshot === null, onClick: () => { void props.create(); }, children: t("new") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => { void props.refresh(); }, children: t(state.busy === "refresh" ? "refreshing" : "refresh") })] }), snapshot !== null && _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-select`, children: t("editorSelect") }), _jsxs("select", { ref: selectRef, id: `${prefix}-select`, disabled: disabled, value: editor?.revision == null ? "" : editor.id, onChange: (event) => { if (event.currentTarget.value)
78
+ void props.open(event.currentTarget.value); }, children: [_jsx("option", { value: "", children: t(editor?.revision === null ? "newDraft" : "choose") }), snapshot.profiles.map((profile, index) => _jsxs("option", { value: profile.id, children: [profile.label?.trim() ? `${profile.label} (${profile.id})` : profile.id, profile.error === undefined ? "" : ` — ${t("invalidProfile", { id: profile.id })}`, profile.warnings?.length ? ` — ${t("warningProfile")}` : ""] }, `${index}:${profile.id}`))] }), snapshot.profiles.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("empty") })] }), snapshot !== null && snapshot.profiles.length > 0 && _jsx("ul", { className: "dsmm-profile-list", "aria-label": t("savedInventory"), children: snapshot.profiles.map((profile, index) => _jsxs("li", { children: [_jsx("p", { children: profile.label?.trim() ? `${profile.label} (${profile.id})` : profile.id }), _jsx("p", { className: "dsmm-hint", children: t("savedRevision", { revision: profile.revision ?? "—" }) }), _jsx(ProfileWarnings, { warnings: profile.warnings, t: t }), profile.error !== undefined && _jsx(IssueDetails, { issue: profile.error, t: t })] }, `${index}:${profile.id}`)) }), state.pendingEditor !== null && _jsxs("div", { className: "dsmm-confirm", role: "group", "aria-labelledby": `${prefix}-confirm`, onKeyDown: (event) => { if (event.key === "Escape") {
79
+ event.preventDefault();
80
+ props.cancelDiscard();
81
+ } }, children: [_jsx("p", { id: `${prefix}-confirm`, children: t("discardPrompt") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", onClick: () => { void props.discardAndOpen(); }, children: t("discard") }), _jsx(Button, { ref: cancelRef, type: "button", variant: "primary", onClick: props.cancelDiscard, children: t("cancel") })] })] })] }), _jsxs("section", { className: "dsmm-zone", "aria-labelledby": `${prefix}-edit`, "data-dsmm-zone": "edit", children: [_jsx("h3", { id: `${prefix}-edit`, children: t("editZone") }), editor === null && _jsx("p", { className: "dsmm-hint", children: t("noEditor") }), editor !== null && _jsxs("div", { className: "dsmm-editor", children: [_jsx("p", { "data-dsmm-editor-state": true, children: t(state.dirty ? "dirty" : applied ? "savedApplied" : "savedNotApplied") }), _jsx("p", { className: "dsmm-hint", children: t("savedRevision", { revision: editor.revision ?? "—" }) }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: editorDisabled || !state.dirty || snapshot === null || state.invalidFields.length > 0, onClick: () => { void props.save(); }, children: t(state.busy === "save" ? "saving" : "save") }), editor.revision !== null && _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => { void props.reload(); }, children: t("reload") })] }), warnings.length > 0 && _jsxs("div", { children: [_jsx("p", { children: t("draftWarnings") }), _jsx(ProfileWarnings, { warnings: warnings, t: t })] }), editor.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("savedWarnings") }), _jsx(ProfileWarnings, { warnings: editor.warnings, t: t })] }) : null, _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: editorDisabled || editor.revision !== null, "aria-invalid": idInvalid || undefined, "aria-describedby": `${prefix}-id-hint${idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editId(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-id-hint`, className: "dsmm-hint", children: t("idHint") })] }), _jsxs("div", { className: "dsmm-catalog", children: [_jsx("h3", { children: t("catalogTitle") }), _jsx("p", { className: "dsmm-hint", children: t("catalogHint") }), state.catalogUnavailable && _jsx("p", { className: "dsmm-hint", children: t("catalogUnavailable") }), state.catalog?.failures.map((failure) => _jsx("p", { className: "dsmm-hint", children: t("catalogFailure", { name: failure.name, id: failure.id }) }, failure.id)), _jsx(Button, { type: "button", variant: "outline", disabled: state.catalogBusy, onClick: () => { void props.refreshCatalog(); }, children: t(state.catalogBusy ? "catalogRefreshing" : "catalogRefresh") })] }), _jsx(StructuredEditor, { state: state, actions: props, disabled: editorDisabled, t: t }, `structured:${state.editorEpoch}`), _jsxs("details", { ref: advancedRef, className: "dsmm-advanced", children: [_jsx("summary", { children: t("advanced") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-content`, children: t("configuration") }), _jsx("textarea", { ref: editorRef, id: `${prefix}-content`, rows: 12, spellCheck: false, value: editor.content, readOnly: readOnly, disabled: disabled, "aria-invalid": rawInvalid || (invalid && !idInvalid) || undefined, "aria-describedby": `${prefix}-content-hint ${prefix}-structural-hint${invalid && !idInvalid ? ` ${prefix}-issue` : ""}`, onChange: (event) => props.editContent(event.currentTarget.value) }), _jsx("p", { id: `${prefix}-content-hint`, className: "dsmm-hint", children: t("configurationHint") }), _jsx("p", { id: `${prefix}-structural-hint`, className: "dsmm-hint", children: t("structuralHint") })] })] }, `advanced:${state.editorEpoch}`)] }), state.issue !== null && _jsxs("div", { className: "dsmm-issue", id: `${prefix}-issue`, role: "alert", children: [_jsx("p", { children: t(issueKey(state.issue)) }), _jsx(IssueDetails, { issue: state.issue, t: t })] })] }), _jsxs("section", { className: "dsmm-zone", "aria-labelledby": `${prefix}-global`, "data-dsmm-zone": "future-default", children: [_jsx("h3", { id: `${prefix}-global`, children: t("globalScope") }), _jsx("p", { className: "dsmm-hint", children: t("newSessions") }), _jsx("p", { "data-dsmm-selection": true, children: selection }), _jsx("p", { className: "dsmm-hint", children: t("futurePin", { revision: snapshot?.selectionRevision ?? "—" }) }), snapshot?.selectedWarnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("futureWarnings") }), _jsx(ProfileWarnings, { warnings: snapshot.selectedWarnings, t: t })] }) : null, _jsx("p", { className: "dsmm-hint", children: t("savedOnlyHint") }), _jsx("p", { id: `${prefix}-global-action`, className: "dsmm-hint", children: t("globalActionHint") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", "aria-describedby": `${prefix}-global-action`, disabled: editorDisabled || state.dirty || editor?.revision == null || !reconcilable || (applied && !selectionConflict), onClick: () => { void props.apply(); }, children: t(state.busy === "apply" ? "applying" : "apply") }), _jsx(Button, { type: "button", variant: "outline", disabled: editorDisabled || !reconcilable || (snapshot?.selectedId === null && !selectionConflict), onClick: () => { void props.reset(); }, children: t(state.busy === "reset" ? "resetting" : "reset") })] }), snapshot?.selectionError !== undefined && _jsxs("div", { className: "dsmm-issue", children: [_jsx("p", { children: t(selectionConflict ? "selectionConflict" : "retry") }), _jsx(IssueDetails, { issue: snapshot.selectionError, t: t })] })] }), _jsx("section", { className: "dsmm-zone", "aria-label": t("sessionScope"), "data-dsmm-zone": "current-session", children: _jsx(SessionScope, { state: state, actions: props, t: t }) }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.busy === "refresh" && snapshot === null ? t("loading") : state.busy === "read" ? t("reading") : notice })] });
67
82
  }
68
83
  //# sourceMappingURL=ProfilesSection.js.map
@@ -0,0 +1,7 @@
1
+ import type { PropsLocale } from "@deepseek-ai/dsh-client-ui-slots";
2
+ import type { DsmmRoleAvailabilityState } from "../profile-types.js";
3
+ export declare function roleAvailability(value: DsmmRoleAvailabilityState | undefined): DsmmRoleAvailabilityState | undefined;
4
+ export declare function RoleAvailability({ value, t }: PropsLocale<"settings.dsmm-profiles"> & {
5
+ value?: DsmmRoleAvailabilityState;
6
+ }): import("react").JSX.Element;
7
+ //# sourceMappingURL=RoleAvailability.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { parseRoleAvailability } from "../profile-remote.js";
3
+ export function roleAvailability(value) {
4
+ if (value === undefined)
5
+ return undefined;
6
+ try {
7
+ return parseRoleAvailability(value);
8
+ }
9
+ catch {
10
+ return undefined;
11
+ }
12
+ }
13
+ export function RoleAvailability({ value, t }) {
14
+ const state = roleAvailability(value);
15
+ if (state === undefined)
16
+ return _jsx("p", { className: "dsmm-hint", children: t("availabilityUnknown") });
17
+ return _jsxs("div", { className: "dsmm-availability", "data-dsmm-role-availability": state.id, children: [_jsx("p", { children: t(state.required ? "roleRequired" : "roleOptional", { reason: state.requiredReason ?? "—" }) }), _jsx("p", { children: t("roleCeiling", { startup: t(state.startupAvailable ? "enabled" : "disabled"), deployment: t(state.deploymentEnabled ? "enabled" : "disabled"), admitted: t(state.admitted ? "enabled" : "disabled") }) }), _jsx("p", { className: "dsmm-hint", children: t("roleProvenance", { source: state.source, capture: state.capture }) }), state.reason !== undefined && _jsx("p", { children: t("roleUnavailableReason", { reason: state.reason }) })] });
18
+ }
19
+ //# sourceMappingURL=RoleAvailability.js.map
@@ -2,15 +2,17 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
2
2
  import { useEffect, useId, useState } from "react";
3
3
  import { Button, IconBranchOutlineRegular, Menu } from "@deepseek-ai/dsh-client-ui-primitives";
4
4
  import { sessionProfileLabels } from "./session-labels.js";
5
+ import { IssueDetails, ProfileWarnings, profileWarnings } from "./diagnostics.js";
6
+ import { RoleAvailability } from "./RoleAvailability.js";
7
+ import { parseSubagentRuntimeAdmissionView } from "../profile-remote.js";
8
+ import { isSafeDiagnosticField } from "../profile-diagnostics.js";
5
9
  const MENU_ISSUE_CODES = new Set(["validation", "conflict", "not-found", "lock-timeout", "unsafe-path", "io", "activation", "corrupt-selection", "limit", "busy", "maintenance", "disposed", "not-owned", "unavailable", "cancelled", "model-unconfigured", "model-choice-changed", "model-service-unavailable", "model-observation-unavailable", "model-selection-failed"]);
6
- const MENU_ROLE_FIELD = /^(?:settings\.roleRouting\.)?dsmm-(?:orchestrator|planner|plan-critic|builder|reviewer|oracle|oracle-2nd|creative|code-search|doc-search|clarifier|media-reader)(?:\.(?:primary|fallbackRoutes)(?:\[[0-7]\])?(?:\.(?:provider|model|reasoningEffort))?|\.strategy|\.rateLimit(?:\.(?:maxRetries|initialDelayMs|maxDelayMs|maxTotalDelayMs|switchAfterRateLimits|maxSwitches))?)?$/u;
7
- const MENU_COMMON_FIELD = /^(?:version|id|label|content|sessionId|expectedRevision|expectedSelectionRevision|expectedAdmissionEpoch|settings(?:\.(?:defaultActive|roleRouting|workflow|guards|runtimeRecovery|runtimePolicy))?)$/u;
8
10
  function menuIssue(issue) {
9
11
  const code = MENU_ISSUE_CODES.has(issue.code) ? issue.code : issue.kind === "transport" ? "transport" : "unavailable";
10
12
  const field = issue.field;
11
13
  // Only closed configuration grammar is displayable; never echo messages,
12
14
  // arbitrary wire fields, provider identifiers, credentials or file paths.
13
- return { code, ...(typeof field === "string" && field.length <= 128 && (MENU_ROLE_FIELD.test(field) || MENU_COMMON_FIELD.test(field)) ? { field } : {}) };
15
+ return { code, ...(isSafeDiagnosticField(field) ? { field } : {}) };
14
16
  }
15
17
  export function SessionScope({ state, actions, t, compact = false }) {
16
18
  const prefix = useId();
@@ -18,12 +20,26 @@ export function SessionScope({ state, actions, t, compact = false }) {
18
20
  const labels = session === null ? null : sessionProfileLabels(session, t);
19
21
  const selected = state.snapshot?.profiles.find((profile) => profile.id === state.sessionChoice);
20
22
  const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy !== null || state.dirty;
23
+ const current = () => actions.readProfileView().currentSessionId === state.currentSessionId;
21
24
  const allowed = session !== null && session.switchAllowed && /^[a-f0-9]{64}$|^absent$/u.test(session.selection.selectionRevision);
22
25
  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");
23
- 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("noSession") }) : _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 && !session.switchAllowed && _jsx("p", { className: "dsmm-hint", children: t("sessionBusy", { reason: session.switchUnavailableReason ?? "unavailable" }) }), _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, onChange: (event) => 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) => _jsx("option", { value: profile.id, disabled: profile.revision === null || profile.error !== undefined, children: profile.label === undefined ? profile.id : `${profile.label} (${profile.id})` }, profile.id))] })] }), state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed || (state.sessionChoice !== null && selected?.revision == null), onClick: () => { void actions.applySession(); }, children: t(state.sessionBusy === "apply" ? "sessionApplying" : "sessionApply") }), !compact && _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed, onClick: () => { 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: () => { void actions.refreshSession(); }, children: t("sessionRefresh") })] }), !compact && 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.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")
26
+ let binding = session?.subagentRuntime;
27
+ try {
28
+ if (binding !== undefined)
29
+ binding = parseSubagentRuntimeAdmissionView(binding);
30
+ }
31
+ catch {
32
+ binding = undefined;
33
+ }
34
+ 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("noSession") }) : _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", children: t("sessionUnavailable") }), session?.warnings?.length ? _jsxs("div", { children: [_jsx("p", { children: t("admissionWarnings") }), _jsx(ProfileWarnings, { warnings: session.warnings, t: t })] }) : null, session !== null && !session.switchAllowed && _jsx("p", { className: "dsmm-hint", children: t("sessionBusy", { reason: session.switchUnavailableReason ?? "unavailable" }) }), _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, onChange: (event) => { if (current())
35
+ 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: profile.revision === null || profile.error !== undefined, children: [profile.label?.trim() ? `${profile.label} (${profile.id})` : 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 || !allowed || session?.profileModel === undefined, onClick: () => { if (current())
36
+ void actions.useSessionProfileModel(); }, children: t("headerUseCurrentModel") }), session !== null && _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))] })] }), state.dirty && _jsx("p", { className: "dsmm-hint", children: t("sessionDirty") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed || (state.sessionChoice !== null && selected?.revision == null), onClick: () => { if (current())
37
+ void actions.applySession(); }, children: t(state.sessionBusy === "apply" ? "sessionApplying" : "sessionApply") }), !compact && _jsx(Button, { type: "button", variant: "outline", disabled: disabled || !allowed, onClick: () => { if (current())
38
+ 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())
39
+ void actions.refreshSession(); }, children: t("sessionRefresh") })] }), !compact && 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.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")
24
40
  : state.sessionIssue.code === "conflict" ? t("sessionConflict")
25
41
  : ["busy", "maintenance", "disposed", "not-owned"].includes(state.sessionIssue.code) ? t("sessionBusy", { reason: state.sessionIssue.code })
26
- : t(state.sessionIssue.code === "validation" ? "validation" : "sessionUnavailable") }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", "aria-atomic": "true", children: state.sessionBusy === "read" ? t("reading") : status })] });
42
+ : 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 })] });
27
43
  }
28
44
  /** Root-scoped native menu; an explicitly scoped foreign occurrence still refuses. */
29
45
  export function SessionProfiles(props) {
@@ -36,7 +52,7 @@ export function SessionProfiles(props) {
36
52
  return null;
37
53
  const { t } = props;
38
54
  const session = state.session;
39
- const admission = session?.admittedSelection ?? (session?.scope === "global-default" ? undefined : session?.selection);
55
+ const admission = session?.admittedSelection;
40
56
  const unknownCaptured = session !== null && admission === undefined;
41
57
  const current = session === null ? "__dsmm_session_unavailable__" : unknownCaptured ? "__dsmm_captured_default__" : admission?.selectedId ?? "";
42
58
  const profiles = state.snapshot?.profiles ?? [];
@@ -62,11 +78,13 @@ export function SessionProfiles(props) {
62
78
  feedback = t("headerBusy");
63
79
  else if (state.sessionNotice !== null)
64
80
  feedback = t(state.sessionNotice === "mode-on" ? "headerModeOn" : state.sessionNotice === "mode-off" ? "headerModeOff" : state.sessionNotice === "applied-with-model" ? "headerAppliedWithModel" : "headerApplied");
65
- const profileName = unknownCaptured ? t("headerCaptured") : currentSaved?.label === undefined ? admission?.selectedId ?? t("sessionBaseline") : `${currentSaved.label} (${currentSaved.id})`;
81
+ const profileName = unknownCaptured ? t("headerCaptured") : currentSaved?.revision === admission?.appliedRevision && currentSaved?.label?.trim() ? `${currentSaved.label} (${currentSaved.id})` : admission?.selectedId ?? t("sessionBaseline");
66
82
  const currentLabel = t("headerCurrentProfile", { profile: session === null ? t("headerUnavailable") : profileName });
67
83
  const entries = [{ type: "label", id: "@current", text: currentLabel }];
84
+ for (const warning of profileWarnings(session?.warnings))
85
+ entries.push({ type: "label", id: `@warning:${warning.code}`, text: t("warningMarker", { code: warning.code, field: warning.field }) });
68
86
  if (id === null && state.snapshot !== null)
69
- entries.push({ type: "label", id: "@future", text: t("sessionFutureDefault", { profile: state.snapshot.profiles.find((profile) => profile.id === state.snapshot.selectedId)?.label ?? state.snapshot.selectedId ?? t("sessionBaseline") }) });
87
+ entries.push({ type: "label", id: "@future", text: t("sessionFutureDefault", { profile: state.snapshot.profiles.find((profile) => profile.id === state.snapshot.selectedId)?.label?.trim() || state.snapshot.selectedId || t("sessionBaseline") }) });
70
88
  if (feedback !== "" && (state.sessionNotice === null || state.sessionIssue !== null))
71
89
  entries.push({ type: "label", id: "@status", text: feedback });
72
90
  const mode = session?.deepwork;
@@ -83,7 +101,7 @@ export function SessionProfiles(props) {
83
101
  entries.push({ id: "__dsmm_captured_default__", label: t("headerCaptured"), disabled: true });
84
102
  entries.push({ type: "separator", id: "@keep-separator" }, { type: "label", id: "@keep-heading", text: t("headerCompactProfiles") }, { id: "", label: t("sessionBaseline"), disabled });
85
103
  for (const profile of profiles)
86
- entries.push({ id: profile.id, label: (profile.label ?? profile.id) + (profile.error === undefined && profile.revision !== null ? "" : ` — ${t("headerSavedUnavailable")}`), disabled: disabled || profile.revision === null || profile.error !== undefined });
104
+ entries.push({ id: profile.id, label: (profile.label?.trim() ? profile.label : profile.id) + (profile.error === undefined && profile.revision !== null ? "" : ` — ${t("headerSavedUnavailable")}`) + (profileWarnings(profile.warnings).length ? ` — ${t("warningProfile")}` : ""), disabled: disabled || profile.revision === null || profile.error !== undefined });
87
105
  entries.push({ type: "separator", id: "@model-separator" }, { id: "@use-model", label: t("headerUseCurrentModel"), disabled: disabled || session?.profileModel === undefined });
88
106
  const open = openFor === id;
89
107
  return _jsxs("div", { className: "dsmm-header-profiles", "data-dsmm-header-profile": true, "aria-busy": committing, children: [_jsx(Menu, { open: open, autoFocus: true, portal: true, align: "start", className: "dsmm-profile-anchor", listClassName: "dsmm-profile-menu", items: entries, selectedId: current, footer: [{ id: "@refresh", label: t("headerCompactRefresh"), disabled: committing || state.busy !== null }], anchor: _jsx(Button, { type: "button", size: "sm", variant: "toolbar", className: "dsmm-profile-trigger", icon: _jsx(IconBranchOutlineRegular, {}), "aria-label": t("headerProfileLabel"), "aria-haspopup": "menu", "aria-expanded": open, "aria-describedby": `${prefix}-feedback`, onClick: () => setOpenFor(open ? undefined : id) }), onClose: () => setOpenFor(undefined), onSelect: (value) => {
@@ -1,10 +1,12 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } 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
+ import { DSMM_LOCALES } from "../profile-locale.js";
4
5
  import { DSMM_RATE_LIMIT_BOUNDS, normalizeRateLimitPolicy } from "../routing-policy.js";
5
6
  import { structuredDocument } from "./structured.js";
6
7
  import { RETRY_FIELD_LABEL_KEYS } from "./locales.js";
7
- const MANUAL = "__dsmm_manual__";
8
+ import { RoleAvailability, roleAvailability } from "./RoleAvailability.js";
9
+ import { EditableChoice } from "./EditableChoice.js";
8
10
  function RetryNumber({ id, name, field, value, inherited, path, disabled, actions, t }) {
9
11
  const [draft, setDraft] = useState(value === undefined ? "" : String(value));
10
12
  const [invalid, setInvalid] = useState(false);
@@ -28,19 +30,22 @@ function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t
28
30
  const group = providers.find((candidate) => candidate.id === value.provider);
29
31
  const model = group?.models.find((candidate) => candidate.id === value.model);
30
32
  const efforts = model?.reasoning?.efforts ?? [];
31
- const providerListed = group !== undefined;
32
- const modelListed = model !== undefined;
33
33
  const updateModel = (provider, modelId) => {
34
34
  // This is an explicit user change, not a catalog refresh. Clear only this
35
35
  // route's adapter-owned effort; do not save or touch the native model default.
36
36
  editRoute(path, provider, modelId);
37
37
  };
38
- return _jsxs("div", { className: "dsmm-route-fields", children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-provider`, children: t("routeProvider", { name }) }), _jsxs("select", { id: `${prefix}-provider`, disabled: disabled, value: providerListed ? value.provider : MANUAL, onChange: (event) => updateModel(event.currentTarget.value === MANUAL ? "" : event.currentTarget.value, ""), children: [_jsx("option", { value: MANUAL, children: providerListed ? t("manual") : t("manualValue", { value: value.provider || t("unset") }) }), providers.map((provider) => _jsxs("option", { value: provider.id, children: [provider.name, " (", provider.id, ")"] }, provider.id))] }), !providerListed && _jsx(Input, { "aria-label": t("manualProvider", { name }), className: "dsmm-input", value: value.provider, disabled: disabled, onChange: (event) => updateModel(event.currentTarget.value, value.model) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-model`, children: t("routeModel", { name }) }), _jsxs("select", { id: `${prefix}-model`, disabled: disabled, value: modelListed ? value.model : MANUAL, onChange: (event) => updateModel(value.provider, event.currentTarget.value === MANUAL ? "" : event.currentTarget.value), children: [_jsx("option", { value: MANUAL, children: modelListed ? t("manual") : t("manualValue", { value: value.model || t("unset") }) }), group?.models.map((candidate) => _jsxs("option", { value: candidate.id, children: [candidate.name, " (", candidate.id, ")"] }, candidate.id))] }), !modelListed && _jsx(Input, { "aria-label": t("manualModel", { name }), className: "dsmm-input", value: value.model, disabled: disabled, onChange: (event) => updateModel(value.provider, event.currentTarget.value) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${prefix}-effort`, children: t("routeEffort", { name }) }), _jsxs("select", { id: `${prefix}-effort`, disabled: disabled, value: value.reasoningEffort ?? "", onChange: (event) => edit([...path, "reasoningEffort"], event.currentTarget.value || undefined), children: [_jsx("option", { value: "", children: t("effortDefault") }), value.reasoningEffort !== undefined && !efforts.some((effort) => effort.id === value.reasoningEffort) && _jsx("option", { value: value.reasoningEffort, children: t("manualValue", { value: value.reasoningEffort }) }), efforts.map((effort) => _jsxs("option", { value: effort.id, children: [effort.name, " (", effort.id, ")"] }, effort.id))] }), _jsx(Input, { "aria-label": t("manualEffort", { name }), className: "dsmm-input", value: value.reasoningEffort ?? "", disabled: disabled, placeholder: t("effortDefault"), onChange: (event) => edit([...path, "reasoningEffort"], event.currentTarget.value || undefined) })] })] });
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) })] })] });
39
39
  }
40
40
  function PolicyFields({ value, inherited, path, name, disabled, actions, t }) {
41
41
  const prefix = useId();
42
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)) })] });
43
43
  }
44
+ function LevelFields({ level, value, path, catalog, disabled, actions, t }) {
45
+ const prefix = useId();
46
+ const mode = value === undefined ? "inherit" : value.provider === undefined ? "effort" : "route";
47
+ 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
+ }
44
49
  /** The same raw draft drives every control; there is no form-to-document rewrite. */
45
50
  export function StructuredEditor({ state, actions, disabled, t }) {
46
51
  const prefix = useId();
@@ -61,7 +66,10 @@ export function StructuredEditor({ state, actions, disabled, t }) {
61
66
  }
62
67
  catch { /* Invalid effective values remain a raw/Host validation error. */ }
63
68
  const rolePath = ["settings", "roleRouting", role?.id ?? ""];
64
- 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 || undefined) })] }), _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("p", { className: "dsmm-hint", children: t(role.enabled ? "roleEnabled" : "roleDisabled") }), _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") }), _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) => {
69
+ const availability = roleAvailability(role?.availability);
70
+ const namedRoles = document.settings.roles;
71
+ 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) => {
65
73
  const name = t("fallbackName", { name: role.label, index: index + 1 });
66
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);
67
75
  }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || (policy.fallbackRoutes?.length ?? 0) >= 32, onClick: () => {
@@ -69,6 +77,6 @@ export function StructuredEditor({ state, actions, disabled, t }) {
69
77
  actions.editPath([...rolePath, "fallbackRoutes"], [{ provider: "", model: "" }]);
70
78
  else
71
79
  actions.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
72
- }, children: t("addFallback", { name: role.label }) })] })] });
80
+ }, children: t("addFallback", { name: role.label }) })] }, role.id)] });
73
81
  }
74
82
  //# sourceMappingURL=StructuredEditor.js.map
@@ -0,0 +1,98 @@
1
+ import type { DsmmChildrenRemote } from "../role-control-remote.js";
2
+ import type { BackgroundTransitionResult, ChildSessionSnapshot, RoleControlAvailability, RoleControlDescendantsSnapshot, RoleControlErrorInfo, SubagentInterruptReceipt, SubagentPromptReceipt, SubagentPromptRequest } from "../role-control-types.js";
3
+ export interface ChildrenIssue extends Partial<RoleControlErrorInfo> {
4
+ kind: "domain" | "transport" | "protocol" | "local";
5
+ code: RoleControlErrorInfo["code"];
6
+ unknown?: boolean;
7
+ }
8
+ export type ChildImage = Extract<SubagentPromptRequest["content"][number], {
9
+ type: "image";
10
+ }>;
11
+ export interface ChildDraft {
12
+ text: string;
13
+ delivery: "queue" | "steer";
14
+ images: readonly ChildImage[];
15
+ imageBusy: boolean;
16
+ uncertain: boolean;
17
+ }
18
+ export type ChildOutcome = {
19
+ kind: "background";
20
+ receipt: BackgroundTransitionResult;
21
+ } | {
22
+ kind: "prompt";
23
+ receipt: SubagentPromptReceipt;
24
+ } | {
25
+ kind: "interrupt";
26
+ receipt: SubagentInterruptReceipt;
27
+ };
28
+ export interface ChildrenSnapshot {
29
+ sessionId: string | null;
30
+ generation: number;
31
+ snapshot: ChildSessionSnapshot | null;
32
+ descendants: RoleControlDescendantsSnapshot | null;
33
+ fresh: boolean;
34
+ reading: boolean;
35
+ issue: ChildrenIssue | null;
36
+ descendantIssue: ChildrenIssue | null;
37
+ drafts: ReadonlyMap<string, ChildDraft>;
38
+ pending: ReadonlyMap<string, "background" | "prompt" | "interrupt">;
39
+ issues: ReadonlyMap<string, ChildrenIssue>;
40
+ outcomes: ReadonlyMap<string, ChildOutcome>;
41
+ }
42
+ export interface ChildrenActions {
43
+ refresh(generation: number): Promise<void>;
44
+ background(generation: number, toolCallId: string, runId: string): Promise<void>;
45
+ prompt(generation: number, childId: string): Promise<void>;
46
+ interrupt(generation: number, childId: string): Promise<void>;
47
+ editText(generation: number, childId: string, text: string): void;
48
+ setDelivery(generation: number, childId: string, delivery: "queue" | "steer"): void;
49
+ addImages(generation: number, childId: string, files: readonly File[]): Promise<void>;
50
+ removeImage(generation: number, childId: string, image: ChildImage): void;
51
+ acknowledgeUnknown(generation: number, childId: string): void;
52
+ }
53
+ export declare const EMPTY_CHILD_DRAFT: ChildDraft;
54
+ export declare const childActionKey: (childId: string) => string;
55
+ export declare const runActionKey: (toolCallId: string, runId: string) => string;
56
+ export declare function enabled(availability: RoleControlAvailability | undefined): boolean;
57
+ /** Client presentation/draft state only. Host owns all run, inbox and admission authority. */
58
+ export declare class ChildrenController {
59
+ private readonly remote;
60
+ private current;
61
+ private owner;
62
+ private connection;
63
+ private connectionGeneration;
64
+ private observedAdmission;
65
+ private disposed;
66
+ private listeners;
67
+ readonly store: {
68
+ getSnapshot: () => ChildrenSnapshot;
69
+ subscribe: (listener: () => void) => (() => void);
70
+ };
71
+ readonly actions: ChildrenActions;
72
+ constructor(remote: DsmmChildrenRemote);
73
+ dispose(): void;
74
+ bindConnection(connection: object | null, generation?: unknown): void;
75
+ bindScope(sessionId: string | null, owner: object | null): void;
76
+ observeAdmission(sessionId: string, epoch: string): void;
77
+ private publish;
78
+ private fence;
79
+ private live;
80
+ private available;
81
+ private draft;
82
+ private child;
83
+ private editDraft;
84
+ private publishDraft;
85
+ private issue;
86
+ private unwrap;
87
+ refresh(generation: number): Promise<void>;
88
+ private begin;
89
+ private finish;
90
+ private refuse;
91
+ private accepted;
92
+ background(generation: number, toolCallId: string, runId: string): Promise<void>;
93
+ private canControl;
94
+ prompt(generation: number, id: string): Promise<void>;
95
+ interrupt(generation: number, id: string): Promise<void>;
96
+ addImages(generation: number, id: string, files: readonly File[]): Promise<void>;
97
+ }
98
+ //# sourceMappingURL=children-controller.d.ts.map