@dsmm/dsmm 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/agent-presets/dsmm-builder/agent.cordis.yml +1 -1
  2. package/agent-presets/dsmm-clarifier/agent.cordis.yml +1 -1
  3. package/agent-presets/dsmm-code-search/agent.cordis.yml +1 -1
  4. package/agent-presets/dsmm-coding/agent.cordis.yml +3 -2
  5. package/agent-presets/dsmm-complex/agent.cordis.yml +2 -1
  6. package/agent-presets/dsmm-creative/agent.cordis.yml +1 -1
  7. package/agent-presets/dsmm-cross-cutting/agent.cordis.yml +1 -1
  8. package/agent-presets/dsmm-deep/agent.cordis.yml +2 -1
  9. package/agent-presets/dsmm-doc-search/agent.cordis.yml +1 -1
  10. package/agent-presets/dsmm-documenting/agent.cordis.yml +1 -1
  11. package/agent-presets/dsmm-frontend/agent.cordis.yml +4 -2
  12. package/agent-presets/dsmm-hard-reasoning/agent.cordis.yml +1 -1
  13. package/agent-presets/dsmm-media-reader/agent.cordis.yml +1 -1
  14. package/agent-presets/dsmm-normal-task/agent.cordis.yml +3 -2
  15. package/agent-presets/dsmm-oracle/agent.cordis.yml +1 -1
  16. package/agent-presets/dsmm-oracle-2nd/agent.cordis.yml +1 -1
  17. package/agent-presets/dsmm-orchestrator/agent.cordis.yml +11 -1
  18. package/agent-presets/dsmm-plan-critic/agent.cordis.yml +1 -1
  19. package/agent-presets/dsmm-planner/agent.cordis.yml +1 -1
  20. package/agent-presets/dsmm-quick/agent.cordis.yml +2 -1
  21. package/agent-presets/dsmm-research/agent.cordis.yml +1 -1
  22. package/agent-presets/dsmm-reviewer/agent.cordis.yml +1 -1
  23. package/docs/native-permissions.md +11 -3
  24. package/docs/roadmap.md +30 -3
  25. package/docs/runtime-recovery.md +30 -2
  26. package/docs/settings-status.md +6 -4
  27. package/docs/skill-sync.md +13 -14
  28. package/lib/client/DeploymentFields.js +30 -2
  29. package/lib/client/DeploymentPage.js +29 -17
  30. package/lib/client/NativeCommandEntries.js +47 -37
  31. package/lib/client/PermissionRuleEntries.d.ts +17 -0
  32. package/lib/client/PermissionRuleEntries.js +70 -0
  33. package/lib/client/PermissionsPanel.js +8 -5
  34. package/lib/client/deployment-locales.d.ts +2 -2
  35. package/lib/client/deployment-locales.js +8 -8
  36. package/lib/client/deployment-modules.d.ts +5 -3
  37. package/lib/client/deployment-modules.js +4 -4
  38. package/lib/client/deployment-workspace.d.ts +4 -0
  39. package/lib/client/deployment-workspace.js +37 -11
  40. package/lib/client/index.js +2 -18
  41. package/lib/client/permission-controller.d.ts +23 -0
  42. package/lib/client/permission-controller.js +59 -27
  43. package/lib/client/permission-locales.d.ts +30 -4
  44. package/lib/client/permission-locales.js +42 -18
  45. package/lib/client/permission-session.d.ts +37 -0
  46. package/lib/client/permission-session.js +34 -0
  47. package/lib/client/styles.d.ts +1 -1
  48. package/lib/client/styles.js +12 -8
  49. package/lib/client.js +1491 -1153
  50. package/lib/core-permission-authority.js +28 -16
  51. package/lib/index.js +2 -9
  52. package/lib/native-admission.d.ts +3 -0
  53. package/lib/native-admission.js +60 -26
  54. package/lib/permission-controller.js +1 -1
  55. package/lib/permission-native-command.js +6 -4
  56. package/lib/permission-settings.d.ts +21 -7
  57. package/lib/permission-settings.js +21 -9
  58. package/lib/role-identity.d.ts +1 -1
  59. package/lib/role-identity.js +16 -4
  60. package/lib/role-policy.d.ts +3 -0
  61. package/lib/role-policy.js +29 -5
  62. package/lib/role-subagents.js +4 -3
  63. package/lib/runtime-integration.js +4 -4
  64. package/lib/settings.js +4 -1
  65. package/lib/state.d.ts +4 -1
  66. package/lib/state.js +37 -6
  67. package/package.json +1 -1
  68. package/prompts/deepwork.md +13 -1
  69. package/prompts/source/agents/orchestrator.md +10 -0
  70. package/prompts/source/category/coding.md +2 -1
  71. package/prompts/source/category/complex.md +1 -0
  72. package/prompts/source/category/deep.md +1 -0
  73. package/prompts/source/category/frontend.md +3 -1
  74. package/prompts/source/category/normal-task.md +2 -1
  75. package/prompts/source/category/quick.md +1 -0
  76. package/prompts/source/deepwork/claude-opus-5.md +2 -0
  77. package/prompts/source/deepwork/default.md +12 -0
  78. package/prompts/source/deepwork/gemini.md +6 -1
  79. package/prompts/source/deepwork/glm.md +5 -1
  80. package/prompts/source/deepwork/gpt.md +22 -2
  81. package/prompts/source/deepwork/kimi-k27.md +2 -0
  82. package/prompts/source/deepwork/planner.md +3 -1
  83. package/prompts/source/deepwork/swe-2.md +2 -0
  84. package/prompts/source/manifest.json +3 -68
  85. package/prompts/source/shared/dsh-host-contract.md +1 -1
  86. package/skills/ast-grep/SKILL.md +1 -1
  87. package/skills/brainstorming/SKILL.md +1 -1
  88. package/skills/coding-agent-sessions/SKILL.md +1 -1
  89. package/skills/debugging/SKILL.md +1 -1
  90. package/skills/dispatching-parallel-agents/SKILL.md +1 -1
  91. package/skills/frontend/SKILL.md +1 -1
  92. package/skills/git-master/SKILL.md +1 -1
  93. package/skills/init-deep/SKILL.md +1 -1
  94. package/skills/receiving-code-review/SKILL.md +1 -1
  95. package/skills/remove-ai-slops/SKILL.md +1 -1
  96. package/skills/requesting-code-review/SKILL.md +1 -1
  97. package/skills/subagent-driven-development/SKILL.md +1 -1
  98. package/skills/using-git-worktrees/SKILL.md +1 -1
  99. package/skills/writing-plans/SKILL.md +1 -1
package/lib/client.js CHANGED
@@ -5,8 +5,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
7
  var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
8
+ for (var name2 in all)
9
+ __defProp(target, name2, { get: all[name2], enumerable: true });
10
10
  };
11
11
  var __copyProps = (to, from2, except, desc) => {
12
12
  if (from2 && typeof from2 === "object" || typeof from2 === "function") {
@@ -969,8 +969,8 @@ function parse(text5, errors = [], options = ParseOptions.DEFAULT) {
969
969
  currentParent = object3;
970
970
  currentProperty = null;
971
971
  },
972
- onObjectProperty: (name) => {
973
- currentProperty = name;
972
+ onObjectProperty: (name2) => {
973
+ currentProperty = name2;
974
974
  },
975
975
  onObjectEnd: () => {
976
976
  currentParent = previousParents.pop();
@@ -1009,9 +1009,9 @@ function parseTree(text5, errors = [], options = ParseOptions.DEFAULT) {
1009
1009
  onObjectBegin: (offset) => {
1010
1010
  currentParent = onValue({ type: "object", offset, length: -1, parent: currentParent, children: [] });
1011
1011
  },
1012
- onObjectProperty: (name, offset, length) => {
1012
+ onObjectProperty: (name2, offset, length) => {
1013
1013
  currentParent = onValue({ type: "property", offset, length: -1, parent: currentParent, children: [] });
1014
- currentParent.children.push({ type: "string", value: name, offset, length, parent: currentParent });
1014
+ currentParent.children.push({ type: "string", value: name2, offset, length, parent: currentParent });
1015
1015
  },
1016
1016
  onObjectEnd: (offset, length) => {
1017
1017
  ensurePropertyComplete(offset + length);
@@ -2416,10 +2416,10 @@ Schema.extend("transform", (data, { inner, callback, preserve }, options) => {
2416
2416
  else return [callback(result), callback(adapted)];
2417
2417
  });
2418
2418
  var formatters = {};
2419
- function defineMethod(name, keys, format2) {
2420
- formatters[name] = format2;
2421
- Object.assign(Schema, { [name](...args) {
2422
- const schema = new Schema({ type: name });
2419
+ function defineMethod(name2, keys, format2) {
2420
+ formatters[name2] = format2;
2421
+ Object.assign(Schema, { [name2](...args) {
2422
+ const schema = new Schema({ type: name2 });
2423
2423
  keys.forEach((key, index) => {
2424
2424
  switch (key) {
2425
2425
  case "sKey":
@@ -2455,9 +2455,9 @@ function defineMethod(name, keys, format2) {
2455
2455
  schema[key] = args[index];
2456
2456
  }
2457
2457
  });
2458
- if (name === "object" || name === "dict") schema.meta.default = {};
2459
- else if (name === "array" || name === "tuple") schema.meta.default = [];
2460
- else if (name === "bitset") schema.meta.default = 0;
2458
+ if (name2 === "object" || name2 === "dict") schema.meta.default = {};
2459
+ else if (name2 === "array" || name2 === "tuple") schema.meta.default = [];
2460
+ else if (name2 === "bitset") schema.meta.default = 0;
2461
2461
  return schema;
2462
2462
  } });
2463
2463
  }
@@ -2593,6 +2593,14 @@ function parsePermissionRulesSave(value) {
2593
2593
  }
2594
2594
 
2595
2595
  // src/permission-settings.ts
2596
+ function parseNativeCommandPattern(input) {
2597
+ if (typeof input !== "string" || input.length > 32768) throw new PermissionRefusal("validation");
2598
+ const tokens = input.replace(/^[ \t]+|[ \t]+$/gu, "").split(/[ \t]+/u);
2599
+ if (tokens.length !== 2 && (tokens.length !== 3 || tokens[2] !== "*") || tokens[0].length === 0 || /[^\p{L}\p{M}\p{N}_./:=+%\\\-]/u.test(tokens[0])) throw new PermissionRefusal("validation");
2600
+ const subcommands = tokens[1].split("|");
2601
+ if (subcommands.some((value) => value.length === 0 || /[^\p{L}\p{M}\p{N}_./:=+%\-]/u.test(value))) throw new PermissionRefusal("validation");
2602
+ return Object.freeze({ executable: tokens[0], subcommands: Object.freeze(subcommands) });
2603
+ }
2596
2604
  function parseNativeCommands(input = {}) {
2597
2605
  const row = permissionRuleRow(input, [], ["enabled", "entries"]);
2598
2606
  if (row.enabled !== void 0 && typeof row.enabled !== "boolean" || row.entries !== void 0 && (!Array.isArray(row.entries) || row.entries.length > 1024)) throw new PermissionRefusal("validation");
@@ -2602,30 +2610,22 @@ function parseNativeCommands(input = {}) {
2602
2610
  };
2603
2611
  const ids = /* @__PURE__ */ new Set();
2604
2612
  const entries = (row.entries ?? []).map((value) => {
2605
- const entry = permissionRuleRow(value, ["id", "mode", "match", "sandboxMode"]), match = permissionRuleRow(entry.match, ["tool", "executable", "args", "workingDirectory"], ["subcommand"]);
2613
+ const entry = permissionRuleRow(value, ["id", "mode", "match", "sandboxMode"]);
2614
+ const match = permissionRuleRow(entry.match, ["tool", "workingDirectory", "commandPattern"]);
2606
2615
  const id2 = text5(entry.id), cwd = text5(match.workingDirectory);
2607
- if (ids.has(id2) || !["ask", "allow"].includes(entry.mode) || !["bash", "pwsh"].includes(match.tool) || !["workspace-write", "danger-full-access"].includes(entry.sandboxMode) || !/^(?:\/|[a-z]:[\\/]|\\\\[^\\/]+[\\/][^\\/]+(?:[\\/]|$))/iu.test(cwd) || !Array.isArray(match.args)) throw new PermissionRefusal("validation");
2616
+ if (ids.has(id2) || !["ask", "allow"].includes(entry.mode) || !["bash", "pwsh"].includes(match.tool) || !["workspace-write", "danger-full-access"].includes(entry.sandboxMode) || !/^(?:\/|[a-z]:[\\/]|\\\\[^\\/]+[\\/][^\\/]+(?:[\\/]|$))/iu.test(cwd)) throw new PermissionRefusal("validation");
2608
2617
  ids.add(id2);
2609
- return Object.freeze({ id: id2, mode: entry.mode, sandboxMode: entry.sandboxMode, match: Object.freeze({
2610
- tool: match.tool,
2611
- executable: text5(match.executable),
2612
- ...match.subcommand === void 0 ? {} : { subcommand: text5(match.subcommand) },
2613
- args: Object.freeze(match.args.map(text5)),
2614
- workingDirectory: cwd
2615
- }) });
2618
+ parseNativeCommandPattern(match.commandPattern);
2619
+ const parsed = { tool: match.tool, workingDirectory: cwd, commandPattern: match.commandPattern };
2620
+ return Object.freeze({ id: id2, mode: entry.mode, sandboxMode: entry.sandboxMode, match: Object.freeze(parsed) });
2616
2621
  });
2617
2622
  return Object.freeze({ enabled: row.enabled ?? false, entries: Object.freeze(entries) });
2618
2623
  }
2624
+ var nativeCommandMatchSchema = Schema.object({ tool: Schema.union(["bash", "pwsh"]).required(), workingDirectory: Schema.string().required(), commandPattern: Schema.string().required() }).required();
2619
2625
  var nativeCommands = Schema.object({ enabled: Schema.boolean().default(false), entries: Schema.array(Schema.object({
2620
2626
  id: Schema.string().required(),
2621
2627
  mode: Schema.union(["ask", "allow"]).required(),
2622
- match: Schema.object({
2623
- tool: Schema.union(["bash", "pwsh"]).required(),
2624
- executable: Schema.string().required(),
2625
- subcommand: Schema.string(),
2626
- args: Schema.array(Schema.string()).required(),
2627
- workingDirectory: Schema.string().required()
2628
- }).required(),
2628
+ match: nativeCommandMatchSchema,
2629
2629
  sandboxMode: Schema.union(["workspace-write", "danger-full-access"]).required()
2630
2630
  })).default([]) });
2631
2631
  var webDefault = Object.freeze({ enabled: true, rule: "inherit" });
@@ -4715,7 +4715,7 @@ function EditableChoice({ id: id2, label, value, options, disabled, placeholder,
4715
4715
 
4716
4716
  // src/client/StructuredEditor.tsx
4717
4717
  var import_jsx_runtime4 = require("react/jsx-runtime");
4718
- function RetryNumber({ id: id2, name, field, value, inherited, path, disabled, actions: actions2, t }) {
4718
+ function RetryNumber({ id: id2, name: name2, field, value, inherited, path, disabled, actions: actions3, t }) {
4719
4719
  const [draft2, setDraft] = (0, import_react2.useState)(value === void 0 ? "" : String(value));
4720
4720
  const [invalid2, setInvalid] = (0, import_react2.useState)(false);
4721
4721
  const [min, max] = DSMM_RATE_LIMIT_BOUNDS[field];
@@ -4725,11 +4725,11 @@ function RetryNumber({ id: id2, name, field, value, inherited, path, disabled, a
4725
4725
  setInvalid(false);
4726
4726
  }, [value]);
4727
4727
  (0, import_react2.useEffect)(() => {
4728
- actions2.setFieldInvalid(key, invalid2);
4729
- return () => actions2.setFieldInvalid(key, false);
4730
- }, [actions2.setFieldInvalid, key, invalid2]);
4728
+ actions3.setFieldInvalid(key, invalid2);
4729
+ return () => actions3.setFieldInvalid(key, false);
4730
+ }, [actions3.setFieldInvalid, key, invalid2]);
4731
4731
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4732
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: id2, children: t("retryField", { name, field: t(RETRY_FIELD_LABEL_KEYS[field]) }) }),
4732
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: id2, children: t("retryField", { name: name2, field: t(RETRY_FIELD_LABEL_KEYS[field]) }) }),
4733
4733
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4734
4734
  import_dsh_client_ui_primitives2.Input,
4735
4735
  {
@@ -4751,8 +4751,8 @@ function RetryNumber({ id: id2, name, field, value, inherited, path, disabled, a
4751
4751
  setDraft(input.value);
4752
4752
  const valid = input.validity.valid && (input.value === "" || Number.isSafeInteger(input.valueAsNumber));
4753
4753
  setInvalid(!valid);
4754
- actions2.setFieldInvalid(key, !valid);
4755
- if (valid) actions2.editPath(path, input.value === "" ? void 0 : input.valueAsNumber);
4754
+ actions3.setFieldInvalid(key, !valid);
4755
+ if (valid) actions3.editPath(path, input.value === "" ? void 0 : input.valueAsNumber);
4756
4756
  }
4757
4757
  }
4758
4758
  ),
@@ -4760,7 +4760,7 @@ function RetryNumber({ id: id2, name, field, value, inherited, path, disabled, a
4760
4760
  invalid2 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { id: `${id2}-invalid`, children: t("invalidNumber") })
4761
4761
  ] });
4762
4762
  }
4763
- function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t }) {
4763
+ function RouteFields({ value, path, name: name2, catalog, disabled, edit, editRoute, t }) {
4764
4764
  const prefix = (0, import_react2.useId)();
4765
4765
  const providers = catalog?.groups ?? [];
4766
4766
  const group = providers.find((candidate) => candidate.id === value.provider);
@@ -4771,12 +4771,12 @@ function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t
4771
4771
  };
4772
4772
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-route-fields", children: [
4773
4773
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4774
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-provider`, children: t("routeProvider", { name }) }),
4774
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-provider`, children: t("routeProvider", { name: name2 }) }),
4775
4775
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4776
4776
  EditableChoice,
4777
4777
  {
4778
4778
  id: `${prefix}-provider`,
4779
- label: t("routeProvider", { name }),
4779
+ label: t("routeProvider", { name: name2 }),
4780
4780
  value: value.provider,
4781
4781
  options: providers,
4782
4782
  disabled,
@@ -4786,12 +4786,12 @@ function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t
4786
4786
  )
4787
4787
  ] }),
4788
4788
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4789
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-model`, children: t("routeModel", { name }) }),
4789
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-model`, children: t("routeModel", { name: name2 }) }),
4790
4790
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4791
4791
  EditableChoice,
4792
4792
  {
4793
4793
  id: `${prefix}-model`,
4794
- label: t("routeModel", { name }),
4794
+ label: t("routeModel", { name: name2 }),
4795
4795
  value: value.model,
4796
4796
  options: group?.models ?? [],
4797
4797
  disabled,
@@ -4800,12 +4800,12 @@ function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t
4800
4800
  )
4801
4801
  ] }),
4802
4802
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4803
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-effort`, children: t("routeEffort", { name }) }),
4803
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-effort`, children: t("routeEffort", { name: name2 }) }),
4804
4804
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
4805
4805
  EditableChoice,
4806
4806
  {
4807
4807
  id: `${prefix}-effort`,
4808
- label: t("routeEffort", { name }),
4808
+ label: t("routeEffort", { name: name2 }),
4809
4809
  value: value.reasoningEffort ?? "",
4810
4810
  options: efforts,
4811
4811
  disabled,
@@ -4816,29 +4816,29 @@ function RouteFields({ value, path, name, catalog, disabled, edit, editRoute, t
4816
4816
  ] })
4817
4817
  ] });
4818
4818
  }
4819
- function PolicyFields({ value, inherited, path, name, disabled, actions: actions2, t }) {
4819
+ function PolicyFields({ value, inherited, path, name: name2, disabled, actions: actions3, t }) {
4820
4820
  const prefix = (0, import_react2.useId)();
4821
4821
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-policy-fields", children: [
4822
4822
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4823
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-strategy`, children: t("strategy", { name }) }),
4824
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-strategy`, disabled, value: value.strategy ?? "", onChange: (event) => actions2.editPath([...path, "strategy"], event.currentTarget.value || void 0), children: [
4823
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-strategy`, children: t("strategy", { name: name2 }) }),
4824
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-strategy`, disabled, value: value.strategy ?? "", onChange: (event) => actions3.editPath([...path, "strategy"], event.currentTarget.value || void 0), children: [
4825
4825
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "", children: t("inheritStrategy", { value: inherited?.strategy ?? t("unknownDefault") }) }),
4826
4826
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "startup-lock", children: t("startupLock") }),
4827
4827
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "rate-limit-fallback", children: t("rateFallback") })
4828
4828
  ] })
4829
4829
  ] }),
4830
4830
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("strategyHint") }),
4831
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "dsmm-route-fields", children: Object.keys(DSMM_RATE_LIMIT_BOUNDS).map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RetryNumber, { id: `${prefix}-${field}`, t, name, field, value: value.rateLimit?.[field], inherited: inherited?.rateLimit[field], path: [...path, "rateLimit", field], disabled, actions: actions2 }, field)) })
4831
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "dsmm-route-fields", children: Object.keys(DSMM_RATE_LIMIT_BOUNDS).map((field) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RetryNumber, { id: `${prefix}-${field}`, t, name: name2, field, value: value.rateLimit?.[field], inherited: inherited?.rateLimit[field], path: [...path, "rateLimit", field], disabled, actions: actions3 }, field)) })
4832
4832
  ] });
4833
4833
  }
4834
- function LevelFields({ level: level2, value, path, catalog, disabled, actions: actions2, t }) {
4834
+ function LevelFields({ level: level2, value, path, catalog, disabled, actions: actions3, t }) {
4835
4835
  const prefix = (0, import_react2.useId)();
4836
4836
  const mode = value === void 0 ? "inherit" : value.provider === void 0 ? "effort" : "route";
4837
4837
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { "data-dsmm-level": level2, children: [
4838
4838
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: t("levelName", { level: level2 }) }),
4839
4839
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4840
4840
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-mode`, children: t("levelMode", { level: level2 }) }),
4841
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-mode`, value: mode, disabled, onChange: (event) => actions2.editPath(
4841
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-mode`, value: mode, disabled, onChange: (event) => actions3.editPath(
4842
4842
  path,
4843
4843
  event.currentTarget.value === "inherit" ? void 0 : event.currentTarget.value === "effort" ? { reasoningEffort: "" } : { provider: "", model: "" }
4844
4844
  ), children: [
@@ -4857,14 +4857,14 @@ function LevelFields({ level: level2, value, path, catalog, disabled, actions: a
4857
4857
  value: value?.reasoningEffort ?? "",
4858
4858
  options: [],
4859
4859
  disabled,
4860
- onChange: (effort) => actions2.editPath([...path, "reasoningEffort"], effort)
4860
+ onChange: (effort) => actions3.editPath([...path, "reasoningEffort"], effort)
4861
4861
  }
4862
4862
  )
4863
4863
  ] }),
4864
- value?.provider !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RouteFields, { value, path, name: t("levelName", { level: level2 }), catalog, disabled, edit: actions2.editPath, editRoute: actions2.editRoute, t })
4864
+ value?.provider !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RouteFields, { value, path, name: t("levelName", { level: level2 }), catalog, disabled, edit: actions3.editPath, editRoute: actions3.editRoute, t })
4865
4865
  ] });
4866
4866
  }
4867
- function StructuredEditor({ state, actions: actions2, disabled, t }) {
4867
+ function StructuredEditor({ state, actions: actions3, disabled, t }) {
4868
4868
  const prefix = (0, import_react2.useId)();
4869
4869
  const [selectedRole, setSelectedRole] = (0, import_react2.useState)("dsmm-orchestrator");
4870
4870
  const document2 = state.editor === null ? null : structuredDocument(state.editor.content);
@@ -4888,12 +4888,12 @@ function StructuredEditor({ state, actions: actions2, disabled, t }) {
4888
4888
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-structured", "data-dsmm-structured": true, children: [
4889
4889
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4890
4890
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-label`, children: t("profileLabel") }),
4891
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Input, { id: `${prefix}-label`, className: "dsmm-input", value: document2.label ?? "", disabled, onChange: (event) => actions2.editPath(["label"], event.currentTarget.value) }),
4892
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: disabled || document2.label === void 0, onClick: () => actions2.editPath(["label"], void 0), children: t("omitLabel") })
4891
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Input, { id: `${prefix}-label`, className: "dsmm-input", value: document2.label ?? "", disabled, onChange: (event) => actions3.editPath(["label"], event.currentTarget.value) }),
4892
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: disabled || document2.label === void 0, onClick: () => actions3.editPath(["label"], void 0), children: t("omitLabel") })
4893
4893
  ] }),
4894
4894
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4895
4895
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-locale`, children: t("businessLocale") }),
4896
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-locale`, value: String(document2.settings.locale ?? ""), disabled, "aria-describedby": `${prefix}-locale-hint`, onChange: (event) => actions2.editPath(["settings", "locale"], event.currentTarget.value || void 0), children: [
4896
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-locale`, value: String(document2.settings.locale ?? ""), disabled, "aria-describedby": `${prefix}-locale-hint`, onChange: (event) => actions3.editPath(["settings", "locale"], event.currentTarget.value || void 0), children: [
4897
4897
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "", children: t("inheritLocale") }),
4898
4898
  typeof document2.settings.locale === "string" && !DSMM_LOCALES.includes(document2.settings.locale) && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: document2.settings.locale, children: t("unsupportedLocale") }),
4899
4899
  DSMM_LOCALES.map((locale) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: locale, children: locale }, locale))
@@ -4902,7 +4902,7 @@ function StructuredEditor({ state, actions: actions2, disabled, t }) {
4902
4902
  ] }),
4903
4903
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4904
4904
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-topology`, children: t("toolTopology") }),
4905
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-topology`, value: topology ?? "", disabled, "aria-describedby": `${prefix}-topology-hint`, onChange: (event) => actions2.editPath(["settings", "subagents", "toolTopology"], event.currentTarget.value || void 0), children: [
4905
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-topology`, value: topology ?? "", disabled, "aria-describedby": `${prefix}-topology-hint`, onChange: (event) => actions3.editPath(["settings", "subagents", "toolTopology"], event.currentTarget.value || void 0), children: [
4906
4906
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "", children: t("inherit") }),
4907
4907
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "per-role", children: "per-role" }),
4908
4908
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "parameterized", children: "parameterized" })
@@ -4911,7 +4911,7 @@ function StructuredEditor({ state, actions: actions2, disabled, t }) {
4911
4911
  ] }),
4912
4912
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4913
4913
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-active`, children: t("defaultActive") }),
4914
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-active`, disabled, value: document2.settings.defaultActive === void 0 ? "" : String(document2.settings.defaultActive), onChange: (event) => actions2.editPath(["settings", "defaultActive"], event.currentTarget.value === "" ? void 0 : event.currentTarget.value === "true"), children: [
4914
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-active`, disabled, value: document2.settings.defaultActive === void 0 ? "" : String(document2.settings.defaultActive), onChange: (event) => actions3.editPath(["settings", "defaultActive"], event.currentTarget.value === "" ? void 0 : event.currentTarget.value === "true"), children: [
4915
4915
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "", children: t("inherit") }),
4916
4916
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "true", children: t("enabled") }),
4917
4917
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "false", children: t("disabled") })
@@ -4920,7 +4920,7 @@ function StructuredEditor({ state, actions: actions2, disabled, t }) {
4920
4920
  ] }),
4921
4921
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { children: [
4922
4922
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: t("profileDefaults") }),
4923
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PolicyFields, { t, value: document2.runtimePolicy, inherited: baseline, path: ["settings", "runtimePolicy"], name: t("profileDefaults"), disabled, actions: actions2 })
4923
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PolicyFields, { t, value: document2.runtimePolicy, inherited: baseline, path: ["settings", "runtimePolicy"], name: t("profileDefaults"), disabled, actions: actions3 })
4924
4924
  ] }),
4925
4925
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4926
4926
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-role`, children: t("roleSelect") }),
@@ -4937,51 +4937,51 @@ function StructuredEditor({ state, actions: actions2, disabled, t }) {
4937
4937
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RoleAvailability, { value: role3.availability, t }),
4938
4938
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4939
4939
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-role-enabled`, children: t("namedRole", { name: role3.label }) }),
4940
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-role-enabled`, value: namedRoles?.[role3.id] === void 0 ? "" : String(namedRoles[role3.id]), disabled, "aria-describedby": `${prefix}-role-hint`, onChange: (event) => actions2.editPath(["settings", "roles", role3.id], event.currentTarget.value === "" ? void 0 : event.currentTarget.value === "true"), children: [
4940
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-role-enabled`, value: namedRoles?.[role3.id] === void 0 ? "" : String(namedRoles[role3.id]), disabled, "aria-describedby": `${prefix}-role-hint`, onChange: (event) => actions3.editPath(["settings", "roles", role3.id], event.currentTarget.value === "" ? void 0 : event.currentTarget.value === "true"), children: [
4941
4941
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "", children: t("inherit") }),
4942
4942
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "true", disabled: availability2 === void 0 || !availability2.startupAvailable || !availability2.deploymentEnabled || availability2.reason === "module-off", children: t("enabled") }),
4943
4943
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "false", disabled: availability2 === void 0 || availability2.required, children: t("disabled") })
4944
4944
  ] }),
4945
4945
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { id: `${prefix}-role-hint`, className: "dsmm-hint", children: t("namedRoleHint") })
4946
4946
  ] }),
4947
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PolicyFields, { t, value: policy, inherited, path: rolePath, name: role3.label, disabled, actions: actions2 }),
4947
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PolicyFields, { t, value: policy, inherited, path: rolePath, name: role3.label, disabled, actions: actions3 }),
4948
4948
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4949
4949
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-primary-mode`, children: t("primaryMode", { name: role3.label }) }),
4950
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-primary-mode`, disabled, value: policy.primary === void 0 ? "inherit" : "explicit", onChange: (event) => actions2.editPath([...rolePath, "primary"], event.currentTarget.value === "inherit" ? void 0 : { provider: "", model: "" }), children: [
4950
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-primary-mode`, disabled, value: policy.primary === void 0 ? "inherit" : "explicit", onChange: (event) => actions3.editPath([...rolePath, "primary"], event.currentTarget.value === "inherit" ? void 0 : { provider: "", model: "" }), children: [
4951
4951
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "inherit", children: t("inheritRoute") }),
4952
4952
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "explicit", children: t("configuredRoute") })
4953
4953
  ] })
4954
4954
  ] }),
4955
- policy.primary !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RouteFields, { t, value: policy.primary, path: [...rolePath, "primary"], name: t("primaryName", { name: role3.label }), catalog: state.catalog, disabled, edit: actions2.editPath, editRoute: actions2.editRoute }),
4955
+ policy.primary !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RouteFields, { t, value: policy.primary, path: [...rolePath, "primary"], name: t("primaryName", { name: role3.label }), catalog: state.catalog, disabled, edit: actions3.editPath, editRoute: actions3.editRoute }),
4956
4956
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("effortChangeHint") }),
4957
4957
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("normalLevel") }),
4958
4958
  role3.id === "dsmm-orchestrator" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("orchestratorLevels") }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
