@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
@@ -0,0 +1,17 @@
1
+ import type { PermissionRule } from "../permission-rules.js";
2
+ import type { DeploymentController } from "./deployment-controller.js";
3
+ import type { PermissionLocaleKey } from "./permission-locales.js";
4
+ type Text = (key: PermissionLocaleKey) => string;
5
+ export declare function validPermissionRules(value: unknown): boolean;
6
+ export declare function PermissionRuleEntries({ value, inherited, controller, disabled, onChange, expanded, onExpandedChange, t }: {
7
+ value: readonly PermissionRule[] | undefined;
8
+ inherited: readonly PermissionRule[];
9
+ controller: DeploymentController;
10
+ disabled: boolean;
11
+ onChange(value: readonly PermissionRule[] | undefined): void;
12
+ expanded?: boolean;
13
+ onExpandedChange?(expanded: boolean): void;
14
+ t: Text;
15
+ }): import("react").JSX.Element;
16
+ export {};
17
+ //# sourceMappingURL=PermissionRuleEntries.d.ts.map
@@ -0,0 +1,70 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useId, useSyncExternalStore } from "react";
3
+ import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { parsePermissionRules } from "../permission-rules.js";
5
+ import { parseAdvanced } from "./deployment-data.js";
6
+ const actions = ["allow", "ask", "deny"];
7
+ const kinds = ["outside-read", "shell", "webSearch", "webFetch"];
8
+ const name = "permissionControl.rules";
9
+ export function validPermissionRules(value) {
10
+ try {
11
+ parsePermissionRules(value);
12
+ return true;
13
+ }
14
+ catch {
15
+ return false;
16
+ }
17
+ }
18
+ function newMatch(kind) {
19
+ return kind === "outside-read" ? { kind, path: "", scope: "exact" } : kind === "shell" ? { kind, executable: "", command: "", workingDirectory: "" } : { kind };
20
+ }
21
+ /** Honest user-import provenance; the Host re-stamps it and owns revision/revocation. */
22
+ function newRule() {
23
+ return { id: "", action: "ask", match: newMatch("outside-read"), source: { kind: "user-import", label: "configuration" }, revision: 0, revoked: false };
24
+ }
25
+ function Row({ rule, index, disabled, change, remove, t }) {
26
+ const id = useId();
27
+ const field = (key) => _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-${key}`, children: t(key === "workingDirectory" ? "cwd" : key) }), _jsx(Input, { className: "dsmm-input", id: `${id}-${key}`, required: true, maxLength: 32768, disabled: disabled, value: key in rule.match ? String(Reflect.get(rule.match, key)) : "", onChange: event => change({ ...rule, match: { ...rule.match, [key]: event.currentTarget.value } }) })] });
28
+ return _jsxs("fieldset", { children: [_jsx("legend", { children: rule.id === "" ? `${t("newRule")} ${index + 1}` : rule.id }), _jsxs("p", { children: [t(rule.revoked ? "revoked" : "active"), " \u00B7 ", t(`action:${rule.action}`)] }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("source") }), _jsx("dd", { children: rule.source.kind === "operator" ? `${t("recordedOperator")} · ${rule.source.savedAt}` : `${t("imported")} · ${rule.source.label}` }), _jsx("dt", { children: t("recordVersion") }), _jsx("dd", { children: rule.revision })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-id`, children: t("id") }), _jsx(Input, { className: "dsmm-input", id: `${id}-id`, required: true, maxLength: 256, disabled: disabled, value: rule.id, onChange: event => change({ ...rule, id: event.currentTarget.value }) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-action`, children: t("action") }), _jsx("select", { id: `${id}-action`, disabled: disabled, value: rule.action, onChange: event => {
29
+ const action = actions.find(value => value === event.currentTarget.value);
30
+ if (action !== undefined)
31
+ change({ ...rule, action });
32
+ }, children: actions.map(action => _jsx("option", { value: action, children: t(`action:${action}`) }, action)) })] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-kind`, children: t("match") }), _jsx("select", { id: `${id}-kind`, disabled: disabled, value: rule.match.kind, onChange: event => {
33
+ const kind = kinds.find(value => value === event.currentTarget.value);
34
+ if (kind !== undefined)
35
+ change({ ...rule, match: newMatch(kind) });
36
+ }, children: kinds.map(kind => _jsx("option", { value: kind, children: t(`kind:${kind}`) }, kind)) })] }), rule.match.kind === "outside-read" && _jsxs(_Fragment, { children: [field("path"), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-scope`, children: t("pathScope") }), _jsxs("select", { id: `${id}-scope`, disabled: disabled, value: rule.match.scope, onChange: event => {
37
+ const scope = event.currentTarget.value;
38
+ if (rule.match.kind === "outside-read" && (scope === "exact" || scope === "tree"))
39
+ change({ ...rule, match: { ...rule.match, scope } });
40
+ }, children: [_jsx("option", { value: "exact", children: t("exact") }), _jsx("option", { value: "tree", children: t("tree") })] })] })] }), rule.match.kind === "shell" && _jsxs(_Fragment, { children: [field("executable"), field("command"), field("workingDirectory")] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: remove, children: [t("removeRule"), " ", index + 1] })] });
41
+ }
42
+ export function PermissionRuleEntries({ value, inherited, controller, disabled, onChange, expanded, onExpandedChange, t }) {
43
+ const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot), id = useId();
44
+ const raw = state.raw[name], locked = raw?.invalid === true, entries = value ?? inherited, valid = validPermissionRules(entries);
45
+ const text = raw?.text ?? (value === undefined ? "" : JSON.stringify(value, null, 2));
46
+ const change = (next) => {
47
+ // Any structured edit supersedes an invalid raw list; that replacement is explicit, not silent.
48
+ if (raw !== undefined)
49
+ controller.clearRaw(name);
50
+ controller.setInvalid(name, !validPermissionRules(next));
51
+ onChange(next);
52
+ };
53
+ const remove = (index) => change(entries.filter((_, position) => position !== index));
54
+ const held = disabled || locked;
55
+ return _jsxs("details", { className: "dsmm-deployment-group", "data-field": name, open: expanded, onToggle: event => onExpandedChange?.(event.currentTarget.open), children: [_jsxs("summary", { children: [t("configRules"), " ", _jsx("code", { children: name })] }), _jsxs("div", { className: "dsmm-structured", children: [_jsx("p", { className: "dsmm-hint", children: t("configRulesHint") }), _jsx("p", { className: "dsmm-hint", children: t(value === undefined ? "inheritedRules" : "explicitRules") }), !valid && _jsx("p", { className: "dsmm-issue", role: "alert", children: t("invalidRule") }), entries.length === 0 && _jsx("p", { children: t("configRulesEmpty") }), entries.map((rule, index) => _jsx(Row, { rule: rule, index: index, disabled: held, t: t, change: next => change(entries.map((row, position) => position === index ? next : row)), remove: () => remove(index) }, index)), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: held || entries.length >= 1024, onClick: () => change([...entries, newRule()]), children: t("addRule") }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: disabled || value === undefined && raw === undefined, onClick: () => { controller.clearRaw(name); onChange(undefined); }, children: t("unset") })] }), _jsxs("details", { children: [_jsx("summary", { id: `${id}-advanced-label`, children: t("advancedRules") }), _jsxs("div", { className: "dsmm-field", children: [_jsx("textarea", { id: `${id}-advanced`, rows: 6, maxLength: 32768, value: text, disabled: disabled, "aria-labelledby": `${id}-advanced-label`, "aria-invalid": locked, "aria-describedby": `${id}-error`, onChange: event => {
56
+ const next = event.currentTarget.value;
57
+ let parsed, ok = false;
58
+ try {
59
+ parsed = parseAdvanced(next);
60
+ ok = parsed === undefined || validPermissionRules(parsed);
61
+ }
62
+ catch {
63
+ ok = false;
64
+ }
65
+ controller.setRaw(name, next, !ok);
66
+ if (ok)
67
+ onChange(parsed);
68
+ } }), _jsx("p", { id: `${id}-error`, className: "dsmm-hint", children: locked ? t("invalidRule") : "" })] })] })] })] });
69
+ }
70
+ //# sourceMappingURL=PermissionRuleEntries.js.map
@@ -1,6 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useEffect, useId, useSyncExternalStore } from "react";
3
3
  import { Button, Input } from "@deepseek-ai/dsh-client-ui-primitives";
4
+ import { displayUnconfirmed, observedRules } from "./permission-controller.js";
4
5
  const actions = ["inherit", "allow", "ask", "deny"];
5
6
  const kinds = ["outside-read", "shell", "webSearch", "webFetch"];
6
7
  const ruleDraft = (rule) => ({ id: rule.id, action: rule.action, match: structuredClone(rule.match) });
@@ -25,22 +26,24 @@ function RuleEditor({ controller, state, t }) {
25
26
  change({ ...editor, match: { ...editor.match, scope } }); }, children: [_jsx("option", { value: "exact", children: t("exact") }), _jsx("option", { value: "tree", children: t("tree") })] })] })] }), editor.match.kind === "shell" && _jsxs(_Fragment, { children: [field("executable", "executable"), field("command", "command"), field("workingDirectory", "cwd")] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "submit", variant: "outline", disabled: disabled, children: t("stage") }), _jsx(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { editor: null }), children: t("cancel") })] })] });
26
27
  }
27
28
  function RuleRecords({ controller, state, t }) {
28
- const records = state.rules?.snapshot.policy.rules ?? state.base?.policy.rules;
29
+ const records = observedRules(state)?.snapshot.policy.rules ?? state.base?.policy.rules;
29
30
  return _jsxs("div", { className: "dsmm-structured", children: [records?.length === 0 && _jsx("p", { children: t("noRules") }), records?.map(rule => _jsxs("fieldset", { children: [_jsx("legend", { children: rule.id }), _jsxs("p", { children: [t(rule.revoked ? "revoked" : "active"), " \u00B7 ", t(`action:${rule.action}`)] }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("match") }), _jsx("dd", { children: t(`kind:${rule.match.kind}`) }), rule.match.kind === "outside-read" && _jsxs(_Fragment, { children: [_jsx("dt", { children: t("path") }), _jsxs("dd", { children: [rule.match.path, " \u00B7 ", t(rule.match.scope)] })] }), rule.match.kind === "shell" && _jsxs(_Fragment, { children: [_jsx("dt", { children: t("executable") }), _jsx("dd", { children: rule.match.executable }), _jsx("dt", { children: t("command") }), _jsx("dd", { children: _jsx("code", { children: rule.match.command }) }), _jsx("dt", { children: t("cwd") }), _jsx("dd", { children: rule.match.workingDirectory })] }), _jsx("dt", { children: t("source") }), _jsx("dd", { children: t(rule.source.kind === "operator" ? "operator" : "imported") })] }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "outline", disabled: !controller.canEdit(state.generation) || state.draft === null, onClick: () => controller.edit(state.generation, { editor: ruleDraft(rule) }), children: t("editRule") }), _jsx(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") })] })] }, rule.id))] });
30
31
  }
31
32
  function PermissionCoverage({ state, t }) {
32
- const value = state.rules?.capabilities;
33
+ const value = observedRules(state)?.capabilities;
33
34
  return _jsxs("section", { className: "dsmm-structured", "aria-label": t("coverageTitle"), children: [_jsx("h3", { children: t("coverageTitle") }), _jsx("p", { className: "dsmm-hint", children: t("coverage") }), _jsx("p", { className: "dsmm-hint", children: t("registrationUnresolved") }), value === undefined ? _jsx("p", { children: t("coverageUnavailable") }) : _jsxs(_Fragment, { children: [_jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("coverageRuntime") }), _jsxs("dd", { children: [t(value.runtime.state), " \u00B7 ", t("mounted"), ": ", t(value.runtime.mounted ? "on" : "off")] })] }), value.runtime.restartRequired && _jsx("p", { children: t("restart") }), value.tools.length === 0 ? _jsx("p", { children: t("coverageEmpty") }) : _jsx("ul", { className: "dsmm-profile-list", children: value.tools.map(tool => _jsx("li", { children: _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("toolName") }), _jsx("dd", { children: _jsx("code", { children: tool.name }) }), _jsx("dt", { children: t("toolKind") }), _jsx("dd", { children: _jsx("code", { children: tool.kind }) }), _jsx("dt", { children: t("toolApproval") }), _jsx("dd", { children: t("nativeOnce") }), _jsx("dt", { children: t("toolMemory") }), _jsx("dd", { children: t("notProvided") })] }) }, tool.name)) }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("outsideReads") }), _jsx("dd", { children: t("limit:outsideReads") }), _jsx("dt", { children: t("finalInode") }), _jsx("dd", { children: t("limit:finalInode") }), _jsx("dt", { children: t("toolMemory") }), _jsx("dd", { children: t("limit:scopedMemory") }), _jsx("dt", { children: t("webFetch") }), _jsx("dd", { children: t("limit:webFetch") }), _jsx("dt", { children: t("searchDestinations") }), _jsx("dd", { children: t("limit:webSearchDestinations") }), _jsx("dt", { children: t("proxyBinding") }), _jsx("dd", { children: t("limit:proxyAddressBinding") }), _jsx("dt", { children: t("shellSockets") }), _jsx("dd", { children: t("limit:shellSockets") }), _jsx("dt", { children: t("providerAuthMcp") }), _jsx("dd", { children: t("limit:providerAuthMcp") })] })] }), _jsx("p", { className: "dsmm-hint", children: t("pathEvidence") })] });
34
35
  }
35
36
  export function PermissionRulesEditor({ controller, state, t }) {
36
- const id = useId(), draft = state.draft, disabled = !controller.canEdit(state.generation), value = state.rules;
37
- return _jsxs("section", { className: "dsmm-zone", "aria-label": t("rules"), children: [_jsx("h3", { children: t("rules") }), _jsx("p", { className: "dsmm-hint", children: t("rulesHint") }), _jsx("p", { className: "dsmm-hint", children: t("networkLimit") }), _jsx("p", { className: "dsmm-hint", children: t("matchHint") }), _jsx(Issue, { value: state.rulesIssue, t: t }), _jsx("p", { className: "dsmm-hint", children: t("observedPolicy") }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("profileOverrideState") }), _jsx("dd", { children: t("profileOverrideUnknown") })] }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("runtime") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.state) }), _jsx("dt", { children: t("mounted") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.mounted ? "on" : "off") })] }), value?.runtime.restartRequired && _jsx("p", { children: t("restart") }), disabled && _jsx("p", { className: "dsmm-hint", children: t(state.reading ? "reading" : "rulesUnavailable") }), state.base !== null && _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: "permissionControl.enabled" }), _jsxs("dd", { children: [t(state.base.policy.enabled ? "on" : "off"), " \u00B7 ", t("coldHint")] }), _jsx("dt", { children: "permissionControl.nativeCommands.enabled" }), _jsx("dd", { children: t(state.base.policy.nativeCommands.enabled ? "on" : "off") })] }), _jsx(PermissionCoverage, { state: state, t: t }), draft !== null && _jsxs(_Fragment, { children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-outside`, children: t("outsideReads") }), _jsx(ActionSelect, { id: `${id}-outside`, value: draft.outsideReads, disabled: disabled, t: t, onChange: outsideReads => controller.edit(state.generation, { outsideReads }) })] }), ["webSearch", "webFetch"].map(key => _jsxs("fieldset", { children: [_jsx("legend", { children: t(key) }), _jsxs("label", { className: "dsmm-actions", htmlFor: `${id}-${key}-enabled`, children: [_jsx("input", { type: "checkbox", id: `${id}-${key}-enabled`, checked: draft[key].enabled, disabled: disabled, onChange: event => controller.edit(state.generation, { [key]: { ...draft[key], enabled: event.currentTarget.checked } }) }), t("enabled")] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-${key}-rule`, children: t("rule") }), _jsx(ActionSelect, { id: `${id}-${key}-rule`, value: draft[key].rule, disabled: disabled, t: t, onChange: rule => controller.edit(state.generation, { [key]: { ...draft[key], rule } }) })] })] }, key)), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || draft.editor !== null, onClick: () => controller.edit(state.generation, { editor: { id: "", action: "ask", match: newMatch("outside-read") } }), children: t("newRule") }), _jsx(RuleEditor, { controller: controller, state: state, t: t }), (draft.upsert.length > 0 || draft.revoke.length > 0) && _jsxs("div", { className: "dsmm-structured", children: [_jsx("h3", { children: t("staged") }), draft.upsert.map(row => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [row.id, " \u00B7 ", t(`kind:${row.match.kind}`), " \u00B7 ", t(`action:${row.action}`)] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { upsert: draft.upsert.filter(rule => rule.id !== row.id) }), children: [t("unstage"), ": ", row.id] })] }, row.id)), draft.revoke.map(ruleId => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [t("stageRevoke"), ": ", ruleId] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { revoke: draft.revoke.filter(id => id !== ruleId) }), children: [t("unstage"), ": ", ruleId] })] }, ruleId))] })] }), _jsx(RuleRecords, { state: state, controller: controller, t: t }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !controller.canSave(state.generation), onClick: () => void controller.save(state.generation), children: t("save") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.scope !== "root" || !state.connected || state.reading || state.busy !== null, onClick: () => void controller.refresh(state.generation, true), children: t("discard") })] }), state.dirty && _jsx("p", { children: t("dirty") })] });
37
+ const id = useId(), draft = state.draft, disabled = !controller.canEdit(state.generation), value = observedRules(state), observedPolicy = value?.snapshot ?? null;
38
+ const writable = state.scope === "root" && state.connected;
39
+ return _jsxs("section", { className: "dsmm-zone", "aria-label": t("rules"), children: [_jsx("h3", { children: t("rules") }), _jsx("p", { className: "dsmm-hint", children: t("rulesHint") }), _jsx("p", { className: "dsmm-hint", children: t("networkLimit") }), _jsx("p", { className: "dsmm-hint", children: t("matchHint") }), _jsx(Issue, { value: state.rulesIssue, t: t }), displayUnconfirmed(state) && _jsx("p", { className: "dsmm-hint", children: t("unconfirmedObservation") }), _jsx("p", { className: "dsmm-hint", children: t("observedPolicy") }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("profileOverrideState") }), _jsx("dd", { children: t("profileOverrideUnknown") })] }), _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: t("runtime") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.state) }), _jsx("dt", { children: t("mounted") }), _jsx("dd", { children: value === null ? t("unknown") : t(value.runtime.mounted ? "on" : "off") })] }), value?.runtime.restartRequired && _jsx("p", { children: t("restart") }), disabled && !state.reading && !displayUnconfirmed(state) && _jsx("p", { className: "dsmm-hint", children: t("rulesUnavailable") }), observedPolicy !== null && _jsxs("dl", { className: "dsmm-child-meta", children: [_jsx("dt", { children: "permissionControl.enabled" }), _jsxs("dd", { children: [t(observedPolicy.policy.enabled ? "on" : "off"), " \u00B7 ", t("coldHint")] }), _jsx("dt", { children: "permissionControl.nativeCommands.enabled" }), _jsx("dd", { children: t(observedPolicy.policy.nativeCommands.enabled ? "on" : "off") })] }), _jsxs("details", { className: "dsmm-deployment-group", children: [_jsx("summary", { children: t("coverageDetails") }), _jsx(PermissionCoverage, { state: state, t: t })] }), draft !== null && _jsxs(_Fragment, { children: [_jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-outside`, children: t("outsideReads") }), _jsx(ActionSelect, { id: `${id}-outside`, value: draft.outsideReads, disabled: disabled, t: t, onChange: outsideReads => controller.edit(state.generation, { outsideReads }) })] }), ["webSearch", "webFetch"].map(key => _jsxs("fieldset", { children: [_jsx("legend", { children: t(key) }), _jsxs("label", { className: "dsmm-actions", htmlFor: `${id}-${key}-enabled`, children: [_jsx("input", { type: "checkbox", id: `${id}-${key}-enabled`, checked: draft[key].enabled, disabled: disabled, onChange: event => controller.edit(state.generation, { [key]: { ...draft[key], enabled: event.currentTarget.checked } }) }), t("enabled")] }), _jsxs("div", { className: "dsmm-field", children: [_jsx("label", { htmlFor: `${id}-${key}-rule`, children: t("rule") }), _jsx(ActionSelect, { id: `${id}-${key}-rule`, value: draft[key].rule, disabled: disabled, t: t, onChange: rule => controller.edit(state.generation, { [key]: { ...draft[key], rule } }) })] })] }, key)), _jsx(Button, { type: "button", variant: "outline", disabled: disabled || draft.editor !== null, onClick: () => controller.edit(state.generation, { editor: { id: "", action: "ask", match: newMatch("outside-read") } }), children: t("newRule") }), _jsx(RuleEditor, { controller: controller, state: state, t: t }), (draft.upsert.length > 0 || draft.revoke.length > 0) && _jsxs("div", { className: "dsmm-structured", children: [_jsx("h3", { children: t("staged") }), draft.upsert.map(row => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [row.id, " \u00B7 ", t(`kind:${row.match.kind}`), " \u00B7 ", t(`action:${row.action}`)] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { upsert: draft.upsert.filter(rule => rule.id !== row.id) }), children: [t("unstage"), ": ", row.id] })] }, row.id)), draft.revoke.map(ruleId => _jsxs("div", { className: "dsmm-field", children: [_jsxs("p", { children: [t("stageRevoke"), ": ", ruleId] }), _jsxs(Button, { type: "button", variant: "outline", disabled: disabled, onClick: () => controller.edit(state.generation, { revoke: draft.revoke.filter(id => id !== ruleId) }), children: [t("unstage"), ": ", ruleId] })] }, ruleId))] })] }), _jsx(RuleRecords, { state: state, controller: controller, t: t }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { type: "button", variant: "primary", disabled: !controller.canSave(state.generation), onClick: () => void controller.save(state.generation), children: t("save") }), _jsx(Button, { type: "button", variant: "outline", disabled: !writable || state.reading || state.busy !== null, onClick: () => void controller.refresh(state.generation), children: t("refresh") }), _jsx(Button, { type: "button", variant: "outline", disabled: !writable || state.reading || state.busy !== null || !state.dirty && state.rulesIssue === null, onClick: () => void controller.refresh(state.generation, true), children: t("discard") })] }), state.dirty && _jsx("p", { children: t("dirty") })] });
38
40
  }
