@dsmm/dsmm 0.3.4 → 0.3.6
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.
- package/docs/settings-status.md +1 -1
- package/lib/client/DeploymentFields.js +18 -1
- package/lib/client/DeploymentPage.js +1 -1
- package/lib/client/NativeCommandEntries.js +1 -1
- package/lib/client/PermissionsPanel.js +7 -6
- package/lib/client/deployment-locales.d.ts +0 -1
- package/lib/client/deployment-locales.js +12 -12
- package/lib/client/index.js +2 -18
- package/lib/client/permission-controller.d.ts +11 -1
- package/lib/client/permission-controller.js +17 -12
- package/lib/client/permission-locales.d.ts +2 -1
- package/lib/client/permission-locales.js +36 -34
- package/lib/client/permission-session.d.ts +37 -0
- package/lib/client/permission-session.js +34 -0
- package/lib/client/styles.d.ts +1 -1
- package/lib/client/styles.js +8 -0
- package/lib/client.js +486 -446
- package/package.json +1 -1
package/docs/settings-status.md
CHANGED
|
@@ -14,7 +14,7 @@ Global and native-profile controls have independent Save, Refresh and Discard ac
|
|
|
14
14
|
|
|
15
15
|
Native structural controls and bounded schema-aware Advanced JSON cover applicable deployment settings. Advanced input is strict JSON, not named-document JSONC. Invalid text and conflicts stay visible. Refresh preserves dirty input and its original revision; explicit discard/reload rebases it. Connection replacement, disconnection, entry replacement and disposal fence old writes. Saving doesn't restart, cancel, apply a named profile or respawn LSP.
|
|
16
16
|
|
|
17
|
-
Configuration edits and Global rules are separate transactions. Writable Global configuration needs no main session; Global rules use a trusted main session as their management entry but persist globally for contexts using that policy. Each transaction retains its own draft, CAS, Save, Refresh and Discard. First load and explicit Refresh show loading; background rule revalidation keeps the existing view, focus and editing controls stable. Observed revocation, conflicts, disconnection and unsynchronized runtime still withdraw the affected mutation authority without discarding its draft.
|
|
17
|
+
Configuration edits and Global rules are separate transactions. Writable Global configuration needs no main session; Global rules use a trusted main session as their management entry but persist globally for contexts using that policy. Each transaction retains its own draft, CAS, Save, Refresh and Discard. First load and explicit Refresh show loading; background rule revalidation keeps the existing view, focus and editing controls stable. A same-session scope gap, owner rebind or connection change keeps the last successful rules observation readable as an explicitly unconfirmed projection while withdrawing mutation authority; a real session switch clears it. Observed revocation, conflicts, disconnection and unsynchronized runtime still withdraw the affected mutation authority without discarding its draft.
|
|
18
18
|
|
|
19
19
|
LSP isn't an applicable UI setting in this version. Its implementation, interfaces and original configuration remain, but DSMM settings hide LSP controls and automatic MCP mounting stays off even with stored `lsp.enabled:true`. Neither a save nor a restart enables it. DSH's own LSP and independently configured MCP are unaffected; the retained historical manual patch isn't a supported DSMM activation entry. See [LSP boundary](lsp.md).
|
|
20
20
|
|
|
@@ -66,6 +66,23 @@ export function Field({ schema, path, controller, initiallyOpen = false, disclos
|
|
|
66
66
|
const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot), snapshot = state.snapshot, id = useId(), name = path.join(".");
|
|
67
67
|
const [open, setOpen] = useState(disclosures?.get(name) ?? initiallyOpen);
|
|
68
68
|
const expand = (expanded) => { disclosures?.set(name, expanded); setOpen(expanded); };
|
|
69
|
+
const unsetGroup = (event) => {
|
|
70
|
+
// The group action lives in the title row; prevent the disclosure's own activation
|
|
71
|
+
// instead of swallowing key events, so Enter/Space each activate this button once.
|
|
72
|
+
event?.preventDefault();
|
|
73
|
+
event?.stopPropagation();
|
|
74
|
+
const summary = event?.currentTarget.closest("summary"), action = event?.currentTarget ?? null;
|
|
75
|
+
controller.clearRaw(name);
|
|
76
|
+
controller.edit(path, undefined);
|
|
77
|
+
// The action is disabled by the reset, so the browser would drop focus to the document;
|
|
78
|
+
// keep it on the group title row instead.
|
|
79
|
+
if (summary !== null && summary !== undefined) {
|
|
80
|
+
const restore = () => { const active = document.activeElement; if (active === null || active === document.body || active === action)
|
|
81
|
+
summary.focus(); };
|
|
82
|
+
if (typeof requestAnimationFrame === "function")
|
|
83
|
+
requestAnimationFrame(() => { restore(); requestAnimationFrame(restore); });
|
|
84
|
+
}
|
|
85
|
+
};
|
|
69
86
|
const explicit = at(state.draft, path), inherited = controller.layer === "global" ? at(snapshot.defaults, path) : at(mergeLayer(mergeLayer(snapshot.defaults, snapshot.global), snapshot.nativeForm?.base ?? {}), path);
|
|
70
87
|
const choices = enumValues(schema), disabled = !controller.canEdit();
|
|
71
88
|
if (name === "permissionControl.nativeCommands.entries")
|
|
@@ -73,7 +90,7 @@ export function Field({ schema, path, controller, initiallyOpen = false, disclos
|
|
|
73
90
|
if (name === "permissionControl.rules")
|
|
74
91
|
return _jsx("div", { "data-field": name, children: _jsx(PermissionRuleEntries, { controller: controller, value: explicit, inherited: (inherited ?? []), disabled: disabled, onChange: value => controller.edit(path, value), expanded: open, onExpandedChange: expand, t: permissionText(t) }) });
|
|
75
92
|
if (schema.type === "object" && schema.fields !== undefined && path[0] !== "roleRouting")
|
|
76
|
-
return _jsxs("details", { className: "dsmm-deployment-group", "data-field": name, open: open, onToggle: event => expand(event.currentTarget.open), children: [_jsx("summary", {
|
|
93
|
+
return _jsxs("details", { className: "dsmm-deployment-group", "data-field": name, open: open, onToggle: event => expand(event.currentTarget.open), children: [_jsx("summary", { className: "dsmm-group-summary-row", children: _jsxs("span", { className: "dsmm-group-summary", children: [_jsx("span", { className: "dsmm-group-summary-label", children: fieldLabel(path, t) }), _jsx(Button, { type: "button", variant: "outline", className: "dsmm-group-summary-action", "data-dsmm-unset": name, hidden: !open, disabled: disabled || explicit === undefined && !Object.keys(state.raw).some(key => key === name || key.startsWith(`${name}.`)), onClick: unsetGroup, children: t("unsetGroup") })] }) }), _jsxs("div", { children: [name === "permissionControl" && _jsx("p", { className: "dsmm-hint", children: permissionText(t)("configPolicyHint") }), _jsx("p", { className: "dsmm-hint", children: t(explicit === undefined ? "inherit" : "explicit") }), Object.entries(schema.fields).map(([key, node]) => _jsx(Field, { schema: node, path: [...path, key], controller: controller, disclosures: disclosures, t: t }, key))] })] });
|
|
77
94
|
if (!["boolean", "string", "number"].includes(schema.type) && choices === null)
|
|
78
95
|
return _jsx(AdvancedField, { schema: schema, path: path, controller: controller, inherited: inherited, upper: controller.layer === "global" ? at(snapshot.profile, path) : undefined, expanded: open, onExpandedChange: expand, t: t });
|
|
79
96
|
return _jsxs("div", { className: "dsmm-field dsmm-deployment-field", "data-field": name, children: [schema.type === "boolean" || choices !== null ? _jsxs(_Fragment, { children: [_jsx("label", { htmlFor: id, children: fieldLabel(path, t) }), _jsxs("select", { id: id, disabled: disabled, value: explicit === undefined ? "inherit" : JSON.stringify(explicit), onChange: event => controller.edit(path, event.currentTarget.value === "inherit" ? undefined : JSON.parse(event.currentTarget.value)), children: [_jsx("option", { value: "inherit", children: `${t("unset")} · ${displayValue(inherited, t)}` }), (choices ?? [true, false]).map(choice => _jsx("option", { value: JSON.stringify(choice), children: displayValue(choice, t) }, String(choice)))] })] }) : _jsx(ScalarField, { schema: schema, path: path, controller: controller, inherited: inherited, t: t }), name === "modelParameters.passthrough" && _jsx("p", { className: "dsmm-hint", children: t("modelParametersHint") }), name === "permissionControl.enabled" && _jsx("p", { className: "dsmm-hint", children: permissionText(t)("coldHint") }), explicit !== undefined && _jsx("p", { className: "dsmm-hint", children: t(equal(explicit, at(snapshot.defaults, path)) ? "defaultPin" : "explicit") }), controller.layer === "profile" && at(snapshot.nativeForm?.base, path) !== undefined && _jsx("p", { className: "dsmm-hint", children: t("hostPin") }), controller.layer === "global" && at(snapshot.profile, path) !== undefined && _jsxs("p", { className: "dsmm-hint", children: [t("profileSource"), ": ", displayValue(at(snapshot.profile, path), t), " \u00B7 ", t("explicit")] })] });
|
|
@@ -99,7 +99,7 @@ export function DeploymentPage(props) {
|
|
|
99
99
|
}, children: [_jsx("option", { value: "global", children: t("global") }), _jsx("option", { value: "profile", children: t("profile") })] })] }), _jsx("p", { className: "dsmm-hint", children: t(navigation.scope === "global" ? "globalHint" : "profileHint") }), navigation.scope === "profile" && (navigation.native === null || !navigation.native.canWriteProfile()) && _jsx("p", { className: "dsmm-hint", children: t("unavailableForm") }), _jsx("div", { className: "dsmm-section-tabs", role: "tablist", "aria-label": t("modules"), children: tabs.map((module, index) => _jsx(Button, { ref: element => { if (element !== null)
|
|
100
100
|
triggers.current.set(module, element);
|
|
101
101
|
else
|
|
102
|
-
triggers.current.delete(module); }, role: "tab", type: "button", id: `${id}-tab-${module}`, "aria-selected": active === module, "aria-controls": `${id}-panel`, tabIndex: active === module ? 0 : -1, "data-dsmm-tab": module, onKeyDown: event => onTabKey(event, index), onClick: () => select(module), children: t(moduleTitle(module)) }, module)) }), active !== null && _jsxs("section", { id: `${id}-panel`, role: "tabpanel", className: "dsmm-section-panel", "aria-labelledby": `${id}-tab-${active}`, "data-dsmm-module": active, children: [_jsx("div", { className: "dsmm-panel-heading", children: _jsx("h2", { id: `${id}-heading`, ref: heading, tabIndex: -1, children: t(moduleTitle(active)) }) }), active === "state" ? _jsxs(_Fragment, { children: [_jsx(StateInspector, { controller: props.core, t: t }), scopeActions] }) : _jsxs(_Fragment, { children: [navigation.scope === "profile" && navigation.native === null ? _jsx("p", { children: t("unavailableForm") }) : state.snapshot === null ? _jsx("p", { children: t(state.busy ? "loading" : "unavailable") }) : _jsxs("div", { "data-dsmm-layer": controller.layer, "aria-busy": state.busy, className: "dsmm-structured", children: [fields.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("noModuleFields") }), fields.map(([key, schema]) => _jsx(Field, { schema: schema, path: [key], controller: controller, initiallyOpen: fields.length === 1 && active !== "permissions", disclosures: disclosures.current[navigation.scope], t: t }, `${navigation.scope}:${key}`)), active === "run" && controller.layer === "profile" && _jsx(NativeRuntimeState, { value: state.snapshot.subagentRuntime, t: t })] }), scopeActions, active === "permissions" &&
|
|
102
|
+
triggers.current.delete(module); }, role: "tab", type: "button", id: `${id}-tab-${module}`, "aria-selected": active === module, "aria-controls": `${id}-panel`, tabIndex: active === module ? 0 : -1, "data-dsmm-tab": module, onKeyDown: event => onTabKey(event, index), onClick: () => select(module), children: t(moduleTitle(module)) }, module)) }), active !== null && _jsxs("section", { id: `${id}-panel`, role: "tabpanel", className: "dsmm-section-panel", "aria-labelledby": `${id}-tab-${active}`, "data-dsmm-module": active, children: [_jsx("div", { className: "dsmm-panel-heading", children: _jsx("h2", { id: `${id}-heading`, ref: heading, tabIndex: -1, children: t(moduleTitle(active)) }) }), active === "state" ? _jsxs(_Fragment, { children: [_jsx(StateInspector, { controller: props.core, t: t }), scopeActions] }) : _jsxs(_Fragment, { children: [navigation.scope === "profile" && navigation.native === null ? _jsx("p", { children: t("unavailableForm") }) : state.snapshot === null ? _jsx("p", { children: t(state.busy ? "loading" : "unavailable") }) : _jsxs("div", { "data-dsmm-layer": controller.layer, "aria-busy": state.busy, className: "dsmm-structured", children: [fields.length === 0 && _jsx("p", { className: "dsmm-hint", children: t("noModuleFields") }), fields.map(([key, schema]) => _jsx(Field, { schema: schema, path: [key], controller: controller, initiallyOpen: fields.length === 1 && active !== "permissions", disclosures: disclosures.current[navigation.scope], t: t }, `${navigation.scope}:${key}`)), active === "run" && controller.layer === "profile" && _jsx(NativeRuntimeState, { value: state.snapshot.subagentRuntime, t: t })] }), scopeActions, active === "permissions" && _jsx("section", { className: "dsmm-zone dsmm-rules-transaction", "aria-label": t("rootRules"), children: workspace.permissions === undefined ? _jsx("p", { children: t("rootRulesUnavailable") }) : _jsx(PermissionsPanel, { controller: workspace.permissions, t: props.permissionsT ?? (key => Object.hasOwn(permissionEn, key) ? permissionText(t)(key) : key) }) })] })] }), navigation.pending !== null && _jsxs("section", { className: "dsmm-confirm", role: "group", "aria-label": t("leaveDraft"), onKeyDown: event => { if (event.key === "Escape" && !event.defaultPrevented) {
|
|
103
103
|
event.preventDefault();
|
|
104
104
|
workspace.continueEditing();
|
|
105
105
|
} }, children: [_jsx("p", { children: t("leaveDraft") }), _jsxs("div", { className: "dsmm-actions", children: [_jsx(Button, { ref: confirmation, type: "button", variant: "primary", onClick: () => workspace.continueEditing(), children: t("continueEditing") }), _jsx(Button, { type: "button", variant: "outline", onClick: () => workspace.keepAndNavigate(), children: t("keepDraft") }), _jsx(Button, { type: "button", variant: "outline", disabled: state.busy, onClick: () => void workspace.discardAndNavigate(), children: t("discardDraft") })] })] })] });
|
|
@@ -73,6 +73,6 @@ export function NativeCommandEntries({ value, inherited, controller, disabled, o
|
|
|
73
73
|
controller.setRaw(draft.path, draft.draft.text, draft.draft.invalid);
|
|
74
74
|
change(entries.filter((_, position) => position !== index));
|
|
75
75
|
};
|
|
76
|
-
return _jsxs("details", { className: "dsmm-deployment-group", children: [_jsxs("summary", { children: [t("nativeCommands"), " ", _jsx("code", { children: name })] }), _jsxs("div", { className: "dsmm-structured", children: [_jsx("p", { className: "dsmm-hint", children: t("nativeCommandsHint") }), _jsx("p", { className: "dsmm-hint", children: t("patternHint") }), _jsx("p", { className: "dsmm-hint", children: t("
|
|
76
|
+
return _jsxs("details", { className: "dsmm-deployment-group", children: [_jsxs("summary", { children: [t("nativeCommands"), " ", _jsx("code", { children: name })] }), _jsxs("div", { className: "dsmm-structured", children: [_jsx("p", { className: "dsmm-hint", children: t("nativeCommandsHint") }), _jsx("p", { className: "dsmm-hint", children: t("patternHint") }), _jsx("p", { className: "dsmm-hint", children: t("registrationUnresolved") }), _jsx("p", { className: "dsmm-hint", children: t(value === undefined ? "inheritedEntries" : "explicitEntries") }), !valid && _jsx("p", { className: "dsmm-issue", role: "alert", children: t("invalidEntry") }), invalidRows.length > 0 && _jsx("p", { className: "dsmm-hint", children: t("invalidPatternHint") }), entries.length === 0 && _jsx("p", { children: t("noEntries") }), entries.map((entry, index) => _jsx(Entry, { entry: entry, index: index, controller: controller, disabled: disabled, 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: disabled || entries.length >= 1024, onClick: () => change([...entries, emptyNativeEntry()]), children: t("addEntry") }), _jsx(Button, { type: "button", variant: "outline", "data-dsmm-unset": name, disabled: disabled || value === undefined && invalidRows.length === 0, onClick: () => { controller.clearRaw(name); change(undefined); }, children: t("unset") })] })] })] });
|
|
77
77
|
}
|
|
78
78
|
//# sourceMappingURL=NativeCommandEntries.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,17 +26,17 @@ 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
|
|
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
|
|
33
|
-
return _jsxs("section", { className: "dsmm-structured", "aria-label": t("coverageTitle"), children: [_jsx("h3", { children: t("coverageTitle") }), _jsx("p", { className: "dsmm-hint", children: t("coverage") }), _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") })] });
|
|
33
|
+
const value = observedRules(state)?.capabilities;
|
|
34
|
+
return _jsxs("section", { className: "dsmm-structured", "aria-label": t("coverageTitle"), children: [_jsx("h3", { children: t("coverageTitle") }), _jsx("p", { className: "dsmm-hint", children: t("matchHint") }), _jsx("p", { className: "dsmm-hint", children: t("networkLimit") }), _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
|
|
37
|
+
const id = useId(), draft = state.draft, disabled = !controller.canEdit(state.generation), value = observedRules(state), observedPolicy = value?.snapshot ?? null;
|
|
37
38
|
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(
|
|
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(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") })] });
|
|
39
40
|
}
|
|
40
41
|
export function PermissionsPanel({ controller, t, sessionId }) {
|
|
41
42
|
const state = useSyncExternalStore(controller.store.subscribe, controller.store.getSnapshot);
|
|
@@ -43,6 +44,6 @@ export function PermissionsPanel({ controller, t, sessionId }) {
|
|
|
43
44
|
if (sessionId !== undefined && sessionId !== state.sessionId)
|
|
44
45
|
return _jsx("p", { className: "dsmm-hint", role: "status", children: t("rulesUnavailable") });
|
|
45
46
|
// 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 }),
|
|
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 }), _jsxs("p", { className: "dsmm-hint", children: [t("nativeApproval"), " ", 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 })] });
|
|
47
48
|
}
|
|
48
49
|
//# sourceMappingURL=PermissionsPanel.js.map
|
|
@@ -2,22 +2,22 @@ export const DEPLOYMENT_NS = "plugins.dsmm";
|
|
|
2
2
|
export const deploymentEn = {
|
|
3
3
|
title: "DSMM", summary: "Global config and profile overrides",
|
|
4
4
|
description: "Layers save independently; native models and running sessions stay unchanged.",
|
|
5
|
-
global: "DSMM Global config", globalHint: "Shared by this Home
|
|
6
|
-
profile: "Current DSH profile overrides", profileHint: "This
|
|
5
|
+
global: "DSMM Global config", globalHint: "Shared by this Home. Unset fields use built-in defaults.",
|
|
6
|
+
profile: "Current DSH profile overrides", profileHint: "This profile only. Unset fields use Global, then Host defaults.",
|
|
7
7
|
profileUnavailable: "Unavailable",
|
|
8
|
-
unavailableForm: "
|
|
8
|
+
unavailableForm: "Read-only profile. Reconnect and refresh to check editing access.",
|
|
9
9
|
ceiling: "Deepwork master is Global-only; profiles and session modes cannot lift its captured ceiling.",
|
|
10
10
|
hostUnknown: "Host bundle status: unknown (separate switch).",
|
|
11
|
-
boundaries: "Saved settings apply to new sessions
|
|
11
|
+
boundaries: "Saved settings apply to new sessions; restart-required changes need a separate Host restart that may cancel sessions.",
|
|
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
|
-
modelParametersHint: "Off
|
|
13
|
+
modelParametersHint: "Off sends no custom parameters and uses native reasoning defaults. Saved values and the 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
15
|
modules: "Configuration sections", scope: "Configuration scope", loading: "Loading configuration…", unset: "Use default configuration",
|
|
16
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: "Global permission rules",
|
|
20
|
+
rootRules: "Global permission rules", 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
23
|
unsetGroup: "Use defaults for this group", unitBytes: "bytes", unitChars: "characters",
|
|
@@ -44,22 +44,22 @@ export const deploymentEn = {
|
|
|
44
44
|
export const deploymentZh = {
|
|
45
45
|
title: "DSMM", summary: "全局配置与当前配置覆盖",
|
|
46
46
|
description: "两层独立保存,不改原生模型或运行中会话。",
|
|
47
|
-
global: "DSMM 全局配置", globalHint: "同一 Home
|
|
48
|
-
profile: "当前 DSH 配置覆盖", profileHint: "
|
|
47
|
+
global: "DSMM 全局配置", globalHint: "同一 Home 共用;未设置字段使用内建默认值。",
|
|
48
|
+
profile: "当前 DSH 配置覆盖", profileHint: "仅影响此配置。未设置字段依次使用全局与宿主默认值。",
|
|
49
49
|
profileUnavailable: "不可用",
|
|
50
|
-
unavailableForm: "
|
|
50
|
+
unavailableForm: "此配置只读;重连并刷新以检查编辑权限。",
|
|
51
51
|
ceiling: "Deepwork 总开关仅全局可改;配置和会话模式不能突破已捕获上限。",
|
|
52
52
|
hostUnknown: "宿主整包状态:未知(独立开关)。",
|
|
53
|
-
boundaries: "
|
|
53
|
+
boundaries: "保存的设置供新会话使用;需重启的更改须另行重启宿主,可能取消会话。",
|
|
54
54
|
core: "Core 核心配置", coreHint: "Core 所有的 desired 意图配置。模型参数透传为普通配置,非子插件;权限控制 enabled 仅启动时捕获。保存不改变当前会话准入;下方可检查意图、启动与准入值,不可用的准入仍为未知。",
|
|
55
|
-
modelParametersHint: "
|
|
55
|
+
modelParametersHint: "关闭后不发送自定义参数,改用原生推理默认值;已保存值与所选模型不变。",
|
|
56
56
|
permissionControlHint: "权限控制挂载仅启动时捕获。保存配置不证明运行时覆盖,也不移除当前保护;Root 规则在权限模块内保持独立权限。",
|
|
57
57
|
modules: "配置分区", scope: "配置范围", loading: "正在加载配置…", unset: "使用默认配置",
|
|
58
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: "全局权限规则",
|
|
62
|
+
rootRules: "全局权限规则", rootRulesUnavailable: "权限规则不可用,请重连后刷新。",
|
|
63
63
|
nativeRuntimeHint: "原生默认开启,Host base 固定值仍适用;挂载仅启动时捕获。保存只设置 desired,不会启动/停止提供商或取消当前会话;独立 Host 重启可能取消会话。",
|
|
64
64
|
nativeRuntimeReadinessHint: "任务进度可在会话中查看。",
|
|
65
65
|
unsetGroup: "整组使用默认配置", unitBytes: "字节", unitChars: "字符",
|
package/lib/client/index.js
CHANGED
|
@@ -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
|
-
|
|
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;
|
|
@@ -19,7 +19,13 @@ export interface PermissionView {
|
|
|
19
19
|
/** Silent background revalidation of an already trusted snapshot; not a busy state. */
|
|
20
20
|
revalidating: boolean;
|
|
21
21
|
busy: "save" | null;
|
|
22
|
+
/** Current-fence authority observation; only a fresh successful read/save may set it. */
|
|
22
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;
|
|
23
29
|
/** Last observed C state; only a successful clean read/save may become the mutation baseline. */
|
|
24
30
|
base: PermissionRulesSaveResult["snapshot"] | null;
|
|
25
31
|
draft: PermissionDraft | null;
|
|
@@ -28,6 +34,10 @@ export interface PermissionView {
|
|
|
28
34
|
notice: "saved" | null;
|
|
29
35
|
}
|
|
30
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;
|
|
31
41
|
/** Borrowed native selection plus last-observed C state; never a Root or policy authority. */
|
|
32
42
|
export declare class PermissionController {
|
|
33
43
|
private state;
|
|
@@ -48,7 +58,7 @@ export declare class PermissionController {
|
|
|
48
58
|
};
|
|
49
59
|
private publish;
|
|
50
60
|
private cancel;
|
|
51
|
-
/** An observed snapshot exists; background work must stay invisible until it changes what is possible. */
|
|
61
|
+
/** An observed snapshot exists for this fence; background work must stay invisible until it changes what is possible. */
|
|
52
62
|
private trusted;
|
|
53
63
|
private fence;
|
|
54
64
|
bindConnection(invoke: PermissionInvoker | null, generation?: unknown): void;
|
|
@@ -11,7 +11,11 @@ export function permissionChanges(view) {
|
|
|
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
13
|
const empty = () => ({ generation: 0, sessionId: null, scope: "unknown", connected: false, reading: false, revalidating: false, busy: null,
|
|
14
|
-
rules: null, base: null, draft: null, rulesIssue: null, dirty: false, notice: null });
|
|
14
|
+
rules: null, display: null, base: null, draft: null, rulesIssue: null, dirty: false, notice: null });
|
|
15
|
+
/** Policy, records, coverage and runtime may render from this observation; authority stays in `rules`. */
|
|
16
|
+
export const observedRules = (view) => view.rules ?? view.display;
|
|
17
|
+
/** The projection is older than the current fence and the current policy is unconfirmed. */
|
|
18
|
+
export const displayUnconfirmed = (view) => view.display !== null && view.rules === null;
|
|
15
19
|
/** Borrowed native selection plus last-observed C state; never a Root or policy authority. */
|
|
16
20
|
export class PermissionController {
|
|
17
21
|
state = empty();
|
|
@@ -31,13 +35,13 @@ export class PermissionController {
|
|
|
31
35
|
return; this.state = { ...this.state, ...patch }; for (const listener of this.listeners)
|
|
32
36
|
listener(); }
|
|
33
37
|
cancel() { this.request.abort(); this.request = new AbortController(); this.requestSequence++; clearTimeout(this.timer); }
|
|
34
|
-
/** An observed snapshot exists; background work must stay invisible until it changes what is possible. */
|
|
38
|
+
/** An observed snapshot exists for this fence; background work must stay invisible until it changes what is possible. */
|
|
35
39
|
trusted() { return this.observed; }
|
|
36
|
-
fence(preserveDraft, preserveBase = preserveDraft) {
|
|
40
|
+
fence(preserveDraft, preserveBase = preserveDraft, preserveDisplay = true) {
|
|
37
41
|
this.cancel();
|
|
38
42
|
this.observed = false;
|
|
39
43
|
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 } });
|
|
44
|
+
...preserveDisplay ? {} : { display: null }, ...preserveDraft ? {} : { draft: null, dirty: false }, ...preserveBase ? {} : { base: null } });
|
|
41
45
|
}
|
|
42
46
|
bindConnection(invoke, generation) {
|
|
43
47
|
if (this.disposed || this.invoke === invoke && this.connection === generation)
|
|
@@ -51,11 +55,11 @@ export class PermissionController {
|
|
|
51
55
|
bindScope(sessionId, owner, scope) {
|
|
52
56
|
if (this.disposed || this.state.sessionId === sessionId && this.owner === owner && this.state.scope === scope)
|
|
53
57
|
return;
|
|
54
|
-
const sameSession = sessionId === this.state.sessionId;
|
|
58
|
+
const sameSession = sessionId !== null && sessionId === this.state.sessionId;
|
|
55
59
|
this.owner = owner;
|
|
56
60
|
// 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);
|
|
61
|
+
// only the draft and the read-only display projection may survive for explicit recovery.
|
|
62
|
+
this.fence(sameSession, false, sameSession);
|
|
59
63
|
this.publish({ sessionId, scope });
|
|
60
64
|
this.schedule(true);
|
|
61
65
|
}
|
|
@@ -69,7 +73,7 @@ export class PermissionController {
|
|
|
69
73
|
this.fence(true); };
|
|
70
74
|
}
|
|
71
75
|
dispose() { if (this.disposed)
|
|
72
|
-
return; this.fence(false); this.disposed = true; this.listeners.clear(); this.invoke = null; this.owner = null; }
|
|
76
|
+
return; this.fence(false, false, false); this.disposed = true; this.listeners.clear(); this.invoke = null; this.owner = null; }
|
|
73
77
|
live(generation) { return !this.disposed && generation === this.state.generation && this.owner !== null && this.invoke !== null && this.state.scope === "root" && this.state.sessionId !== null; }
|
|
74
78
|
schedule(immediate = false) {
|
|
75
79
|
clearTimeout(this.timer);
|
|
@@ -98,7 +102,8 @@ export class PermissionController {
|
|
|
98
102
|
// A user-triggered refresh upgrades an in-flight silent read into its visible own request.
|
|
99
103
|
if (!background && this.state.revalidating)
|
|
100
104
|
this.cancel();
|
|
101
|
-
|
|
105
|
+
// An automatic read over an existing display projection is silent; a first load stays visible.
|
|
106
|
+
const visible = !background || !this.trusted() && this.state.display === null;
|
|
102
107
|
const sequence = ++this.requestSequence, signal = this.request.signal, id = this.state.sessionId;
|
|
103
108
|
this.publish(visible ? { reading: true, revalidating: false } : { revalidating: true });
|
|
104
109
|
try {
|
|
@@ -107,13 +112,13 @@ export class PermissionController {
|
|
|
107
112
|
return;
|
|
108
113
|
this.observed = true;
|
|
109
114
|
const retain = this.state.dirty && !discard;
|
|
110
|
-
this.publish({ rules: value, rulesIssue: retain && this.state.base?.revision !== value.snapshot.revision ? "stale" : null,
|
|
115
|
+
this.publish({ rules: value, display: value, rulesIssue: retain && this.state.base?.revision !== value.snapshot.revision ? "stale" : null,
|
|
111
116
|
...retain ? {} : { base: value.snapshot, draft: draftOf(value.snapshot.policy), dirty: false } });
|
|
112
117
|
}
|
|
113
118
|
catch (error) {
|
|
114
119
|
if (!this.live(generation) || signal.aborted || sequence !== this.requestSequence)
|
|
115
120
|
return;
|
|
116
|
-
// Keep the last trusted projection visible; only its mutation authority is withdrawn.
|
|
121
|
+
// Keep the last trusted projection (current or display-only) visible; only its mutation authority is withdrawn.
|
|
117
122
|
this.publish({ rulesIssue: this.issue(error) });
|
|
118
123
|
}
|
|
119
124
|
finally {
|
|
@@ -159,7 +164,7 @@ export class PermissionController {
|
|
|
159
164
|
const result = await this.invoke("saveRules", [current.id, request], current.signal);
|
|
160
165
|
if (this.live(generation)) {
|
|
161
166
|
this.observed = true;
|
|
162
|
-
this.publish({ rules: result, base: result.snapshot, draft: draftOf(result.snapshot.policy), dirty: false, rulesIssue: null, notice: "saved" });
|
|
167
|
+
this.publish({ rules: result, display: result, base: result.snapshot, draft: draftOf(result.snapshot.policy), dirty: false, rulesIssue: null, notice: "saved" });
|
|
163
168
|
}
|
|
164
169
|
}
|
|
165
170
|
catch (error) {
|
|
@@ -3,6 +3,8 @@ export declare const permissionEn: {
|
|
|
3
3
|
title: string;
|
|
4
4
|
rules: string;
|
|
5
5
|
nativeApproval: string;
|
|
6
|
+
sandboxScope: string;
|
|
7
|
+
unconfirmedObservation: string;
|
|
6
8
|
root: string;
|
|
7
9
|
noRoot: string;
|
|
8
10
|
child: string;
|
|
@@ -65,7 +67,6 @@ export declare const permissionEn: {
|
|
|
65
67
|
pattern: string;
|
|
66
68
|
patternHint: string;
|
|
67
69
|
invalidPattern: string;
|
|
68
|
-
patternScope: string;
|
|
69
70
|
restrictedFullAccess: string;
|
|
70
71
|
rulesUnavailable: string;
|
|
71
72
|
configRules: string;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export const PERMISSIONS_NS = "settings.dsmm-permissions";
|
|
2
2
|
export const permissionEn = {
|
|
3
|
-
title: "Permission control", rules: "
|
|
4
|
-
nativeApproval: "Approve commands in the native prompt
|
|
3
|
+
title: "Permission control", rules: "Rules",
|
|
4
|
+
nativeApproval: "Approve commands in the native prompt; Allow covers that call only.",
|
|
5
|
+
sandboxScope: "These rules set allow, ask or deny. The Host sandbox and its native prompt still decide what an approved call may touch.",
|
|
6
|
+
unconfirmedObservation: "Showing the last successful observation. The current selection is not confirmed yet, so editing and saving stay unavailable.",
|
|
5
7
|
root: "Selected main session", noRoot: "Select a main session to view its permission rules.",
|
|
6
8
|
child: "Select this child’s main session to edit Global rules.",
|
|
7
9
|
unknown: "Unavailable / unknown", reading: "Reading…", busy: "Operation pending…",
|
|
@@ -10,33 +12,32 @@ export const permissionEn = {
|
|
|
10
12
|
inherit: "Inherit native policy", "action:allow": "Allow", "action:ask": "Ask", "action:deny": "Deny",
|
|
11
13
|
"kind:outside-read": "Outside-workspace read", "kind:shell": "Shell operation", "kind:webSearch": "Web search", "kind:webFetch": "Web fetch",
|
|
12
14
|
path: "Canonical path", pathScope: "Path match", exact: "Exact path", tree: "Path and descendants",
|
|
13
|
-
networkLimit: "Web rules cover public web tools only
|
|
14
|
-
rulesHint: "
|
|
15
|
-
configPolicyHint: "Profile settings override Global
|
|
16
|
-
configRulesHint: "Record list for this
|
|
17
|
-
coldHint: "
|
|
15
|
+
networkLimit: "Web rules cover public web tools only; private networks, shell and sockets are outside this permission.",
|
|
16
|
+
rulesHint: "Global policy, saved separately from configuration. Clear blocking profile overrides, then refresh.",
|
|
17
|
+
configPolicyHint: "Profile settings override Global; arrays replace inherited lists. Refresh to check what is effective.",
|
|
18
|
+
configRulesHint: "Record list for this layer. The Host owns source and revision; imported records are never verified approvals. An empty list is an explicit empty replacement.",
|
|
19
|
+
coldHint: "Host restart required; current protection stays active. Restart may cancel sessions.",
|
|
18
20
|
guardScope: "Guard scope", shellSafety: "Shell command safety", gitWrite: "Git write approval", toolOutputTruncation: "Tool output truncation", planValidation: "Plan format validation", questionLabels: "Question label helper", todoDiscipline: "Todo discipline helper", maxInlineBytes: "Maximum inline output", maxLabelChars: "Maximum label length", unitBytes: "bytes", unitChars: "characters",
|
|
19
|
-
nativeCommands: "Command rules", nativeCommandsHint: "Default Off.
|
|
20
|
-
registrationUnresolved: "Executor identity
|
|
21
|
-
entryId: "Entry ID", tool: "Tool", sandboxMode: "Sandbox mode", mode: "Native action", addEntry: "Add entry", removeEntry: "Remove entry", noEntries: "No command entries.", unset: "Unset — restore inheritance", inheritedEntries: "Inherited entries; editing pins a replacement array in this layer.", explicitEntries: "Explicit replacement array in this layer.", invalidEntry: "Invalid entry:
|
|
21
|
+
nativeCommands: "Command rules", nativeCommandsHint: "Default Off. New entries use Ask and workspace-write; other permission limits still apply.",
|
|
22
|
+
registrationUnresolved: "Executor identity unconfirmed; verify tool, executable, environment and sandbox.",
|
|
23
|
+
entryId: "Entry ID", tool: "Tool", sandboxMode: "Sandbox mode", mode: "Native action", addEntry: "Add entry", removeEntry: "Remove entry", noEntries: "No command entries.", unset: "Unset — restore inheritance", inheritedEntries: "Inherited entries; editing pins a replacement array in this layer.", explicitEntries: "Explicit replacement array in this layer.", invalidEntry: "Invalid entry: IDs must be unique and nonblank, pattern valid, working directory absolute. Draft retained; Save locked.",
|
|
22
24
|
pattern: "Command pattern",
|
|
23
|
-
patternHint: "
|
|
24
|
-
invalidPattern: "Invalid pattern:
|
|
25
|
-
patternScope: "Any trailing arguments are allowed, so the selected program can run its own builds, tests and internal scripts. This is not a path or filesystem grant, and shell pipes, chaining, redirects and substitutions still follow the ordinary native path.",
|
|
25
|
+
patternHint: "Example: go build|test *. With or without *, any trailing arguments (including program scripts) are allowed. No character glob, regex or path grants.",
|
|
26
|
+
invalidPattern: "Invalid pattern: one executable and the subcommand position only, space-separated. Pipe alternatives must be nonblank literals; * may only be the final token.",
|
|
26
27
|
restrictedFullAccess: "danger-full-access — retained from the saved value; not offered here",
|
|
27
|
-
rulesUnavailable: "Editing requires an open main session, local editing permission and
|
|
28
|
+
rulesUnavailable: "Editing requires an open main session, local editing permission and synced rules. Check profile overrides, then reconnect and refresh.",
|
|
28
29
|
configRules: "Imported configuration rules", inheritedRules: "Inherited records; editing pins a replacement list in this layer.", explicitRules: "Explicit replacement list in this layer.",
|
|
29
30
|
configRulesEmpty: "This layer stores no permission rules.", addRule: "Add imported rule", removeRule: "Remove rule", advancedRules: "Advanced rule JSON",
|
|
30
|
-
invalidRule: "Invalid rule list:
|
|
31
|
+
invalidRule: "Invalid rule list: IDs must be unique and nonblank, actions allow/ask/deny, and matches complete. Draft retained; Save locked.",
|
|
31
32
|
recordedOperator: "Recorded operator source (metadata, not approval)",
|
|
32
|
-
invalidPatternHint: "
|
|
33
|
+
invalidPatternHint: "Fix invalid patterns before saving. Removing a row drops only its draft; Unset replaces the whole array with the inherited list.",
|
|
33
34
|
observedPolicy: "Effective policy (including profile overrides)",
|
|
34
|
-
profileOverrideState: "Profile overrides", profileOverrideUnknown: "Unknown
|
|
35
|
-
matchHint: "Match an exact path or
|
|
35
|
+
profileOverrideState: "Profile overrides", profileOverrideUnknown: "Unknown — select the DSH profile scope to inspect.",
|
|
36
|
+
matchHint: "Match an exact path or tree, an exact shell tool/command/directory, or a web tool. Allow grants no outside-workspace writes.",
|
|
36
37
|
source: "Actual source", recordVersion: "Record version", savedAt: "Saved at", operator: "Verified Host operator", imported: "User import", active: "Active record", revoked: "Revoked record",
|
|
37
38
|
base: "Draft version", savedRevision: "Saved version", runtimeRevision: "Effective version", runtime: "Rule synchronization", synced: "Synced", updating: "Updating", unsynced: "Unsynced — saving unavailable",
|
|
38
39
|
mounted: "Startup mounted", on: "On", off: "Off", restart: "Independent restart required",
|
|
39
|
-
coverageTitle: "Tool coverage", coverageDetails: "Details", coverage: "Last
|
|
40
|
+
coverageTitle: "Tool coverage", coverageDetails: "Details", coverage: "Last observation for this main session; executor readiness and network access need separate checks.",
|
|
40
41
|
coverageUnavailable: "Coverage unavailable / unknown. No trusted live observation was returned.", coverageEmpty: "No trusted tool registrations observed for this Root.",
|
|
41
42
|
coverageRuntime: "Observed consumer state", coverageRevision: "Observed consumer runtime source", toolName: "Observed tool name", toolKind: "Trusted registration kind",
|
|
42
43
|
toolApproval: "Approval boundary", nativeOnce: "Native prompt — once only", toolMemory: "Scoped approval memory", notProvided: "Not provided",
|
|
@@ -60,8 +61,10 @@ export const permissionEn = {
|
|
|
60
61
|
"issue:protocol": "Untrusted or mismatched service response. Refresh or reconnect.",
|
|
61
62
|
};
|
|
62
63
|
export const permissionZh = {
|
|
63
|
-
title: "权限控制", rules: "
|
|
64
|
+
title: "权限控制", rules: "规则",
|
|
64
65
|
nativeApproval: "请在原生提示中批准命令;「允许」仅批准本次调用。",
|
|
66
|
+
sandboxScope: "这些规则决定允许、询问或拒绝;具体调用可触及的范围仍由宿主沙箱及其原生提示决定。",
|
|
67
|
+
unconfirmedObservation: "当前显示上次成功观测;当前选择尚未确认,编辑与保存暂不可用。",
|
|
65
68
|
root: "所选主会话", noRoot: "请选择主会话以查看权限规则。", child: "请切换到此子会话的主会话后编辑全局规则。",
|
|
66
69
|
unknown: "不可用/未知", reading: "正在读取…", busy: "操作处理中…",
|
|
67
70
|
executable: "原生 Shell 注册身份(精确匹配)", command: "完整命令(精确匹配)", cwd: "工作目录(精确匹配)", id: "规则 ID", action: "规则动作", match: "匹配类型",
|
|
@@ -69,29 +72,28 @@ export const permissionZh = {
|
|
|
69
72
|
inherit: "继承原生策略", "action:allow": "允许", "action:ask": "询问", "action:deny": "拒绝",
|
|
70
73
|
"kind:outside-read": "工作区外读取", "kind:shell": "Shell 操作", "kind:webSearch": "网页搜索", "kind:webFetch": "网页抓取",
|
|
71
74
|
path: "规范路径", pathScope: "路径匹配", exact: "精确路径", tree: "此路径及子树",
|
|
72
|
-
networkLimit: "
|
|
73
|
-
rulesHint: "
|
|
74
|
-
configPolicyHint: "
|
|
75
|
-
configRulesHint: "
|
|
75
|
+
networkLimit: "网页规则仅覆盖公共网页工具;私网、Shell 与 socket 不在此权限内。",
|
|
76
|
+
rulesHint: "全局策略,与配置分别保存。若配置覆盖阻止保存,请先清除覆盖再刷新。",
|
|
77
|
+
configPolicyHint: "当前配置优先于全局,数组整体替换继承列表。保存后刷新以检查实际生效状态。",
|
|
78
|
+
configRulesHint: "此配置层的记录列表。来源与版本由宿主维护;导入记录永不代表已核验批准。空列表表示显式清空。",
|
|
76
79
|
coldHint: "更改此开关需重启宿主,此前保留当前保护。重启可能取消会话。",
|
|
77
80
|
guardScope: "保护范围", shellSafety: "Shell 命令安全", gitWrite: "Git 写入审批", toolOutputTruncation: "工具输出截断", planValidation: "计划格式校验", questionLabels: "问题标签辅助", todoDiscipline: "Todo 纪律辅助", maxInlineBytes: "内联输出上限", maxLabelChars: "标签长度上限", unitBytes: "字节", unitChars: "字符",
|
|
78
|
-
nativeCommands: "命令规则", nativeCommandsHint: "
|
|
79
|
-
registrationUnresolved: "
|
|
80
|
-
entryId: "条目 ID", tool: "工具", sandboxMode: "沙箱模式", mode: "原生动作", addEntry: "添加条目", removeEntry: "移除条目", noEntries: "没有命令条目。", unset: "Unset——恢复继承", inheritedEntries: "继承的条目;编辑后在此层固定为整体替换数组。", explicitEntries: "此层显式整体替换数组。", invalidEntry: "条目无效:ID
|
|
81
|
+
nativeCommands: "命令规则", nativeCommandsHint: "默认关闭;新条目使用询问与 workspace-write,仍受其他权限限制。",
|
|
82
|
+
registrationUnresolved: "执行器身份未确认;请先核验工具、可执行程序、环境与沙箱。",
|
|
83
|
+
entryId: "条目 ID", tool: "工具", sandboxMode: "沙箱模式", mode: "原生动作", addEntry: "添加条目", removeEntry: "移除条目", noEntries: "没有命令条目。", unset: "Unset——恢复继承", inheritedEntries: "继承的条目;编辑后在此层固定为整体替换数组。", explicitEntries: "此层显式整体替换数组。", invalidEntry: "条目无效:ID 需唯一非空、模式有效、工作目录为绝对路径。草稿保留,保存已锁定。",
|
|
81
84
|
pattern: "命令模式",
|
|
82
|
-
patternHint: "
|
|
83
|
-
invalidPattern: "
|
|
84
|
-
patternScope: "允许任意后续参数,因此被选程序可以运行自身的构建、测试和内部脚本。这不是路径或文件系统授权;shell 管道、拼接、重定向与替换仍走普通原生路径。",
|
|
85
|
+
patternHint: "例:go build|test *。省略 * 也允许任意后续参数(含程序脚本);不支持字符通配或正则,也不授予路径权限。",
|
|
86
|
+
invalidPattern: "模式无效:仅一个可执行程序与子命令位置,以空格分隔。竖线备选须为非空字面量,* 只能是最后一个 token。",
|
|
85
87
|
restrictedFullAccess: "danger-full-access——保留自已保存的值,此处不提供创建",
|
|
86
|
-
rulesUnavailable: "
|
|
88
|
+
rulesUnavailable: "编辑需要已打开的主会话、本地编辑权限与已同步规则。请检查配置覆盖,再重连刷新。",
|
|
87
89
|
configRules: "导入的配置规则", inheritedRules: "继承的记录;编辑后在此层固定为整体替换列表。", explicitRules: "此层显式整体替换列表。",
|
|
88
90
|
configRulesEmpty: "此层没有权限规则记录。", addRule: "添加导入规则", removeRule: "移除规则", advancedRules: "高级规则 JSON",
|
|
89
|
-
invalidRule: "规则列表无效:ID
|
|
91
|
+
invalidRule: "规则列表无效:ID 需唯一非空,动作为 allow/ask/deny,匹配条件完整。草稿保留,保存已锁定。",
|
|
90
92
|
recordedOperator: "记录的 operator 来源(元数据,不代表批准)",
|
|
91
|
-
invalidPatternHint: "
|
|
93
|
+
invalidPatternHint: "请先修正无效模式。移除某行只丢弃该行草稿;Unset 用继承列表整体替换。",
|
|
92
94
|
observedPolicy: "有效策略(含当前配置覆盖)",
|
|
93
95
|
profileOverrideState: "配置覆盖", profileOverrideUnknown: "未知,请在上方选择当前 DSH 配置查看覆盖值。",
|
|
94
|
-
matchHint: "可匹配精确路径或目录树、精确 Shell
|
|
96
|
+
matchHint: "可匹配精确路径或目录树、精确 Shell 工具与命令及目录,或网页工具。允许不授予工作区外写入。",
|
|
95
97
|
source: "实际来源", recordVersion: "记录版本", savedAt: "保存时间", operator: "宿主已核验 operator", imported: "用户导入", active: "有效记录", revoked: "已撤销记录",
|
|
96
98
|
base: "草稿版本", savedRevision: "保存版本", runtimeRevision: "生效版本", runtime: "规则同步", synced: "已同步", updating: "同步中", unsynced: "未同步——暂不可保存",
|
|
97
99
|
mounted: "启动时已挂载", on: "开启", off: "关闭", restart: "需要另行重启",
|