4959
4959
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("levelsHint") }),
4960
- ["low", "high", "max"].map((level2) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LevelFields, { level: level2, value: policy.levels?.[level2], path: [...rolePath, "levels", level2], catalog: state.catalog, disabled, actions: actions2, t }, level2))
4960
+ ["low", "high", "max"].map((level2) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(LevelFields, { level: level2, value: policy.levels?.[level2], path: [...rolePath, "levels", level2], catalog: state.catalog, disabled, actions: actions3, t }, level2))
4961
4961
  ] }),
4962
4962
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-field", children: [
4963
4963
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("label", { htmlFor: `${prefix}-fallback-mode`, children: t("fallbackMode", { name: role3.label }) }),
4964
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-fallback-mode`, disabled, value: policy.fallbackRoutes === void 0 ? "inherit" : "explicit", onChange: (event) => actions2.editPath([...rolePath, "fallbackRoutes"], event.currentTarget.value === "inherit" ? void 0 : []), children: [
4964
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("select", { id: `${prefix}-fallback-mode`, disabled, value: policy.fallbackRoutes === void 0 ? "inherit" : "explicit", onChange: (event) => actions3.editPath([...rolePath, "fallbackRoutes"], event.currentTarget.value === "inherit" ? void 0 : []), children: [
4965
4965
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "inherit", children: t("inheritChain") }),
4966
4966
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("option", { value: "explicit", children: t("configuredChain") })
4967
4967
  ] })
4968
4968
  ] }),
4969
4969
  policy.fallbackRoutes?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: "dsmm-hint", children: t("emptyChain") }),
4970
4970
  policy.fallbackRoutes?.map((candidate, index) => {
4971
- const name = t("fallbackName", { name: role3.label, index: index + 1 });
4971
+ const name2 = t("fallbackName", { name: role3.label, index: index + 1 });
4972
4972
  return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("fieldset", { children: [
4973
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: name }),
4974
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RouteFields, { t, value: candidate, path: [...rolePath, "fallbackRoutes", index], name, catalog: state.catalog, disabled, edit: actions2.editPath, editRoute: actions2.editRoute }),
4973
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("legend", { children: name2 }),
4974
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(RouteFields, { t, value: candidate, path: [...rolePath, "fallbackRoutes", index], name: name2, catalog: state.catalog, disabled, edit: actions3.editPath, editRoute: actions3.editRoute }),
4975
4975
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "dsmm-actions", children: [
4976
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: disabled || index === 0, onClick: () => actions2.moveFallback(role3.id, index, index - 1), children: t("moveUp", { name }) }),
4977
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: disabled || index === policy.fallbackRoutes.length - 1, onClick: () => actions2.moveFallback(role3.id, index, index + 1), children: t("moveDown", { name }) }),
4978
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled, onClick: () => actions2.editPath([...rolePath, "fallbackRoutes", index], void 0), children: t("removeFallback", { name }) })
4976
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: disabled || index === 0, onClick: () => actions3.moveFallback(role3.id, index, index - 1), children: t("moveUp", { name: name2 }) }),
4977
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: disabled || index === policy.fallbackRoutes.length - 1, onClick: () => actions3.moveFallback(role3.id, index, index + 1), children: t("moveDown", { name: name2 }) }),
4978
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled, onClick: () => actions3.editPath([...rolePath, "fallbackRoutes", index], void 0), children: t("removeFallback", { name: name2 }) })
4979
4979
  ] })
4980
4980
  ] }, index);
4981
4981
  }),
4982
4982
  /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_dsh_client_ui_primitives2.Button, { type: "button", variant: "outline", disabled: disabled || (policy.fallbackRoutes?.length ?? 0) >= 32, onClick: () => {
4983
- if (policy.fallbackRoutes === void 0) actions2.editPath([...rolePath, "fallbackRoutes"], [{ provider: "", model: "" }]);
4984
- else actions2.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
4983
+ if (policy.fallbackRoutes === void 0) actions3.editPath([...rolePath, "fallbackRoutes"], [{ provider: "", model: "" }]);
4984
+ else actions3.editPath([...rolePath, "fallbackRoutes", policy.fallbackRoutes.length], { provider: "", model: "" });
4985
4985
  }, children: t("addFallback", { name: role3.label }) })
4986
4986
  ] }, role3.id)
4987
4987
  ] });
@@ -5030,14 +5030,14 @@ function menuIssue(issue) {
5030
5030
  const field = issue.field;
5031
5031
  return { code, ...isSafeDiagnosticField(field) ? { field } : {} };
5032
5032
  }
5033
- function SessionScope({ state, actions: actions2, t, compact = false }) {
5033
+ function SessionScope({ state, actions: actions3, t, compact = false }) {
5034
5034
  const prefix = (0, import_react3.useId)();
5035
5035
  const session = state.session;
5036
5036
  const labels = session === null ? null : sessionProfileLabels(session, t);
5037
5037
  const selected = state.snapshot?.profiles.find((profile) => profile.id === state.sessionChoice);
5038
5038
  const disabled = state.busy !== null || state.pendingEditor !== null || state.sessionBusy !== null || state.dirty || state.invalidFields.length > 0;
5039
5039
  const current = () => {
5040
- const live = actions2.readProfileView();
5040
+ const live = actions3.readProfileView();
5041
5041
  return live.currentSessionId === state.currentSessionId && live.sessionViewEpoch === state.sessionViewEpoch && live.session === session;
5042
5042
  };
5043
5043
  const ready = session !== null && !state.sessionUnconfirmed && !session.refreshRequired && !session.selection.refreshRequired && writableSelectionVersion(session.selection.selectionRevision);
@@ -5064,7 +5064,7 @@ function SessionScope({ state, actions: actions2, t, compact = false }) {
5064
5064
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsmm-field", children: [
5065
5065
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { htmlFor: `${prefix}-choice`, children: t("sessionSelect") }),
5066
5066
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("select", { id: `${prefix}-choice`, value: state.sessionChoice ?? "", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : void 0, onChange: (event) => {
5067
- if (current()) actions2.chooseSessionProfile(event.currentTarget.value || null);
5067
+ if (current()) actions3.chooseSessionProfile(event.currentTarget.value || null);
5068
5068
  }, children: [
5069
5069
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: t("sessionBaseline") }),
5070
5070
  state.sessionChoice !== null && selected === void 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: state.sessionChoice, children: state.sessionChoice }),
@@ -5077,7 +5077,7 @@ function SessionScope({ state, actions: actions2, t, compact = false }) {
5077
5077
  !compact && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
5078
5078
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "dsmm-hint", children: t("sessionModelHint") }),
5079
5079
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: disabled || !modelAllowed, "aria-describedby": !modelAllowed ? `${prefix}-model-reason` : void 0, onClick: () => {
5080
- if (current()) void actions2.useSessionProfileModel();
5080
+ if (current()) void actions3.useSessionProfileModel();
5081
5081
  }, children: t("headerUseCurrentModel") }),
5082
5082
  !modelAllowed && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "dsmm-hint", id: `${prefix}-model-reason`, children: capabilityReason(session?.selectModelUnavailableReason, t) }),
5083
5083
  session !== null && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("details", { children: [
@@ -5101,13 +5101,13 @@ function SessionScope({ state, actions: actions2, t, compact = false }) {
5101
5101
  state.sessionUnconfirmed && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { role: "status", children: t("sessionUnconfirmedRefresh") }),
5102
5102
  /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "dsmm-actions", children: [
5103
5103
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: disabled || !allowed || state.sessionChoice !== null && !isConfigRevision(selected?.revision), "aria-describedby": !allowed ? `${prefix}-overlay-reason` : void 0, onClick: () => {
5104
- if (current()) void actions2.applySession();
5104
+ if (current()) void actions3.applySession();
5105
5105
  }, children: t(state.sessionBusy === "apply" ? "sessionApplying" : "sessionApply") }),
5106
5106
  !compact && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: disabled || !allowed, "aria-describedby": !allowed ? `${prefix}-overlay-reason` : void 0, onClick: () => {
5107
- if (current()) void actions2.resetSession();
5107
+ if (current()) void actions3.resetSession();
5108
5108
  }, children: t(state.sessionBusy === "reset" ? "sessionResetting" : "sessionReset") }),
5109
5109
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_dsh_client_ui_primitives3.Button, { type: "button", variant: "outline", disabled: state.sessionBusy !== null || state.busy !== null || state.pendingEditor !== null, onClick: () => {
5110
- if (current()) void actions2.refreshSession();
5110
+ if (current()) void actions3.refreshSession();
5111
5111
  }, children: t("sessionRefresh") })
5112
5112
  ] })
5113
5113
  ] }),
@@ -5454,17 +5454,21 @@ var PROFILE_STYLES = `
5454
5454
  .dsmm-profiles :is(.dsmm-warning,.dsmm-diagnostic,.dsmm-availability){min-width:0;display:flex;flex-direction:column;gap:4px;overflow-wrap:anywhere}
5455
5455
  .dsmm-profiles .dsmm-warning{border-left:4px solid var(--dsw-alias-state-warn-primary);padding:8px 12px;color:var(--dsw-alias-label-primary)}
5456
5456
  .dsmm-deployment{gap:8px}
5457
- .dsmm-deployment-frame{display:grid;grid-template-columns:minmax(0,240px) minmax(0,1fr);gap:16px;min-width:0;align-items:start}
5458
- .dsmm-module-list{display:flex;flex-direction:column;gap:8px;min-width:0}
5459
- .dsmm-module-list button{justify-content:flex-start;text-align:start}
5460
- .dsmm-module-list button[aria-expanded=true]{background:var(--dsw-alias-interactive-bg-active);border-color:var(--dsw-alias-label-secondary)}
5461
- .dsmm-module-drawer{display:flex;flex-direction:column;gap:16px;min-width:0;width:100%;box-sizing:border-box;padding:16px;border:1px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-1)}
5462
- .dsmm-drawer-heading{display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between;align-items:center;min-width:0}
5463
- .dsmm-drawer-heading h2:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
5457
+ .dsmm-section-tabs{display:flex;gap:8px;min-width:0;max-width:100%;overflow-x:auto;overscroll-behavior-x:contain;border-bottom:1px solid var(--dsw-alias-border-l4);padding-bottom:2px}
5458
+ .dsmm-section-tabs button{flex:0 0 auto;justify-content:center;white-space:nowrap;border-color:transparent;border-bottom:2px solid transparent;border-radius:var(--dsw-radius-md) var(--dsw-radius-md) 0 0;background:transparent;color:var(--dsw-alias-label-secondary);font-weight:400}
5459
+ .dsmm-section-tabs button:hover{background:var(--dsw-alias-interactive-bg-hover)}
5460
+ .dsmm-section-tabs button[aria-selected=true]{background:var(--dsw-alias-interactive-bg-active);border-bottom-color:var(--dsw-alias-label-primary);color:var(--dsw-alias-label-primary);font-weight:500}
5461
+ .dsmm-section-panel{display:flex;flex-direction:column;gap:16px;min-width:0;width:100%;box-sizing:border-box}
5462
+ .dsmm-panel-heading{display:flex;flex-wrap:wrap;gap:8px;justify-content:space-between;align-items:center;min-width:0}
5463
+ .dsmm-panel-heading h2:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px}
5464
+ .dsmm-rules-transaction{padding-top:16px}
5464
5465
  .dsmm-scope-save{display:flex;flex-direction:column;gap:8px;padding-top:16px;border-top:1px solid var(--dsw-alias-border-l4)}
5465
- @media(max-width:768px){.dsmm-deployment-frame{grid-template-columns:minmax(0,1fr)}.dsmm-deployment-frame[data-drawer-open=true]>.dsmm-module-list{display:none}}
5466
5466
  .dsmm-deployment .dsmm-deployment-group{border-top:1px solid var(--dsw-alias-border-l4);padding-top:8px;min-width:0}
5467
5467
  .dsmm-deployment .dsmm-deployment-group>div{display:flex;flex-direction:column;gap:8px;padding-top:8px}
5468
+ .dsmm-deployment summary .dsmm-group-summary{display:flex;align-items:center;gap:8px;min-width:0}
5469
+ .dsmm-deployment .dsmm-group-summary-label{flex:1 1 auto;min-width:0;overflow-wrap:anywhere}
5470
+ .dsmm-deployment .dsmm-group-summary-action{flex:0 0 auto;min-height:28px;height:28px;padding:0 8px}
5471
+ .dsmm-deployment .dsmm-group-summary-action[hidden]{display:none}
5468
5472
  .dsmm-deployment code{font-family:var(--ds-font-family-code);overflow-wrap:anywhere}
5469
5473
  .dsmm-deployment label code,.dsmm-deployment summary code{margin-left:8px;font-size:12px;line-height:18px;font-weight:400;color:var(--dsw-alias-label-secondary)}
5470
5474
  .dsmm-deployment pre{margin:0;max-width:100%;white-space:pre-wrap;overflow-wrap:anywhere;font-family:var(--ds-font-family-code)}
@@ -5811,8 +5815,27 @@ var DeploymentController = class _DeploymentController {
5811
5815
  };
5812
5816
 
5813
5817
  // src/client/DeploymentPage.tsx
5814
- var import_react8 = require("react");
5815
- var import_dsh_client_ui_primitives8 = require("@deepseek-ai/dsh-client-ui-primitives");
5818
+ var import_react9 = require("react");
5819
+ var import_dsh_client_ui_primitives9 = require("@deepseek-ai/dsh-client-ui-primitives");
5820
+
5821
+ // src/client/deployment-modules.ts
5822
+ var CONFIG_MODULES = ["run", "routes", "workflow", "permissions", "state"];
5823
+ var NAVIGATION_MODULES = [...CONFIG_MODULES, "other"];
5824
+ var moduleTitle = (module2) => `module:${module2}`;
5825
+ function moduleFor(path) {
5826
+ const key = path.split(".")[0];
5827
+ if (["defaultActive", "modules", "modelParameters", "runtime"].includes(key)) return "run";
5828
+ if (["roleRouting", "runtimePolicy", "runtimeRecovery"].includes(key)) return "routes";
5829
+ if (["workflow", "roles", "skills", "presets", "businessLocale", "locale", "promptOrder", "subagents"].includes(key)) return "workflow";
5830
+ if (["permissionControl", "guards"].includes(key)) return "permissions";
5831
+ return "other";
5832
+ }
5833
+ function editableConfigField(key, layer) {
5834
+ return !["lsp", "modeName", "section"].includes(key) && !(key === "modules" && layer === "profile") && !(key === "runtime" && layer === "global");
5835
+ }
5836
+ function moduleFields(schema, module2, layer) {
5837
+ return Object.entries(schema.fields ?? {}).filter(([key]) => editableConfigField(key, layer) && moduleFor(key) === module2);
5838
+ }
5816
5839
 
5817
5840
  // src/client/deployment-workspace.ts