39
41
  export function PermissionsPanel({ controller, t, sessionId }) {
40
42
  const state = useSyncExternalStore(controller.store.subscribe, controller.store.getSnapshot);
41
43
  useEffect(() => controller.watch(), [controller]);
42
44
  if (sessionId !== undefined && sessionId !== state.sessionId)
43
45
  return _jsx("p", { className: "dsmm-hint", role: "status", children: t("rulesUnavailable") });
44
- return _jsxs("section", { className: "dsmm-profiles dsmm-children dsmm-permissions", "data-dsmm-permissions": true, "aria-label": t("title"), "aria-busy": state.reading || state.busy !== null, children: [_jsx("h2", { children: t("title") }), _jsx(RootState, { state: state, t: t }), _jsx("p", { className: "dsmm-hint", children: t("nativeApproval") }), _jsx("p", { className: "dsmm-status", role: "status", "aria-live": "polite", children: state.busy !== null ? t("busy") : state.reading ? t("reading") : state.notice === null ? "" : t(state.notice) }), _jsx(PermissionRulesEditor, { controller: controller, state: state, t: t })] });
46
+ // Silent revalidation never flips the region busy; a save reports through its own status line.
47
+ return _jsxs("section", { className: "dsmm-profiles dsmm-children dsmm-permissions", "data-dsmm-permissions": true, "aria-label": t("title"), "aria-busy": state.reading, children: [_jsx("h2", { children: t("title") }), _jsx(RootState, { state: state, t: t }), _jsx("p", { className: "dsmm-hint", children: t("nativeApproval") }), _jsx("p", { className: "dsmm-hint", children: t("sandboxScope") }), _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) }), _jsx(PermissionRulesEditor, { controller: controller, state: state, t: t })] });
45
48
  }
