@dsmm/dsmm 0.3.3 → 0.3.4

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 (96) 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 +12 -1
  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 +4 -2
  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/permission-controller.d.ts +13 -0
  41. package/lib/client/permission-controller.js +50 -23
  42. package/lib/client/permission-locales.d.ts +28 -4
  43. package/lib/client/permission-locales.js +38 -18
  44. package/lib/client/styles.d.ts +1 -1
  45. package/lib/client/styles.js +8 -8
  46. package/lib/client.js +1024 -728
  47. package/lib/core-permission-authority.js +28 -16
  48. package/lib/index.js +2 -9
  49. package/lib/native-admission.d.ts +3 -0
  50. package/lib/native-admission.js +60 -26
  51. package/lib/permission-controller.js +1 -1
  52. package/lib/permission-native-command.js +6 -4
  53. package/lib/permission-settings.d.ts +21 -7
  54. package/lib/permission-settings.js +21 -9
  55. package/lib/role-identity.d.ts +1 -1
  56. package/lib/role-identity.js +16 -4
  57. package/lib/role-policy.d.ts +3 -0
  58. package/lib/role-policy.js +29 -5
  59. package/lib/role-subagents.js +4 -3
  60. package/lib/runtime-integration.js +4 -4
  61. package/lib/settings.js +4 -1
  62. package/lib/state.d.ts +4 -1
  63. package/lib/state.js +37 -6
  64. package/package.json +1 -1
  65. package/prompts/deepwork.md +13 -1
  66. package/prompts/source/agents/orchestrator.md +10 -0
  67. package/prompts/source/category/coding.md +2 -1
  68. package/prompts/source/category/complex.md +1 -0
  69. package/prompts/source/category/deep.md +1 -0
  70. package/prompts/source/category/frontend.md +3 -1
  71. package/prompts/source/category/normal-task.md +2 -1
  72. package/prompts/source/category/quick.md +1 -0
  73. package/prompts/source/deepwork/claude-opus-5.md +2 -0
  74. package/prompts/source/deepwork/default.md +12 -0
  75. package/prompts/source/deepwork/gemini.md +6 -1
  76. package/prompts/source/deepwork/glm.md +5 -1
  77. package/prompts/source/deepwork/gpt.md +22 -2
  78. package/prompts/source/deepwork/kimi-k27.md +2 -0
  79. package/prompts/source/deepwork/planner.md +3 -1
  80. package/prompts/source/deepwork/swe-2.md +2 -0
  81. package/prompts/source/manifest.json +3 -68
  82. package/prompts/source/shared/dsh-host-contract.md +1 -1
  83. package/skills/ast-grep/SKILL.md +1 -1
  84. package/skills/brainstorming/SKILL.md +1 -1
  85. package/skills/coding-agent-sessions/SKILL.md +1 -1
  86. package/skills/debugging/SKILL.md +1 -1
  87. package/skills/dispatching-parallel-agents/SKILL.md +1 -1
  88. package/skills/frontend/SKILL.md +1 -1
  89. package/skills/git-master/SKILL.md +1 -1
  90. package/skills/init-deep/SKILL.md +1 -1
  91. package/skills/receiving-code-review/SKILL.md +1 -1
  92. package/skills/remove-ai-slops/SKILL.md +1 -1
  93. package/skills/requesting-code-review/SKILL.md +1 -1
  94. package/skills/subagent-driven-development/SKILL.md +1 -1
  95. package/skills/using-git-worktrees/SKILL.md +1 -1
  96. package/skills/writing-plans/SKILL.md +1 -1
@@ -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
@@ -34,13 +34,15 @@ function PermissionCoverage({ state, t }) {
34
34
  }
35
35
  export function PermissionRulesEditor({ controller, state, t }) {
36
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 writable = state.scope === "root" && state.connected;
38
+ 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 && !state.reading && _jsx("p", { className: "dsmm-hint", children: t("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") })] }), _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
39
  }
39
40
  export function PermissionsPanel({ controller, t, sessionId }) {
40
41
  const state = useSyncExternalStore(controller.store.subscribe, controller.store.getSnapshot);
41
42
  useEffect(() => controller.watch(), [controller]);
42
43
  if (sessionId !== undefined && sessionId !== state.sessionId)
43
44
  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 })] });
45
+ // Silent revalidation never flips the region busy; a save reports through its own status line.
46
+ 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-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
47
  }