5818
5841
  var DeploymentWorkspace = class {
@@ -5828,6 +5851,7 @@ var DeploymentWorkspace = class {
5828
5851
  }
5829
5852
  state = { scope: "global", module: null, pending: null, native: null, revision: 0 };
5830
5853
  listeners = /* @__PURE__ */ new Set();
5854
+ visited = { global: null, profile: null };
5831
5855
  forms = null;
5832
5856
  profiles = /* @__PURE__ */ new Map();
5833
5857
  stopForm;
@@ -5894,28 +5918,44 @@ var DeploymentWorkspace = class {
5894
5918
  controller(scope = this.state.scope) {
5895
5919
  return scope === "global" ? this.core : this.state.native;
5896
5920
  }
5921
+ /** First visit opens the first section with editable fields; afterwards the last viewed section. */
5922
+ defaultSection(scope) {
5923
+ const restored = this.visited[scope];
5924
+ if (restored !== null) return restored;
5925
+ const snapshot4 = this.controller(scope)?.getSnapshot().snapshot;
5926
+ if (snapshot4 !== null && snapshot4 !== void 0) {
5927
+ const schema = scopeSchema(snapshot4, scope);
5928
+ for (const module2 of CONFIG_MODULES) if (module2 !== "state" && moduleFields(schema, module2, scope).length > 0) return module2;
5929
+ }
5930
+ return "state";
5931
+ }
5897
5932
  hasPending() {
5898
5933
  return this.controller()?.getSnapshot().dirty === true || this.state.module === "permissions" && this.permissions?.store.getSnapshot().dirty === true;
5899
5934
  }
5900
5935
  request(destination) {
5901
5936
  const switched = destination.scope !== this.state.scope;
5902
- const leaving = switched || this.state.module !== null && destination.module !== this.state.module;
5903
- if (leaving && this.hasPending()) this.changed({ pending: destination });
5904
- else {
5905
- this.changed({ ...destination, pending: null });
5906
- if (switched) void this.controller()?.refresh();
5937
+ const leaving = switched || this.state.module !== null && destination.module !== null && destination.module !== this.state.module;
5938
+ if (leaving && this.hasPending()) {
5939
+ this.changed({ pending: destination });
5940
+ return;
5907
5941
  }
5942
+ const module2 = destination.module ?? this.defaultSection(destination.scope);
5943
+ this.visited[destination.scope] = module2;
5944
+ this.changed({ scope: destination.scope, module: module2, pending: null });
5945
+ if (switched) void this.controller()?.refresh();
5908
5946
  }
5909
5947
  continueEditing() {
5910
5948
  this.changed({ pending: null });
5911
5949
  }
5950
+ /** Explicitly keep every draft and move anyway; the draft stays in contribution memory. */
5912
5951
  keepAndNavigate() {
5913
5952
  const target = this.state.pending;
5914
- if (target !== null) {
5915
- const switched = target.scope !== this.state.scope;
5916
- this.changed({ ...target, pending: null });
5917
- if (switched) void this.controller()?.refresh();
5918
- }
5953
+ if (target === null) return;
5954
+ const module2 = target.module ?? this.defaultSection(target.scope);
5955
+ this.visited[target.scope] = module2;
5956
+ const switched = target.scope !== this.state.scope;
5957
+ this.changed({ scope: target.scope, module: module2, pending: null });
5958
+ if (switched) void this.controller()?.refresh();
5919
5959
  }
5920
5960
  async discardAndNavigate() {
5921
5961
  const destination = this.state.pending;
@@ -5926,10 +5966,11 @@ var DeploymentWorkspace = class {
5926
5966
  if (controller.getSnapshot().dirty || controller.getSnapshot().issue !== null) return;
5927
5967
  }
5928
5968
  if (this.state.module === "permissions" && this.permissions?.store.getSnapshot().dirty) {
5929
- await this.permissions.refresh(this.permissions.store.getSnapshot().generation, true);
5969
+ const permissions = this.permissions.store.getSnapshot();
5970
+ await this.permissions.refresh(permissions.generation, true);
5930
5971
  if (this.permissions.store.getSnapshot().dirty) return;
5931
5972
  }
5932
- if (this.state.pending === destination) this.changed({ ...destination, pending: null });
5973
+ if (this.state.pending === destination) this.request(destination);
5933
5974
  }
5934
5975
  async save() {
5935
5976
  const controller = this.controller();
@@ -5956,28 +5997,9 @@ function deploymentWorkspace(core, permissions) {
5956
5997
  return workspace;
5957
5998
  }
5958
5999
 
5959
- // src/client/deployment-modules.ts
5960
- var CONFIG_MODULES = ["run", "routes", "workflow", "subagents", "permissions", "other", "state"];
5961
- var moduleTitle = (module2) => `module:${module2}`;
5962
- function moduleFor(path) {
5963
- const key = path.split(".")[0];
5964
- if (["defaultActive", "modules", "modelParameters", "runtime"].includes(key)) return "run";
5965
- if (["roleRouting", "runtimePolicy", "runtimeRecovery"].includes(key)) return "routes";
5966
- if (["workflow", "roles", "skills", "presets", "businessLocale", "locale", "promptOrder"].includes(key)) return "workflow";
5967
- if (key === "subagents") return "subagents";
5968
- if (["permissionControl", "guards"].includes(key)) return "permissions";
5969
- return "other";
5970
- }
5971
- function editableConfigField(key, layer) {
5972
- return !["lsp", "modeName", "section"].includes(key) && !(key === "modules" && layer === "profile") && !(key === "runtime" && layer === "global");
5973
- }
5974
- function moduleFields(schema, module2, layer) {
5975
- return Object.entries(schema.fields ?? {}).filter(([key]) => editableConfigField(key, layer) && moduleFor(key) === module2);
5976
- }
5977
-
5978
6000
  // src/client/DeploymentFields.tsx
5979
- var import_react6 = require("react");
5980
- var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
6001
+ var import_react7 = require("react");
6002
+ var import_dsh_client_ui_primitives7 = require("@deepseek-ai/dsh-client-ui-primitives");
5981
6003
 
5982
6004
  // src/client/deployment-locales.ts
5983
6005
  var DEPLOYMENT_NS = "plugins.dsmm";
@@ -5998,17 +6020,15 @@ var deploymentEn = {
5998
6020
  coreHint: "Core-owned desired settings. Model-parameter passthrough is ordinary config, not a subplugin. The permission-control enabled flag is startup-pinned. Save does not change current-session admission; inspect desired, startup and admitted values below. Unavailable admission stays unknown.",
5999
6021
  modelParametersHint: "Off stops sending custom parameters and uses native reasoning defaults. Saved values and your selected model stay unchanged.",
6000
6022
  permissionControlHint: "Permission-control mounting is startup-pinned. Saved configuration does not prove runtime coverage or remove current protections. Root rules keep their independent authority inside Permissions.",
6001
- modules: "Configuration modules",
6023
+ modules: "Configuration sections",
6002
6024
  scope: "Configuration scope",
6003
- close: "Close module",
6004
6025
  loading: "Loading configuration…",
6005
6026
  unset: "Use default configuration",
6006
6027
  "module:run": "Run and modules",
6007
6028
  "module:routes": "Model routes and recovery",
6008
- "module:workflow": "Workflow, roles and skills",
6009
- "module:subagents": "Subagent settings",
6010
- "module:permissions": "Permissions and guards",
6011
- "module:other": "Other settings",
6029
+ "module:workflow": "Workflow, roles and subagents",
6030
+ "module:permissions": "Permissions and safety",
6031
+ "module:other": "Other / advanced",
6012
6032
  "module:state": "Configuration state",
6013
6033
  saveScope: "Save selected configuration scope",
6014
6034
  pendingModules: "Pending modules in this scope",
@@ -6019,12 +6039,14 @@ var deploymentEn = {
6019
6039
  continueEditing: "Continue editing",
6020
6040
  keepDraft: "Keep draft and return",
6021
6041
  discardDraft: "Discard draft and leave",
6022
- rootRules: "Session permission rules",
6023
- rootRulesHint: "Rules save separately. Select an open main session with editing access and synchronized permissions.",
6042
+ rootRules: "Global permission rules",
6043
+ rootRulesHint: "Choose an open main session with editing access as the editor for Global rules. Saved rules persist in Global policy and affect every context that uses it; they are not session-private. This transaction saves separately from configuration.",
6024
6044
  rootRulesUnavailable: "Permission rules unavailable. Reconnect and refresh.",
6025
6045
  nativeRuntimeHint: "Native default On; Host base pins still apply. Mounting is captured at startup. Saving stages desired configuration only; it does not start/stop providers or cancel running sessions. A separate Host restart may cancel sessions.",
6026
6046
  nativeRuntimeReadinessHint: "Task progress is available in the session.",
6027
6047
  unsetGroup: "Use defaults for this group",
6048
+ unitBytes: "bytes",
6049
+ unitChars: "characters",
6028
6050
  nativeRuntimeState: "Observed native runtime",
6029
6051
  nativeRuntimeBinding: "Observed runtime composition",
6030
6052
  nativeRuntimeFence: "Execution admission ready",
@@ -6100,17 +6122,15 @@ var deploymentZh = {
6100
6122
  coreHint: "Core 所有的 desired 意图配置。模型参数透传为普通配置,非子插件;权限控制 enabled 仅启动时捕获。保存不改变当前会话准入;下方可检查意图、启动与准入值,不可用的准入仍为未知。",
6101
6123
  modelParametersHint: "关闭后停止发送自定义参数,并使用原生推理默认值;已保存的值和所选模型不变。",
6102
6124
  permissionControlHint: "权限控制挂载仅启动时捕获。保存配置不证明运行时覆盖,也不移除当前保护;Root 规则在权限模块内保持独立权限。",
6103
- modules: "配置模块",
6125
+ modules: "配置分区",
6104
6126
  scope: "配置范围",
6105
- close: "关闭模块",
6106
6127
  loading: "正在加载配置…",
6107
6128
  unset: "使用默认配置",
6108
6129
  "module:run": "运行与模块",
6109
6130
  "module:routes": "模型路由与恢复",
6110
- "module:workflow": "工作流、角色与技能",
6111
- "module:subagents": "子 Agent 设置",
6112
- "module:permissions": "权限与保护",
6113
- "module:other": "其他设置",
6131
+ "module:workflow": "工作流、角色与子 Agent",
6132
+ "module:permissions": "权限与安全",
6133
+ "module:other": "其他与高级",
6114
6134
  "module:state": "配置状态",
6115
6135
  saveScope: "保存所选配置作用域",
6116
6136
  pendingModules: "此作用域的待保存模块",
@@ -6121,12 +6141,14 @@ var deploymentZh = {
6121
6141
  continueEditing: "继续编辑",
6122
6142
  keepDraft: "保留草稿并返回",
6123
6143
  discardDraft: "放弃草稿并离开",
6124
- rootRules: "会话权限规则",
6125
- rootRulesHint: "规则单独保存。请选择已打开的主会话,并确认有编辑权限且权限已同步。",
6144
+ rootRules: "全局权限规则",
6145
+ rootRulesHint: "请选择已打开且有编辑权限的主会话作为全局规则的编辑入口。保存的规则写入全局策略,对所有使用该策略的上下文生效,并非会话私有。此事务与配置分别保存。",
6126
6146
  rootRulesUnavailable: "权限规则不可用,请重连后刷新。",
6127
6147
  nativeRuntimeHint: "原生默认开启,Host base 固定值仍适用;挂载仅启动时捕获。保存只设置 desired,不会启动/停止提供商或取消当前会话;独立 Host 重启可能取消会话。",
6128
6148
  nativeRuntimeReadinessHint: "任务进度可在会话中查看。",
6129
6149
  unsetGroup: "整组使用默认配置",
6150
+ unitBytes: "字节",
6151
+ unitChars: "字符",
6130
6152
  nativeRuntimeState: "已观测原生运行时",
6131
6153
  nativeRuntimeBinding: "已观测运行时组合",
6132
6154
  nativeRuntimeFence: "执行准入已就绪",
@@ -6252,8 +6274,10 @@ var deploymentFieldLabels = {
6252
6274
  var PERMISSIONS_NS = "settings.dsmm-permissions";
6253
6275
  var permissionEn = {
6254
6276
  title: "Permission control",
6255
- rules: "Global permission rules",
6277
+ rules: "Global permission rules (through the selected main session)",
6256
6278
  nativeApproval: "Approve commands in the native prompt. Allow approves only that call.",
6279
+ sandboxScope: "These rules decide allow, ask or deny for tools and matches. The Host sandbox and its native approval prompt remain separate and authoritative for what an approved call may touch.",
6280
+ unconfirmedObservation: "Showing the last successful observation. The current selection is not confirmed yet, so editing and saving stay unavailable.",
6257
6281
  root: "Selected main session",
6258
6282
  noRoot: "Select a main session to view its permission rules.",
6259
6283
  child: "Select this child’s main session to edit Global rules.",
@@ -6284,29 +6308,51 @@ var permissionEn = {
6284
6308
  exact: "Exact path",
6285
6309
  tree: "Path and descendants",
6286
6310
  networkLimit: "Web rules cover public web tools only. Private networks, shell commands and sockets remain outside this permission.",
6287
- rulesHint: "Saves Global rules for the selected main session. If profile overrides block saving, edit or clear them in the profile scope above, then refresh.",
6311
+ rulesHint: "Rules are edited through the selected main session but are Global policy, not session-private: saving persists them for every context that uses this policy. This transaction is separate from configuration above. If profile overrides block saving, edit or clear them in the profile scope, then refresh.",
6288
6312
  configPolicyHint: "Profile settings override Global settings. Arrays replace inherited lists. Refresh session permissions after saving to check what is effective.",
6289
- configRulesHint: "Edit existing records or imported rules with valid provenance. Use the session rules editor for verified approvals. An empty array clears inherited records.",
6313
+ configRulesHint: "Record list for this configuration layer. The form supplies ID, action and match only; the Host assigns the imported source and preserves the record version during import. Imported records are never verified approvals. Use the Global rules transaction below for operator-verified changes. An empty list is an explicit empty replacement.",
6290
6314
  coldHint: "Changing this switch requires a Host restart. Current protection stays active until then. Restart may cancel sessions.",
6291
- nativeCommands: "Exact command rules",
6292
- nativeCommandsHint: "Default Off. Match the tool, executable, subcommand, ordered arguments, directory and sandbox exactly. No wildcards. Other approval, denial and read-only restrictions still apply. New entries ask for approval and use workspace-write.",
6293
- registrationUnresolved: "Executor identity is unconfirmed. Verify the tool, executable, environment and sandbox before entering exact values.",
6315
+ guardScope: "Guard scope",
6316
+ shellSafety: "Shell command safety",
6317
+ gitWrite: "Git write approval",
6318
+ toolOutputTruncation: "Tool output truncation",
6319
+ planValidation: "Plan format validation",
6320
+ questionLabels: "Question label helper",
6321
+ todoDiscipline: "Todo discipline helper",
6322
+ maxInlineBytes: "Maximum inline output",
6323
+ maxLabelChars: "Maximum label length",
6324
+ unitBytes: "bytes",
6325
+ unitChars: "characters",
6326
+ nativeCommands: "Command rules",
6327
+ nativeCommandsHint: "Default Off. Each rule stores one command pattern: an executable and fixed subcommand alternatives, with any trailing arguments. Legacy exact executable/argument rules are rejected, not converted. Other approval, denial and read-only restrictions still apply. New entries use ask and workspace-write.",
6328
+ registrationUnresolved: "Executor identity is unconfirmed. Verify the tool, executable, environment and sandbox before entering values.",
6294
6329
  entryId: "Entry ID",
6295
- tool: "Tool (exact)",
6296
- nativeExecutable: "Executable (exact)",
6297
- subcommand: "Subcommand (optional; blank omits)",
6298
- args: "Ordered arguments (JSON string array)",
6299
- sandboxMode: "Sandbox mode (exact)",
6330
+ tool: "Tool",
6331
+ sandboxMode: "Sandbox mode",
6300
6332
  mode: "Native action",
6301
- addEntry: "Add exact entry",
6333
+ addEntry: "Add entry",
6302
6334
  removeEntry: "Remove entry",
6303
- noEntries: "No exact command entries.",
6335
+ noEntries: "No command entries.",
6304
6336
  unset: "Unset — restore inheritance",
6305
6337
  inheritedEntries: "Inherited entries; editing pins a replacement array in this layer.",
6306
6338
  explicitEntries: "Explicit replacement array in this layer.",
6307
- invalidEntry: "Invalid exact entry: use unique nonblank IDs, exact nonblank strings, an absolute Host working directory, and a JSON string array. Draft retained; Save locked.",
6339
+ invalidEntry: "Invalid entry: use unique nonblank IDs, a valid pattern, and an absolute Host working directory. Draft retained; Save locked.",
6340
+ pattern: "Command pattern",
6341
+ patternHint: "One executable, one subcommand or pipe-separated alternatives, then an optional * for the argument tail: go build|test and go build|test * both allow any trailing arguments. The * only covers trailing arguments; there is no character glob or regular expression.",
6342
+ invalidPattern: "Invalid pattern: use one executable and the subcommand position only, separated by spaces. Pipe alternatives must be nonblank literals and * may appear only as the final token.",
6343
+ patternScope: "Any trailing arguments are allowed, so the selected program can run its own builds, tests and internal scripts. This is not a path or filesystem grant, and shell pipes, chaining, redirects and substitutions still follow the ordinary native path.",
6344
+ restrictedFullAccess: "danger-full-access — retained from the saved value; not offered here",
6308
6345
  rulesUnavailable: "Editing requires an open main session, local editing permission and synchronized rules. Check profile overrides, reconnect and refresh.",
6309
- invalidArgsHint: "Correct invalid argument JSON before removing rows, or explicitly Unset this entire array to restore inheritance. Other fields do not discard invalid text.",
6346
+ configRules: "Imported configuration rules",
6347
+ inheritedRules: "Inherited records; editing pins a replacement list in this layer.",
6348
+ explicitRules: "Explicit replacement list in this layer.",
6349
+ configRulesEmpty: "This layer stores no permission rules.",
6350
+ addRule: "Add imported rule",
6351
+ removeRule: "Remove rule",
6352
+ advancedRules: "Advanced rule JSON",
6353
+ invalidRule: "Invalid rule list: use unique nonblank IDs, allow/ask/deny actions, and a complete match. Draft retained; Save locked.",
6354
+ recordedOperator: "Recorded operator source (metadata, not approval)",
6355
+ invalidPatternHint: "Correct invalid pattern text before saving. Removing a row discards only that row's draft and keeps the others; Unset replaces this whole array with the inherited list.",
6310
6356
  observedPolicy: "Effective policy (including profile overrides)",
6311
6357
  profileOverrideState: "Profile overrides",
6312
6358
  profileOverrideUnknown: "Unknown. Choose Current DSH profile above to inspect overrides.",
@@ -6330,6 +6376,7 @@ var permissionEn = {
6330
6376
  off: "Off",
6331
6377
  restart: "Independent restart required",
6332
6378
  coverageTitle: "Tool coverage",
6379
+ coverageDetails: "Details",
6333
6380
  coverage: "Last observed for this main session. Executor readiness and network access must be checked separately.",
6334
6381
  coverageUnavailable: "Coverage unavailable / unknown. No trusted live observation was returned.",
6335
6382
  coverageEmpty: "No trusted tool registrations observed for this Root.",
@@ -6365,6 +6412,7 @@ var permissionEn = {
6365
6412
  staged: "Unsaved rule changes",
6366
6413
  noRules: "No saved rules.",
6367
6414
  save: "Save",
6415
+ refresh: "Refresh rules",
6368
6416
  discard: "Discard draft and reload",
6369
6417
  dirty: "Unsaved rules draft",
6370
6418
  saved: "Rules saved. Check synchronization below.",
@@ -6382,8 +6430,10 @@ var permissionEn = {
6382
6430
  };
6383
6431
  var permissionZh = {
6384
6432
  title: "权限控制",
6385
- rules: "全局权限规则",
6433
+ rules: "全局权限规则(通过所选主会话管理)",
6386
6434
  nativeApproval: "请在原生提示中批准命令;「允许」仅批准本次调用。",
6435
+ sandboxScope: "这些规则决定工具与匹配项的允许、询问或拒绝;具体调用可触及的范围仍由宿主沙箱及其原生批准提示单独决定。",
6436
+ unconfirmedObservation: "当前显示上次成功观测;当前选择尚未确认,编辑与保存暂不可用。",
6387
6437
  root: "所选主会话",
6388
6438
  noRoot: "请选择主会话以查看权限规则。",
6389
6439
  child: "请切换到此子会话的主会话后编辑全局规则。",
@@ -6414,29 +6464,51 @@ var permissionZh = {
6414
6464
  exact: "精确路径",
6415
6465
  tree: "此路径及子树",
6416
6466
  networkLimit: "网页规则仅覆盖公共网页工具,不包含私网、Shell 命令或 socket 权限。",
6417
- rulesHint: "为所选主会话保存全局规则。若配置覆盖阻止保存,请在上方当前配置范围内编辑或清除覆盖,再刷新。",
6467
+ rulesHint: "规则通过所选主会话编辑,但属于全局策略而非会话私有:保存后对所有使用该策略的上下文生效。此事务与上方配置事务相互独立。若配置覆盖阻止保存,请在配置范围内编辑或清除覆盖,再刷新。",
6418
6468
  configPolicyHint: "当前配置优先于全局配置,数组整体替换继承列表。保存后请刷新会话权限以检查实际生效状态。",
6419
- configRulesHint: "可编辑已有记录或带合法来源的导入规则。经核验的批准请使用会话规则编辑器。空数组会清除继承的记录。",
6469
+ configRulesHint: "此配置层的记录列表。表单只提供 ID、动作与匹配条件;导入时由宿主指定来源并保留记录版本。导入记录永不被标记为已核验批准;经核验的更改请使用下方全局规则事务。空列表表示显式整体替换为空。",
6420
6470
  coldHint: "更改此开关需重启宿主,此前保留当前保护。重启可能取消会话。",
6421
- nativeCommands: "精确命令规则",
6422
- nativeCommandsHint: "默认关闭。精确匹配工具、可执行程序、子命令、有序参数、目录和沙箱,不支持通配符。其他审批、拒绝和只读限制仍有效。新条目使用询问与 workspace-write。",
6423
- registrationUnresolved: "执行器身份尚未确认,请核验工具、可执行程序、环境和沙箱后再填写精确值。",
6471
+ guardScope: "保护范围",
6472
+ shellSafety: "Shell 命令安全",
6473
+ gitWrite: "Git 写入审批",
6474
+ toolOutputTruncation: "工具输出截断",
6475
+ planValidation: "计划格式校验",
6476
+ questionLabels: "问题标签辅助",
6477
+ todoDiscipline: "Todo 纪律辅助",
6478
+ maxInlineBytes: "内联输出上限",
6479
+ maxLabelChars: "标签长度上限",
6480
+ unitBytes: "字节",
6481
+ unitChars: "字符",
6482
+ nativeCommands: "命令规则",
6483
+ nativeCommandsHint: "默认关闭。每条规则只保存一个命令模式:一个可执行程序与固定子命令备选,并允许任意后续参数。旧的精确可执行程序/参数规则会被拒绝,不会转换。其他审批、拒绝和只读限制仍有效。新条目使用询问与 workspace-write。",
6484
+ registrationUnresolved: "执行器身份尚未确认,请核验工具、可执行程序、环境和沙箱后再填写值。",
6424
6485
  entryId: "条目 ID",
6425
- tool: "工具(精确)",
6426
- nativeExecutable: "可执行程序(精确)",
6427
- subcommand: "子命令(可选,留空省略)",
6428
- args: "有序参数(JSON 字符串数组)",
6429
- sandboxMode: "沙箱模式(精确)",
6486
+ tool: "工具",
6487
+ sandboxMode: "沙箱模式",
6430
6488
  mode: "原生动作",
6431
- addEntry: "添加精确条目",
6489
+ addEntry: "添加条目",
6432
6490
  removeEntry: "移除条目",
6433
- noEntries: "没有精确命令条目。",
6491
+ noEntries: "没有命令条目。",
6434
6492
  unset: "Unset——恢复继承",
6435
6493
  inheritedEntries: "继承的条目;编辑后在此层固定为整体替换数组。",
6436
6494
  explicitEntries: "此层显式整体替换数组。",
6437
- invalidEntry: "精确条目无效:ID 需唯一且非空,精确字符串不可空,工作目录为宿主绝对路径,参数为 JSON 字符串数组。草稿保留,保存已锁定。",
6495
+ invalidEntry: "条目无效:ID 需唯一且非空,模式语法需有效,工作目录为宿主绝对路径。草稿保留,保存已锁定。",
6496
+ pattern: "命令模式",
6497
+ patternHint: "一个可执行程序、一个子命令或用竖线分隔的备选,最后可选 * 表示参数尾部;go build|test 与 go build|test * 都允许任意后续参数。* 仅覆盖后续参数,不支持字符通配或正则表达式。",
6498
+ invalidPattern: "模式无效:只允许一个可执行程序与子命令位置,以空格分隔。竖线备选须为完整非空字面量,* 只能是最后一个独立 token。",
6499
+ patternScope: "允许任意后续参数,因此被选程序可以运行自身的构建、测试和内部脚本。这不是路径或文件系统授权;shell 管道、拼接、重定向与替换仍走普通原生路径。",
6500
+ restrictedFullAccess: "danger-full-access——保留自已保存的值,此处不提供创建",
6438
6501
  rulesUnavailable: "编辑需要已打开的主会话、本地编辑权限和已同步的规则。请检查配置覆盖,重连后刷新。",
6439
- invalidArgsHint: "请修正无效参数 JSON 后再移除条目;也可显式 Unset 整个数组以恢复继承。修改其他字段不会丢弃无效文本。",
6502
+ configRules: "导入的配置规则",
6503
+ inheritedRules: "继承的记录;编辑后在此层固定为整体替换列表。",
6504
+ explicitRules: "此层显式整体替换列表。",
6505
+ configRulesEmpty: "此层没有权限规则记录。",
6506
+ addRule: "添加导入规则",
6507
+ removeRule: "移除规则",
6508
+ advancedRules: "高级规则 JSON",
6509
+ invalidRule: "规则列表无效:ID 需唯一且非空,动作为 allow/ask/deny,匹配条件完整。草稿保留,保存已锁定。",
6510
+ recordedOperator: "记录的 operator 来源(元数据,不代表批准)",
6511
+ invalidPatternHint: "请修正无效模式文本后再保存。移除某一行只丢弃该行草稿并保留其他行;Unset 则用继承列表整体替换此数组。",
6440
6512
  observedPolicy: "有效策略(含当前配置覆盖)",
6441
6513
  profileOverrideState: "配置覆盖",
6442
6514
  profileOverrideUnknown: "未知,请在上方选择当前 DSH 配置查看覆盖值。",
@@ -6460,6 +6532,7 @@ var permissionZh = {
6460
6532
  off: "关闭",
6461
6533
  restart: "需要另行重启",
6462
6534
  coverageTitle: "工具覆盖范围",
6535
+ coverageDetails: "详细信息",
6463
6536
  coverage: "所选主会话最近观测的覆盖范围,执行器就绪和网络访问需另行检查。",
6464
6537
  coverageUnavailable: "覆盖不可用/未知:未返回可信的实时观测。",
6465
6538
  coverageEmpty: "未观测到此 Root 的可信工具注册。",
@@ -6495,6 +6568,7 @@ var permissionZh = {
6495
6568
  staged: "未保存的规则更改",
6496
6569
  noRules: "尚无已保存规则。",
6497
6570
  save: "保存",
6571
+ refresh: "刷新规则",
6498
6572
  discard: "丢弃草稿并重载",
6499
6573
  dirty: "规则草稿未保存",
6500
6574
  saved: "规则已保存,请核对下方同步状态。",
@@ -6515,6 +6589,7 @@ var permissionZh = {
6515
6589
  var import_react5 = require("react");
6516
6590
  var import_dsh_client_ui_primitives5 = require("@deepseek-ai/dsh-client-ui-primitives");
6517
6591
  var import_jsx_runtime7 = require("react/jsx-runtime");
6592
+ var ENTRIES_PATH = "permissionControl.nativeCommands.entries";
6518
6593
  function validNativeEntries(entries) {
6519
6594
  try {
6520
6595
  parseNativeCommands({ entries });
@@ -6524,40 +6599,37 @@ function validNativeEntries(entries) {
6524
6599
  }
6525
6600
  }
6526
6601
  function emptyNativeEntry() {
6527
- return { id: "", mode: "ask", sandboxMode: "workspace-write", match: { tool: "bash", executable: "", args: [], workingDirectory: "" } };
6602
+ return { id: "", mode: "ask", sandboxMode: "workspace-write", match: { tool: "bash", workingDirectory: "", commandPattern: "" } };
6603
+ }
6604
+ function patternValid(value) {
6605
+ try {
6606
+ parseNativeCommandPattern(value);
6607
+ return true;
6608
+ } catch {
6609
+ return false;
6610
+ }
6528
6611
  }
6529
- function Arguments({ value, controller, name, disabled, onChange, t }) {
6530
- const state = (0, import_react5.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), id2 = (0, import_react5.useId)(), raw = state.raw[name], text5 = raw?.text ?? JSON.stringify(value), bad = raw?.invalid === true;
6612
+ function TextField({ id: id2, label, value, disabled, onChange }) {
6531
6613
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsmm-field", children: [
6532
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: id2, children: t("args") }),
6533
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("textarea", { id: id2, rows: 3, maxLength: 32768, disabled, value: text5, "aria-invalid": bad, "aria-describedby": `${id2}-error`, onChange: (event) => {
6534
- const raw2 = event.currentTarget.value;
6535
- let parsed;
6536
- try {
6537
- parsed = parseAdvanced(raw2);
6538
- } catch {
6539
- }
6540
- const valid = Array.isArray(parsed) && parsed.every((item) => typeof item === "string" && item.trim() !== "" && !item.includes("\0") && item.length <= 32768);
6541
- controller.setRaw(name, raw2, !valid);
6542
- if (valid) onChange(parsed);
6614
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: id2, children: label }),
6615
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives5.Input, { className: "dsmm-input", id: id2, value, maxLength: 32768, disabled, required: true, onChange: (event) => onChange(event.currentTarget.value) })
6616
+ ] });
6617
+ }
6618
+ function Pattern({ value, controller, name: name2, disabled, onChange, t }) {
6619
+ const state = (0, import_react5.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), id2 = (0, import_react5.useId)(), raw = state.raw[name2], text5 = raw?.text ?? value, bad = raw?.invalid === true;
6620
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsmm-field", children: [
6621
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: `${id2}-pattern`, children: t("pattern") }),
6622
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives5.Input, { className: "dsmm-input", id: `${id2}-pattern`, value: text5, maxLength: 32768, disabled, required: true, "aria-invalid": bad, "aria-describedby": bad ? `${id2}-error` : void 0, spellCheck: false, autoComplete: "off", onChange: (event) => {
6623
+ const next = event.currentTarget.value, valid = patternValid(next);
6624
+ controller.setRaw(name2, next, !valid);
6625
+ if (valid) onChange(next);
6543
6626
  } }),
6544
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { id: `${id2}-error`, className: "dsmm-hint", children: bad ? t("invalidEntry") : "" })
6627
+ bad && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { id: `${id2}-error`, className: "dsmm-hint", children: t("invalidPattern") })
6545
6628
  ] });
6546
6629
  }
6547
- function Entry({ entry, index, controller, disabled, removeDisabled, change, remove, t }) {
6548
- const id2 = (0, import_react5.useId)();
6630
+ function Entry({ entry, index, controller, disabled, change, remove, t }) {
6631
+ const id2 = (0, import_react5.useId)(), match = entry.match, row = `${ENTRIES_PATH}.${index}`;
6549
6632
  const valid = validNativeEntries([entry]);
6550
- const text5 = (key, label) => /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsmm-field", children: [
6551
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: `${id2}-${key}`, children: t(label) }),
6552
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives5.Input, { className: "dsmm-input", id: `${id2}-${key}`, value: key === "id" ? entry.id : entry.match[key] ?? "", maxLength: 32768, disabled, required: key !== "subcommand", onChange: (event) => {
6553
- const value = event.currentTarget.value;
6554
- if (key === "id") change({ ...entry, id: value });
6555
- else if (key === "subcommand" && value === "") {
6556
- const { subcommand: _omitted, ...match } = entry.match;
6557
- change({ ...entry, match });
6558
- } else change({ ...entry, match: { ...entry.match, [key]: value } });
6559
- } })
6560
- ] });
6561
6633
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("fieldset", { "aria-describedby": !valid ? `${id2}-error` : void 0, children: [
6562
6634
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("legend", { children: [
6563
6635
  t("nativeCommands"),
@@ -6565,29 +6637,33 @@ function Entry({ entry, index, controller, disabled, removeDisabled, change, rem
6565
6637
  index + 1
6566
6638
  ] }),
6567
6639
  !valid && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", id: `${id2}-error`, children: t("invalidEntry") }),
6568
- text5("id", "entryId"),
6640
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TextField, { id: `${id2}-id`, label: t("entryId"), value: entry.id, disabled, onChange: (value) => change({ ...entry, id: value }) }),
6569
6641
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsmm-field", children: [
6570
6642
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: `${id2}-tool`, children: t("tool") }),
6571
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { id: `${id2}-tool`, disabled, value: entry.match.tool, onChange: (event) => {
6643
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("select", { id: `${id2}-tool`, disabled, value: match.tool, onChange: (event) => {
6572
6644
  const tool = event.currentTarget.value;
6573
- if (tool === "bash" || tool === "pwsh") change({ ...entry, match: { ...entry.match, tool } });
6645
+ if (tool === "bash" || tool === "pwsh") change({ ...entry, match: { ...match, tool } });
6574
6646
  }, children: ["bash", "pwsh"].map((value) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value, children: value }, value)) })
6575
6647
  ] }),
6576
- text5("executable", "nativeExecutable"),
6577
- text5("subcommand", "subcommand"),
6578
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Arguments, { value: entry.match.args, controller, name: `permissionControl.nativeCommands.entries.${index}.args`, disabled, t, onChange: (args) => change({ ...entry, match: { ...entry.match, args } }) }),
6579
- text5("workingDirectory", "cwd"),
6648
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
6649
+ Pattern,
6650
+ {
6651
+ value: match.commandPattern,
6652
+ controller,
6653
+ name: `${row}.commandPattern`,
6654
+ disabled,
6655
+ t,
6656
+ onChange: (commandPattern) => change({ ...entry, match: { ...match, commandPattern } })
6657
+ }
6658
+ ),
6659
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TextField, { id: `${id2}-workingDirectory`, label: t("cwd"), value: match.workingDirectory, disabled, onChange: (workingDirectory) => change({ ...entry, match: { ...match, workingDirectory } }) }),
6580
6660
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsmm-field", children: [
6581
6661
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("label", { htmlFor: `${id2}-sandbox`, children: t("sandboxMode") }),
6582
6662
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("select", { id: `${id2}-sandbox`, disabled, value: entry.sandboxMode, onChange: (event) => {
6583
6663
  if (event.currentTarget.value === "workspace-write") change({ ...entry, sandboxMode: "workspace-write" });
6584
6664
  }, children: [
6585
6665
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "workspace-write", children: "workspace-write" }),
6586
- entry.sandboxMode === "danger-full-access" && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("option", { value: "danger-full-access", disabled: true, children: [
6587
- "danger-full-access (",
6588
- t("source"),
6589
- ")"
6590
- ] })
6666
+ entry.sandboxMode === "danger-full-access" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "danger-full-access", disabled: true, children: t("restrictedFullAccess") })
6591
6667
  ] })
6592
6668
  ] }),
6593
6669
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsmm-field", children: [
@@ -6600,7 +6676,7 @@ function Entry({ entry, index, controller, disabled, removeDisabled, change, rem
6600
6676
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("option", { value: "allow", children: t("action:allow") })
6601
6677
  ] })
6602
6678
  ] }),
6603
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_dsh_client_ui_primitives5.Button, { type: "button", variant: "outline", disabled: disabled || removeDisabled, onClick: remove, children: [
6679
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_dsh_client_ui_primitives5.Button, { type: "button", variant: "outline", disabled, onClick: remove, children: [
6604
6680
  t("removeEntry"),
6605
6681
  " ",
6606
6682
  index + 1
@@ -6608,26 +6684,40 @@ function Entry({ entry, index, controller, disabled, removeDisabled, change, rem
6608
6684
  ] });
6609
6685
  }
6610
6686
  function NativeCommandEntries({ value, inherited, controller, disabled, onChange, setInvalid, t }) {
6611
- const entries = value ?? inherited, name = "permissionControl.nativeCommands.entries";
6687
+ const entries = value ?? inherited, name2 = ENTRIES_PATH;
6612
6688
  const state = (0, import_react5.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
6613
- const invalidArgs = state.invalidFields.filter((path) => path.startsWith(`${name}.`) && path.endsWith(".args"));
6689
+ const invalidRows = state.invalidFields.filter((path) => path.startsWith(`${name2}.`) && path.endsWith(".commandPattern"));
6614
6690
  const valid = validNativeEntries(entries);
6615
6691
  const change = (next) => {
6616
- setInvalid(name, !validNativeEntries(next ?? inherited));
6692
+ setInvalid(name2, !validNativeEntries(next ?? inherited));
6617
6693
  onChange(next);
6618
6694
  };
6695
+ const remove = (index) => {
6696
+ const drafts = Object.entries(state.raw).flatMap(([path, draft2]) => {
6697
+ if (!path.startsWith(`${name2}.`)) return [];
6698
+ const [row, ...field] = path.slice(name2.length + 1).split(".");
6699
+ const position = Number(row);
6700
+ if (!Number.isInteger(position) || field.length === 0 || position === index) return [];
6701
+ return [{ path: `${name2}.${position > index ? position - 1 : position}.${field.join(".")}`, draft: draft2 }];
6702
+ });
6703
+ controller.clearRaw(name2);
6704
+ for (const draft2 of drafts) controller.setRaw(draft2.path, draft2.draft.text, draft2.draft.invalid);
6705
+ change(entries.filter((_, position) => position !== index));
6706
+ };
6619
6707
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("details", { className: "dsmm-deployment-group", children: [
6620
6708
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("summary", { children: [
6621
6709
  t("nativeCommands"),
6622
6710
  " ",
6623
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: name })
6711
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("code", { children: name2 })
6624
6712
  ] }),
6625
6713
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsmm-structured", children: [
6626
6714
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("nativeCommandsHint") }),
6715
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("patternHint") }),
6716
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("patternScope") }),
6627
6717
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("registrationUnresolved") }),
6628
6718
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t(value === void 0 ? "inheritedEntries" : "explicitEntries") }),
6629
6719
  !valid && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-issue", role: "alert", children: t("invalidEntry") }),
6630
- invalidArgs.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("invalidArgsHint") }),
6720
+ invalidRows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { className: "dsmm-hint", children: t("invalidPatternHint") }),
6631
6721
  entries.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("p", { children: t("noEntries") }),
6632
6722
  entries.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
6633
6723
  Entry,
@@ -6636,20 +6726,16 @@ function NativeCommandEntries({ value, inherited, controller, disabled, onChange
6636
6726
  index,
6637
6727
  controller,
6638
6728
  disabled,
6639
- removeDisabled: invalidArgs.length > 0,
6640
6729
  t,
6641
6730
  change: (next) => change(entries.map((row, position) => position === index ? next : row)),
6642
- remove: () => {
6643
- controller.clearRaw(name);
6644
- change(entries.filter((_, position) => position !== index));
6645
- }
6731
+ remove: () => remove(index)
6646
6732
  },
6647
6733
  index
6648
6734
  )),
6649
6735
  /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "dsmm-actions", children: [
6650
6736
  /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives5.Button, { type: "button", variant: "outline", disabled: disabled || entries.length >= 1024, onClick: () => change([...entries, emptyNativeEntry()]), children: t("addEntry") }),
6651
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives5.Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: disabled || value === void 0 && invalidArgs.length === 0, onClick: () => {
6652
- controller.clearRaw(name);
6737
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_dsh_client_ui_primitives5.Button, { type: "button", variant: "outline", "data-dsmm-unset": name2, disabled: disabled || value === void 0 && invalidRows.length === 0, onClick: () => {
6738
+ controller.clearRaw(name2);
6653
6739
  change(void 0);
6654
6740
  }, children: t("unset") })
6655
6741
  ] })
@@ -6657,12 +6743,174 @@ function NativeCommandEntries({ value, inherited, controller, disabled, onChange
6657
6743
  ] });
6658
6744
  }
6659
6745
 
6660
- // src/client/DeploymentFields.tsx
6746
+ // src/client/PermissionRuleEntries.tsx
6747
+ var import_react6 = require("react");
6748
+ var import_dsh_client_ui_primitives6 = require("@deepseek-ai/dsh-client-ui-primitives");
6661
6749
  var import_jsx_runtime8 = require("react/jsx-runtime");
6750
+ var actions = ["allow", "ask", "deny"];
6751
+ var kinds = ["outside-read", "shell", "webSearch", "webFetch"];
6752
+ var name = "permissionControl.rules";
6753
+ function validPermissionRules(value) {
6754
+ try {
6755
+ parsePermissionRules(value);
6756
+ return true;
6757
+ } catch {
6758
+ return false;
6759
+ }
6760
+ }
6761
+ function newMatch(kind) {
6762
+ return kind === "outside-read" ? { kind, path: "", scope: "exact" } : kind === "shell" ? { kind, executable: "", command: "", workingDirectory: "" } : { kind };
6763
+ }
6764
+ function newRule() {
6765
+ return { id: "", action: "ask", match: newMatch("outside-read"), source: { kind: "user-import", label: "configuration" }, revision: 0, revoked: false };
6766
+ }
6767
+ function Row({ rule, index, disabled, change, remove, t }) {
6768
+ const id2 = (0, import_react6.useId)();
6769
+ const field = (key) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-field", children: [
6770
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: `${id2}-${key}`, children: t(key === "workingDirectory" ? "cwd" : key) }),
6771
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives6.Input, { className: "dsmm-input", id: `${id2}-${key}`, required: true, maxLength: 32768, disabled, value: key in rule.match ? String(Reflect.get(rule.match, key)) : "", onChange: (event) => change({ ...rule, match: { ...rule.match, [key]: event.currentTarget.value } }) })
6772
+ ] });
6773
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("fieldset", { children: [
6774
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("legend", { children: rule.id === "" ? `${t("newRule")} ${index + 1}` : rule.id }),
6775
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { children: [
6776
+ t(rule.revoked ? "revoked" : "active"),
6777
+ " · ",
6778
+ t(`action:${rule.action}`)
6779
+ ] }),
6780
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("dl", { className: "dsmm-child-meta", children: [
6781
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("dt", { children: t("source") }),
6782
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("dd", { children: rule.source.kind === "operator" ? `${t("recordedOperator")} · ${rule.source.savedAt}` : `${t("imported")} · ${rule.source.label}` }),
6783
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("dt", { children: t("recordVersion") }),
6784
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("dd", { children: rule.revision })
6785
+ ] }),
6786
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-field", children: [
6787
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: `${id2}-id`, children: t("id") }),
6788
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives6.Input, { className: "dsmm-input", id: `${id2}-id`, required: true, maxLength: 256, disabled, value: rule.id, onChange: (event) => change({ ...rule, id: event.currentTarget.value }) })
6789
+ ] }),
6790
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-field", children: [
6791
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: `${id2}-action`, children: t("action") }),
6792
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("select", { id: `${id2}-action`, disabled, value: rule.action, onChange: (event) => {
6793
+ const action2 = actions.find((value) => value === event.currentTarget.value);
6794
+ if (action2 !== void 0) change({ ...rule, action: action2 });
6795
+ }, children: actions.map((action2) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: action2, children: t(`action:${action2}`) }, action2)) })
6796
+ ] }),
6797
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-field", children: [
6798
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: `${id2}-kind`, children: t("match") }),
6799
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("select", { id: `${id2}-kind`, disabled, value: rule.match.kind, onChange: (event) => {
6800
+ const kind = kinds.find((value) => value === event.currentTarget.value);
6801
+ if (kind !== void 0) change({ ...rule, match: newMatch(kind) });
6802
+ }, children: kinds.map((kind) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: kind, children: t(`kind:${kind}`) }, kind)) })
6803
+ ] }),
6804
+ rule.match.kind === "outside-read" && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
6805
+ field("path"),
6806
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-field", children: [
6807
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: `${id2}-scope`, children: t("pathScope") }),
6808
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { id: `${id2}-scope`, disabled, value: rule.match.scope, onChange: (event) => {
6809
+ const scope = event.currentTarget.value;
6810
+ if (rule.match.kind === "outside-read" && (scope === "exact" || scope === "tree")) change({ ...rule, match: { ...rule.match, scope } });
6811
+ }, children: [
6812
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "exact", children: t("exact") }),
6813
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "tree", children: t("tree") })
6814
+ ] })
6815
+ ] })
6816
+ ] }),
6817
+ rule.match.kind === "shell" && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
6818
+ field("executable"),
6819
+ field("command"),
6820
+ field("workingDirectory")
6821
+ ] }),
6822
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_dsh_client_ui_primitives6.Button, { type: "button", variant: "outline", disabled, onClick: remove, children: [
6823
+ t("removeRule"),
6824
+ " ",
6825
+ index + 1
6826
+ ] })
6827
+ ] });
6828
+ }
6829
+ function PermissionRuleEntries({ value, inherited, controller, disabled, onChange, expanded, onExpandedChange, t }) {
6830
+ const state = (0, import_react6.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), id2 = (0, import_react6.useId)();
6831
+ const raw = state.raw[name], locked = raw?.invalid === true, entries = value ?? inherited, valid = validPermissionRules(entries);
6832
+ const text5 = raw?.text ?? (value === void 0 ? "" : JSON.stringify(value, null, 2));
6833
+ const change = (next) => {
6834
+ if (raw !== void 0) controller.clearRaw(name);
6835
+ controller.setInvalid(name, !validPermissionRules(next));
6836
+ onChange(next);
6837
+ };
6838
+ const remove = (index) => change(entries.filter((_, position) => position !== index));
6839
+ const held = disabled || locked;
6840
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { className: "dsmm-deployment-group", "data-field": name, open: expanded, onToggle: (event) => onExpandedChange?.(event.currentTarget.open), children: [
6841
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("summary", { children: [
6842
+ t("configRules"),
6843
+ " ",
6844
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("code", { children: name })
6845
+ ] }),
6846
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-structured", children: [
6847
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: t("configRulesHint") }),
6848
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: t(value === void 0 ? "inheritedRules" : "explicitRules") }),
6849
+ !valid && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-issue", role: "alert", children: t("invalidRule") }),
6850
+ entries.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { children: t("configRulesEmpty") }),
6851
+ entries.map((rule, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
6852
+ Row,
6853
+ {
6854
+ rule,
6855
+ index,
6856
+ disabled: held,
6857
+ t,
6858
+ change: (next) => change(entries.map((row, position) => position === index ? next : row)),
6859
+ remove: () => remove(index)
6860
+ },
6861
+ index
6862
+ )),
6863
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-actions", children: [
6864
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", variant: "outline", disabled: held || entries.length >= 1024, onClick: () => change([...entries, newRule()]), children: t("addRule") }),
6865
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: disabled || value === void 0 && raw === void 0, onClick: () => {
6866
+ controller.clearRaw(name);
6867
+ onChange(void 0);
6868
+ }, children: t("unset") })
6869
+ ] }),
6870
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { children: [
6871
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("summary", { id: `${id2}-advanced-label`, children: t("advancedRules") }),
6872
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-field", children: [
6873
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("textarea", { id: `${id2}-advanced`, rows: 6, maxLength: 32768, value: text5, disabled, "aria-labelledby": `${id2}-advanced-label`, "aria-invalid": locked, "aria-describedby": `${id2}-error`, onChange: (event) => {
6874
+ const next = event.currentTarget.value;
6875
+ let parsed, ok = false;
6876
+ try {
6877
+ parsed = parseAdvanced(next);
6878
+ ok = parsed === void 0 || validPermissionRules(parsed);
6879
+ } catch {
6880
+ ok = false;
6881
+ }
6882
+ controller.setRaw(name, next, !ok);
6883
+ if (ok) onChange(parsed);
6884
+ } }),
6885
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { id: `${id2}-error`, className: "dsmm-hint", children: locked ? t("invalidRule") : "" })
6886
+ ] })
6887
+ ] })
6888
+ ] })
6889
+ ] });
6890
+ }
6891
+
6892
+ // src/client/DeploymentFields.tsx
6893
+ var import_jsx_runtime9 = require("react/jsx-runtime");
6662
6894
  var permissionText = (t) => (key) => (t("global") === "DSMM 全局配置" ? permissionZh : permissionEn)[key];