46
49
  //# sourceMappingURL=PermissionsPanel.js.map
@@ -18,13 +18,11 @@ export declare const deploymentEn: {
18
18
  permissionControlHint: string;
19
19
  modules: string;
20
20
  scope: string;
21
- close: string;
22
21
  loading: string;
23
22
  unset: string;
24
23
  "module:run": string;
25
24
  "module:routes": string;
26
25
  "module:workflow": string;
27
- "module:subagents": string;
28
26
  "module:permissions": string;
29
27
  "module:other": string;
30
28
  "module:state": string;
@@ -43,6 +41,8 @@ export declare const deploymentEn: {
43
41
  nativeRuntimeHint: string;
44
42
  nativeRuntimeReadinessHint: string;
45
43
  unsetGroup: string;
44
+ unitBytes: string;
45
+ unitChars: string;
46
46
  nativeRuntimeState: string;
47
47
  nativeRuntimeBinding: string;
48
48
  nativeRuntimeFence: string;
@@ -12,15 +12,15 @@ export const deploymentEn = {
12
12
  core: "Core", 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.",
13
13
  modelParametersHint: "Off stops sending custom parameters and uses native reasoning defaults. Saved values and your selected model stay unchanged.",
14
14
  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.",
15
- modules: "Configuration modules", scope: "Configuration scope", close: "Close module", loading: "Loading configuration…", unset: "Use default configuration",
16
- "module:run": "Run and modules", "module:routes": "Model routes and recovery", "module:workflow": "Workflow, roles and skills", "module:subagents": "Subagent settings", "module:permissions": "Permissions and guards", "module:other": "Other settings", "module:state": "Configuration state",
15
+ modules: "Configuration sections", scope: "Configuration scope", loading: "Loading configuration…", unset: "Use default configuration",
16
+ "module:run": "Run and modules", "module:routes": "Model routes and recovery", "module:workflow": "Workflow, roles and subagents", "module:permissions": "Permissions and safety", "module:other": "Other / advanced", "module:state": "Configuration state",
17
17
  saveScope: "Save selected configuration scope", pendingModules: "Pending modules in this scope", savedRefreshRequired: "Saved — refresh required before further edits", sessionObserved: "Current-session admission observed",
18
18
  noModuleFields: "No editable settings in this scope.",
19
19
  leaveDraft: "Unsaved or invalid draft. Choose how to leave; nothing is saved or discarded automatically.", continueEditing: "Continue editing", keepDraft: "Keep draft and return", discardDraft: "Discard draft and leave",
20
- rootRules: "Session permission rules", rootRulesHint: "Rules save separately. Select an open main session with editing access and synchronized permissions.", rootRulesUnavailable: "Permission rules unavailable. Reconnect and refresh.",
20
+ rootRules: "Global permission rules", 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.", rootRulesUnavailable: "Permission rules unavailable. Reconnect and refresh.",
21
21
  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.",
22
22
  nativeRuntimeReadinessHint: "Task progress is available in the session.",
23
- unsetGroup: "Use defaults for this group",
23
+ unsetGroup: "Use defaults for this group", unitBytes: "bytes", unitChars: "characters",
24
24
  nativeRuntimeState: "Observed native runtime", nativeRuntimeBinding: "Observed runtime composition", nativeRuntimeFence: "Execution admission ready", nativeRuntimeRestart: "Restart required", nativeRuntimeStock: "Official Host runtime", nativeRuntimeUnavailable: "Unavailable / unknown",
25
25
  "nativeRuntimeReason-explicit-composition-required": "The Host requires an explicit native runtime composition.", "nativeRuntimeReason-duplicate-provider": "More than one native provider is present; readiness is not confirmed.", "nativeRuntimeReason-authority-not-ready": "Native execution authority is not ready.", "nativeRuntimeReason-disabled": "The saved native runtime is disabled.", "nativeRuntimeReason-pending-restart": "Saved desired state differs from the mounted native composition; restart is pending.", "nativeRuntimeReason-scope-conflict": "Native scope ownership conflicts; readiness is not confirmed.",
26
26
  saveGlobal: "Save", saveProfile: "Save", saving: "Saving…", refresh: "Refresh", discard: "Discard and reload", dirty: "Unsaved changes", saved: "Saved",
@@ -54,15 +54,15 @@ export const deploymentZh = {
54
54
  core: "Core 核心配置", coreHint: "Core 所有的 desired 意图配置。模型参数透传为普通配置,非子插件;权限控制 enabled 仅启动时捕获。保存不改变当前会话准入;下方可检查意图、启动与准入值,不可用的准入仍为未知。",
55
55
  modelParametersHint: "关闭后停止发送自定义参数,并使用原生推理默认值;已保存的值和所选模型不变。",
56
56
  permissionControlHint: "权限控制挂载仅启动时捕获。保存配置不证明运行时覆盖,也不移除当前保护;Root 规则在权限模块内保持独立权限。",
57
- modules: "配置模块", scope: "配置范围", close: "关闭模块", loading: "正在加载配置…", unset: "使用默认配置",
58
- "module:run": "运行与模块", "module:routes": "模型路由与恢复", "module:workflow": "工作流、角色与技能", "module:subagents": "子 Agent 设置", "module:permissions": "权限与保护", "module:other": "其他设置", "module:state": "配置状态",
57
+ modules: "配置分区", scope: "配置范围", loading: "正在加载配置…", unset: "使用默认配置",
58
+ "module:run": "运行与模块", "module:routes": "模型路由与恢复", "module:workflow": "工作流、角色与子 Agent", "module:permissions": "权限与安全", "module:other": "其他与高级", "module:state": "配置状态",
59
59
  saveScope: "保存所选配置作用域", pendingModules: "此作用域的待保存模块", savedRefreshRequired: "已保存——需刷新后继续编辑", sessionObserved: "已观测当前会话准入",
60
60
  noModuleFields: "此范围内没有可编辑的设置。",
61
61
  leaveDraft: "仍有未保存或无效草稿,请选择离开方式;不会自动保存或丢弃。", continueEditing: "继续编辑", keepDraft: "保留草稿并返回", discardDraft: "放弃草稿并离开",
62
- rootRules: "会话权限规则", rootRulesHint: "规则单独保存。请选择已打开的主会话,并确认有编辑权限且权限已同步。", rootRulesUnavailable: "权限规则不可用,请重连后刷新。",
62
+ rootRules: "全局权限规则", rootRulesHint: "请选择已打开且有编辑权限的主会话作为全局规则的编辑入口。保存的规则写入全局策略,对所有使用该策略的上下文生效,并非会话私有。此事务与配置分别保存。", rootRulesUnavailable: "权限规则不可用,请重连后刷新。",
63
63
  nativeRuntimeHint: "原生默认开启,Host base 固定值仍适用;挂载仅启动时捕获。保存只设置 desired,不会启动/停止提供商或取消当前会话;独立 Host 重启可能取消会话。",
64
64
  nativeRuntimeReadinessHint: "任务进度可在会话中查看。",
65
- unsetGroup: "整组使用默认配置",
65
+ unsetGroup: "整组使用默认配置", unitBytes: "字节", unitChars: "字符",
66
66
  nativeRuntimeState: "已观测原生运行时", nativeRuntimeBinding: "已观测运行时组合", nativeRuntimeFence: "执行准入已就绪", nativeRuntimeRestart: "需要重启", nativeRuntimeStock: "官方 Host 运行时", nativeRuntimeUnavailable: "不可用/未知",
67
67
  "nativeRuntimeReason-explicit-composition-required": "Host 需要显式的原生运行时组合。", "nativeRuntimeReason-duplicate-provider": "存在重复原生 provider,无法确认就绪状态。", "nativeRuntimeReason-authority-not-ready": "原生执行权限尚未就绪。", "nativeRuntimeReason-disabled": "已保存的原生运行时为关闭。", "nativeRuntimeReason-pending-restart": "已保存 desired 与已挂载原生组合不同,等待独立重启。", "nativeRuntimeReason-scope-conflict": "原生 scope 所有权冲突,无法确认就绪状态。",
68
68
  saveGlobal: "保存", saveProfile: "保存", saving: "正在保存…", refresh: "刷新", discard: "丢弃并重载", dirty: "未保存", saved: "已保存",
@@ -1,9 +1,11 @@
1
1
  import type { DeploymentSchemaNode } from "../profile-types.js";
2
2
  import type { DeploymentLocaleKey } from "./deployment-locales.js";
3
- export declare const CONFIG_MODULES: readonly ["run", "routes", "workflow", "subagents", "permissions", "other", "state"];
4
- export type ConfigModule = typeof CONFIG_MODULES[number];
3
+ /** The five flat sections. "other" is appended only when an ungrouped field exists. */
4
+ export declare const CONFIG_MODULES: readonly ["run", "routes", "workflow", "permissions", "state"];
5
+ export declare const NAVIGATION_MODULES: readonly ["run", "routes", "workflow", "permissions", "state", "other"];
6
+ export type ConfigModule = typeof NAVIGATION_MODULES[number];
5
7
  export declare const moduleTitle: (module: ConfigModule) => DeploymentLocaleKey;
6
- export declare function moduleFor(path: string): Exclude<ConfigModule, "state">;
8
+ export declare function moduleFor(path: string): ConfigModule;
7
9
  export declare function editableConfigField(key: string, layer: "global" | "profile"): boolean;
8
10
  export declare function moduleFields(schema: DeploymentSchemaNode, module: ConfigModule, layer: "global" | "profile"): Array<[string, DeploymentSchemaNode]>;
9
11
  //# sourceMappingURL=deployment-modules.d.ts.map
@@ -1,4 +1,6 @@
1
- export const CONFIG_MODULES = ["run", "routes", "workflow", "subagents", "permissions", "other", "state"];
1
+ /** The five flat sections. "other" is appended only when an ungrouped field exists. */
2
+ export const CONFIG_MODULES = ["run", "routes", "workflow", "permissions", "state"];
3
+ export const NAVIGATION_MODULES = [...CONFIG_MODULES, "other"];
2
4
  export const moduleTitle = (module) => `module:${module}`;
3
5
  export function moduleFor(path) {
4
6
  const key = path.split(".")[0];
@@ -6,10 +8,8 @@ export function moduleFor(path) {
6
8
  return "run";
7
9
  if (["roleRouting", "runtimePolicy", "runtimeRecovery"].includes(key))
8
10
  return "routes";
9
- if (["workflow", "roles", "skills", "presets", "businessLocale", "locale", "promptOrder"].includes(key))
11
+ if (["workflow", "roles", "skills", "presets", "businessLocale", "locale", "promptOrder", "subagents"].includes(key))
10
12
  return "workflow";
11
- if (key === "subagents")
12
- return "subagents";
13
13
  if (["permissionControl", "guards"].includes(key))
14
14
  return "permissions";
15
15
  return "other";
@@ -18,6 +18,7 @@ export declare class DeploymentWorkspace {
18
18
  readonly permissions?: PermissionController | undefined;
19
19
  private state;
20
20
  private listeners;
21
+ private visited;
21
22
  private forms;
22
23
  private profiles;
23
24
  private stopForm?;
@@ -35,9 +36,12 @@ export declare class DeploymentWorkspace {
35
36
  bindForms(forms: ConfigForms | null): void;
36
37
  private sync;
37
38
  controller(scope?: ConfigScope): DeploymentController | null;
39
+ /** First visit opens the first section with editable fields; afterwards the last viewed section. */
40
+ private defaultSection;
38
41
  hasPending(): boolean;
39
42
  request(destination: Destination): void;
40
43
  continueEditing(): void;
44
+ /** Explicitly keep every draft and move anyway; the draft stays in contribution memory. */
41
45
  keepAndNavigate(): void;
42
46
  discardAndNavigate(): Promise<void>;
43
47
  save(): Promise<void>;
@@ -1,9 +1,12 @@
1
+ import { CONFIG_MODULES, moduleFields } from "./deployment-modules.js";
2
+ import { scopeSchema } from "./deployment-data.js";
1
3
  /** Contribution-owned memory only. Navigation never saves, applies, or rebases drafts. */
2
4
  export class DeploymentWorkspace {
3
5
  core;
4
6
  permissions;
5
7
  state = { scope: "global", module: null, pending: null, native: null, revision: 0 };
6
8
  listeners = new Set();
9
+ visited = { global: null, profile: null };
7
10
  forms = null;
8
11
  profiles = new Map();
9
12
  stopForm;
@@ -68,25 +71,47 @@ export class DeploymentWorkspace {
68
71
  this.changed({ native });
69
72
  }
70
73
  controller(scope = this.state.scope) { return scope === "global" ? this.core : this.state.native; }
74
+ /** First visit opens the first section with editable fields; afterwards the last viewed section. */
75
+ defaultSection(scope) {
76
+ const restored = this.visited[scope];
77
+ if (restored !== null)
78
+ return restored;
79
+ const snapshot = this.controller(scope)?.getSnapshot().snapshot;
80
+ if (snapshot !== null && snapshot !== undefined) {
81
+ const schema = scopeSchema(snapshot, scope);
82
+ for (const module of CONFIG_MODULES)
83
+ if (module !== "state" && moduleFields(schema, module, scope).length > 0)
84
+ return module;
85
+ }
86
+ return "state";
87
+ }
71
88
  hasPending() { return this.controller()?.getSnapshot().dirty === true || this.state.module === "permissions" && this.permissions?.store.getSnapshot().dirty === true; }
72
89
  request(destination) {
73
90
  const switched = destination.scope !== this.state.scope;
74
- const leaving = switched || this.state.module !== null && destination.module !== this.state.module;
75
- if (leaving && this.hasPending())
91
+ const leaving = switched || this.state.module !== null && destination.module !== null && destination.module !== this.state.module;
92
+ if (leaving && this.hasPending()) {
76
93
  this.changed({ pending: destination });
77
- else {
78
- this.changed({ ...destination, pending: null });
79
- if (switched)
80
- void this.controller()?.refresh();
94
+ return;
81
95
  }
96
+ const module = destination.module ?? this.defaultSection(destination.scope);
97
+ this.visited[destination.scope] = module;
98
+ this.changed({ scope: destination.scope, module, pending: null });
99
+ if (switched)
100
+ void this.controller()?.refresh();
82
101
  }
83
102
  continueEditing() { this.changed({ pending: null }); }
84
- keepAndNavigate() { const target = this.state.pending; if (target !== null) {
103
+ /** Explicitly keep every draft and move anyway; the draft stays in contribution memory. */
104
+ keepAndNavigate() {
105
+ const target = this.state.pending;
106
+ if (target === null)
107
+ return;
108
+ const module = target.module ?? this.defaultSection(target.scope);
109
+ this.visited[target.scope] = module;
85
110
  const switched = target.scope !== this.state.scope;
86
- this.changed({ ...target, pending: null });
111
+ this.changed({ scope: target.scope, module, pending: null });
87
112
  if (switched)
88
113
  void this.controller()?.refresh();
89
- } }
114
+ }
90
115
  async discardAndNavigate() {
91
116
  const destination = this.state.pending;
92
117
  if (destination === null)
@@ -98,12 +123,13 @@ export class DeploymentWorkspace {
98
123
  return;
99
124
  }
100
125
  if (this.state.module === "permissions" && this.permissions?.store.getSnapshot().dirty) {
101
- await this.permissions.refresh(this.permissions.store.getSnapshot().generation, true);
126
+ const permissions = this.permissions.store.getSnapshot();
127
+ await this.permissions.refresh(permissions.generation, true);
102
128
  if (this.permissions.store.getSnapshot().dirty)
103
129
  return;
104
130
  }
105
131
  if (this.state.pending === destination)
106
- this.changed({ ...destination, pending: null });
132
+ this.request(destination);
107
133
  }
108
134
  async save() { const controller = this.controller(); if (controller === null)
109
135
  return; await controller.save(); if (controller !== this.core && controller.getSnapshot().saved)
@@ -11,6 +11,7 @@ import { DEPLOYMENT_NS, deploymentEn, deploymentZh } from "./deployment-locales.
11
11
  import { ROLE_CONTROL_REMOTE } from "../role-control-remote.js";
12
12
  import { PERMISSION_REMOTE } from "../permission-remote.js";
13
13
  import { permissionClient } from "./permission-client.js";
14
+ import { bindPermissionSession } from "./permission-session.js";
14
15
  import { PermissionController } from "./permission-controller.js";
15
16
  import { PERMISSIONS_NS, permissionEn, permissionZh } from "./permission-locales.js";
16
17
  import { registerRoleToolViews } from "./RoleToolView.js";
@@ -42,24 +43,7 @@ export async function apply(ctx) {
42
43
  });
43
44
  void ctx.inject(["uiSession", "sessions"], sessionCtx => {
44
45
  const source = sessionCtx.uiSession.adapter.current, sessions = sessionCtx.sessions;
45
- let observed, stop;
46
- const update = () => {
47
- const id = source.getSnapshot().key, binding = id === undefined ? undefined : sessions.binding(id);
48
- if (binding !== observed) {
49
- stop?.();
50
- observed = binding;
51
- stop = binding?.session.subscribe(update);
52
- }
53
- const snapshot = binding?.session.getSnapshot(), catalog = sessions.list.getSnapshot(), summary = id === undefined ? undefined : catalog.byId[id];
54
- const child = snapshot?.subagent != null || summary?.origin === "subagent" || summary?.parentId !== undefined;
55
- const root = id !== undefined && binding?.sessionId === id && snapshot?.sessionId === id && snapshot.openState === "open" && !snapshot.removed
56
- && catalog.ids.includes(id) && summary !== undefined && !child;
57
- permissions.bindScope(id ?? null, binding ?? null, child ? "child" : root ? "root" : "unknown");
58
- };
59
- update();
60
- sessionCtx.effect(() => source.subscribe(update));
61
- sessionCtx.effect(() => sessions.list.subscribe(update));
62
- sessionCtx.effect(() => () => { stop?.(); permissions.bindScope(null, null, "unknown"); }, "dsmm: permission native session withdrawal");
46
+ sessionCtx.effect(() => bindPermissionSession(source, sessions, permissions), "dsmm: permission native session withdrawal");
63
47
  });
64
48
  let deployment = null;
65
49
  let profiles = null;
@@ -14,9 +14,19 @@ export interface PermissionView {
14
14
  sessionId: string | null;
15
15
  scope: "unknown" | "root" | "child";
16
16
  connected: boolean;
17
+ /** Visible first load or explicit refresh only; background revalidation never sets it. */
17
18
  reading: boolean;
19
+ /** Silent background revalidation of an already trusted snapshot; not a busy state. */
20
+ revalidating: boolean;
18
21
  busy: "save" | null;
22
+ /** Current-fence authority observation; only a fresh successful read/save may set it. */
19
23
  rules: PermissionRulesSaveResult | null;
24
+ /**
25
+ * Last successful observation kept for display across a same-session scope gap,
26
+ * owner rebind or connection change. Never a base or mutation authority.
27
+ */
28
+ display: PermissionRulesSaveResult | null;
29
+ /** Last observed C state; only a successful clean read/save may become the mutation baseline. */
20
30
  base: PermissionRulesSaveResult["snapshot"] | null;
21
31
  draft: PermissionDraft | null;
22
32
  rulesIssue: PermissionIssue | null;
@@ -24,6 +34,10 @@ export interface PermissionView {
24
34
  notice: "saved" | null;
25
35
  }
26
36
  export declare function permissionChanges(view: PermissionView): PermissionRulesSaveRequest | null;
37
+ /** Policy, records, coverage and runtime may render from this observation; authority stays in `rules`. */
38
+ export declare const observedRules: (view: PermissionView) => PermissionRulesSaveResult | null;
39
+ /** The projection is older than the current fence and the current policy is unconfirmed. */
40
+ export declare const displayUnconfirmed: (view: PermissionView) => boolean;
27
41
  /** Borrowed native selection plus last-observed C state; never a Root or policy authority. */
28
42
  export declare class PermissionController {
29
43
  private state;
@@ -36,12 +50,16 @@ export declare class PermissionController {
36
50
  private timer?;
37
51
  private watchers;
38
52
  private disposed;
53
+ /** A successful read/save exists for the current scope fence; not mutation authority. */
54
+ private observed;
39
55
  readonly store: {
40
56
  getSnapshot: () => PermissionView;
41
57
  subscribe: (listener: () => void) => (() => void);
42
58
  };
43
59
  private publish;
44
60
  private cancel;
61
+ /** An observed snapshot exists for this fence; background work must stay invisible until it changes what is possible. */
62
+ private trusted;
45
63
  private fence;
46
64
  bindConnection(invoke: PermissionInvoker | null, generation?: unknown): void;
47
65
  bindScope(sessionId: string | null, owner: object | null, scope: PermissionView["scope"]): void;
@@ -51,9 +69,14 @@ export declare class PermissionController {
51
69
  private schedule;
52
70
  private issue;
53
71
  private synchronized;
72
+ /** A background request in flight never disables editing or saving; only its own save/authority does. */
54
73
  canEdit(generation: number): boolean;
55
74
  canSave(generation: number): boolean;
75
+ /** User-triggered refresh: visible busy state on this transaction only. */
56
76
  refresh(generation: number, discard?: boolean): Promise<void>;
77
+ /** Watch-driven revalidation. Invisible once a trusted snapshot exists. */
78
+ private revalidate;
79
+ private load;
57
80
  edit(generation: number, patch: Partial<PermissionDraft>): void;
58
81
  stageRule(generation: number): void;
59
82
  stageRevoke(generation: number, id: string): void;