46
48
  //# 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)
@@ -14,9 +14,13 @@ 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;
19
22
  rules: PermissionRulesSaveResult | null;
23
+ /** Last observed C state; only a successful clean read/save may become the mutation baseline. */
20
24
  base: PermissionRulesSaveResult["snapshot"] | null;
21
25
  draft: PermissionDraft | null;
22
26
  rulesIssue: PermissionIssue | null;
@@ -36,12 +40,16 @@ export declare class PermissionController {
36
40
  private timer?;
37
41
  private watchers;
38
42
  private disposed;
43
+ /** A successful read/save exists for the current scope fence; not mutation authority. */
44
+ private observed;
39
45
  readonly store: {
40
46
  getSnapshot: () => PermissionView;
41
47
  subscribe: (listener: () => void) => (() => void);
42
48
  };
43
49
  private publish;
44
50
  private cancel;
51
+ /** An observed snapshot exists; background work must stay invisible until it changes what is possible. */
52
+ private trusted;
45
53
  private fence;
46
54
  bindConnection(invoke: PermissionInvoker | null, generation?: unknown): void;
47
55
  bindScope(sessionId: string | null, owner: object | null, scope: PermissionView["scope"]): void;
@@ -51,9 +59,14 @@ export declare class PermissionController {
51
59
  private schedule;
52
60
  private issue;
53
61
  private synchronized;
62
+ /** A background request in flight never disables editing or saving; only its own save/authority does. */
54
63
  canEdit(generation: number): boolean;
55
64
  canSave(generation: number): boolean;
65
+ /** User-triggered refresh: visible busy state on this transaction only. */
56
66
  refresh(generation: number, discard?: boolean): Promise<void>;
67
+ /** Watch-driven revalidation. Invisible once a trusted snapshot exists. */
68
+ private revalidate;
69
+ private load;
57
70
  edit(generation: number, patch: Partial<PermissionDraft>): void;
58
71
  stageRule(generation: number): void;
59
72
  stageRevoke(generation: number, id: string): void;
@@ -10,7 +10,7 @@ export function permissionChanges(view) {
10
10
  return null;
11
11
  return { expectedRevision: base.revision, ...(Object.keys(changes).length ? { changes } : {}), ...(draft.upsert.length ? { upsert: draft.upsert } : {}), ...(draft.revoke.length ? { revoke: draft.revoke } : {}) };
12
12
  }
13
- const empty = () => ({ generation: 0, sessionId: null, scope: "unknown", connected: false, reading: false, busy: null,
13
+ const empty = () => ({ generation: 0, sessionId: null, scope: "unknown", connected: false, reading: false, revalidating: false, busy: null,
14
14
  rules: null, base: null, draft: null, rulesIssue: null, dirty: false, notice: null });
15
15
  /** Borrowed native selection plus last-observed C state; never a Root or policy authority. */
16
16
  export class PermissionController {
@@ -24,15 +24,20 @@ export class PermissionController {
24
24
  timer;
25
25
  watchers = 0;
26
26
  disposed = false;
27
+ /** A successful read/save exists for the current scope fence; not mutation authority. */
28
+ observed = false;
27
29
  store = { getSnapshot: () => this.state, subscribe: (listener) => { this.listeners.add(listener); return () => { this.listeners.delete(listener); }; } };
28
30
  publish(patch) { if (this.disposed)
29
31
  return; this.state = { ...this.state, ...patch }; for (const listener of this.listeners)
30
32
  listener(); }
31
33
  cancel() { this.request.abort(); this.request = new AbortController(); this.requestSequence++; clearTimeout(this.timer); }
32
- fence(preserve) {
34
+ /** An observed snapshot exists; background work must stay invisible until it changes what is possible. */
35
+ trusted() { return this.observed; }
36
+ fence(preserveDraft, preserveBase = preserveDraft) {
33
37
  this.cancel();
34
- this.publish({ generation: this.state.generation + 1, reading: false, busy: null, notice: null,
35
- rules: null, rulesIssue: null, ...preserve ? {} : { base: null, draft: null, dirty: false } });
38
+ this.observed = false;
39
+ this.publish({ generation: this.state.generation + 1, reading: false, revalidating: false, busy: null, notice: null, rules: null, rulesIssue: null,
40
+ ...preserveDraft ? {} : { draft: null, dirty: false }, ...preserveBase ? {} : { base: null } });
36
41
  }
37
42
  bindConnection(invoke, generation) {
38
43
  if (this.disposed || this.invoke === invoke && this.connection === generation)
@@ -46,9 +51,11 @@ export class PermissionController {
46
51
  bindScope(sessionId, owner, scope) {
47
52
  if (this.disposed || this.state.sessionId === sessionId && this.owner === owner && this.state.scope === scope)
48
53
  return;
49
- const preserve = sessionId === this.state.sessionId;
54
+ const sameSession = sessionId === this.state.sessionId;
50
55
  this.owner = owner;
51
- this.fence(preserve);
56
+ // A replaced owner invalidates the old base even when the session ID is unchanged;
57
+ // only the draft may survive for explicit recovery.
58
+ this.fence(sameSession, false);
52
59
  this.publish({ sessionId, scope });
53
60
  this.schedule(true);
54
61
  }
@@ -68,7 +75,7 @@ export class PermissionController {
68
75
  clearTimeout(this.timer);
69
76
  if (this.watchers === 0 || !this.live(this.state.generation))
70
77
  return;
71
- this.timer = setTimeout(() => { void this.refresh(this.state.generation); }, immediate ? 0 : 1000);
78
+ this.timer = setTimeout(() => { void this.revalidate(this.state.generation); }, immediate ? 0 : 1000);
72
79
  this.timer.unref?.();
73
80
  }
74
81
  issue(error) { return error instanceof PermissionClientError ? error.code : "transport"; }
@@ -76,26 +83,43 @@ export class PermissionController {
76
83
  const value = this.state.rules;
77
84
  return value !== null && value.runtime.state === "synced" && value.runtime.savedRevision === value.snapshot.revision && value.runtime.runtimeRevision === value.snapshot.revision;
78
85
  }
86
+ /** A background request in flight never disables editing or saving; only its own save/authority does. */
79
87
  canEdit(generation) { return this.live(generation) && this.state.rulesIssue === null && this.synchronized() && this.state.busy === null; }
80
- canSave(generation) { return this.canEdit(generation) && !this.state.reading && this.state.dirty && this.state.draft?.editor === null; }
81
- async refresh(generation, discard = false) {
82
- if (!this.live(generation) || this.state.reading || this.state.busy !== null)
88
+ canSave(generation) { return this.canEdit(generation) && this.state.dirty && this.state.draft?.editor === null; }
89
+ /** User-triggered refresh: visible busy state on this transaction only. */
90
+ async refresh(generation, discard = false) { await this.load(generation, discard, false); }
91
+ /** Watch-driven revalidation. Invisible once a trusted snapshot exists. */
92
+ async revalidate(generation) { await this.load(generation, false, true); }
93
+ async load(generation, discard, background) {
94
+ if (!this.live(generation) || this.state.busy !== null || this.state.reading)
83
95
  return;
84
- const sequence = ++this.requestSequence, signal = this.request.signal, id = this.state.sessionId;
85
- this.publish({ reading: true });
86
- const [rules] = await Promise.allSettled([this.invoke("describeRules", [id], signal)]);
87
- if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence)
96
+ if (background && this.state.revalidating)
88
97
  return;
89
- if (rules.status === "rejected") {
90
- this.publish({ rules: null, rulesIssue: this.issue(rules.reason), reading: false });
91
- }
92
- else {
93
- const value = rules.value;
98
+ // A user-triggered refresh upgrades an in-flight silent read into its visible own request.
99
+ if (!background && this.state.revalidating)
100
+ this.cancel();
101
+ const visible = !background || !this.trusted();
102
+ const sequence = ++this.requestSequence, signal = this.request.signal, id = this.state.sessionId;
103
+ this.publish(visible ? { reading: true, revalidating: false } : { revalidating: true });
104
+ try {
105
+ const value = await this.invoke("describeRules", [id], signal);
106
+ if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence)
107
+ return;
108
+ this.observed = true;
94
109
  const retain = this.state.dirty && !discard;
95
110
  this.publish({ rules: value, rulesIssue: retain && this.state.base?.revision !== value.snapshot.revision ? "stale" : null,
96
- reading: false,
97
111
  ...retain ? {} : { base: value.snapshot, draft: draftOf(value.snapshot.policy), dirty: false } });
98
112
  }
113
+ catch (error) {
114
+ if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence)
115
+ return;
116
+ // Keep the last trusted projection visible; only its mutation authority is withdrawn.
117
+ this.publish({ rulesIssue: this.issue(error) });
118
+ }
119
+ finally {
120
+ if (this.live(generation) && sequence === this.requestSequence)
121
+ this.publish({ reading: false, revalidating: false });
122
+ }
99
123
  this.schedule();
100
124
  }
101
125
  edit(generation, patch) {
@@ -121,8 +145,9 @@ export class PermissionController {
121
145
  this.edit(generation, { upsert: draft.upsert.filter(row => row.id !== id), revoke: [...new Set([...draft.revoke, id])], editor: draft.editor?.id === id ? null : draft.editor });
122
146
  }
123
147
  begin(busy) {
148
+ // Invalidate and abort unfinished reads so a late response cannot overwrite the save result.
124
149
  this.cancel();
125
- this.publish({ busy, notice: null });
150
+ this.publish({ busy, reading: false, revalidating: false, notice: null });
126
151
  return { signal: this.request.signal, id: this.state.sessionId };
127
152
  }
128
153
  async save(generation) {
@@ -132,12 +157,14 @@ export class PermissionController {
132
157
  const current = this.begin("save");
133
158
  try {
134
159
  const result = await this.invoke("saveRules", [current.id, request], current.signal);
135
- if (this.live(generation))
160
+ if (this.live(generation)) {
161
+ this.observed = true;
136
162
  this.publish({ rules: result, base: result.snapshot, draft: draftOf(result.snapshot.policy), dirty: false, rulesIssue: null, notice: "saved" });
163
+ }
137
164
  }
138
165
  catch (error) {
139
166
  if (this.live(generation))
140
- this.publish({ rules: null, rulesIssue: this.issue(error) });
167
+ this.publish({ rulesIssue: this.issue(error) });
141
168
  }
142
169
  finally {
143
170
  if (this.live(generation)) {
@@ -37,14 +37,22 @@ export declare const permissionEn: {
37
37
  configPolicyHint: string;
38
38
  configRulesHint: string;
39
39
  coldHint: string;
40
+ guardScope: string;
41
+ shellSafety: string;
42
+ gitWrite: string;
43
+ toolOutputTruncation: string;
44
+ planValidation: string;
45
+ questionLabels: string;
46
+ todoDiscipline: string;
47
+ maxInlineBytes: string;
48
+ maxLabelChars: string;
49
+ unitBytes: string;
50
+ unitChars: string;
40
51
  nativeCommands: string;
41
52
  nativeCommandsHint: string;
42
53
  registrationUnresolved: string;
43
54
  entryId: string;
44
55
  tool: string;
45
- nativeExecutable: string;
46
- subcommand: string;
47
- args: string;
48
56
  sandboxMode: string;
49
57
  mode: string;
50
58
  addEntry: string;
@@ -54,8 +62,22 @@ export declare const permissionEn: {
54
62
  inheritedEntries: string;
55
63
  explicitEntries: string;
56
64
  invalidEntry: string;
65
+ pattern: string;
66
+ patternHint: string;
67
+ invalidPattern: string;
68
+ patternScope: string;
69
+ restrictedFullAccess: string;
57
70
  rulesUnavailable: string;
58
- invalidArgsHint: string;
71
+ configRules: string;
72
+ inheritedRules: string;
73
+ explicitRules: string;
74
+ configRulesEmpty: string;
75
+ addRule: string;
76
+ removeRule: string;
77
+ advancedRules: string;
78
+ invalidRule: string;
79
+ recordedOperator: string;
80
+ invalidPatternHint: string;
59
81
  observedPolicy: string;
60
82
  profileOverrideState: string;
61
83
  profileOverrideUnknown: string;
@@ -79,6 +101,7 @@ export declare const permissionEn: {
79
101
  off: string;
80
102
  restart: string;
81
103
  coverageTitle: string;
104
+ coverageDetails: string;
82
105
  coverage: string;
83
106
  coverageUnavailable: string;
84
107
  coverageEmpty: string;
@@ -114,6 +137,7 @@ export declare const permissionEn: {
114
137
  staged: string;
115
138
  noRules: string;
116
139
  save: string;
140
+ refresh: string;
117
141
  discard: string;
118
142
  dirty: string;
119
143
  saved: string;