6663
6895
  function fieldLabel(path, t) {
6664
6896
  const key = path.at(-1);
6665
6897
  if (path[0] === "permissionControl" && ["outsideReads", "webSearch", "webFetch", "rules", "nativeCommands", "rule"].includes(key)) return permissionText(t)(key);
6898
+ if (path[0] === "guards") {
6899
+ const guard = {
6900
+ scope: "guardScope",
6901
+ shellCommandSafety: "shellSafety",
6902
+ gitWriteGuard: "gitWrite",
6903
+ toolOutputTruncation: "toolOutputTruncation",
6904
+ planFormatValidation: "planValidation",
6905
+ questionLabelHelper: "questionLabels",
6906
+ todoDisciplineHelper: "todoDiscipline",
6907
+ enabled: "enabled",
6908
+ maxInlineBytes: "maxInlineBytes",
6909
+ maxLabelChars: "maxLabelChars"
6910
+ };
6911
+ const mapped = guard[key];
6912
+ if (mapped !== void 0) return permissionText(t)(mapped);
6913
+ }
6666
6914
  const item = deploymentFieldLabels[key];
6667
6915
  return item === void 0 ? key.replace(/^dsmm-/u, "").replace(/([a-z])([A-Z])/gu, "$1 $2") : item[t("global") === "DSMM 全局配置" ? 1 : 0];
6668
6916
  }
@@ -6673,24 +6921,24 @@ function displayValue(value, t) {
6673
6921
  return text5.length > 120 ? `${text5.slice(0, 120)}…` : text5;
6674
6922
  }
6675
6923
  function AdvancedField({ schema, path, controller, inherited, upper, expanded, onExpandedChange, t }) {
6676
- const state = (0, import_react6.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), id2 = (0, import_react6.useId)(), name = path.join(".");
6677
- const value = at(state.draft, path), raw = state.raw[name], text5 = raw?.text ?? (value === void 0 ? "" : JSON.stringify(value, null, 2)), invalid2 = raw?.invalid === true;
6678
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { className: "dsmm-deployment-group", "data-field": name, open: expanded, onToggle: (event) => onExpandedChange?.(event.currentTarget.open), children: [
6679
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("summary", { id: `${id2}-label`, children: [
6924
+ const state = (0, import_react7.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), id2 = (0, import_react7.useId)(), name2 = path.join(".");
6925
+ const value = at(state.draft, path), raw = state.raw[name2], text5 = raw?.text ?? (value === void 0 ? "" : JSON.stringify(value, null, 2)), invalid2 = raw?.invalid === true;
6926
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: "dsmm-deployment-group", "data-field": name2, open: expanded, onToggle: (event) => onExpandedChange?.(event.currentTarget.open), children: [
6927
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("summary", { id: `${id2}-label`, children: [
6680
6928
  fieldLabel(path, t),
6681
6929
  " · ",
6682
6930
  t("advanced")
6683
6931
  ] }),
6684
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-field", children: [
6685
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", id: `${id2}-hint`, children: t("advancedHint") }),
6686
- path[0] === "permissionControl" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: permissionText(t)("configRulesHint") }),
6687
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: t(value === void 0 ? "inherit" : "explicit") }),
6688
- upper !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { className: "dsmm-hint", children: [
6932
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
6933
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", id: `${id2}-hint`, children: t("advancedHint") }),
6934
+ path[0] === "permissionControl" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: permissionText(t)("configRulesHint") }),
6935
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t(value === void 0 ? "inherit" : "explicit") }),
6936
+ upper !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "dsmm-hint", children: [
6689
6937
  t("profileSource"),
6690
6938
  ": ",
6691
6939
  displayValue(upper, t)
6692
6940
  ] }),
6693
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("textarea", { id: id2, rows: 6, maxLength: 32768, value: text5, disabled: !controller.canEdit(), "aria-labelledby": `${id2}-label`, "aria-invalid": invalid2, "aria-describedby": `${id2}-hint ${id2}-error`, onChange: (event) => {
6941
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("textarea", { id: id2, rows: 6, maxLength: 32768, value: text5, disabled: !controller.canEdit(), "aria-labelledby": `${id2}-label`, "aria-invalid": invalid2, "aria-describedby": `${id2}-hint ${id2}-error`, onChange: (event) => {
6694
6942
  const next = event.currentTarget.value;
6695
6943
  let parsed, valid = true;
6696
6944
  try {
@@ -6700,85 +6948,104 @@ function AdvancedField({ schema, path, controller, inherited, upper, expanded, o
6700
6948
  } catch {
6701
6949
  valid = false;
6702
6950
  }
6703
- controller.setRaw(name, next, !valid);
6951
+ controller.setRaw(name2, next, !valid);
6704
6952
  if (valid) controller.edit(path, parsed);
6705
6953
  } }),
6706
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { id: `${id2}-error`, className: "dsmm-hint", children: invalid2 ? t("invalid") : "" }),
6707
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: !controller.canEdit() || value === void 0 && raw === void 0, onClick: () => {
6708
- controller.clearRaw(name);
6954
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { id: `${id2}-error`, className: "dsmm-hint", children: invalid2 ? t("invalid") : "" }),
6955
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", "data-dsmm-unset": name2, disabled: !controller.canEdit() || value === void 0 && raw === void 0, onClick: () => {
6956
+ controller.clearRaw(name2);
6709
6957
  controller.edit(path, void 0);
6710
6958
  }, children: t("unset") }),
6711
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { children: [
6712
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("summary", { children: t("inherit") }),
6713
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("pre", { children: JSON.stringify(inherited, null, 2) })
6959
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { children: [
6960
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { children: t("inherit") }),
6961
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("pre", { children: JSON.stringify(inherited, null, 2) })
6714
6962
  ] }),
6715
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { children: [
6716
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("summary", { children: "schema" }),
6717
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("pre", { children: JSON.stringify(schema, null, 2) })
6963
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { children: [
6964
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { children: "schema" }),
6965
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("pre", { children: JSON.stringify(schema, null, 2) })
6718
6966
  ] })
6719
6967
  ] })
6720
6968
  ] });
6721
6969
  }
6722
6970
  function ScalarField({ schema, path, controller, inherited, t }) {
6723
- const state = (0, import_react6.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), id2 = (0, import_react6.useId)(), name = path.join(".");
6724
- const value = at(state.draft, path), raw = state.raw[name], bad = raw?.invalid === true;
6725
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
6726
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: id2, children: fieldLabel(path, t) }),
6727
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-actions", children: [
6728
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives6.Input, { className: "dsmm-input", id: id2, type: "text", inputMode: schema.type === "number" ? "decimal" : void 0, value: raw?.text ?? String(value ?? inherited ?? ""), disabled: !controller.canEdit(), "aria-invalid": bad, "aria-describedby": `${id2}-error`, onChange: (event) => {
6971
+ const state = (0, import_react7.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), id2 = (0, import_react7.useId)(), name2 = path.join(".");
6972
+ const value = at(state.draft, path), raw = state.raw[name2], bad = raw?.invalid === true;
6973
+ const units = name2 === "guards.toolOutputTruncation.maxInlineBytes" ? ` · ${permissionText(t)("unitBytes")}` : name2 === "guards.questionLabelHelper.maxLabelChars" ? ` · ${permissionText(t)("unitChars")}` : "";
6974
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
6975
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: id2, children: fieldLabel(path, t) }),
6976
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-actions", children: [
6977
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Input, { className: "dsmm-input", id: id2, type: "text", inputMode: schema.type === "number" ? "decimal" : void 0, value: raw?.text ?? String(value ?? inherited ?? ""), disabled: !controller.canEdit(), "aria-invalid": bad, "aria-describedby": `${id2}-error`, onChange: (event) => {
6729
6978
  const text5 = event.currentTarget.value, candidate = schema.type === "number" ? Number(text5) : text5;
6730
6979
  const valid = (schema.type !== "number" || text5.trim() !== "") && validateEditorValue(candidate, schema);
6731
- controller.setRaw(name, text5, !valid);
6980
+ controller.setRaw(name2, text5, !valid);
6732
6981
  if (valid) controller.edit(path, candidate);
6733
6982
  } }),
6734
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: !controller.canEdit() || value === void 0 && raw === void 0, onClick: () => {
6735
- controller.clearRaw(name);
6983
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", "data-dsmm-unset": name2, disabled: !controller.canEdit() || value === void 0 && raw === void 0, onClick: () => {
6984
+ controller.clearRaw(name2);
6736
6985
  controller.edit(path, void 0);
6737
6986
  }, children: t("unset") })
6738
6987
  ] }),
6739
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { id: `${id2}-error`, className: "dsmm-hint", children: [
6988
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { id: `${id2}-error`, className: "dsmm-hint", children: [
6740
6989
  bad ? t("invalid") : "",
6741
- schema.type === "number" && (schema.min !== void 0 || schema.max !== void 0) ? ` ${schema.min ?? "—"} – ${schema.max ?? "—"}` : ""
6990
+ schema.type === "number" && (schema.min !== void 0 || schema.max !== void 0) ? ` ${schema.min ?? "—"} – ${schema.max ?? "—"}` : "",
6991
+ units
6742
6992
  ] })
6743
6993
  ] });
6744
6994
  }
6745
6995
  function Field({ schema, path, controller, initiallyOpen = false, disclosures, t }) {
6746
6996
  if (schema.type === "transform" && schema.inner !== void 0) schema = schema.inner;
6747
- const state = (0, import_react6.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), snapshot4 = state.snapshot, id2 = (0, import_react6.useId)(), name = path.join(".");
6748
- const [open, setOpen] = (0, import_react6.useState)(disclosures?.get(name) ?? initiallyOpen);
6997
+ const state = (0, import_react7.useSyncExternalStore)(controller.subscribe, controller.getSnapshot), snapshot4 = state.snapshot, id2 = (0, import_react7.useId)(), name2 = path.join(".");
6998
+ const [open, setOpen] = (0, import_react7.useState)(disclosures?.get(name2) ?? initiallyOpen);
6749
6999
  const expand = (expanded) => {
6750
- disclosures?.set(name, expanded);
7000
+ disclosures?.set(name2, expanded);
6751
7001
  setOpen(expanded);
6752
7002
  };
7003
+ const unsetGroup = (event) => {
7004
+ event?.preventDefault();
7005
+ event?.stopPropagation();
7006
+ const summary = event?.currentTarget.closest("summary"), action2 = event?.currentTarget ?? null;
7007
+ controller.clearRaw(name2);
7008
+ controller.edit(path, void 0);
7009
+ if (summary !== null && summary !== void 0) {
7010
+ const restore = () => {
7011
+ const active = document.activeElement;
7012
+ if (active === null || active === document.body || active === action2) summary.focus();
7013
+ };
7014
+ if (typeof requestAnimationFrame === "function") requestAnimationFrame(() => {
7015
+ restore();
7016
+ requestAnimationFrame(restore);
7017
+ });
7018
+ }
7019
+ };
6753
7020
  const explicit = at(state.draft, path), inherited = controller.layer === "global" ? at(snapshot4.defaults, path) : at(mergeLayer(mergeLayer(snapshot4.defaults, snapshot4.global), snapshot4.nativeForm?.base ?? {}), path);
6754
7021
  const choices = enumValues(schema), disabled = !controller.canEdit();
6755
- if (name === "permissionControl.nativeCommands.entries") return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-field": name, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(NativeCommandEntries, { controller, value: explicit, inherited: inherited ?? [], disabled, onChange: (value) => controller.edit(path, value), setInvalid: (key, bad) => controller.setInvalid(key, bad), t: permissionText(t) }) });
6756
- if (schema.type === "object" && schema.fields !== void 0 && path[0] !== "roleRouting") return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("details", { className: "dsmm-deployment-group", "data-field": name, open, onToggle: (event) => expand(event.currentTarget.open), children: [
6757
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("summary", { children: fieldLabel(path, t) }),
6758
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { children: [
6759
- name === "permissionControl" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: permissionText(t)("configPolicyHint") }),
6760
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: t(explicit === void 0 ? "inherit" : "explicit") }),
6761
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_dsh_client_ui_primitives6.Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: disabled || explicit === void 0 && !Object.keys(state.raw).some((key) => key === name || key.startsWith(`${name}.`)), onClick: () => {
6762
- controller.clearRaw(name);
6763
- controller.edit(path, void 0);
6764
- }, children: t("unsetGroup") }),
6765
- Object.entries(schema.fields).map(([key, node]) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Field, { schema: node, path: [...path, key], controller, disclosures, t }, key))
7022
+ if (name2 === "permissionControl.nativeCommands.entries") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { "data-field": name2, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(NativeCommandEntries, { controller, value: explicit, inherited: inherited ?? [], disabled, onChange: (value) => controller.edit(path, value), setInvalid: (key, bad) => controller.setInvalid(key, bad), t: permissionText(t) }) });
7023
+ if (name2 === "permissionControl.rules") return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { "data-field": name2, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PermissionRuleEntries, { controller, value: explicit, inherited: inherited ?? [], disabled, onChange: (value) => controller.edit(path, value), expanded: open, onExpandedChange: expand, t: permissionText(t) }) });
7024
+ if (schema.type === "object" && schema.fields !== void 0 && path[0] !== "roleRouting") return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("details", { className: "dsmm-deployment-group", "data-field": name2, open, onToggle: (event) => expand(event.currentTarget.open), children: [
7025
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("summary", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("span", { className: "dsmm-group-summary", children: [
7026
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "dsmm-group-summary-label", children: fieldLabel(path, t) }),
7027
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", className: "dsmm-group-summary-action", "data-dsmm-unset": name2, hidden: !open, disabled: disabled || explicit === void 0 && !Object.keys(state.raw).some((key) => key === name2 || key.startsWith(`${name2}.`)), onClick: unsetGroup, children: t("unsetGroup") })
7028
+ ] }) }),
7029
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { children: [
7030
+ name2 === "permissionControl" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: permissionText(t)("configPolicyHint") }),
7031
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t(explicit === void 0 ? "inherit" : "explicit") }),
7032
+ Object.entries(schema.fields).map(([key, node]) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Field, { schema: node, path: [...path, key], controller, disclosures, t }, key))
6766
7033
  ] })
6767
7034
  ] });
6768
- if (!["boolean", "string", "number"].includes(schema.type) && choices === null) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AdvancedField, { schema, path, controller, inherited, upper: controller.layer === "global" ? at(snapshot4.profile, path) : void 0, expanded: open, onExpandedChange: expand, t });
6769
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "dsmm-field dsmm-deployment-field", "data-field": name, children: [
6770
- schema.type === "boolean" || choices !== null ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
6771
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("label", { htmlFor: id2, children: fieldLabel(path, t) }),
6772
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("select", { id: id2, disabled, value: explicit === void 0 ? "inherit" : JSON.stringify(explicit), onChange: (event) => controller.edit(path, event.currentTarget.value === "inherit" ? void 0 : JSON.parse(event.currentTarget.value)), children: [
6773
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "inherit", children: `${t("unset")} · ${displayValue(inherited, t)}` }),
6774
- (choices ?? [true, false]).map((choice2) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: JSON.stringify(choice2), children: displayValue(choice2, t) }, String(choice2)))
7035
+ if (!["boolean", "string", "number"].includes(schema.type) && choices === null) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(AdvancedField, { schema, path, controller, inherited, upper: controller.layer === "global" ? at(snapshot4.profile, path) : void 0, expanded: open, onExpandedChange: expand, t });
7036
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field dsmm-deployment-field", "data-field": name2, children: [
7037
+ schema.type === "boolean" || choices !== null ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
7038
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: id2, children: fieldLabel(path, t) }),
7039
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("select", { id: id2, disabled, value: explicit === void 0 ? "inherit" : JSON.stringify(explicit), onChange: (event) => controller.edit(path, event.currentTarget.value === "inherit" ? void 0 : JSON.parse(event.currentTarget.value)), children: [
7040
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "inherit", children: `${t("unset")} · ${displayValue(inherited, t)}` }),
7041
+ (choices ?? [true, false]).map((choice2) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: JSON.stringify(choice2), children: displayValue(choice2, t) }, String(choice2)))
6775
7042
  ] })
6776
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ScalarField, { schema, path, controller, inherited, t }),
6777
- name === "modelParameters.passthrough" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: t("modelParametersHint") }),
6778
- name === "permissionControl.enabled" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: permissionText(t)("coldHint") }),
6779
- explicit !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: t(equal(explicit, at(snapshot4.defaults, path)) ? "defaultPin" : "explicit") }),
6780
- controller.layer === "profile" && at(snapshot4.nativeForm?.base, path) !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "dsmm-hint", children: t("hostPin") }),
6781
- controller.layer === "global" && at(snapshot4.profile, path) !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { className: "dsmm-hint", children: [
7043
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ScalarField, { schema, path, controller, inherited, t }),
7044
+ name2 === "modelParameters.passthrough" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("modelParametersHint") }),
7045
+ name2 === "permissionControl.enabled" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: permissionText(t)("coldHint") }),
7046
+ explicit !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t(equal(explicit, at(snapshot4.defaults, path)) ? "defaultPin" : "explicit") }),
7047
+ controller.layer === "profile" && at(snapshot4.nativeForm?.base, path) !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("hostPin") }),
7048
+ controller.layer === "global" && at(snapshot4.profile, path) !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "dsmm-hint", children: [
6782
7049
  t("profileSource"),
6783
7050
  ": ",
6784
7051
  displayValue(at(snapshot4.profile, path), t),
@@ -6789,253 +7056,580 @@ function Field({ schema, path, controller, initiallyOpen = false, disclosures, t
6789
7056
  }
6790
7057
 
6791
7058
  // src/client/PermissionsPanel.tsx
6792
- var import_react7 = require("react");
6793
- var import_dsh_client_ui_primitives7 = require("@deepseek-ai/dsh-client-ui-primitives");
6794
- var import_jsx_runtime9 = require("react/jsx-runtime");
6795
- var actions = ["inherit", "allow", "ask", "deny"];
6796
- var kinds = ["outside-read", "shell", "webSearch", "webFetch"];
6797
- var ruleDraft = (rule) => ({ id: rule.id, action: rule.action, match: structuredClone(rule.match) });
6798
- var newMatch = (kind) => kind === "outside-read" ? { kind, path: "", scope: "exact" } : kind === "shell" ? { kind, executable: "", command: "", workingDirectory: "" } : { kind };
6799
- function Issue({ value, t }) {
6800
- return value === null ? null : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { className: "dsmm-issue", role: "alert", children: [
6801
- t(`issue:${value}`),
6802
- " ",
6803
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { children: value })
6804
- ] });
7059
+ var import_react8 = require("react");
7060
+ var import_dsh_client_ui_primitives8 = require("@deepseek-ai/dsh-client-ui-primitives");
7061
+
7062
+ // src/permission-remote.ts
7063
+ function fail3() {
7064
+ throw new TypeError("Invalid permission DTO.");
6805
7065
  }
6806
- function RootState({ state, t }) {
6807
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
6808
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { children: [
6809
- t("root"),
6810
- ": ",
6811
- t(state.scope === "root" && state.connected ? "active" : "unknown")
6812
- ] }),
6813
- state.scope !== "root" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t(state.scope === "child" ? "child" : "noRoot") }),
6814
- !state.connected && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("unknown") })
6815
- ] });
7066
+ function text3(value, max = 512) {
7067
+ if (typeof value !== "string" || value.length === 0 || value.length > max || /[\u0000-\u001f\u007f]/u.test(value)) fail3();
7068
+ return value;
6816
7069
  }
6817
- function ActionSelect({ id: id2, value, inherit = true, onChange, disabled, t }) {
6818
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("select", { id: id2, value, disabled, onChange: (event) => {
6819
- const choice2 = actions.find((value2) => value2 === event.currentTarget.value);
6820
- if (choice2 !== void 0) onChange(choice2);
6821
- }, children: actions.filter((value2) => inherit || value2 !== "inherit").map((value2) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: value2, children: t(value2 === "inherit" ? "inherit" : `action:${value2}`) }, value2)) });
7070
+ function parsePermissionSessionId(value) {
7071
+ return text3(value, 256);
6822
7072
  }
6823
- function RuleEditor({ controller, state, t }) {
6824
- const id2 = (0, import_react7.useId)(), editor = state.draft?.editor;
6825
- if (editor == null) return null;
6826
- const disabled = !controller.canEdit(state.generation), change = (value) => controller.edit(state.generation, { editor: value });
6827
- const field = (key, label) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
6828
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: `${id2}-${key}`, children: t(label) }),
6829
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Input, { className: "dsmm-input", id: `${id2}-${key}`, required: true, maxLength: 32768, disabled, value: key in editor.match ? String(Reflect.get(editor.match, key)) : "", onChange: (event) => change({ ...editor, match: { ...editor.match, [key]: event.currentTarget.value } }) })
6830
- ] });
6831
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("form", { className: "dsmm-structured", "aria-label": t("editor"), onSubmit: (event) => {
6832
- event.preventDefault();
6833
- controller.stageRule(state.generation);
6834
- }, children: [
6835
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
6836
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: `${id2}-id`, children: t("id") }),
6837
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Input, { className: "dsmm-input", id: `${id2}-id`, required: true, maxLength: 256, value: editor.id, disabled, onChange: (event) => change({ ...editor, id: event.currentTarget.value }) })
6838
- ] }),
6839
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
6840
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: `${id2}-action`, children: t("action") }),
6841
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionSelect, { id: `${id2}-action`, value: editor.action, disabled, inherit: false, t, onChange: (action2) => {
6842
- if (action2 !== "inherit") change({ ...editor, action: action2 });
6843
- } })
6844
- ] }),
6845
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
6846
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: `${id2}-kind`, children: t("match") }),
6847
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("select", { id: `${id2}-kind`, value: editor.match.kind, disabled, onChange: (event) => {
6848
- const kind = kinds.find((value) => value === event.currentTarget.value);
6849
- if (kind !== void 0) change({ ...editor, match: newMatch(kind) });
6850
- }, children: kinds.map((kind) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: kind, children: t(`kind:${kind}`) }, kind)) })
6851
- ] }),
6852
- editor.match.kind === "outside-read" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
6853
- field("path", "path"),
6854
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
6855
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: `${id2}-path-scope`, children: t("pathScope") }),
6856
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("select", { id: `${id2}-path-scope`, value: editor.match.scope, disabled, onChange: (event) => {
6857
- const scope = event.currentTarget.value;
6858
- if (editor.match.kind === "outside-read" && (scope === "exact" || scope === "tree")) change({ ...editor, match: { ...editor.match, scope } });
6859
- }, children: [
6860
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "exact", children: t("exact") }),
6861
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("option", { value: "tree", children: t("tree") })
6862
- ] })
6863
- ] })
6864
- ] }),
6865
- editor.match.kind === "shell" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
6866
- field("executable", "executable"),
6867
- field("command", "command"),
6868
- field("workingDirectory", "cwd")
6869
- ] }),
6870
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-actions", children: [
6871
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "submit", variant: "outline", disabled, children: t("stage") }),
6872
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", disabled, onClick: () => controller.edit(state.generation, { editor: null }), children: t("cancel") })
6873
- ] })
6874
- ] });
7073
+ function parseRuntime(value) {
7074
+ const runtime = permissionRuleRow(value, ["savedRevision", "runtimeRevision", "state", "mounted", "restartRequired"]);
7075
+ if (!["synced", "updating", "unsynced"].includes(runtime.state) || typeof runtime.mounted !== "boolean" || typeof runtime.restartRequired !== "boolean") fail3();
7076
+ return { savedRevision: permissionRevision(runtime.savedRevision), runtimeRevision: permissionRevision(runtime.runtimeRevision), state: runtime.state, mounted: runtime.mounted, restartRequired: runtime.restartRequired };
6875
7077
  }
6876
- function RuleRecords({ controller, state, t }) {
6877
- const records = state.rules?.snapshot.policy.rules ?? state.base?.policy.rules;
6878
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-structured", children: [
6879
- records?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: t("noRules") }),
6880
- records?.map((rule) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("fieldset", { children: [
6881
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("legend", { children: rule.id }),
6882
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { children: [
6883
- t(rule.revoked ? "revoked" : "active"),
6884
- " · ",
6885
- t(`action:${rule.action}`)
6886
- ] }),
6887
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dl", { className: "dsmm-child-meta", children: [
6888
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("match") }),
6889
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t(`kind:${rule.match.kind}`) }),
6890
- rule.match.kind === "outside-read" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
6891
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("path") }),
6892
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dd", { children: [
6893
- rule.match.path,
6894
- " · ",
6895
- t(rule.match.scope)
6896
- ] })
6897
- ] }),
6898
- rule.match.kind === "shell" && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
6899
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("executable") }),
6900
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: rule.match.executable }),
6901
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("command") }),
6902
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { children: rule.match.command }) }),
6903
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("cwd") }),
6904
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: rule.match.workingDirectory })
6905
- ] }),
6906
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("source") }),
6907
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t(rule.source.kind === "operator" ? "operator" : "imported") })
6908
- ] }),
6909
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-actions", children: [
6910
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", disabled: !controller.canEdit(state.generation) || state.draft === null, onClick: () => controller.edit(state.generation, { editor: ruleDraft(rule) }), children: t("editRule") }),
6911
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", disabled: !controller.canEdit(state.generation) || state.draft === null || rule.revoked || state.draft.revoke.includes(rule.id), onClick: () => controller.stageRevoke(state.generation, rule.id), children: t("stageRevoke") })
6912
- ] })
6913
- ] }, rule.id))
6914
- ] });
7078
+ function parseCapabilities(value) {
7079
+ const input = permissionRuleRow(value, ["limits", "runtime", "tools"]);
7080
+ const limits = permissionRuleRow(input.limits, ["outsideReads", "finalInode", "scopedMemory", "webFetch", "webSearchDestinations", "proxyAddressBinding", "shellSockets", "providerAuthMcp"]);
7081
+ if (limits.outsideReads !== "tool-call-boundary" || limits.finalInode !== false || limits.scopedMemory !== "not-provided-by-native-rules" || limits.webFetch !== "native-public-only" || limits.webSearchDestinations !== "unsupported" || limits.proxyAddressBinding !== "native-proxy-dependent" || limits.shellSockets !== "native-executor-dependent" || limits.providerAuthMcp !== "not-covered") fail3();
7082
+ if (!Array.isArray(input.tools) || input.tools.length > 1024) fail3();
7083
+ const tools = [];
7084
+ const names = /* @__PURE__ */ new Set();
7085
+ for (const value2 of input.tools) {
7086
+ const tool = permissionRuleRow(value2, ["name", "kind", "approval", "scopedMemory"]), name2 = text3(tool.name);
7087
+ if (!["read", "glob", "grep", "shell", "webSearch", "webFetch"].includes(tool.kind) || tool.approval !== "native-once" || tool.scopedMemory !== false || names.has(name2)) fail3();
7088
+ names.add(name2);
7089
+ tools.push({ name: name2, kind: tool.kind, approval: "native-once", scopedMemory: false });
7090
+ }
7091
+ return { limits: {
7092
+ outsideReads: "tool-call-boundary",
7093
+ finalInode: false,
7094
+ scopedMemory: "not-provided-by-native-rules",
7095
+ webFetch: "native-public-only",
7096
+ webSearchDestinations: "unsupported",
7097
+ proxyAddressBinding: "native-proxy-dependent",
7098
+ shellSockets: "native-executor-dependent",
7099
+ providerAuthMcp: "not-covered"
7100
+ }, runtime: parseRuntime(input.runtime), tools };
6915
7101
  }
6916
- function PermissionCoverage({ state, t }) {
6917
- const value = state.rules?.capabilities;
6918
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: "dsmm-structured", "aria-label": t("coverageTitle"), children: [
6919
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { children: t("coverageTitle") }),
6920
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("coverage") }),
6921
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("registrationUnresolved") }),
6922
- value === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: t("coverageUnavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
6923
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dl", { className: "dsmm-child-meta", children: [
6924
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("coverageRuntime") }),
6925
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dd", { children: [
6926
- t(value.runtime.state),
6927
- " · ",
6928
- t("mounted"),
6929
- ": ",
6930
- t(value.runtime.mounted ? "on" : "off")
6931
- ] })
6932
- ] }),
6933
- value.runtime.restartRequired && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: t("restart") }),
6934
- value.tools.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: t("coverageEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("ul", { className: "dsmm-profile-list", children: value.tools.map((tool) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dl", { className: "dsmm-child-meta", children: [
6935
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("toolName") }),
6936
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { children: tool.name }) }),
6937
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("toolKind") }),
6938
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("code", { children: tool.kind }) }),
6939
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("toolApproval") }),
6940
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("nativeOnce") }),
6941
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("toolMemory") }),
6942
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("notProvided") })
6943
- ] }) }, tool.name)) }),
6944
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dl", { className: "dsmm-child-meta", children: [
6945
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("outsideReads") }),
6946
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("limit:outsideReads") }),
6947
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("finalInode") }),
6948
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("limit:finalInode") }),
6949
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("toolMemory") }),
6950
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("limit:scopedMemory") }),
6951
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("webFetch") }),
6952
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("limit:webFetch") }),
6953
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("searchDestinations") }),
6954
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("limit:webSearchDestinations") }),
6955
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("proxyBinding") }),
6956
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("limit:proxyAddressBinding") }),
6957
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("shellSockets") }),
6958
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("limit:shellSockets") }),
6959
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("providerAuthMcp") }),
6960
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("limit:providerAuthMcp") })
6961
- ] })
6962
- ] }),
6963
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("pathEvidence") })
6964
- ] });
7102
+ function parsePermissionRulesResult(value) {
7103
+ const input = permissionRuleRow(value, ["snapshot", "runtime"], ["capabilities"]), snapshot4 = permissionRuleRow(input.snapshot, ["revision", "policy"]);
7104
+ return {
7105
+ snapshot: { revision: permissionRevision(snapshot4.revision), policy: resolvePermissionControl(snapshot4.policy) },
7106
+ runtime: parseRuntime(input.runtime),
7107
+ ...Object.hasOwn(input, "capabilities") ? { capabilities: parseCapabilities(input.capabilities) } : {}
7108
+ };
6965
7109
  }
6966
- function PermissionRulesEditor({ controller, state, t }) {
6967
- const id2 = (0, import_react7.useId)(), draft2 = state.draft, disabled = !controller.canEdit(state.generation), value = state.rules;
6968
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("section", { className: "dsmm-zone", "aria-label": t("rules"), children: [
6969
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { children: t("rules") }),
6970
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("rulesHint") }),
6971
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("networkLimit") }),
6972
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("matchHint") }),
6973
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Issue, { value: state.rulesIssue, t }),
6974
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("observedPolicy") }),
6975
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dl", { className: "dsmm-child-meta", children: [
6976
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("profileOverrideState") }),
6977
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t("profileOverrideUnknown") })
6978
- ] }),
6979
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dl", { className: "dsmm-child-meta", children: [
6980
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("runtime") }),
6981
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: value === null ? t("unknown") : t(value.runtime.state) }),
6982
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: t("mounted") }),
6983
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: value === null ? t("unknown") : t(value.runtime.mounted ? "on" : "off") })
6984
- ] }),
6985
- value?.runtime.restartRequired && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: t("restart") }),
6986
- disabled && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t(state.reading ? "reading" : "rulesUnavailable") }),
6987
- state.base !== null && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dl", { className: "dsmm-child-meta", children: [
6988
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: "permissionControl.enabled" }),
6989
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("dd", { children: [
6990
- t(state.base.policy.enabled ? "on" : "off"),
6991
- " · ",
7110
+ var codec2 = (name2, parse3) => ({ mode: "strict", typeSymbol: `@dsmm/dsmm#${name2}`, create: () => ({ parse: parse3 }) });
7111
+ function descriptor2(method, result, request) {
7112
+ return {
7113
+ id: `@dsmm/dsmm-permissions#dsmmPermissions/${method}`,
7114
+ service: "dsmmPermissions",
7115
+ namespace: "dsmmPermissions",
7116
+ method,
7117
+ invocation: { kind: "direct" },
7118
+ parameters: [
7119
+ { name: "sessionId", wire: "sessionId", source: "json", codec: codec2("PermissionSessionId", parsePermissionSessionId) },
7120
+ ...request === void 0 ? [] : [{ name: "request", wire: "request", source: "json", codec: request }]
7121
+ ],
7122
+ result
7123
+ };
7124
+ }
7125
+ var PERMISSION_REMOTE = { package: "@dsmm/dsmm-permissions", descriptors: [
7126
+ descriptor2("describeRules", codec2("PermissionRulesResult", parsePermissionRulesResult)),
7127
+ descriptor2("saveRules", codec2("PermissionRulesResult", parsePermissionRulesResult), codec2("PermissionRulesSaveRequest", parsePermissionRulesSave))
7128
+ ] };
7129
+ var PERMISSION_HOST = { package: PERMISSION_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: PERMISSION_REMOTE.descriptors };
7130
+
7131
+ // src/client/permission-client.ts
7132
+ var PermissionClientError = class extends Error {
7133
+ constructor(code) {
7134
+ super("Permission operation unavailable.");
7135
+ this.code = code;
7136
+ }
7137
+ };
7138
+ var codes = /* @__PURE__ */ new Set(["not-owned", "stale", "cancelled", "unavailable", "validation", "not-found", "scope-unavailable", "replayed", "denied"]);
7139
+ function permissionClient(connection) {
7140
+ return async (method, args, signal) => {
7141
+ const descriptor4 = PERMISSION_REMOTE.descriptors.find((item) => item.method === method);
7142
+ const payload = {};
7143
+ descriptor4.parameters.forEach((parameter, index) => {
7144
+ payload[parameter.wire] = args[index];
7145
+ });
7146
+ let result;
7147
+ try {
7148
+ result = await connection.rpc.call("/api", `dsmmPermissions/${method}`, { args: payload }, signal);
7149
+ } catch {
7150
+ throw new PermissionClientError(signal.aborted ? "cancelled" : "transport");
7151
+ }
7152
+ if (!result.ok) {
7153
+ const code = Reflect.get(result.error.details, "code");
7154
+ throw new PermissionClientError(result.error.code === "dsmm-permissions/refused" && codes.has(code) ? code : "unavailable");
7155
+ }
7156
+ signal.throwIfAborted();
7157
+ try {
7158
+ if (descriptor4.result.mode !== "strict") throw new Error("Strict permission codec required.");
7159
+ return descriptor4.result.create().parse(result.value);
7160
+ } catch {
7161
+ throw new PermissionClientError("protocol");
7162
+ }
7163
+ };
7164
+ }
7165
+
7166
+ // src/client/permission-controller.ts
7167
+ var draftOf = (policy) => ({ outsideReads: policy.outsideReads, webSearch: { ...policy.webSearch }, webFetch: { ...policy.webFetch }, upsert: [], revoke: [], editor: null });
7168
+ var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
7169
+ function permissionChanges(view) {
7170
+ const { base, draft: draft2 } = view;
7171
+ if (base === null || draft2 === null) return null;
7172
+ const changes = Object.fromEntries(["outsideReads", "webSearch", "webFetch"].filter((key) => !same(base.policy[key], draft2[key])).map((key) => [key, draft2[key]]));
7173
+ if (Object.keys(changes).length === 0 && draft2.upsert.length === 0 && draft2.revoke.length === 0) return null;
7174
+ return { expectedRevision: base.revision, ...Object.keys(changes).length ? { changes } : {}, ...draft2.upsert.length ? { upsert: draft2.upsert } : {}, ...draft2.revoke.length ? { revoke: draft2.revoke } : {} };
7175
+ }
7176
+ var empty = () => ({
7177
+ generation: 0,
7178
+ sessionId: null,
7179
+ scope: "unknown",
7180
+ connected: false,
7181
+ reading: false,
7182
+ revalidating: false,
7183
+ busy: null,
7184
+ rules: null,
7185
+ display: null,
7186
+ base: null,
7187
+ draft: null,
7188
+ rulesIssue: null,
7189
+ dirty: false,
7190
+ notice: null
7191
+ });
7192
+ var observedRules = (view) => view.rules ?? view.display;
7193
+ var displayUnconfirmed = (view) => view.display !== null && view.rules === null;
7194
+ var PermissionController = class {
7195
+ state = empty();
7196
+ listeners = /* @__PURE__ */ new Set();
7197
+ invoke = null;
7198
+ connection;
7199
+ owner = null;
7200
+ request = new AbortController();
7201
+ requestSequence = 0;
7202
+ timer;
7203
+ watchers = 0;
7204
+ disposed = false;
7205
+ /** A successful read/save exists for the current scope fence; not mutation authority. */
7206
+ observed = false;
7207
+ store = { getSnapshot: () => this.state, subscribe: (listener) => {
7208
+ this.listeners.add(listener);
7209
+ return () => {
7210
+ this.listeners.delete(listener);
7211
+ };
7212
+ } };
7213
+ publish(patch) {
7214
+ if (this.disposed) return;
7215
+ this.state = { ...this.state, ...patch };
7216
+ for (const listener of this.listeners) listener();
7217
+ }
7218
+ cancel() {
7219
+ this.request.abort();
7220
+ this.request = new AbortController();
7221
+ this.requestSequence++;
7222
+ clearTimeout(this.timer);
7223
+ }
7224
+ /** An observed snapshot exists for this fence; background work must stay invisible until it changes what is possible. */
7225
+ trusted() {
7226
+ return this.observed;
7227
+ }
7228
+ fence(preserveDraft, preserveBase = preserveDraft, preserveDisplay = true) {
7229
+ this.cancel();
7230
+ this.observed = false;
7231
+ this.publish({
7232
+ generation: this.state.generation + 1,
7233
+ reading: false,
7234
+ revalidating: false,
7235
+ busy: null,
7236
+ notice: null,
7237
+ rules: null,
7238
+ rulesIssue: null,
7239
+ ...preserveDisplay ? {} : { display: null },
7240
+ ...preserveDraft ? {} : { draft: null, dirty: false },
7241
+ ...preserveBase ? {} : { base: null }
7242
+ });
7243
+ }
7244
+ bindConnection(invoke, generation) {
7245
+ if (this.disposed || this.invoke === invoke && this.connection === generation) return;
7246
+ this.invoke = invoke;
7247
+ this.connection = generation;
7248
+ this.fence(true);
7249
+ this.publish({ connected: invoke !== null });
7250
+ this.schedule(true);
7251
+ }
7252
+ bindScope(sessionId2, owner, scope) {
7253
+ if (this.disposed || this.state.sessionId === sessionId2 && this.owner === owner && this.state.scope === scope) return;
7254
+ const sameSession = sessionId2 !== null && sessionId2 === this.state.sessionId;
7255
+ this.owner = owner;
7256
+ this.fence(sameSession, false, sameSession);
7257
+ this.publish({ sessionId: sessionId2, scope });
7258
+ this.schedule(true);
7259
+ }
7260
+ watch() {
7261
+ this.watchers++;
7262
+ if (this.watchers === 1) this.schedule(true);
7263
+ let active = true;
7264
+ return () => {
7265
+ if (!active) return;
7266
+ active = false;
7267
+ this.watchers--;
7268
+ if (this.watchers === 0) this.fence(true);
7269
+ };
7270
+ }
7271
+ dispose() {
7272
+ if (this.disposed) return;
7273
+ this.fence(false, false, false);
7274
+ this.disposed = true;
7275
+ this.listeners.clear();
7276
+ this.invoke = null;
7277
+ this.owner = null;
7278
+ }
7279
+ live(generation) {
7280
+ return !this.disposed && generation === this.state.generation && this.owner !== null && this.invoke !== null && this.state.scope === "root" && this.state.sessionId !== null;
7281
+ }
7282
+ schedule(immediate = false) {
7283
+ clearTimeout(this.timer);
7284
+ if (this.watchers === 0 || !this.live(this.state.generation)) return;
7285
+ this.timer = setTimeout(() => {
7286
+ void this.revalidate(this.state.generation);
7287
+ }, immediate ? 0 : 1e3);
7288
+ this.timer.unref?.();
7289
+ }
7290
+ issue(error) {
7291
+ return error instanceof PermissionClientError ? error.code : "transport";
7292
+ }
7293
+ synchronized() {
7294
+ const value = this.state.rules;
7295
+ return value !== null && value.runtime.state === "synced" && value.runtime.savedRevision === value.snapshot.revision && value.runtime.runtimeRevision === value.snapshot.revision;
7296
+ }
7297
+ /** A background request in flight never disables editing or saving; only its own save/authority does. */
7298
+ canEdit(generation) {
7299
+ return this.live(generation) && this.state.rulesIssue === null && this.synchronized() && this.state.busy === null;
7300
+ }
7301
+ canSave(generation) {
7302
+ return this.canEdit(generation) && this.state.dirty && this.state.draft?.editor === null;
7303
+ }
7304
+ /** User-triggered refresh: visible busy state on this transaction only. */
7305
+ async refresh(generation, discard = false) {
7306
+ await this.load(generation, discard, false);
7307
+ }
7308
+ /** Watch-driven revalidation. Invisible once a trusted snapshot exists. */
7309
+ async revalidate(generation) {
7310
+ await this.load(generation, false, true);
7311
+ }
7312
+ async load(generation, discard, background) {
7313
+ if (!this.live(generation) || this.state.busy !== null || this.state.reading) return;
7314
+ if (background && this.state.revalidating) return;
7315
+ if (!background && this.state.revalidating) this.cancel();
7316
+ const visible = !background || !this.trusted() && this.state.display === null;
7317
+ const sequence = ++this.requestSequence, signal = this.request.signal, id2 = this.state.sessionId;
7318
+ this.publish(visible ? { reading: true, revalidating: false } : { revalidating: true });
7319
+ try {
7320
+ const value = await this.invoke("describeRules", [id2], signal);
7321
+ if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence) return;
7322
+ this.observed = true;
7323
+ const retain = this.state.dirty && !discard;
7324
+ this.publish({
7325
+ rules: value,
7326
+ display: value,
7327
+ rulesIssue: retain && this.state.base?.revision !== value.snapshot.revision ? "stale" : null,
7328
+ ...retain ? {} : { base: value.snapshot, draft: draftOf(value.snapshot.policy), dirty: false }
7329
+ });
7330
+ } catch (error) {
7331
+ if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence) return;
7332
+ this.publish({ rulesIssue: this.issue(error) });
7333
+ } finally {
7334
+ if (this.live(generation) && sequence === this.requestSequence) this.publish({ reading: false, revalidating: false });
7335
+ }
7336
+ this.schedule();
7337
+ }
7338
+ edit(generation, patch) {
7339
+ if (!this.canEdit(generation) || this.state.draft === null) return;
7340
+ const draft2 = { ...this.state.draft, ...patch };
7341
+ this.publish({ draft: draft2, notice: null });
7342
+ this.publish({ dirty: draft2.editor !== null || permissionChanges(this.state) !== null });
7343
+ }
7344
+ stageRule(generation) {
7345
+ const draft2 = this.state.draft, editor = draft2?.editor;
7346
+ if (editor == null || !editor.id || editor.id.length > 256 || editor.id.includes("\0")) return;
7347
+ const match = editor.match;
7348
+ if (match.kind === "outside-read" && !match.path || match.kind === "shell" && (!match.executable || !match.command || !match.workingDirectory)) return;
7349
+ this.edit(generation, { upsert: [...draft2.upsert.filter((row) => row.id !== editor.id), structuredClone(editor)], revoke: draft2.revoke.filter((id2) => id2 !== editor.id), editor: null });
7350
+ }
7351
+ stageRevoke(generation, id2) {
7352
+ const draft2 = this.state.draft;
7353
+ if (draft2 === null || !this.state.base?.policy.rules.some((rule) => rule.id === id2)) return;
7354
+ this.edit(generation, { upsert: draft2.upsert.filter((row) => row.id !== id2), revoke: [.../* @__PURE__ */ new Set([...draft2.revoke, id2])], editor: draft2.editor?.id === id2 ? null : draft2.editor });
7355
+ }
7356
+ begin(busy) {
7357
+ this.cancel();
7358
+ this.publish({ busy, reading: false, revalidating: false, notice: null });
7359
+ return { signal: this.request.signal, id: this.state.sessionId };
7360
+ }
7361
+ async save(generation) {
7362
+ const request = permissionChanges(this.state);
7363
+ if (!this.canSave(generation) || request === null) return;
7364
+ const current = this.begin("save");
7365
+ try {
7366
+ const result = await this.invoke("saveRules", [current.id, request], current.signal);
7367
+ if (this.live(generation)) {
7368
+ this.observed = true;
7369
+ this.publish({ rules: result, display: result, base: result.snapshot, draft: draftOf(result.snapshot.policy), dirty: false, rulesIssue: null, notice: "saved" });
7370
+ }
7371
+ } catch (error) {
7372
+ if (this.live(generation)) this.publish({ rulesIssue: this.issue(error) });
7373
+ } finally {
7374
+ if (this.live(generation)) {
7375
+ this.publish({ busy: null });
7376
+ this.schedule();
7377
+ }
7378
+ }
7379
+ }
7380
+ };
7381
+
7382
+ // src/client/PermissionsPanel.tsx
7383
+ var import_jsx_runtime10 = require("react/jsx-runtime");
7384
+ var actions2 = ["inherit", "allow", "ask", "deny"];
7385
+ var kinds2 = ["outside-read", "shell", "webSearch", "webFetch"];
7386
+ var ruleDraft = (rule) => ({ id: rule.id, action: rule.action, match: structuredClone(rule.match) });
7387
+ var newMatch2 = (kind) => kind === "outside-read" ? { kind, path: "", scope: "exact" } : kind === "shell" ? { kind, executable: "", command: "", workingDirectory: "" } : { kind };
7388
+ function Issue({ value, t }) {
7389
+ return value === null ? null : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "dsmm-issue", role: "alert", children: [
7390
+ t(`issue:${value}`),
7391
+ " ",
7392
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("code", { children: value })
7393
+ ] });
7394
+ }
7395
+ function RootState({ state, t }) {
7396
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
7397
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7398
+ t("root"),
7399
+ ": ",
7400
+ t(state.scope === "root" && state.connected ? "active" : "unknown")
7401
+ ] }),
7402
+ state.scope !== "root" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t(state.scope === "child" ? "child" : "noRoot") }),
7403
+ !state.connected && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("unknown") })
7404
+ ] });
7405
+ }
7406
+ function ActionSelect({ id: id2, value, inherit = true, onChange, disabled, t }) {
7407
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("select", { id: id2, value, disabled, onChange: (event) => {
7408
+ const choice2 = actions2.find((value2) => value2 === event.currentTarget.value);
7409
+ if (choice2 !== void 0) onChange(choice2);
7410
+ }, children: actions2.filter((value2) => inherit || value2 !== "inherit").map((value2) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: value2, children: t(value2 === "inherit" ? "inherit" : `action:${value2}`) }, value2)) });
7411
+ }
7412
+ function RuleEditor({ controller, state, t }) {
7413
+ const id2 = (0, import_react8.useId)(), editor = state.draft?.editor;
7414
+ if (editor == null) return null;
7415
+ const disabled = !controller.canEdit(state.generation), change = (value) => controller.edit(state.generation, { editor: value });
7416
+ const field = (key, label) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7417
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: `${id2}-${key}`, children: t(label) }),
7418
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Input, { className: "dsmm-input", id: `${id2}-${key}`, required: true, maxLength: 32768, disabled, value: key in editor.match ? String(Reflect.get(editor.match, key)) : "", onChange: (event) => change({ ...editor, match: { ...editor.match, [key]: event.currentTarget.value } }) })
7419
+ ] });
7420
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("form", { className: "dsmm-structured", "aria-label": t("editor"), onSubmit: (event) => {
7421
+ event.preventDefault();
7422
+ controller.stageRule(state.generation);
7423
+ }, children: [
7424
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7425
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: `${id2}-id`, children: t("id") }),
7426
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Input, { className: "dsmm-input", id: `${id2}-id`, required: true, maxLength: 256, value: editor.id, disabled, onChange: (event) => change({ ...editor, id: event.currentTarget.value }) })
7427
+ ] }),
7428
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7429
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: `${id2}-action`, children: t("action") }),
7430
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ActionSelect, { id: `${id2}-action`, value: editor.action, disabled, inherit: false, t, onChange: (action2) => {
7431
+ if (action2 !== "inherit") change({ ...editor, action: action2 });
7432
+ } })
7433
+ ] }),
7434
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7435
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: `${id2}-kind`, children: t("match") }),
7436
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("select", { id: `${id2}-kind`, value: editor.match.kind, disabled, onChange: (event) => {
7437
+ const kind = kinds2.find((value) => value === event.currentTarget.value);
7438
+ if (kind !== void 0) change({ ...editor, match: newMatch2(kind) });
7439
+ }, children: kinds2.map((kind) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: kind, children: t(`kind:${kind}`) }, kind)) })
7440
+ ] }),
7441
+ editor.match.kind === "outside-read" && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
7442
+ field("path", "path"),
7443
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7444
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: `${id2}-path-scope`, children: t("pathScope") }),
7445
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("select", { id: `${id2}-path-scope`, value: editor.match.scope, disabled, onChange: (event) => {
7446
+ const scope = event.currentTarget.value;
7447
+ if (editor.match.kind === "outside-read" && (scope === "exact" || scope === "tree")) change({ ...editor, match: { ...editor.match, scope } });
7448
+ }, children: [
7449
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "exact", children: t("exact") }),
7450
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "tree", children: t("tree") })
7451
+ ] })
7452
+ ] })
7453
+ ] }),
7454
+ editor.match.kind === "shell" && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
7455
+ field("executable", "executable"),
7456
+ field("command", "command"),
7457
+ field("workingDirectory", "cwd")
7458
+ ] }),
7459
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-actions", children: [
7460
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "submit", variant: "outline", disabled, children: t("stage") }),
7461
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled, onClick: () => controller.edit(state.generation, { editor: null }), children: t("cancel") })
7462
+ ] })
7463
+ ] });
7464
+ }
7465
+ function RuleRecords({ controller, state, t }) {
7466
+ const records = observedRules(state)?.snapshot.policy.rules ?? state.base?.policy.rules;
7467
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-structured", children: [
7468
+ records?.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("noRules") }),
7469
+ records?.map((rule) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("fieldset", { children: [
7470
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("legend", { children: rule.id }),
7471
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7472
+ t(rule.revoked ? "revoked" : "active"),
7473
+ " · ",
7474
+ t(`action:${rule.action}`)
7475
+ ] }),
7476
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-child-meta", children: [
7477
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("match") }),
7478
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t(`kind:${rule.match.kind}`) }),
7479
+ rule.match.kind === "outside-read" && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
7480
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("path") }),
7481
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dd", { children: [
7482
+ rule.match.path,
7483
+ " · ",
7484
+ t(rule.match.scope)
7485
+ ] })
7486
+ ] }),
7487
+ rule.match.kind === "shell" && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
7488
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("executable") }),
7489
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: rule.match.executable }),
7490
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("command") }),
7491
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("code", { children: rule.match.command }) }),
7492
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("cwd") }),
7493
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: rule.match.workingDirectory })
7494
+ ] }),
7495
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("source") }),
7496
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t(rule.source.kind === "operator" ? "operator" : "imported") })
7497
+ ] }),
7498
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-actions", children: [
7499
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled: !controller.canEdit(state.generation) || state.draft === null, onClick: () => controller.edit(state.generation, { editor: ruleDraft(rule) }), children: t("editRule") }),
7500
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled: !controller.canEdit(state.generation) || state.draft === null || rule.revoked || state.draft.revoke.includes(rule.id), onClick: () => controller.stageRevoke(state.generation, rule.id), children: t("stageRevoke") })
7501
+ ] })
7502
+ ] }, rule.id))
7503
+ ] });
7504
+ }
7505
+ function PermissionCoverage({ state, t }) {
7506
+ const value = observedRules(state)?.capabilities;
7507
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-structured", "aria-label": t("coverageTitle"), children: [
7508
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { children: t("coverageTitle") }),
7509
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("coverage") }),
7510
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("registrationUnresolved") }),
7511
+ value === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("coverageUnavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
7512
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-child-meta", children: [
7513
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("coverageRuntime") }),
7514
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dd", { children: [
7515
+ t(value.runtime.state),
7516
+ " · ",
7517
+ t("mounted"),
7518
+ ": ",
7519
+ t(value.runtime.mounted ? "on" : "off")
7520
+ ] })
7521
+ ] }),
7522
+ value.runtime.restartRequired && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("restart") }),
7523
+ value.tools.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("coverageEmpty") }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("ul", { className: "dsmm-profile-list", children: value.tools.map((tool) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-child-meta", children: [
7524
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("toolName") }),
7525
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("code", { children: tool.name }) }),
7526
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("toolKind") }),
7527
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("code", { children: tool.kind }) }),
7528
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("toolApproval") }),
7529
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("nativeOnce") }),
7530
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("toolMemory") }),
7531
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("notProvided") })
7532
+ ] }) }, tool.name)) }),
7533
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-child-meta", children: [
7534
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("outsideReads") }),
7535
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("limit:outsideReads") }),
7536
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("finalInode") }),
7537
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("limit:finalInode") }),
7538
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("toolMemory") }),
7539
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("limit:scopedMemory") }),
7540
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("webFetch") }),
7541
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("limit:webFetch") }),
7542
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("searchDestinations") }),
7543
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("limit:webSearchDestinations") }),
7544
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("proxyBinding") }),
7545
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("limit:proxyAddressBinding") }),
7546
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("shellSockets") }),
7547
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("limit:shellSockets") }),
7548
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("providerAuthMcp") }),
7549
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("limit:providerAuthMcp") })
7550
+ ] })
7551
+ ] }),
7552
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("pathEvidence") })
7553
+ ] });
7554
+ }
7555
+ function PermissionRulesEditor({ controller, state, t }) {
7556
+ const id2 = (0, import_react8.useId)(), draft2 = state.draft, disabled = !controller.canEdit(state.generation), value = observedRules(state), observedPolicy = value?.snapshot ?? null;
7557
+ const writable = state.scope === "root" && state.connected;
7558
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-zone", "aria-label": t("rules"), children: [
7559
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { children: t("rules") }),
7560
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("rulesHint") }),
7561
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("networkLimit") }),
7562
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("matchHint") }),
7563
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Issue, { value: state.rulesIssue, t }),
7564
+ displayUnconfirmed(state) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("unconfirmedObservation") }),
7565
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("observedPolicy") }),
7566
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-child-meta", children: [
7567
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("profileOverrideState") }),
7568
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t("profileOverrideUnknown") })
7569
+ ] }),
7570
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-child-meta", children: [
7571
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("runtime") }),
7572
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: value === null ? t("unknown") : t(value.runtime.state) }),
7573
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: t("mounted") }),
7574
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: value === null ? t("unknown") : t(value.runtime.mounted ? "on" : "off") })
7575
+ ] }),
7576
+ value?.runtime.restartRequired && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("restart") }),
7577
+ disabled && !state.reading && !displayUnconfirmed(state) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("rulesUnavailable") }),
7578
+ observedPolicy !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-child-meta", children: [
7579
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: "permissionControl.enabled" }),
7580
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dd", { children: [
7581
+ t(observedPolicy.policy.enabled ? "on" : "off"),
7582
+ " · ",
6992
7583
  t("coldHint")
6993
7584
  ] }),
6994
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dt", { children: "permissionControl.nativeCommands.enabled" }),
6995
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("dd", { children: t(state.base.policy.nativeCommands.enabled ? "on" : "off") })
7585
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: "permissionControl.nativeCommands.enabled" }),
7586
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dd", { children: t(observedPolicy.policy.nativeCommands.enabled ? "on" : "off") })
6996
7587
  ] }),
6997
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PermissionCoverage, { state, t }),
6998
- draft2 !== null && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
6999
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
7000
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: `${id2}-outside`, children: t("outsideReads") }),
7001
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionSelect, { id: `${id2}-outside`, value: draft2.outsideReads, disabled, t, onChange: (outsideReads) => controller.edit(state.generation, { outsideReads }) })
7588
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("details", { className: "dsmm-deployment-group", children: [
7589
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("summary", { children: t("coverageDetails") }),
7590
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PermissionCoverage, { state, t })
7591
+ ] }),
7592
+ draft2 !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
7593
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7594
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: `${id2}-outside`, children: t("outsideReads") }),
7595
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ActionSelect, { id: `${id2}-outside`, value: draft2.outsideReads, disabled, t, onChange: (outsideReads) => controller.edit(state.generation, { outsideReads }) })
7002
7596
  ] }),
7003
- ["webSearch", "webFetch"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("fieldset", { children: [
7004
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("legend", { children: t(key) }),
7005
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: "dsmm-actions", htmlFor: `${id2}-${key}-enabled`, children: [
7006
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("input", { type: "checkbox", id: `${id2}-${key}-enabled`, checked: draft2[key].enabled, disabled, onChange: (event) => controller.edit(state.generation, { [key]: { ...draft2[key], enabled: event.currentTarget.checked } }) }),
7597
+ ["webSearch", "webFetch"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("fieldset", { children: [
7598
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("legend", { children: t(key) }),
7599
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("label", { className: "dsmm-actions", htmlFor: `${id2}-${key}-enabled`, children: [
7600
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("input", { type: "checkbox", id: `${id2}-${key}-enabled`, checked: draft2[key].enabled, disabled, onChange: (event) => controller.edit(state.generation, { [key]: { ...draft2[key], enabled: event.currentTarget.checked } }) }),
7007
7601
  t("enabled")
7008
7602
  ] }),
7009
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
7010
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("label", { htmlFor: `${id2}-${key}-rule`, children: t("rule") }),
7011
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ActionSelect, { id: `${id2}-${key}-rule`, value: draft2[key].rule, disabled, t, onChange: (rule) => controller.edit(state.generation, { [key]: { ...draft2[key], rule } }) })
7603
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7604
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: `${id2}-${key}-rule`, children: t("rule") }),
7605
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ActionSelect, { id: `${id2}-${key}-rule`, value: draft2[key].rule, disabled, t, onChange: (rule) => controller.edit(state.generation, { [key]: { ...draft2[key], rule } }) })
7012
7606
  ] })
7013
7607
  ] }, key)),
7014
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", disabled: disabled || draft2.editor !== null, onClick: () => controller.edit(state.generation, { editor: { id: "", action: "ask", match: newMatch("outside-read") } }), children: t("newRule") }),
7015
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RuleEditor, { controller, state, t }),
7016
- (draft2.upsert.length > 0 || draft2.revoke.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-structured", children: [
7017
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h3", { children: t("staged") }),
7018
- draft2.upsert.map((row) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
7019
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { children: [
7608
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled: disabled || draft2.editor !== null, onClick: () => controller.edit(state.generation, { editor: { id: "", action: "ask", match: newMatch2("outside-read") } }), children: t("newRule") }),
7609
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RuleEditor, { controller, state, t }),
7610
+ (draft2.upsert.length > 0 || draft2.revoke.length > 0) && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-structured", children: [
7611
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { children: t("staged") }),
7612
+ draft2.upsert.map((row) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7613
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7020
7614
  row.id,
7021
7615
  " · ",
7022
7616
  t(`kind:${row.match.kind}`),
7023
7617
  " · ",
7024
7618
  t(`action:${row.action}`)
7025
7619
  ] }),
7026
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", disabled, onClick: () => controller.edit(state.generation, { upsert: draft2.upsert.filter((rule) => rule.id !== row.id) }), children: [
7620
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled, onClick: () => controller.edit(state.generation, { upsert: draft2.upsert.filter((rule) => rule.id !== row.id) }), children: [
7027
7621
  t("unstage"),
7028
7622
  ": ",
7029
7623
  row.id
7030
7624
  ] })
7031
7625
  ] }, row.id)),
7032
- draft2.revoke.map((ruleId) => /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-field", children: [
7033
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("p", { children: [
7626
+ draft2.revoke.map((ruleId) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7627
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7034
7628
  t("stageRevoke"),
7035
7629
  ": ",
7036
7630
  ruleId
7037
7631
  ] }),
7038
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", disabled, onClick: () => controller.edit(state.generation, { revoke: draft2.revoke.filter((id3) => id3 !== ruleId) }), children: [
7632
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled, onClick: () => controller.edit(state.generation, { revoke: draft2.revoke.filter((id3) => id3 !== ruleId) }), children: [
7039
7633
  t("unstage"),
7040
7634
  ": ",
7041
7635
  ruleId
@@ -7043,58 +7637,60 @@ function PermissionRulesEditor({ controller, state, t }) {
7043
7637
  ] }, ruleId))
7044
7638
  ] })
7045
7639
  ] }),
7046
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RuleRecords, { state, controller, t }),
7047
- /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "dsmm-actions", children: [
7048
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "primary", disabled: !controller.canSave(state.generation), onClick: () => void controller.save(state.generation), children: t("save") }),
7049
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_dsh_client_ui_primitives7.Button, { type: "button", variant: "outline", disabled: state.scope !== "root" || !state.connected || state.reading || state.busy !== null, onClick: () => void controller.refresh(state.generation, true), children: t("discard") })
7640
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RuleRecords, { state, controller, t }),
7641
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-actions", children: [
7642
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "primary", disabled: !controller.canSave(state.generation), onClick: () => void controller.save(state.generation), children: t("save") }),
7643
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled: !writable || state.reading || state.busy !== null, onClick: () => void controller.refresh(state.generation), children: t("refresh") }),
7644
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled: !writable || state.reading || state.busy !== null || !state.dirty && state.rulesIssue === null, onClick: () => void controller.refresh(state.generation, true), children: t("discard") })
7050
7645
  ] }),
7051
- state.dirty && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: t("dirty") })
7646
+ state.dirty && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("dirty") })
7052
7647
  ] });
7053
7648
  }
7054
7649
  function PermissionsPanel({ controller, t, sessionId: sessionId2 }) {
7055
- const state = (0, import_react7.useSyncExternalStore)(controller.store.subscribe, controller.store.getSnapshot);
7056
- (0, import_react7.useEffect)(() => controller.watch(), [controller]);
7057
- if (sessionId2 !== void 0 && sessionId2 !== state.sessionId) return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", role: "status", children: t("rulesUnavailable") });
7058
- return /* @__PURE__ */ (0, import_jsx_runtime9.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: [
7059
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("h2", { children: t("title") }),
7060
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(RootState, { state, t }),
7061
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-hint", children: t("nativeApproval") }),
7062
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: state.busy !== null ? t("busy") : state.reading ? t("reading") : state.notice === null ? "" : t(state.notice) }),
7063
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(PermissionRulesEditor, { controller, state, t })
7650
+ const state = (0, import_react8.useSyncExternalStore)(controller.store.subscribe, controller.store.getSnapshot);
7651
+ (0, import_react8.useEffect)(() => controller.watch(), [controller]);
7652
+ if (sessionId2 !== void 0 && sessionId2 !== state.sessionId) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", role: "status", children: t("rulesUnavailable") });
7653
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-profiles dsmm-children dsmm-permissions", "data-dsmm-permissions": true, "aria-label": t("title"), "aria-busy": state.reading, children: [
7654
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { children: t("title") }),
7655
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(RootState, { state, t }),
7656
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("nativeApproval") }),
7657
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("sandboxScope") }),
7658
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: state.busy !== null ? t("busy") : state.reading ? t("reading") : state.notice === null ? "" : t(state.notice) }),
7659
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PermissionRulesEditor, { controller, state, t })
7064
7660
  ] });
7065
7661
  }
7066
7662
 
7067
7663
  // src/client/DeploymentPage.tsx
7068
- var import_jsx_runtime10 = require("react/jsx-runtime");
7664
+ var import_jsx_runtime11 = require("react/jsx-runtime");
7069
7665
  function ScopeSave({ controller, workspace, refreshOnly = false, t }) {
7070
- const state = (0, import_react8.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
7666
+ const state = (0, import_react9.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
7071
7667
  const pending = [...new Set(controller.pendingPaths().map(moduleFor))];
7072
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-scope-save", "aria-label": t(refreshOnly ? "refresh" : "saveScope"), children: [
7073
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: refreshOnly ? state.busy ? t("loading") : "" : state.busy ? t("saving") : state.refreshRequired ? t("savedRefreshRequired") : state.saved ? t("saved") : state.dirty ? t("dirty") : "" }),
7074
- !refreshOnly && pending.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7668
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { className: "dsmm-scope-save", "aria-label": t("saveScope"), children: [
7669
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: refreshOnly ? state.busy ? t("loading") : "" : state.busy ? t("saving") : state.refreshRequired ? t("savedRefreshRequired") : state.saved ? t("saved") : state.dirty ? t("dirty") : "" }),
7670
+ !refreshOnly && pending.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
7075
7671
  t("pendingModules"),
7076
7672
  ": ",
7077
7673
  pending.map((module2) => t(moduleTitle(module2))).join(" · ")
7078
7674
  ] }),
7079
- state.issue !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-issue", role: "alert", children: t(state.issue) }),
7080
- !refreshOnly && state.invalidFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-issue", role: "alert", children: t("invalid") }),
7081
- controller.layer === "profile" && !controller.canWriteProfile() && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("unavailableForm") }),
7082
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-actions", children: [
7083
- !refreshOnly && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "primary", disabled: !controller.canSave(), onClick: () => void (workspace?.save() ?? controller.save()), children: t(controller.layer === "global" ? "saveGlobal" : "saveProfile") }),
7084
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void controller.refresh(), children: t("refresh") }),
7085
- !refreshOnly && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled: state.busy || !state.dirty && state.issue === null && !state.refreshRequired, onClick: () => void controller.refresh(true), children: t("discard") })
7675
+ state.issue !== null && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-issue", role: "alert", children: t(state.issue) }),
7676
+ !refreshOnly && state.invalidFields.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-issue", role: "alert", children: t("invalid") }),
7677
+ controller.layer === "profile" && !controller.canWriteProfile() && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-hint", children: t("unavailableForm") }),
7678
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "dsmm-actions", children: [
7679
+ !refreshOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dsh_client_ui_primitives9.Button, { type: "button", variant: "primary", disabled: !controller.canSave(), onClick: () => void (workspace?.save() ?? controller.save()), children: t(controller.layer === "global" ? "saveGlobal" : "saveProfile") }),
7680
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dsh_client_ui_primitives9.Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void controller.refresh(), children: t("refresh") }),
7681
+ !refreshOnly && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dsh_client_ui_primitives9.Button, { type: "button", variant: "outline", disabled: state.busy || !state.dirty && state.issue === null && !state.refreshRequired, onClick: () => void controller.refresh(true), children: t("discard") })
7086
7682
  ] })
7087
7683
  ] });
7088
7684
  }
7089
7685
  function NativeRuntimeState({ value, t }) {
7090
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("details", { className: "dsmm-availability", children: [
7091
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("summary", { children: t("nativeRuntimeState") }),
7092
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7686
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("details", { className: "dsmm-availability", children: [
7687
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("summary", { children: t("nativeRuntimeState") }),
7688
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
7093
7689
  t("nativeRuntimeBinding"),
7094
7690
  ": ",
7095
7691
  t(value?.binding === "stock" ? "nativeRuntimeStock" : value?.binding === "unavailable" ? "nativeRuntimeUnavailable" : "unknown")
7096
7692
  ] }),
7097
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7693
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
7098
7694
  t("nativeRuntimeFence"),
7099
7695
  ": ",
7100
7696
  value === void 0 ? t("unknown") : t(value.deliveryFenceReady ? "on" : "off"),
@@ -7103,20 +7699,20 @@ function NativeRuntimeState({ value, t }) {
7103
7699
  ": ",
7104
7700
  value === void 0 ? t("unknown") : t(value.restartRequired ? "on" : "off")
7105
7701
  ] }),
7106
- value?.reason !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t(`nativeRuntimeReason-${value.reason}`) })
7702
+ value?.reason !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t(`nativeRuntimeReason-${value.reason}`) })
7107
7703
  ] });
7108
7704
  }
7109
7705
  function StateInspector({ controller, t }) {
7110
- const { snapshot: snapshot4, session, dirty, issue } = (0, import_react8.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
7111
- if (snapshot4 === null) return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("unavailable") });
7706
+ const { snapshot: snapshot4, session, dirty, issue } = (0, import_react9.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
7707
+ if (snapshot4 === null) return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("unavailable") });
7112
7708
  const admitted = session?.configuration ?? null;
7113
7709
  const source = (value2) => t(value2 === "profile" ? "profileSource" : value2 === "global" ? "globalSource" : value2 === "defaults" ? "defaultsSource" : value2 === "named-session" ? "namedSource" : value2 === "startup" ? "startupSource" : value2 === "deployment" ? "deploymentCapture" : value2 === "mixed" ? "mixedSource" : "unknown");
7114
7710
  const value = (layer, path) => layer === void 0 ? t("unknown") : at(layer, path.split(".")) === void 0 ? t("absent") : displayValue(at(layer, path.split(".")), t);
7115
7711
  const restart = (snapshot4.nextRoot?.restartRequired ?? []).filter((path) => visibleDeploymentPath(path.split(".")));
7116
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-structured", children: [
7117
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { role: "status", children: session === null ? t("noSession") : admitted === null ? t("sessionUnavailable") : t("sessionObserved") }),
7118
- (dirty || issue !== null) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("inspectorStale") }),
7119
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7712
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "dsmm-structured", children: [
7713
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { role: "status", children: session === null ? t("noSession") : admitted === null ? t("sessionUnavailable") : t("sessionObserved") }),
7714
+ (dirty || issue !== null) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-hint", children: t("inspectorStale") }),
7715
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
7120
7716
  t("globalSource"),
7121
7717
  ": ",
7122
7718
  t(configurationVersionState(snapshot4.globalRevision)),
@@ -7125,52 +7721,52 @@ function StateInspector({ controller, t }) {
7125
7721
  ": ",
7126
7722
  t(configurationVersionState(snapshot4.nativeRevision))
7127
7723
  ] }),
7128
- snapshot4.subagentRuntime !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NativeRuntimeState, { value: snapshot4.subagentRuntime, t }),
7129
- snapshot4.modules.map((module2) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-zone", children: [
7130
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { children: module2.descriptor.label }),
7131
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7724
+ snapshot4.subagentRuntime !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NativeRuntimeState, { value: snapshot4.subagentRuntime, t }),
7725
+ snapshot4.modules.map((module2) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { className: "dsmm-zone", children: [
7726
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { children: module2.descriptor.label }),
7727
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
7132
7728
  t("desired"),
7133
7729
  ": ",
7134
7730
  t(module2.desired.enabled ? "on" : "off"),
7135
7731
  " · ",
7136
7732
  source(module2.desired.source)
7137
7733
  ] }),
7138
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7734
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
7139
7735
  t("startup"),
7140
7736
  ": ",
7141
7737
  module2.startupMounted == null ? t("unknown") : t(module2.startupMounted ? "on" : "off")
7142
7738
  ] }),
7143
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7739
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
7144
7740
  t("next"),
7145
7741
  ": ",
7146
7742
  module2.nextRoot.admitted == null ? t("unknown") : t(module2.nextRoot.admitted ? "on" : "off")
7147
7743
  ] }),
7148
- module2.pending && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("pending") })
7744
+ module2.pending && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("pending") })
7149
7745
  ] }, module2.descriptor.id)),
7150
- inspectorPaths(snapshot4, admitted).map((path) => /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dl", { className: "dsmm-deployment-state", children: [
7151
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("dt", { children: path }),
7152
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dd", { children: [
7746
+ inspectorPaths(snapshot4, admitted).map((path) => /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("dl", { className: "dsmm-deployment-state", children: [
7747
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("dt", { children: path }),
7748
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("dd", { children: [
7153
7749
  t("desired"),
7154
7750
  ": ",
7155
7751
  value(snapshot4.desired, path),
7156
7752
  " · ",
7157
7753
  source(snapshot4.sources[path])
7158
7754
  ] }),
7159
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dd", { children: [
7755
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("dd", { children: [
7160
7756
  t("startup"),
7161
7757
  ": ",
7162
7758
  value(snapshot4.startup, path),
7163
7759
  " · ",
7164
7760
  source(snapshot4.startupSources?.[path])
7165
7761
  ] }),
7166
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dd", { children: [
7762
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("dd", { children: [
7167
7763
  t("next"),
7168
7764
  ": ",
7169
7765
  value(snapshot4.nextRoot?.settings, path),
7170
7766
  " · ",
7171
7767
  source(snapshot4.nextRoot?.sources[path])
7172
7768
  ] }),
7173
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("dd", { children: [
7769
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("dd", { children: [
7174
7770
  t("session"),
7175
7771
  ": ",
7176
7772
  value(admitted?.settings, path),
@@ -7178,7 +7774,7 @@ function StateInspector({ controller, t }) {
7178
7774
  source(admitted?.sources[path])
7179
7775
  ] })
7180
7776
  ] }, path)),
7181
- restart.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { children: [
7777
+ restart.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
7182
7778
  t("pending"),
7183
7779
  ": ",
7184
7780
  restart.join(", ")
@@ -7187,27 +7783,30 @@ function StateInspector({ controller, t }) {
7187
7783
  }
7188
7784
  function DeploymentPage(props) {
7189
7785
  const workspace = props.workspace ?? deploymentWorkspace(props.core, props.permissions);
7190
- const navigation = (0, import_react8.useSyncExternalStore)(workspace.subscribe, workspace.getSnapshot);
7191
- const core = (0, import_react8.useSyncExternalStore)(props.core.subscribe, props.core.getSnapshot);
7786
+ const navigation = (0, import_react9.useSyncExternalStore)(workspace.subscribe, workspace.getSnapshot);
7787
+ const core = (0, import_react9.useSyncExternalStore)(props.core.subscribe, props.core.getSnapshot);
7192
7788
  const controller = workspace.controller() ?? props.core;
7193
- const state = (0, import_react8.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
7194
- const id2 = (0, import_react8.useId)(), heading = (0, import_react8.useRef)(null), triggers = (0, import_react8.useRef)(/* @__PURE__ */ new Map()), previous = (0, import_react8.useRef)(null);
7195
- const scopeControl = (0, import_react8.useRef)(null), confirmation = (0, import_react8.useRef)(null);
7196
- const resume = (0, import_react8.useRef)(null);
7197
- const disclosures = (0, import_react8.useRef)({ global: /* @__PURE__ */ new Map(), profile: /* @__PURE__ */ new Map() });
7789
+ const state = (0, import_react9.useSyncExternalStore)(controller.subscribe, controller.getSnapshot);
7790
+ const id2 = (0, import_react9.useId)(), heading = (0, import_react9.useRef)(null), triggers = (0, import_react9.useRef)(/* @__PURE__ */ new Map()), previous = (0, import_react9.useRef)(null);
7791
+ const scopeControl = (0, import_react9.useRef)(null), confirmation = (0, import_react9.useRef)(null);
7792
+ const resume = (0, import_react9.useRef)(null);
7793
+ const disclosures = (0, import_react9.useRef)({ global: /* @__PURE__ */ new Map(), profile: /* @__PURE__ */ new Map() });
7198
7794
  const { t } = props, snapshot4 = state.snapshot ?? core.snapshot, active = navigation.module;
7199
- (0, import_react8.useEffect)(() => {
7795
+ (0, import_react9.useEffect)(() => {
7200
7796
  if (props.view === "page") void props.core.refresh();
7201
7797
  }, [props.core, props.view]);
7202
- (0, import_react8.useEffect)(() => {
7798
+ (0, import_react9.useEffect)(() => {
7203
7799
  if (props.forms !== void 0) workspace.bindForms(props.forms);
7204
7800
  }, [workspace, props.forms]);
7205
- (0, import_react8.useEffect)(() => {
7801
+ (0, import_react9.useEffect)(() => {
7802
+ if (navigation.module === null && core.snapshot !== null) workspace.request({ scope: navigation.scope, module: null });
7803
+ }, [core.snapshot, navigation.module, navigation.scope, workspace]);
7804
+ (0, import_react9.useEffect)(() => {
7206
7805
  if (active !== null) heading.current?.focus();
7207
7806
  else if (previous.current !== null) triggers.current.get(previous.current)?.focus();
7208
7807
  previous.current = active;
7209
7808
  }, [active]);
7210
- (0, import_react8.useEffect)(() => {
7809
+ (0, import_react9.useEffect)(() => {
7211
7810
  if (navigation.pending !== null) {
7212
7811
  resume.current = { element: document.activeElement, scope: navigation.scope, module: active };
7213
7812
  confirmation.current?.focus();
@@ -7220,69 +7819,87 @@ function DeploymentPage(props) {
7220
7819
  else if (from2.scope !== navigation.scope) scopeControl.current?.focus();
7221
7820
  }
7222
7821
  }, [navigation.pending, navigation.scope, active]);
7223
- if (props.view === "summary") return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { children: t("summary") });
7822
+ if (props.view === "summary") return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { children: t("summary") });
7224
7823
  const fields = snapshot4 === null || active === null ? [] : moduleFields(scopeSchema(snapshot4, controller.layer), active, controller.layer);
7225
- const modules = CONFIG_MODULES.filter((module2) => module2 === "state" || module2 === "permissions" || snapshot4 === null || moduleFields(snapshot4.schema, module2, "global").length + moduleFields(scopeSchema(snapshot4, "profile"), module2, "profile").length > 0);
7226
- const scopeActions = /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ScopeSave, { controller: active === "state" ? props.core : controller, workspace, refreshOnly: active === "state" || workspace.controller() === null, t });
7227
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-profiles dsmm-deployment", "data-dsmm-page": true, "aria-label": t("title"), children: [
7228
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("boundaries") }),
7229
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-field", children: [
7230
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("label", { htmlFor: `${id2}-scope`, children: t("scope") }),
7231
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("select", { ref: scopeControl, id: `${id2}-scope`, value: navigation.scope, disabled: state.busy || navigation.pending !== null, onChange: (event) => {
7824
+ const tabs = NAVIGATION_MODULES.filter((module2) => module2 !== "other" || snapshot4 === null || moduleFields(snapshot4.schema, "other", "global").length + moduleFields(scopeSchema(snapshot4, "profile"), "other", "profile").length > 0);
7825
+ const select = (module2) => workspace.request({ scope: navigation.scope, module: module2 });
7826
+ const onTabKey = (event, index) => {
7827
+ const last = tabs.length - 1, move = (target) => {
7828
+ const next = tabs[(target + tabs.length) % tabs.length];
7829
+ triggers.current.get(next)?.focus();
7830
+ };
7831
+ if (event.key === "ArrowRight") move(index + 1);
7832
+ else if (event.key === "ArrowLeft") move(index - 1);
7833
+ else if (event.key === "Home") move(0);
7834
+ else if (event.key === "End") move(last);
7835
+ else return;
7836
+ event.preventDefault();
7837
+ };
7838
+ const scopeActions = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(ScopeSave, { controller: active === "state" ? props.core : controller, workspace, refreshOnly: active === "state" || workspace.controller() === null, t });
7839
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { className: "dsmm-profiles dsmm-deployment", "data-dsmm-page": true, "aria-label": t("title"), children: [
7840
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-hint", children: t("boundaries") }),
7841
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "dsmm-field", children: [
7842
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("label", { htmlFor: `${id2}-scope`, children: t("scope") }),
7843
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("select", { ref: scopeControl, id: `${id2}-scope`, value: navigation.scope, disabled: state.busy || navigation.pending !== null, onChange: (event) => {
7232
7844
  const scope = event.currentTarget.value;
7233
- if (scope === "global" || scope === "profile") workspace.request({ scope, module: active });
7845
+ if (scope === "global" || scope === "profile") workspace.request({ scope, module: null });
7234
7846
  }, children: [
7235
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "global", children: t("global") }),
7236
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("option", { value: "profile", children: t("profile") })
7847
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: "global", children: t("global") }),
7848
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("option", { value: "profile", children: t("profile") })
7237
7849
  ] })
7238
7850
  ] }),
7239
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t(navigation.scope === "global" ? "globalHint" : "profileHint") }),
7240
- navigation.scope === "profile" && (navigation.native === null || !navigation.native.canWriteProfile()) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("unavailableForm") }),
7241
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-deployment-frame", "data-drawer-open": active !== null, children: [
7242
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("nav", { className: "dsmm-module-list", "aria-label": t("modules"), children: modules.map((module2) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { ref: (element) => {
7243
- if (element !== null) triggers.current.set(module2, element);
7244
- }, type: "button", variant: "outline", disabled: navigation.pending !== null, "aria-expanded": active === module2, "aria-controls": `${id2}-drawer`, onClick: () => workspace.request({ scope: navigation.scope, module: module2 }), children: t(moduleTitle(module2)) }, module2)) }),
7245
- active !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("aside", { id: `${id2}-drawer`, className: "dsmm-module-drawer", "aria-labelledby": `${id2}-heading`, "data-dsmm-module": active, onKeyDown: (event) => {
7246
- if (event.key !== "Escape" || event.defaultPrevented) return;
7247
- const target = event.target;
7248
- if (target.tagName === "SELECT" && (!globalThis.CSS?.supports("selector(select:open)") || target.matches("select:open"))) return;
7249
- event.preventDefault();
7250
- if (navigation.pending !== null) workspace.continueEditing();
7251
- else workspace.request({ scope: navigation.scope, module: null });
7252
- }, children: [
7253
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-drawer-heading", children: [
7254
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { id: `${id2}-heading`, ref: heading, tabIndex: -1, children: t(moduleTitle(active)) }),
7255
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => workspace.request({ scope: navigation.scope, module: null }), children: t("close") })
7851
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-hint", children: t(navigation.scope === "global" ? "globalHint" : "profileHint") }),
7852
+ navigation.scope === "profile" && (navigation.native === null || !navigation.native.canWriteProfile()) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-hint", children: t("unavailableForm") }),
7853
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "dsmm-section-tabs", role: "tablist", "aria-label": t("modules"), children: tabs.map((module2, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
7854
+ import_dsh_client_ui_primitives9.Button,
7855
+ {
7856
+ ref: (element) => {
7857
+ if (element !== null) triggers.current.set(module2, element);
7858
+ else triggers.current.delete(module2);
7859
+ },
7860
+ role: "tab",
7861
+ type: "button",
7862
+ id: `${id2}-tab-${module2}`,
7863
+ "aria-selected": active === module2,
7864
+ "aria-controls": `${id2}-panel`,
7865
+ tabIndex: active === module2 ? 0 : -1,
7866
+ "data-dsmm-tab": module2,
7867
+ onKeyDown: (event) => onTabKey(event, index),
7868
+ onClick: () => select(module2),
7869
+ children: t(moduleTitle(module2))
7870
+ },
7871
+ module2
7872
+ )) }),
7873
+ active !== null && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { id: `${id2}-panel`, role: "tabpanel", className: "dsmm-section-panel", "aria-labelledby": `${id2}-tab-${active}`, "data-dsmm-module": active, children: [
7874
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "dsmm-panel-heading", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h2", { id: `${id2}-heading`, ref: heading, tabIndex: -1, children: t(moduleTitle(active)) }) }),
7875
+ active === "state" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
7876
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(StateInspector, { controller: props.core, t }),
7877
+ scopeActions
7878
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
7879
+ navigation.scope === "profile" && navigation.native === null ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("unavailableForm") }) : state.snapshot === null ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t(state.busy ? "loading" : "unavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { "data-dsmm-layer": controller.layer, "aria-busy": state.busy, className: "dsmm-structured", children: [
7880
+ fields.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-hint", children: t("noModuleFields") }),
7881
+ fields.map(([key, schema]) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Field, { schema, path: [key], controller, initiallyOpen: fields.length === 1 && active !== "permissions", disclosures: disclosures.current[navigation.scope], t }, `${navigation.scope}:${key}`)),
7882
+ active === "run" && controller.layer === "profile" && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(NativeRuntimeState, { value: state.snapshot.subagentRuntime, t })
7256
7883
  ] }),
7257
- active === "state" ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
7258
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(StateInspector, { controller: props.core, t }),
7259
- scopeActions
7260
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
7261
- navigation.scope === "profile" && navigation.native === null ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("unavailableForm") }) : state.snapshot === null ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t(state.busy ? "loading" : "unavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { "data-dsmm-layer": controller.layer, "aria-busy": state.busy, className: "dsmm-structured", children: [
7262
- fields.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("noModuleFields") }),
7263
- fields.map(([key, schema]) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Field, { schema, path: [key], controller, initiallyOpen: fields.length === 1 && active !== "permissions", disclosures: disclosures.current[navigation.scope], t }, `${navigation.scope}:${key}`)),
7264
- active === "run" && controller.layer === "profile" && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(NativeRuntimeState, { value: state.snapshot.subagentRuntime, t })
7265
- ] }),
7266
- scopeActions,
7267
- active === "permissions" && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-zone", children: [
7268
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { children: t("rootRules") }),
7269
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { className: "dsmm-hint", children: t("rootRulesHint") }),
7270
- workspace.permissions === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("rootRulesUnavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PermissionsPanel, { controller: workspace.permissions, t: props.permissionsT ?? ((key) => Object.hasOwn(permissionEn, key) ? permissionText(t)(key) : key) })
7271
- ] })
7884
+ scopeActions,
7885
+ active === "permissions" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { className: "dsmm-zone dsmm-rules-transaction", "aria-label": t("rootRules"), children: [
7886
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("h3", { children: t("rootRules") }),
7887
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-hint", children: t("rootRulesHint") }),
7888
+ workspace.permissions === void 0 ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("rootRulesUnavailable") }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(PermissionsPanel, { controller: workspace.permissions, t: props.permissionsT ?? ((key) => Object.hasOwn(permissionEn, key) ? permissionText(t)(key) : key) })
7272
7889
  ] })
7273
7890
  ] })
7274
7891
  ] }),
7275
- navigation.pending !== null && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("section", { className: "dsmm-confirm", role: "group", "aria-label": t("leaveDraft"), onKeyDown: (event) => {
7892
+ navigation.pending !== null && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("section", { className: "dsmm-confirm", role: "group", "aria-label": t("leaveDraft"), onKeyDown: (event) => {
7276
7893
  if (event.key === "Escape" && !event.defaultPrevented) {
7277
7894
  event.preventDefault();
7278
7895
  workspace.continueEditing();
7279
7896
  }
7280
7897
  }, children: [
7281
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { children: t("leaveDraft") }),
7282
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "dsmm-actions", children: [
7283
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { ref: confirmation, type: "button", variant: "primary", onClick: () => workspace.continueEditing(), children: t("continueEditing") }),
7284
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", onClick: () => workspace.keepAndNavigate(), children: t("keepDraft") }),
7285
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_dsh_client_ui_primitives8.Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void workspace.discardAndNavigate(), children: t("discardDraft") })
7898
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("leaveDraft") }),
7899
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "dsmm-actions", children: [
7900
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dsh_client_ui_primitives9.Button, { ref: confirmation, type: "button", variant: "primary", onClick: () => workspace.continueEditing(), children: t("continueEditing") }),
7901
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dsh_client_ui_primitives9.Button, { type: "button", variant: "outline", onClick: () => workspace.keepAndNavigate(), children: t("keepDraft") }),
7902
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dsh_client_ui_primitives9.Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void workspace.discardAndNavigate(), children: t("discardDraft") })
7286
7903
  ] })
7287
7904
  ] })
7288
7905
  ] });
@@ -7303,65 +7920,65 @@ var ROLE_CONTROL_ERROR_CODES = ["validation", "not-owned", "unavailable", "cance
7303
7920
  var ROLE_CONTROL_ERROR_FIELDS = ["sessionId", "parentSessionId", "childSessionId", "request", "content", "clientTimeZone"];
7304
7921
 
7305
7922
  // src/role-control-remote.ts
7306
- function fail3() {
7923
+ function fail4() {
7307
7924
  throw new TypeError("Invalid Deepwork child control DTO.");
7308
7925
  }
7309
7926
  function json(value, depth2 = 0, active = /* @__PURE__ */ new Set()) {
7310
- if (depth2 > 24) fail3();
7927
+ if (depth2 > 24) fail4();
7311
7928
  if (value === null || typeof value === "boolean" || typeof value === "string") return value;
7312
7929
  if (typeof value === "number" && Number.isFinite(value)) return value;
7313
- if (typeof value !== "object" || value === null || active.has(value)) fail3();
7930
+ if (typeof value !== "object" || value === null || active.has(value)) fail4();
7314
7931
  const isArray = Array.isArray(value);
7315
- if (Object.getPrototypeOf(value) !== (isArray ? Array.prototype : Object.prototype) && (isArray || Object.getPrototypeOf(value) !== null)) fail3();
7316
- if (Object.getOwnPropertySymbols(value).length) fail3();
7932
+ if (Object.getPrototypeOf(value) !== (isArray ? Array.prototype : Object.prototype) && (isArray || Object.getPrototypeOf(value) !== null)) fail4();
7933
+ if (Object.getOwnPropertySymbols(value).length) fail4();
7317
7934
  for (const [key, property2] of Object.entries(Object.getOwnPropertyDescriptors(value))) {
7318
7935
  if (isArray && key === "length") continue;
7319
- if (!Object.hasOwn(property2, "value") || !property2.enumerable || ["__proto__", "prototype", "constructor"].includes(key) || isArray && !/^(0|[1-9][0-9]*)$/u.test(key)) fail3();
7936
+ if (!Object.hasOwn(property2, "value") || !property2.enumerable || ["__proto__", "prototype", "constructor"].includes(key) || isArray && !/^(0|[1-9][0-9]*)$/u.test(key)) fail4();
7320
7937
  }
7321
- if (isArray && Object.keys(value).length !== value.length) fail3();
7938
+ if (isArray && Object.keys(value).length !== value.length) fail4();
7322
7939
  active.add(value);
7323
7940
  const result = isArray ? value.map((child2) => json(child2, depth2 + 1, active)) : Object.fromEntries(Object.entries(value).map(([key, child2]) => [key, json(child2, depth2 + 1, active)]));
7324
7941
  active.delete(value);
7325
7942
  return result;
7326
7943
  }
7327
7944
  function object2(value, required, optional2 = []) {
7328
- if (typeof value !== "object" || value === null || Array.isArray(value)) fail3();
7945
+ if (typeof value !== "object" || value === null || Array.isArray(value)) fail4();
7329
7946
  const row = value;
7330
- if (required.some((key) => !Object.hasOwn(row, key)) || Object.keys(row).some((key) => !required.includes(key) && !optional2.includes(key))) fail3();
7947
+ if (required.some((key) => !Object.hasOwn(row, key)) || Object.keys(row).some((key) => !required.includes(key) && !optional2.includes(key))) fail4();
7331
7948
  return row;
7332
7949
  }
7333
7950
  function choice(value, choices) {
7334
- if (!choices.includes(value)) fail3();
7951
+ if (!choices.includes(value)) fail4();
7335
7952
  return value;
7336
7953
  }
7337
- function text3(value, max) {
7338
- if (typeof value !== "string" || value.length > max || /[\u0000-\u001f\u007f]/u.test(value) || new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value) fail3();
7954
+ function text4(value, max) {
7955
+ if (typeof value !== "string" || value.length > max || /[\u0000-\u001f\u007f]/u.test(value) || new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(new TextEncoder().encode(value)) !== value) fail4();
7339
7956
  return value;
7340
7957
  }
7341
7958
  function identity(value) {
7342
- if (!isNativeSessionId(value)) fail3();
7959
+ if (!isNativeSessionId(value)) fail4();
7343
7960
  return value;
7344
7961
  }
7345
7962
  function epoch2(value) {
7346
- if (typeof value !== "string" || !/^[a-f0-9]{64}$/u.test(value)) fail3();
7963
+ if (typeof value !== "string" || !/^[a-f0-9]{64}$/u.test(value)) fail4();
7347
7964
  return value;
7348
7965
  }
7349
7966
  function array(value, max = 4096) {
7350
- if (!Array.isArray(value) || value.length > max) fail3();
7967
+ if (!Array.isArray(value) || value.length > max) fail4();
7351
7968
  return value;
7352
7969
  }
7353
7970
  function bool(value) {
7354
- if (typeof value !== "boolean") fail3();
7971
+ if (typeof value !== "boolean") fail4();
7355
7972
  return value;
7356
7973
  }
7357
7974
  function depth(value) {
7358
- if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 4096) fail3();
7975
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 1 || value > 4096) fail4();
7359
7976
  return value;
7360
7977
  }
7361
7978
  function availability(value) {
7362
7979
  const row = object2(value, ["enabled"], ["reason"]);
7363
7980
  if (row.enabled === true && !Object.hasOwn(row, "reason")) return { enabled: true };
7364
- if (row.enabled !== false) fail3();
7981
+ if (row.enabled !== false) fail4();
7365
7982
  return { enabled: false, reason: choice(row.reason, ROLE_CONTROL_DISABLED_REASONS) };
7366
7983
  }
7367
7984
  function capabilities(value) {
@@ -7374,12 +7991,12 @@ function child(value) {
7374
7991
  const mode = choice(row.mode, ["one-shot", "continuable", "unknown"]);
7375
7992
  const prompt = availability(controls.prompt), interrupt = availability(controls.interrupt);
7376
7993
  const readonly = bool(row.readonly);
7377
- if (readonly !== (!prompt.enabled && !interrupt.enabled) || mode !== "continuable" && (prompt.enabled || interrupt.enabled)) fail3();
7994
+ if (readonly !== (!prompt.enabled && !interrupt.enabled) || mode !== "continuable" && (prompt.enabled || interrupt.enabled)) fail4();
7378
7995
  const invocation = Object.hasOwn(row, "invocation") ? parseDsmmInvocationView(row.invocation) : void 0;
7379
7996
  const routeComparison = Object.hasOwn(row, "routeComparison") ? parseDsmmRoleRouteComparison(row.routeComparison) : void 0;
7380
7997
  const id2 = identity(row.id);
7381
- if (invocation !== void 0 && (invocation.childId !== id2 || invocation.mode !== mode)) fail3();
7382
- if (routeComparison !== void 0 && routeComparison.childId !== id2) fail3();
7998
+ if (invocation !== void 0 && (invocation.childId !== id2 || invocation.mode !== mode)) fail4();
7999
+ if (routeComparison !== void 0 && routeComparison.childId !== id2) fail4();
7383
8000
  return {
7384
8001
  id: id2,
7385
8002
  parentSessionId: identity(row.parentSessionId),
@@ -7387,7 +8004,7 @@ function child(value) {
7387
8004
  activity: choice(row.activity, ["running", "inactive"]),
7388
8005
  readonly,
7389
8006
  controls: { prompt, interrupt },
7390
- ...Object.hasOwn(row, "label") ? { label: text3(row.label, 120) } : {},
8007
+ ...Object.hasOwn(row, "label") ? { label: text4(row.label, 120) } : {},
7391
8008
  ...invocation === void 0 ? {} : { invocation },
7392
8009
  ...routeComparison === void 0 ? {} : { routeComparison }
7393
8010
  };
@@ -7395,7 +8012,7 @@ function child(value) {
7395
8012
  function snapshot3(value) {
7396
8013
  const row = object2(value, ["sessionId", "admissionEpoch", "children", "capabilities"]);
7397
8014
  const sessionId2 = identity(row.sessionId), admissionEpoch = epoch2(row.admissionEpoch), children = array(row.children).map(child);
7398
- if (children.some((child2) => child2.parentSessionId !== sessionId2)) fail3();
8015
+ if (children.some((child2) => child2.parentSessionId !== sessionId2)) fail4();
7399
8016
  return { sessionId: sessionId2, admissionEpoch, children, capabilities: capabilities(row.capabilities) };
7400
8017
  }
7401
8018
  function descendants(value) {
@@ -7406,390 +8023,130 @@ function descendants(value) {
7406
8023
  if (entry.kind === "child") {
7407
8024
  object2(entry, ["kind", "depth", "child", "hasChildren"]);
7408
8025
  const projected = child(entry.child);
7409
- if (entry.depth !== 1 && (projected.controls.prompt.enabled || projected.controls.interrupt.enabled)) fail3();
8026
+ if (entry.depth !== 1 && (projected.controls.prompt.enabled || projected.controls.interrupt.enabled)) fail4();
7410
8027
  return { kind: "child", depth: depth(entry.depth), child: projected, hasChildren: bool(entry.hasChildren) };
7411
8028
  }
7412
8029
  object2(entry, ["kind", "depth", "id", "parentSessionId", "reason"]);
7413
- if (entry.kind !== "diagnostic") fail3();
8030
+ if (entry.kind !== "diagnostic") fail4();
7414
8031
  return { kind: "diagnostic", depth: depth(entry.depth), id: identity(entry.id), parentSessionId: identity(entry.parentSessionId), reason: choice(entry.reason, ["corrupt", "unsupported", "unavailable"]) };
7415
8032
  });
7416
8033
  for (const entry of entries) {
7417
8034
  const parent = entry.kind === "child" ? entry.child.parentSessionId : entry.parentSessionId;
7418
- if (entry.depth === 1 !== (parent === sessionId2)) fail3();
8035
+ if (entry.depth === 1 !== (parent === sessionId2)) fail4();
7419
8036
  }
7420
8037
  return { sessionId: sessionId2, admissionEpoch, descendants: entries };
7421
8038
  }
7422
8039
  function promptRequest(value) {
7423
8040
  const row = object2(value, ["requestId", "parentSessionId", "childSessionId", "mode", "delivery", "content"], ["clientTimeZone"]);
7424
- if (row.mode !== "continuable") fail3();
8041
+ if (row.mode !== "continuable") fail4();
7425
8042
  const content2 = array(row.content, Number.MAX_SAFE_INTEGER).map((value2) => {
7426
8043
  const part = object2(value2, ["type"], ["text", "mediaType", "data", "name"]);
7427
8044
  if (part.type === "text") {
7428
8045
  object2(part, ["type", "text"]);
7429
- if (typeof part.text !== "string") fail3();
8046
+ if (typeof part.text !== "string") fail4();
7430
8047
  return { type: "text", text: part.text };
7431
8048
  }
7432
8049
  object2(part, ["type", "mediaType", "data"], ["name"]);
7433
- if (part.type !== "image" || typeof part.data !== "string") fail3();
8050
+ if (part.type !== "image" || typeof part.data !== "string") fail4();
7434
8051
  return {
7435
8052
  type: "image",
7436
8053
  mediaType: choice(part.mediaType, ["image/png", "image/jpeg", "image/webp", "image/gif"]),
7437
8054
  data: part.data,
7438
- ...Object.hasOwn(part, "name") ? { name: text3(part.name, 256) } : {}
8055
+ ...Object.hasOwn(part, "name") ? { name: text4(part.name, 256) } : {}
7439
8056
  };
7440
8057
  });
7441
- if (content2.length === 0) fail3();
8058
+ if (content2.length === 0) fail4();
7442
8059
  return {
7443
8060
  requestId: identity(row.requestId),
7444
8061
  parentSessionId: identity(row.parentSessionId),
7445
8062
  childSessionId: identity(row.childSessionId),
7446
8063
  mode: "continuable",
7447
8064
  delivery: choice(row.delivery, ["queue", "steer"]),
7448
- content: content2,
7449
- ...Object.hasOwn(row, "clientTimeZone") ? { clientTimeZone: text3(row.clientTimeZone, 128) } : {}
7450
- };
7451
- }
7452
- function interruptRequest(value) {
7453
- const row = object2(value, ["parentSessionId", "childSessionId", "mode"]);
7454
- if (row.mode !== "continuable") fail3();
7455
- return { parentSessionId: identity(row.parentSessionId), childSessionId: identity(row.childSessionId), mode: "continuable" };
7456
- }
7457
- function promptReceipt(value) {
7458
- const row = object2(value, ["messageId"]);
7459
- return { messageId: identity(row.messageId) };
7460
- }
7461
- function interruptReceipt(value) {
7462
- const row = object2(value, ["accepted"]);
7463
- if (row.accepted !== true) fail3();
7464
- return { accepted: true };
7465
- }
7466
- function errorInfo2(value) {
7467
- const row = object2(value, ["code"], ["field", "reason"]);
7468
- return {
7469
- code: choice(row.code, ROLE_CONTROL_ERROR_CODES),
7470
- ...Object.hasOwn(row, "field") ? { field: choice(row.field, ROLE_CONTROL_ERROR_FIELDS) } : {},
7471
- ...Object.hasOwn(row, "reason") ? { reason: choice(row.reason, ROLE_CONTROL_DISABLED_REASONS) } : {}
7472
- };
7473
- }
7474
- var parseRoleControlErrorInfo = (value) => errorInfo2(json(value));
7475
- var parseChildSessionSnapshot = (value) => snapshot3(json(value));
7476
- var parseRoleControlDescendants = (value) => descendants(json(value));
7477
- var parseRoleControlPromptRequest = (value) => promptRequest(json(value));
7478
- function codec2(symbol, parse3) {
7479
- return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: (value) => parse3(json(value)) }) };
7480
- }
7481
- function descriptor2(method, result, request) {
7482
- return {
7483
- id: `@dsmm/dsmm-children#dsmmChildren/${method}`,
7484
- service: "dsmmChildren",
7485
- namespace: "dsmmChildren",
7486
- method,
7487
- invocation: { kind: "direct" },
7488
- parameters: [
7489
- { name: "sessionId", wire: "sessionId", source: "json", codec: codec2("ChildControlSessionId", identity) },
7490
- ...request === void 0 ? [] : [{ name: "request", wire: "request", source: "json", codec: request }]
7491
- ],
7492
- result
7493
- };
7494
- }
7495
- var ROLE_CONTROL_REMOTE = { package: "@dsmm/dsmm-children", descriptors: [
7496
- descriptor2("describe", codec2("ChildSessionSnapshot", snapshot3)),
7497
- descriptor2("descendants", codec2("RoleControlDescendantsSnapshot", descendants)),
7498
- descriptor2("prompt", codec2("SubagentPromptReceipt", promptReceipt), codec2("SubagentPromptRequest", promptRequest)),
7499
- descriptor2("interrupt", codec2("SubagentInterruptReceipt", interruptReceipt), codec2("RoleControlInterruptRequest", interruptRequest))
7500
- ] };
7501
- var ROLE_CONTROL_HOST = { package: ROLE_CONTROL_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: ROLE_CONTROL_REMOTE.descriptors };
7502
-
7503
- // src/permission-remote.ts
7504
- function fail4() {
7505
- throw new TypeError("Invalid permission DTO.");
7506
- }
7507
- function text4(value, max = 512) {
7508
- if (typeof value !== "string" || value.length === 0 || value.length > max || /[\u0000-\u001f\u007f]/u.test(value)) fail4();
7509
- return value;
7510
- }
7511
- function parsePermissionSessionId(value) {
7512
- return text4(value, 256);
7513
- }
7514
- function parseRuntime(value) {
7515
- const runtime = permissionRuleRow(value, ["savedRevision", "runtimeRevision", "state", "mounted", "restartRequired"]);
7516
- if (!["synced", "updating", "unsynced"].includes(runtime.state) || typeof runtime.mounted !== "boolean" || typeof runtime.restartRequired !== "boolean") fail4();
7517
- return { savedRevision: permissionRevision(runtime.savedRevision), runtimeRevision: permissionRevision(runtime.runtimeRevision), state: runtime.state, mounted: runtime.mounted, restartRequired: runtime.restartRequired };
7518
- }
7519
- function parseCapabilities(value) {
7520
- const input = permissionRuleRow(value, ["limits", "runtime", "tools"]);
7521
- const limits = permissionRuleRow(input.limits, ["outsideReads", "finalInode", "scopedMemory", "webFetch", "webSearchDestinations", "proxyAddressBinding", "shellSockets", "providerAuthMcp"]);
7522
- if (limits.outsideReads !== "tool-call-boundary" || limits.finalInode !== false || limits.scopedMemory !== "not-provided-by-native-rules" || limits.webFetch !== "native-public-only" || limits.webSearchDestinations !== "unsupported" || limits.proxyAddressBinding !== "native-proxy-dependent" || limits.shellSockets !== "native-executor-dependent" || limits.providerAuthMcp !== "not-covered") fail4();
7523
- if (!Array.isArray(input.tools) || input.tools.length > 1024) fail4();
7524
- const tools = [];
7525
- const names = /* @__PURE__ */ new Set();
7526
- for (const value2 of input.tools) {
7527
- const tool = permissionRuleRow(value2, ["name", "kind", "approval", "scopedMemory"]), name = text4(tool.name);
7528
- if (!["read", "glob", "grep", "shell", "webSearch", "webFetch"].includes(tool.kind) || tool.approval !== "native-once" || tool.scopedMemory !== false || names.has(name)) fail4();
7529
- names.add(name);
7530
- tools.push({ name, kind: tool.kind, approval: "native-once", scopedMemory: false });
7531
- }
7532
- return { limits: {
7533
- outsideReads: "tool-call-boundary",
7534
- finalInode: false,
7535
- scopedMemory: "not-provided-by-native-rules",
7536
- webFetch: "native-public-only",
7537
- webSearchDestinations: "unsupported",
7538
- proxyAddressBinding: "native-proxy-dependent",
7539
- shellSockets: "native-executor-dependent",
7540
- providerAuthMcp: "not-covered"
7541
- }, runtime: parseRuntime(input.runtime), tools };
8065
+ content: content2,
8066
+ ...Object.hasOwn(row, "clientTimeZone") ? { clientTimeZone: text4(row.clientTimeZone, 128) } : {}
8067
+ };
7542
8068
  }
7543
- function parsePermissionRulesResult(value) {
7544
- const input = permissionRuleRow(value, ["snapshot", "runtime"], ["capabilities"]), snapshot4 = permissionRuleRow(input.snapshot, ["revision", "policy"]);
8069
+ function interruptRequest(value) {
8070
+ const row = object2(value, ["parentSessionId", "childSessionId", "mode"]);
8071
+ if (row.mode !== "continuable") fail4();
8072
+ return { parentSessionId: identity(row.parentSessionId), childSessionId: identity(row.childSessionId), mode: "continuable" };
8073
+ }
8074
+ function promptReceipt(value) {
8075
+ const row = object2(value, ["messageId"]);
8076
+ return { messageId: identity(row.messageId) };
8077
+ }
8078
+ function interruptReceipt(value) {
8079
+ const row = object2(value, ["accepted"]);
8080
+ if (row.accepted !== true) fail4();
8081
+ return { accepted: true };
8082
+ }
8083
+ function errorInfo2(value) {
8084
+ const row = object2(value, ["code"], ["field", "reason"]);
7545
8085
  return {
7546
- snapshot: { revision: permissionRevision(snapshot4.revision), policy: resolvePermissionControl(snapshot4.policy) },
7547
- runtime: parseRuntime(input.runtime),
7548
- ...Object.hasOwn(input, "capabilities") ? { capabilities: parseCapabilities(input.capabilities) } : {}
8086
+ code: choice(row.code, ROLE_CONTROL_ERROR_CODES),
8087
+ ...Object.hasOwn(row, "field") ? { field: choice(row.field, ROLE_CONTROL_ERROR_FIELDS) } : {},
8088
+ ...Object.hasOwn(row, "reason") ? { reason: choice(row.reason, ROLE_CONTROL_DISABLED_REASONS) } : {}
7549
8089
  };
7550
8090
  }
7551
- var codec3 = (name, parse3) => ({ mode: "strict", typeSymbol: `@dsmm/dsmm#${name}`, create: () => ({ parse: parse3 }) });
8091
+ var parseRoleControlErrorInfo = (value) => errorInfo2(json(value));
8092
+ var parseChildSessionSnapshot = (value) => snapshot3(json(value));
8093
+ var parseRoleControlDescendants = (value) => descendants(json(value));
8094
+ var parseRoleControlPromptRequest = (value) => promptRequest(json(value));
8095
+ function codec3(symbol, parse3) {
8096
+ return { mode: "strict", typeSymbol: `@dsmm/dsmm#${symbol}`, create: () => ({ parse: (value) => parse3(json(value)) }) };
8097
+ }
7552
8098
  function descriptor3(method, result, request) {
7553
8099
  return {
7554
- id: `@dsmm/dsmm-permissions#dsmmPermissions/${method}`,
7555
- service: "dsmmPermissions",
7556
- namespace: "dsmmPermissions",
8100
+ id: `@dsmm/dsmm-children#dsmmChildren/${method}`,
8101
+ service: "dsmmChildren",
8102
+ namespace: "dsmmChildren",
7557
8103
  method,
7558
8104
  invocation: { kind: "direct" },
7559
8105
  parameters: [
7560
- { name: "sessionId", wire: "sessionId", source: "json", codec: codec3("PermissionSessionId", parsePermissionSessionId) },
8106
+ { name: "sessionId", wire: "sessionId", source: "json", codec: codec3("ChildControlSessionId", identity) },
7561
8107
  ...request === void 0 ? [] : [{ name: "request", wire: "request", source: "json", codec: request }]
7562
8108
  ],
7563
8109
  result
7564
8110
  };
7565
8111
  }
7566
- var PERMISSION_REMOTE = { package: "@dsmm/dsmm-permissions", descriptors: [
7567
- descriptor3("describeRules", codec3("PermissionRulesResult", parsePermissionRulesResult)),
7568
- descriptor3("saveRules", codec3("PermissionRulesResult", parsePermissionRulesResult), codec3("PermissionRulesSaveRequest", parsePermissionRulesSave))
8112
+ var ROLE_CONTROL_REMOTE = { package: "@dsmm/dsmm-children", descriptors: [
8113
+ descriptor3("describe", codec3("ChildSessionSnapshot", snapshot3)),
8114
+ descriptor3("descendants", codec3("RoleControlDescendantsSnapshot", descendants)),
8115
+ descriptor3("prompt", codec3("SubagentPromptReceipt", promptReceipt), codec3("SubagentPromptRequest", promptRequest)),
8116
+ descriptor3("interrupt", codec3("SubagentInterruptReceipt", interruptReceipt), codec3("RoleControlInterruptRequest", interruptRequest))
7569
8117
  ] };
7570
- var PERMISSION_HOST = { package: PERMISSION_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: PERMISSION_REMOTE.descriptors };
8118
+ var ROLE_CONTROL_HOST = { package: ROLE_CONTROL_REMOTE.package, face: "host", schemas: [], model: { services: [], events: [], objects: [] }, invocations: ROLE_CONTROL_REMOTE.descriptors };
7571
8119
 
7572
- // src/client/permission-client.ts
7573
- var PermissionClientError = class extends Error {
7574
- constructor(code) {
7575
- super("Permission operation unavailable.");
7576
- this.code = code;
7577
- }
7578
- };
7579
- var codes = /* @__PURE__ */ new Set(["not-owned", "stale", "cancelled", "unavailable", "validation", "not-found", "scope-unavailable", "replayed", "denied"]);
7580
- function permissionClient(connection) {
7581
- return async (method, args, signal) => {
7582
- const descriptor4 = PERMISSION_REMOTE.descriptors.find((item) => item.method === method);
7583
- const payload = {};
7584
- descriptor4.parameters.forEach((parameter, index) => {
7585
- payload[parameter.wire] = args[index];
7586
- });
7587
- let result;
7588
- try {
7589
- result = await connection.rpc.call("/api", `dsmmPermissions/${method}`, { args: payload }, signal);
7590
- } catch {
7591
- throw new PermissionClientError(signal.aborted ? "cancelled" : "transport");
7592
- }
7593
- if (!result.ok) {
7594
- const code = Reflect.get(result.error.details, "code");
7595
- throw new PermissionClientError(result.error.code === "dsmm-permissions/refused" && codes.has(code) ? code : "unavailable");
7596
- }
7597
- signal.throwIfAborted();
7598
- try {
7599
- if (descriptor4.result.mode !== "strict") throw new Error("Strict permission codec required.");
7600
- return descriptor4.result.create().parse(result.value);
7601
- } catch {
7602
- throw new PermissionClientError("protocol");
8120
+ // src/client/permission-session.ts
8121
+ function bindPermissionSession(source, sessions, permissions) {
8122
+ let observed, stop;
8123
+ const update = () => {
8124
+ const id2 = source.getSnapshot().key, binding = id2 === void 0 ? void 0 : sessions.binding(id2);
8125
+ if (binding !== observed) {
8126
+ stop?.();
8127
+ observed = binding;
8128
+ stop = binding?.session.subscribe(update);
7603
8129
  }
8130
+ const snapshot4 = binding?.session.getSnapshot(), catalog = sessions.list.getSnapshot(), summary = id2 === void 0 ? void 0 : catalog.byId[id2];
8131
+ const child2 = snapshot4?.subagent != null || summary?.origin === "subagent" || summary?.parentId !== void 0;
8132
+ const root = id2 !== void 0 && binding?.sessionId === id2 && snapshot4?.sessionId === id2 && snapshot4.openState === "open" && !snapshot4.removed && catalog.ids.includes(id2) && summary !== void 0 && !child2;
8133
+ permissions.bindScope(id2 ?? null, binding ?? null, child2 ? "child" : root ? "root" : "unknown");
8134
+ };
8135
+ update();
8136
+ const stopSource = source.subscribe(update), stopCatalog = sessions.list.subscribe(update);
8137
+ let active = true;
8138
+ return () => {
8139
+ if (!active) return;
8140
+ active = false;
8141
+ stopSource();
8142
+ stopCatalog();
8143
+ stop?.();
8144
+ permissions.bindScope(null, null, "unknown");
7604
8145
  };
7605
8146
  }
7606
8147
 
7607
- // src/client/permission-controller.ts
7608
- var draftOf = (policy) => ({ outsideReads: policy.outsideReads, webSearch: { ...policy.webSearch }, webFetch: { ...policy.webFetch }, upsert: [], revoke: [], editor: null });
7609
- var same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
7610
- function permissionChanges(view) {
7611
- const { base, draft: draft2 } = view;
7612
- if (base === null || draft2 === null) return null;
7613
- const changes = Object.fromEntries(["outsideReads", "webSearch", "webFetch"].filter((key) => !same(base.policy[key], draft2[key])).map((key) => [key, draft2[key]]));
7614
- if (Object.keys(changes).length === 0 && draft2.upsert.length === 0 && draft2.revoke.length === 0) return null;
7615
- return { expectedRevision: base.revision, ...Object.keys(changes).length ? { changes } : {}, ...draft2.upsert.length ? { upsert: draft2.upsert } : {}, ...draft2.revoke.length ? { revoke: draft2.revoke } : {} };
7616
- }
7617
- var empty = () => ({
7618
- generation: 0,
7619
- sessionId: null,
7620
- scope: "unknown",
7621
- connected: false,
7622
- reading: false,
7623
- busy: null,
7624
- rules: null,
7625
- base: null,
7626
- draft: null,
7627
- rulesIssue: null,
7628
- dirty: false,
7629
- notice: null
7630
- });
7631
- var PermissionController = class {
7632
- state = empty();
7633
- listeners = /* @__PURE__ */ new Set();
7634
- invoke = null;
7635
- connection;
7636
- owner = null;
7637
- request = new AbortController();
7638
- requestSequence = 0;
7639
- timer;
7640
- watchers = 0;
7641
- disposed = false;
7642
- store = { getSnapshot: () => this.state, subscribe: (listener) => {
7643
- this.listeners.add(listener);
7644
- return () => {
7645
- this.listeners.delete(listener);
7646
- };
7647
- } };
7648
- publish(patch) {
7649
- if (this.disposed) return;
7650
- this.state = { ...this.state, ...patch };
7651
- for (const listener of this.listeners) listener();
7652
- }
7653
- cancel() {
7654
- this.request.abort();
7655
- this.request = new AbortController();
7656
- this.requestSequence++;
7657
- clearTimeout(this.timer);
7658
- }
7659
- fence(preserve) {
7660
- this.cancel();
7661
- this.publish({
7662
- generation: this.state.generation + 1,
7663
- reading: false,
7664
- busy: null,
7665
- notice: null,
7666
- rules: null,
7667
- rulesIssue: null,
7668
- ...preserve ? {} : { base: null, draft: null, dirty: false }
7669
- });
7670
- }
7671
- bindConnection(invoke, generation) {
7672
- if (this.disposed || this.invoke === invoke && this.connection === generation) return;
7673
- this.invoke = invoke;
7674
- this.connection = generation;
7675
- this.fence(true);
7676
- this.publish({ connected: invoke !== null });
7677
- this.schedule(true);
7678
- }
7679
- bindScope(sessionId2, owner, scope) {
7680
- if (this.disposed || this.state.sessionId === sessionId2 && this.owner === owner && this.state.scope === scope) return;
7681
- const preserve = sessionId2 === this.state.sessionId;
7682
- this.owner = owner;
7683
- this.fence(preserve);
7684
- this.publish({ sessionId: sessionId2, scope });
7685
- this.schedule(true);
7686
- }
7687
- watch() {
7688
- this.watchers++;
7689
- if (this.watchers === 1) this.schedule(true);
7690
- let active = true;
7691
- return () => {
7692
- if (!active) return;
7693
- active = false;
7694
- this.watchers--;
7695
- if (this.watchers === 0) this.fence(true);
7696
- };
7697
- }
7698
- dispose() {
7699
- if (this.disposed) return;
7700
- this.fence(false);
7701
- this.disposed = true;
7702
- this.listeners.clear();
7703
- this.invoke = null;
7704
- this.owner = null;
7705
- }
7706
- live(generation) {
7707
- return !this.disposed && generation === this.state.generation && this.owner !== null && this.invoke !== null && this.state.scope === "root" && this.state.sessionId !== null;
7708
- }
7709
- schedule(immediate = false) {
7710
- clearTimeout(this.timer);
7711
- if (this.watchers === 0 || !this.live(this.state.generation)) return;
7712
- this.timer = setTimeout(() => {
7713
- void this.refresh(this.state.generation);
7714
- }, immediate ? 0 : 1e3);
7715
- this.timer.unref?.();
7716
- }
7717
- issue(error) {
7718
- return error instanceof PermissionClientError ? error.code : "transport";
7719
- }
7720
- synchronized() {
7721
- const value = this.state.rules;
7722
- return value !== null && value.runtime.state === "synced" && value.runtime.savedRevision === value.snapshot.revision && value.runtime.runtimeRevision === value.snapshot.revision;
7723
- }
7724
- canEdit(generation) {
7725
- return this.live(generation) && this.state.rulesIssue === null && this.synchronized() && this.state.busy === null;
7726
- }
7727
- canSave(generation) {
7728
- return this.canEdit(generation) && !this.state.reading && this.state.dirty && this.state.draft?.editor === null;
7729
- }
7730
- async refresh(generation, discard = false) {
7731
- if (!this.live(generation) || this.state.reading || this.state.busy !== null) return;
7732
- const sequence = ++this.requestSequence, signal = this.request.signal, id2 = this.state.sessionId;
7733
- this.publish({ reading: true });
7734
- const [rules] = await Promise.allSettled([this.invoke("describeRules", [id2], signal)]);
7735
- if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence) return;
7736
- if (rules.status === "rejected") {
7737
- this.publish({ rules: null, rulesIssue: this.issue(rules.reason), reading: false });
7738
- } else {
7739
- const value = rules.value;
7740
- const retain = this.state.dirty && !discard;
7741
- this.publish({
7742
- rules: value,
7743
- rulesIssue: retain && this.state.base?.revision !== value.snapshot.revision ? "stale" : null,
7744
- reading: false,
7745
- ...retain ? {} : { base: value.snapshot, draft: draftOf(value.snapshot.policy), dirty: false }
7746
- });
7747
- }
7748
- this.schedule();
7749
- }
7750
- edit(generation, patch) {
7751
- if (!this.canEdit(generation) || this.state.draft === null) return;
7752
- const draft2 = { ...this.state.draft, ...patch };
7753
- this.publish({ draft: draft2, notice: null });
7754
- this.publish({ dirty: draft2.editor !== null || permissionChanges(this.state) !== null });
7755
- }
7756
- stageRule(generation) {
7757
- const draft2 = this.state.draft, editor = draft2?.editor;
7758
- if (editor == null || !editor.id || editor.id.length > 256 || editor.id.includes("\0")) return;
7759
- const match = editor.match;
7760
- if (match.kind === "outside-read" && !match.path || match.kind === "shell" && (!match.executable || !match.command || !match.workingDirectory)) return;
7761
- this.edit(generation, { upsert: [...draft2.upsert.filter((row) => row.id !== editor.id), structuredClone(editor)], revoke: draft2.revoke.filter((id2) => id2 !== editor.id), editor: null });
7762
- }
7763
- stageRevoke(generation, id2) {
7764
- const draft2 = this.state.draft;
7765
- if (draft2 === null || !this.state.base?.policy.rules.some((rule) => rule.id === id2)) return;
7766
- this.edit(generation, { upsert: draft2.upsert.filter((row) => row.id !== id2), revoke: [.../* @__PURE__ */ new Set([...draft2.revoke, id2])], editor: draft2.editor?.id === id2 ? null : draft2.editor });
7767
- }
7768
- begin(busy) {
7769
- this.cancel();
7770
- this.publish({ busy, notice: null });
7771
- return { signal: this.request.signal, id: this.state.sessionId };
7772
- }
7773
- async save(generation) {
7774
- const request = permissionChanges(this.state);
7775
- if (!this.canSave(generation) || request === null) return;
7776
- const current = this.begin("save");
7777
- try {
7778
- const result = await this.invoke("saveRules", [current.id, request], current.signal);
7779
- if (this.live(generation)) this.publish({ rules: result, base: result.snapshot, draft: draftOf(result.snapshot.policy), dirty: false, rulesIssue: null, notice: "saved" });
7780
- } catch (error) {
7781
- if (this.live(generation)) this.publish({ rules: null, rulesIssue: this.issue(error) });
7782
- } finally {
7783
- if (this.live(generation)) {
7784
- this.publish({ busy: null });
7785
- this.schedule();
7786
- }
7787
- }
7788
- }
7789
- };
7790
-
7791
8148
  // src/client/RoleToolView.tsx
7792
- var import_dsh_client_ui_primitives9 = require("@deepseek-ai/dsh-client-ui-primitives");
8149
+ var import_dsh_client_ui_primitives10 = require("@deepseek-ai/dsh-client-ui-primitives");
7793
8150
 
7794
8151
  // src/client/RoleToolView-data.ts
7795
8152
  var roleToolKeys = {
@@ -7906,7 +8263,7 @@ var roleToolZh = {
7906
8263
  };
7907
8264
 
7908
8265
  // src/client/RoleToolView.tsx
7909
- var import_jsx_runtime11 = require("react/jsx-runtime");
8266
+ var import_jsx_runtime12 = require("react/jsx-runtime");
7910
8267
  var styles = `
7911
8268
  .dsmm-role-tool{min-width:0;color:var(--dsw-alias-label-primary);font-family:var(--dsw-font-family);font-size:14px;line-height:22px}
7912
8269
  .dsmm-role-tool .dsmm-role-heading{color:var(--dsw-alias-label-primary);height:auto;min-height:32px}
@@ -7930,36 +8287,36 @@ function RoleToolView(props) {
7930
8287
  const target = actual?.role ?? requested.target;
7931
8288
  const title = `${t("call")} ${target === void 0 ? t("unknownTarget") : roleToolDisplay(target)}${(actual?.level ?? requested.level) === void 0 ? "" : ` · ${actual?.level ?? requested.level}`}`;
7932
8289
  const state = result?.error?.code === "interrupted" ? "stopped" : failed ? "error" : result === void 0 ? props.phase === "preparing" ? "preparing" : "running" : actual?.jobId !== void 0 || actual?.mode === "continuable" ? "background" : "result";
7933
- const code = (value) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dsh_client_ui_primitives9.CodeBlock, { code: value, copyLabel: t("copy"), copiedLabel: t("copied") });
7934
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "dsmm-role-tool", "data-dsmm-role-tool": props.toolName, "data-identity": actual === void 0 ? "requested" : "actual", "data-state": state, children: [
7935
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
7936
- import_dsh_client_ui_primitives9.DisclosureRow,
8290
+ const code = (value) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives10.CodeBlock, { code: value, copyLabel: t("copy"), copiedLabel: t("copied") });
8291
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-role-tool", "data-dsmm-role-tool": props.toolName, "data-identity": actual === void 0 ? "requested" : "actual", "data-state": state, children: [
8292
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
8293
+ import_dsh_client_ui_primitives10.DisclosureRow,
7937
8294
  {
7938
8295
  title,
7939
8296
  titleClassName: "dsmm-role-title",
7940
8297
  rowClassName: "dsmm-role-heading",
7941
8298
  contentClassName: "dsmm-role-text",
7942
- icon: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dsh_client_ui_primitives9.StateDot, { state: state === "error" ? "error" : state === "stopped" ? "warning" : result === void 0 ? "ongoing" : state === "background" ? "idle" : "done" }),
8299
+ icon: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives10.StateDot, { state: state === "error" ? "error" : state === "stopped" ? "warning" : result === void 0 ? "ongoing" : state === "background" ? "idle" : "done" }),
7943
8300
  open: expanded,
7944
8301
  expandable: true,
7945
8302
  onToggle: toggle,
7946
8303
  expandOnRowClick: true,
7947
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "dsmm-role-body", children: [
7948
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
8304
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-role-body", children: [
8305
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
7949
8306
  props.toolName,
7950
8307
  " · ",
7951
8308
  props.callId
7952
8309
  ] }),
7953
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "dsmm-role-status", children: [
8310
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "dsmm-role-status", children: [
7954
8311
  t("requested"),
7955
8312
  " ",
7956
8313
  t(requested.kind),
7957
8314
  ": ",
7958
8315
  requested.target === void 0 ? t("unknown") : roleToolDisplay(requested.target)
7959
8316
  ] }),
7960
- requested.description !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-role-status", children: requested.description }),
7961
- actual !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
7962
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
8317
+ requested.description !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-role-status", children: requested.description }),
8318
+ actual !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8319
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
7963
8320
  t("actual"),
7964
8321
  " ",
7965
8322
  t(requested.kind),
@@ -7970,7 +8327,7 @@ function RoleToolView(props) {
7970
8327
  ": ",
7971
8328
  actual.level
7972
8329
  ] }),
7973
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { children: [
8330
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
7974
8331
  t("routeSource"),
7975
8332
  ": ",
7976
8333
  actual.routeSource,
@@ -7980,31 +8337,31 @@ function RoleToolView(props) {
7980
8337
  actual.route === void 0 ? t("unknown") : `${actual.route.provider}/${actual.route.model}${actual.route.reasoningEffort === void 0 ? "" : ` · ${actual.route.reasoningEffort}`}`
7981
8338
  ] })
7982
8339
  ] }),
7983
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
7984
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t(props.phase === "preparing" ? "preparingArgs" : "args") }),
7985
- raw === "" ? /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("emptyArgs") }) : code(raw)
8340
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
8341
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t(props.phase === "preparing" ? "preparingArgs" : "args") }),
8342
+ raw === "" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("emptyArgs") }) : code(raw)
7986
8343
  ] }),
7987
- result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
7988
- actual === void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("unavailable") }),
7989
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
7990
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("output") }),
8344
+ result !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8345
+ actual === void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("unavailable") }),
8346
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
8347
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("output") }),
7991
8348
  code(JSON.stringify(result.content, null, 2))
7992
8349
  ] }),
7993
- result.error != null && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
7994
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("failure") }),
8350
+ result.error != null && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
8351
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("failure") }),
7995
8352
  code(JSON.stringify(result.error, null, 2))
7996
8353
  ] }),
7997
- result.meta != null && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { children: [
7998
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { children: t("metadata") }),
8354
+ result.meta != null && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { children: [
8355
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("metadata") }),
7999
8356
  code(JSON.stringify(result.meta, null, 2))
8000
8357
  ] })
8001
8358
  ] })
8002
8359
  ] })
8003
8360
  }
8004
8361
  ),
8005
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "dsmm-role-actions", children: [
8006
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("p", { className: "dsmm-role-status", role: "status", children: t(state) }),
8007
- props.inspect !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_dsh_client_ui_primitives9.Button, { variant: "ghost", size: "sm", onClick: props.inspect, children: t("inspect") })
8362
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-role-actions", children: [
8363
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-role-status", role: "status", children: t(state) }),
8364
+ props.inspect !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives10.Button, { variant: "ghost", size: "sm", onClick: props.inspect, children: t("inspect") })
8008
8365
  ] })
8009
8366
  ] });
8010
8367
  }
@@ -8331,17 +8688,17 @@ var ChildrenController = class {
8331
8688
  };
8332
8689
 
8333
8690
  // src/client/ChildrenPanel.tsx
8334
- var import_react9 = require("react");
8335
- var import_dsh_client_ui_primitives10 = require("@deepseek-ai/dsh-client-ui-primitives");
8336
- var import_jsx_runtime12 = require("react/jsx-runtime");
8691
+ var import_react10 = require("react");
8692
+ var import_dsh_client_ui_primitives11 = require("@deepseek-ai/dsh-client-ui-primitives");
8693
+ var import_jsx_runtime13 = require("react/jsx-runtime");
8337
8694
  function ControlAvailability({ value, label, t }) {
8338
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-availability", children: [
8339
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8695
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-availability", children: [
8696
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8340
8697
  t(label),
8341
8698
  ": ",
8342
8699
  t(value?.enabled === true ? "enabled" : "disabled")
8343
8700
  ] }),
8344
- value?.enabled !== true && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t(`reason:${value?.reason ?? "unavailable"}`) })
8701
+ value?.enabled !== true && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t(`reason:${value?.reason ?? "unavailable"}`) })
8345
8702
  ] });
8346
8703
  }
8347
8704
  function routeText(route3) {
@@ -8350,38 +8707,38 @@ function routeText(route3) {
8350
8707
  function RouteComparisonDetails({ value, t }) {
8351
8708
  const initial = value?.initialRoute, live = value?.liveRoute;
8352
8709
  const liveReasons = { "no-own-request-header": "routeNoOwnHeader", "invalid-own-request-header": "routeInvalidOwnHeader", "not-observed": "routeNotObserved" };
8353
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-availability", children: [
8354
- value === void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("comparisonUnobserved") }),
8355
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dl", { className: "dsmm-child-meta", children: [
8356
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("initialRoute") }),
8357
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: initial?.status === "known" ? routeText(initial.route) : t("routeUnknown") }),
8358
- initial?.status === "known" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8359
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("initialRouteSource") }),
8360
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dd", { children: [
8710
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-availability", children: [
8711
+ value === void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("comparisonUnobserved") }),
8712
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("dl", { className: "dsmm-child-meta", children: [
8713
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("initialRoute") }),
8714
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: initial?.status === "known" ? routeText(initial.route) : t("routeUnknown") }),
8715
+ initial?.status === "known" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8716
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("initialRouteSource") }),
8717
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("dd", { children: [
8361
8718
  t("routeCaptureSource"),
8362
8719
  " · ",
8363
8720
  initial.source
8364
8721
  ] })
8365
- ] }) : initial !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8366
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("initialRouteReason") }),
8367
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dd", { children: [
8722
+ ] }) : initial !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8723
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("initialRouteReason") }),
8724
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("dd", { children: [
8368
8725
  t("routeMissingCapture"),
8369
8726
  " · ",
8370
8727
  initial.reason
8371
8728
  ] })
8372
8729
  ] }),
8373
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("liveRoute") }),
8374
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: live?.status === "known" ? routeText(live.route) : t("routeUnknown") }),
8375
- live?.status === "known" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8376
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("liveRouteSource") }),
8377
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dd", { children: [
8730
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("liveRoute") }),
8731
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: live?.status === "known" ? routeText(live.route) : t("routeUnknown") }),
8732
+ live?.status === "known" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8733
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("liveRouteSource") }),
8734
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("dd", { children: [
8378
8735
  t("routeOwnHeaderSource"),
8379
8736
  " · ",
8380
8737
  live.source
8381
8738
  ] })
8382
- ] }) : live !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8383
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("liveRouteReason") }),
8384
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dd", { children: [
8739
+ ] }) : live !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8740
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("liveRouteReason") }),
8741
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("dd", { children: [
8385
8742
  t(liveReasons[live.reason]),
8386
8743
  " · ",
8387
8744
  live.reason
@@ -8391,69 +8748,69 @@ function RouteComparisonDetails({ value, t }) {
8391
8748
  ] });
8392
8749
  }
8393
8750
  function InvocationDetails({ value, t, showComparison = true }) {
8394
- if (value === void 0) return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("invocationUnavailable") });
8395
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8396
- showComparison && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RouteComparisonDetails, { value: value.routeComparison, t }),
8397
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dl", { className: "dsmm-child-meta", children: [
8398
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("role") }),
8399
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("dd", { children: [
8751
+ if (value === void 0) return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("invocationUnavailable") });
8752
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8753
+ showComparison && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(RouteComparisonDetails, { value: value.routeComparison, t }),
8754
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("dl", { className: "dsmm-child-meta", children: [
8755
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("role") }),
8756
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("dd", { children: [
8400
8757
  value.label,
8401
8758
  " · ",
8402
8759
  value.role
8403
8760
  ] }),
8404
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("level") }),
8405
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: value.level }),
8406
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("mode") }),
8407
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: value.mode }),
8408
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("reportedRoute") }),
8409
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: value.route === void 0 ? t("routeUnreported") : routeText(value.route) }),
8410
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("routeSource") }),
8411
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: value.routeSource }),
8412
- value.runId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8413
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("runId") }),
8414
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: value.runId })
8761
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("level") }),
8762
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: value.level }),
8763
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("mode") }),
8764
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: value.mode }),
8765
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("reportedRoute") }),
8766
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: value.route === void 0 ? t("routeUnreported") : routeText(value.route) }),
8767
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("routeSource") }),
8768
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: value.routeSource }),
8769
+ value.runId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8770
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("runId") }),
8771
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: value.runId })
8415
8772
  ] }),
8416
- value.childId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8417
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("childId") }),
8418
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: value.childId })
8773
+ value.childId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8774
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("childId") }),
8775
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: value.childId })
8419
8776
  ] }),
8420
- value.jobId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8421
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dt", { children: t("jobId") }),
8422
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("dd", { children: value.jobId })
8777
+ value.jobId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8778
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dt", { children: t("jobId") }),
8779
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("dd", { children: value.jobId })
8423
8780
  ] })
8424
8781
  ] })
8425
8782
  ] });
8426
8783
  }
8427
8784
  function Issue2({ value, t }) {
8428
8785
  if (!value) return null;
8429
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-issue", role: "alert", children: [
8430
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t(value.unknown ? "unknownAction" : "error", { code: value.code }) }),
8431
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8786
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-issue", role: "alert", children: [
8787
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t(value.unknown ? "unknownAction" : "error", { code: value.code }) }),
8788
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8432
8789
  value.code,
8433
8790
  value.field === void 0 ? "" : ` · ${t("field")}: ${value.field}`
8434
8791
  ] }),
8435
- value.reason !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t(`reason:${value.reason}`) })
8792
+ value.reason !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t(`reason:${value.reason}`) })
8436
8793
  ] });
8437
8794
  }
8438
8795
  function Outcome({ value, t }) {
8439
8796
  if (!value) return null;
8440
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "dsmm-availability", role: "status", "aria-live": "polite", children: value.kind === "prompt" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("promptAccepted", { id: value.receipt.messageId }) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("interruptAccepted") }) });
8797
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "dsmm-availability", role: "status", "aria-live": "polite", children: value.kind === "prompt" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("promptAccepted", { id: value.receipt.messageId }) }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("interruptAccepted") }) });
8441
8798
  }
8442
- function ChildComposer({ child: child2, state, actions: actions2, t }) {
8443
- const prefix = (0, import_react9.useId)(), picker = (0, import_react9.useRef)(null), generation = state.generation, key = childActionKey(child2.id);
8799
+ function ChildComposer({ child: child2, state, actions: actions3, t }) {
8800
+ const prefix = (0, import_react10.useId)(), picker = (0, import_react10.useRef)(null), generation = state.generation, key = childActionKey(child2.id);
8444
8801
  const draft2 = state.drafts.get(child2.id) ?? EMPTY_CHILD_DRAFT;
8445
8802
  const pending = state.pending.has(key), available = state.fresh && !state.reading && !pending;
8446
8803
  const canPrompt = available && enabled(state.snapshot?.capabilities.prompt) && enabled(child2.controls.prompt) && !child2.readonly && child2.mode === "continuable";
8447
8804
  const canImages = canPrompt && enabled(state.snapshot?.capabilities.images) && !draft2.imageBusy;
8448
8805
  const submit = canPrompt && !draft2.uncertain && !draft2.imageBusy && (draft2.text.trim() !== "" || draft2.images.length > 0) && (draft2.images.length === 0 || enabled(state.snapshot?.capabilities.images));
8449
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("form", { className: "dsmm-child-composer", "aria-label": t("prompt"), onSubmit: (event) => {
8806
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("form", { className: "dsmm-child-composer", "aria-label": t("prompt"), onSubmit: (event) => {
8450
8807
  event.preventDefault();
8451
- if (submit) void actions2.prompt(generation, child2.id);
8808
+ if (submit) void actions3.prompt(generation, child2.id);
8452
8809
  }, children: [
8453
- !state.fresh && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t(state.reading ? "reading" : "stale") }),
8454
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-field", children: [
8455
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { htmlFor: `${prefix}-message`, children: t("text") }),
8456
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
8810
+ !state.fresh && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t(state.reading ? "reading" : "stale") }),
8811
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-field", children: [
8812
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { htmlFor: `${prefix}-message`, children: t("text") }),
8813
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
8457
8814
  "textarea",
8458
8815
  {
8459
8816
  id: `${prefix}-message`,
@@ -8462,179 +8819,179 @@ function ChildComposer({ child: child2, state, actions: actions2, t }) {
8462
8819
  value: draft2.text,
8463
8820
  disabled: pending,
8464
8821
  "aria-describedby": `${prefix}-delivery-hint${draft2.uncertain ? ` ${prefix}-unknown` : ""}`,
8465
- onChange: (event) => actions2.editText(generation, child2.id, event.currentTarget.value)
8822
+ onChange: (event) => actions3.editText(generation, child2.id, event.currentTarget.value)
8466
8823
  }
8467
8824
  )
8468
8825
  ] }),
8469
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-field", children: [
8470
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("label", { htmlFor: `${prefix}-delivery`, children: t("delivery") }),
8471
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("select", { id: `${prefix}-delivery`, value: draft2.delivery, disabled: !canPrompt, "aria-describedby": `${prefix}-delivery-hint`, onChange: (event) => {
8826
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-field", children: [
8827
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("label", { htmlFor: `${prefix}-delivery`, children: t("delivery") }),
8828
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("select", { id: `${prefix}-delivery`, value: draft2.delivery, disabled: !canPrompt, "aria-describedby": `${prefix}-delivery-hint`, onChange: (event) => {
8472
8829
  const value = event.currentTarget.value;
8473
- if (value === "queue" || value === "steer") actions2.setDelivery(generation, child2.id, value);
8830
+ if (value === "queue" || value === "steer") actions3.setDelivery(generation, child2.id, value);
8474
8831
  }, children: [
8475
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "queue", children: t("queue") }),
8476
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("option", { value: "steer", children: t("steer") })
8832
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "queue", children: t("queue") }),
8833
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("option", { value: "steer", children: t("steer") })
8477
8834
  ] }),
8478
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { id: `${prefix}-delivery-hint`, className: "dsmm-hint", children: t("deliveryHint") })
8835
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { id: `${prefix}-delivery-hint`, className: "dsmm-hint", children: t("deliveryHint") })
8479
8836
  ] }),
8480
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-field", children: [
8481
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { id: `${prefix}-images-hint`, className: "dsmm-hint", children: t("imagesHint") }),
8482
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("input", { ref: picker, hidden: true, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", multiple: true, disabled: !canImages, "aria-label": t("images"), onChange: (event) => {
8837
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-field", children: [
8838
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { id: `${prefix}-images-hint`, className: "dsmm-hint", children: t("imagesHint") }),
8839
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("input", { ref: picker, hidden: true, type: "file", accept: "image/png,image/jpeg,image/webp,image/gif", multiple: true, disabled: !canImages, "aria-label": t("images"), onChange: (event) => {
8483
8840
  const files = Array.from(event.currentTarget.files ?? []);
8484
8841
  event.currentTarget.value = "";
8485
- if (canImages) void actions2.addImages(generation, child2.id, files);
8842
+ if (canImages) void actions3.addImages(generation, child2.id, files);
8486
8843
  } }),
8487
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives10.Button, { type: "button", variant: "outline", disabled: !canImages, "aria-describedby": `${prefix}-images-hint`, onClick: () => {
8844
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_dsh_client_ui_primitives11.Button, { type: "button", variant: "outline", disabled: !canImages, "aria-describedby": `${prefix}-images-hint`, onClick: () => {
8488
8845
  if (canImages) picker.current?.click();
8489
8846
  }, children: t("images") }),
8490
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ControlAvailability, { value: state.snapshot?.capabilities.images, label: "imageAvailability", t }),
8491
- draft2.images.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("ul", { className: "dsmm-profile-list", children: draft2.images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("li", { children: [
8492
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8847
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ControlAvailability, { value: state.snapshot?.capabilities.images, label: "imageAvailability", t }),
8848
+ draft2.images.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("ul", { className: "dsmm-profile-list", children: draft2.images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("li", { children: [
8849
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8493
8850
  image.name ?? image.mediaType,
8494
8851
  " · ",
8495
8852
  image.mediaType
8496
8853
  ] }),
8497
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives10.Button, { type: "button", variant: "outline", disabled: pending || draft2.imageBusy, onClick: () => actions2.removeImage(generation, child2.id, image), "aria-label": `${t("removeImage")}: ${image.name ?? image.mediaType}`, children: t("removeImage") })
8854
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_dsh_client_ui_primitives11.Button, { type: "button", variant: "outline", disabled: pending || draft2.imageBusy, onClick: () => actions3.removeImage(generation, child2.id, image), "aria-label": `${t("removeImage")}: ${image.name ?? image.mediaType}`, children: t("removeImage") })
8498
8855
  ] }, index)) })
8499
8856
  ] }),
8500
- draft2.uncertain && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-warning", children: [
8501
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { id: `${prefix}-unknown`, children: t("unknown") }),
8502
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives10.Button, { type: "button", variant: "outline", disabled: !state.fresh || state.reading || pending, onClick: () => actions2.acknowledgeUnknown(generation, child2.id), children: t("acknowledge") })
8857
+ draft2.uncertain && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-warning", children: [
8858
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { id: `${prefix}-unknown`, children: t("unknown") }),
8859
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_dsh_client_ui_primitives11.Button, { type: "button", variant: "outline", disabled: !state.fresh || state.reading || pending, onClick: () => actions3.acknowledgeUnknown(generation, child2.id), children: t("acknowledge") })
8503
8860
  ] }),
8504
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ControlAvailability, { value: !enabled(state.snapshot?.capabilities.prompt) ? state.snapshot?.capabilities.prompt : child2.controls.prompt, label: "promptAvailability", t }),
8505
- draft2.text.trim() === "" && draft2.images.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("emptyMessage") }),
8506
- draft2.images.length > 0 && !enabled(state.snapshot?.capabilities.images) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("deniedImages") }),
8507
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-actions", children: [
8508
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives10.Button, { type: "submit", variant: "primary", disabled: !submit, children: t("send") }),
8509
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
8510
- import_dsh_client_ui_primitives10.Button,
8861
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ControlAvailability, { value: !enabled(state.snapshot?.capabilities.prompt) ? state.snapshot?.capabilities.prompt : child2.controls.prompt, label: "promptAvailability", t }),
8862
+ draft2.text.trim() === "" && draft2.images.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("emptyMessage") }),
8863
+ draft2.images.length > 0 && !enabled(state.snapshot?.capabilities.images) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("deniedImages") }),
8864
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-actions", children: [
8865
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_dsh_client_ui_primitives11.Button, { type: "submit", variant: "primary", disabled: !submit, children: t("send") }),
8866
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
8867
+ import_dsh_client_ui_primitives11.Button,
8511
8868
  {
8512
8869
  type: "button",
8513
8870
  variant: "outline",
8514
8871
  disabled: !available || !enabled(state.snapshot?.capabilities.interrupt) || !enabled(child2.controls.interrupt) || child2.readonly || child2.mode !== "continuable",
8515
- onClick: () => void actions2.interrupt(generation, child2.id),
8872
+ onClick: () => void actions3.interrupt(generation, child2.id),
8516
8873
  children: t("interrupt")
8517
8874
  }
8518
8875
  )
8519
8876
  ] }),
8520
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: pending ? t("pending") : draft2.imageBusy ? t("imageReading") : "" })
8877
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: pending ? t("pending") : draft2.imageBusy ? t("imageReading") : "" })
8521
8878
  ] });
8522
8879
  }
8523
- function ChildDetails({ child: child2, state, actions: actions2, t, inspection = false }) {
8524
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("fieldset", { children: [
8525
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("legend", { children: child2.label?.trim() ? child2.label : child2.id }),
8526
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8880
+ function ChildDetails({ child: child2, state, actions: actions3, t, inspection = false }) {
8881
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("fieldset", { children: [
8882
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("legend", { children: child2.label?.trim() ? child2.label : child2.id }),
8883
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8527
8884
  t("childId"),
8528
8885
  ": ",
8529
8886
  child2.id
8530
8887
  ] }),
8531
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8888
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8532
8889
  t("parentId"),
8533
8890
  ": ",
8534
8891
  child2.parentSessionId
8535
8892
  ] }),
8536
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8893
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8537
8894
  t("mode"),
8538
8895
  ": ",
8539
8896
  child2.mode
8540
8897
  ] }),
8541
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8898
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8542
8899
  t("activity"),
8543
8900
  ": ",
8544
8901
  child2.activity
8545
8902
  ] }),
8546
- (inspection || child2.readonly) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("readonly") }),
8547
- child2.mode === "one-shot" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("oneShot") }),
8548
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(RouteComparisonDetails, { value: child2.routeComparison, t }),
8549
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(InvocationDetails, { value: child2.invocation, t, showComparison: false }),
8550
- (!inspection || !child2.controls.prompt.enabled) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ControlAvailability, { value: child2.controls.prompt, label: "promptAvailability", t }),
8551
- (!inspection || !child2.controls.interrupt.enabled) && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ControlAvailability, { value: child2.controls.interrupt, label: "interruptAvailability", t }),
8552
- !inspection && child2.mode === "continuable" && !child2.readonly && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChildComposer, { child: child2, state, actions: actions2, t }),
8553
- !inspection && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8554
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Issue2, { value: state.issues.get(childActionKey(child2.id)), t }),
8555
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Outcome, { value: state.outcomes.get(childActionKey(child2.id)), t })
8903
+ (inspection || child2.readonly) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("readonly") }),
8904
+ child2.mode === "one-shot" && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("oneShot") }),
8905
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(RouteComparisonDetails, { value: child2.routeComparison, t }),
8906
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(InvocationDetails, { value: child2.invocation, t, showComparison: false }),
8907
+ (!inspection || !child2.controls.prompt.enabled) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ControlAvailability, { value: child2.controls.prompt, label: "promptAvailability", t }),
8908
+ (!inspection || !child2.controls.interrupt.enabled) && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ControlAvailability, { value: child2.controls.interrupt, label: "interruptAvailability", t }),
8909
+ !inspection && child2.mode === "continuable" && !child2.readonly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ChildComposer, { child: child2, state, actions: actions3, t }),
8910
+ !inspection && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8911
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Issue2, { value: state.issues.get(childActionKey(child2.id)), t }),
8912
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Outcome, { value: state.outcomes.get(childActionKey(child2.id)), t })
8556
8913
  ] })
8557
8914
  ] });
8558
8915
  }
8559
8916
  function ChildrenPanel(props) {
8560
8917
  const state = props.useChildren((snapshot4) => snapshot4), { t } = props, generation = state.generation;
8561
- if (props.sessionId === void 0 || props.sessionId !== state.sessionId) return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: "dsmm-profiles dsmm-children", children: [
8562
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { children: t("title") }),
8563
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t(state.sessionId === null ? "noSession" : "foreign") })
8918
+ if (props.sessionId === void 0 || props.sessionId !== state.sessionId) return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: "dsmm-profiles dsmm-children", children: [
8919
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h2", { children: t("title") }),
8920
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t(state.sessionId === null ? "noSession" : "foreign") })
8564
8921
  ] });
8565
8922
  const data = state.snapshot;
8566
8923
  const refreshingDisabled = state.reading || state.pending.size > 0 || [...state.drafts.values()].some((draft2) => draft2.imageBusy);
8567
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: "dsmm-profiles dsmm-children", "aria-label": t("title"), "aria-busy": state.reading, children: [
8568
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h2", { children: t("title") }),
8569
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("description") }),
8570
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8924
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: "dsmm-profiles dsmm-children", "aria-label": t("title"), "aria-busy": state.reading, children: [
8925
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h2", { children: t("title") }),
8926
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("description") }),
8927
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8571
8928
  t("session"),
8572
8929
  ": ",
8573
8930
  state.sessionId
8574
8931
  ] }),
8575
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "dsmm-actions", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_dsh_client_ui_primitives10.Button, { type: "button", variant: "outline", disabled: refreshingDisabled, onClick: () => void props.refresh(generation), children: t("refresh") }) }),
8576
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: state.reading ? t("reading") : state.pending.size > 0 ? t("pending") : !state.fresh ? t(data === null ? "unavailable" : "stale") : "" }),
8577
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Issue2, { value: state.issue, t }),
8578
- data !== null && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8579
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8932
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "dsmm-actions", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_dsh_client_ui_primitives11.Button, { type: "button", variant: "outline", disabled: refreshingDisabled, onClick: () => void props.refresh(generation), children: t("refresh") }) }),
8933
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: state.reading ? t("reading") : state.pending.size > 0 ? t("pending") : !state.fresh ? t(data === null ? "unavailable" : "stale") : "" }),
8934
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Issue2, { value: state.issue, t }),
8935
+ data !== null && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8936
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8580
8937
  t("epoch"),
8581
8938
  ": ",
8582
8939
  data.admissionEpoch
8583
8940
  ] }),
8584
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: "dsmm-availability", children: [
8585
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8941
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: "dsmm-availability", children: [
8942
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8586
8943
  t("runtime"),
8587
8944
  ": ",
8588
8945
  data.capabilities.runtime.binding
8589
8946
  ] }),
8590
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8947
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8591
8948
  t("fence"),
8592
8949
  ": ",
8593
8950
  t(data.capabilities.runtime.deliveryFenceReady ? "yes" : "no")
8594
8951
  ] }),
8595
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8952
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8596
8953
  t("restart"),
8597
8954
  ": ",
8598
8955
  t(data.capabilities.runtime.restartRequired ? "yes" : "no")
8599
8956
  ] }),
8600
- data.capabilities.runtime.reason !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("authority") }),
8601
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ControlAvailability, { value: data.capabilities.prompt, label: "promptAvailability", t }),
8602
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ControlAvailability, { value: data.capabilities.interrupt, label: "interruptAvailability", t })
8957
+ data.capabilities.runtime.reason !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("authority") }),
8958
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ControlAvailability, { value: data.capabilities.prompt, label: "promptAvailability", t }),
8959
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ControlAvailability, { value: data.capabilities.interrupt, label: "interruptAvailability", t })
8603
8960
  ] }),
8604
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("backgroundHint") }),
8605
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: "dsmm-zone", "aria-label": t("children"), children: [
8606
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { children: t("children") }),
8607
- data.children.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("emptyChildren") }) : data.children.map((child2) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChildDetails, { child: child2, state, actions: props, t }, child2.id))
8961
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("backgroundHint") }),
8962
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: "dsmm-zone", "aria-label": t("children"), children: [
8963
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("children") }),
8964
+ data.children.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("emptyChildren") }) : data.children.map((child2) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ChildDetails, { child: child2, state, actions: props, t }, child2.id))
8608
8965
  ] })
8609
8966
  ] }),
8610
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("section", { className: "dsmm-zone", "aria-label": t("descendants"), children: [
8611
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("h3", { children: t("descendants") }),
8612
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Issue2, { value: state.descendantIssue, t }),
8613
- state.descendants === null ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("treeUnavailable") }) : state.descendants.descendants.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "dsmm-hint", children: t("emptyDescendants") }) : state.descendants.descendants.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-availability", children: [
8614
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8967
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("section", { className: "dsmm-zone", "aria-label": t("descendants"), children: [
8968
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("h3", { children: t("descendants") }),
8969
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Issue2, { value: state.descendantIssue, t }),
8970
+ state.descendants === null ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("treeUnavailable") }) : state.descendants.descendants.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "dsmm-hint", children: t("emptyDescendants") }) : state.descendants.descendants.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-availability", children: [
8971
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8615
8972
  t("depth"),
8616
8973
  ": ",
8617
8974
  entry.depth
8618
8975
  ] }),
8619
- entry.kind === "diagnostic" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "dsmm-issue", children: [
8620
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: t("diagnostic", { reason: entry.reason }) }),
8621
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8976
+ entry.kind === "diagnostic" ? /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "dsmm-issue", children: [
8977
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { children: t("diagnostic", { reason: entry.reason }) }),
8978
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8622
8979
  t("childId"),
8623
8980
  ": ",
8624
8981
  entry.id
8625
8982
  ] }),
8626
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8983
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8627
8984
  t("parentId"),
8628
8985
  ": ",
8629
8986
  entry.parentSessionId
8630
8987
  ] })
8631
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
8632
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { children: [
8988
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(import_jsx_runtime13.Fragment, { children: [
8989
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { children: [
8633
8990
  t("subtree"),
8634
8991
  ": ",
8635
8992
  t(entry.hasChildren ? "yes" : "no")
8636
8993
  ] }),
8637
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(ChildDetails, { child: entry.child, state, actions: props, t, inspection: true })
8994
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(ChildDetails, { child: entry.child, state, actions: props, t, inspection: true })
8638
8995
  ] })
8639
8996
  ] }, index))
8640
8997
  ] })
@@ -8663,26 +9020,7 @@ async function apply(ctx) {
8663
9020
  });
8664
9021
  void ctx.inject(["uiSession", "sessions"], (sessionCtx) => {
8665
9022
  const source = sessionCtx.uiSession.adapter.current, sessions = sessionCtx.sessions;
8666
- let observed, stop;
8667
- const update = () => {
8668
- const id2 = source.getSnapshot().key, binding = id2 === void 0 ? void 0 : sessions.binding(id2);
8669
- if (binding !== observed) {
8670
- stop?.();
8671
- observed = binding;
8672
- stop = binding?.session.subscribe(update);
8673
- }
8674
- const snapshot4 = binding?.session.getSnapshot(), catalog = sessions.list.getSnapshot(), summary = id2 === void 0 ? void 0 : catalog.byId[id2];
8675
- const child2 = snapshot4?.subagent != null || summary?.origin === "subagent" || summary?.parentId !== void 0;
8676
- const root = id2 !== void 0 && binding?.sessionId === id2 && snapshot4?.sessionId === id2 && snapshot4.openState === "open" && !snapshot4.removed && catalog.ids.includes(id2) && summary !== void 0 && !child2;
8677
- permissions.bindScope(id2 ?? null, binding ?? null, child2 ? "child" : root ? "root" : "unknown");
8678
- };
8679
- update();
8680
- sessionCtx.effect(() => source.subscribe(update));
8681
- sessionCtx.effect(() => sessions.list.subscribe(update));
8682
- sessionCtx.effect(() => () => {
8683
- stop?.();
8684
- permissions.bindScope(null, null, "unknown");
8685
- }, "dsmm: permission native session withdrawal");
9023
+ sessionCtx.effect(() => bindPermissionSession(source, sessions, permissions), "dsmm: permission native session withdrawal");
8686
9024
  });
8687
9025
  let deployment = null;
8688
9026
  let profiles = null;