dsh-edge 0.18.0 → 0.19.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +8 -8
- package/README.zh.md +8 -8
- package/THIRD_PARTY_NOTICES.md +2011 -449
- package/dist/assets/fonts/Montserrat-OFL.txt +93 -0
- package/dist/assets/fonts/montserrat-light-Cvd2VjE_.woff2 +0 -0
- package/dist/assets/fonts/montserrat-medium-B4OyO9CN.woff2 +0 -0
- package/dist/assets/fonts/montserrat-regular-DYep38cA.woff2 +0 -0
- package/dist/assets/index-Cq6ljTv2.css +1 -0
- package/dist/assets/index-Dy0OhsZ5.js +127 -0
- package/dist/assets/langs/asciidoc-Ve4PFQV2.js +2 -0
- package/dist/assets/langs/bat-BkioyH1T.js +2 -0
- package/dist/assets/langs/bibtex-CHM0blh-.js +2 -0
- package/dist/assets/langs/clojure-P80f7IUj.js +2 -0
- package/dist/assets/langs/cmake-D1j8_8rp.js +2 -0
- package/dist/assets/langs/csv-fuZLfV_i.js +2 -0
- package/dist/assets/langs/dart-bE4Kk8sk.js +2 -0
- package/dist/assets/langs/diff-D97Zzqfu.js +2 -0
- package/dist/assets/langs/dotenv-Da5cRb03.js +2 -0
- package/dist/assets/langs/elixir-CvYZzuDY.js +2 -0
- package/dist/assets/langs/erlang-DsQrWhSR.js +2 -0
- package/dist/assets/langs/fish-BvzEVeQv.js +2 -0
- package/dist/assets/langs/fsharp-CXgrBDvD.js +2 -0
- package/dist/assets/langs/graphql-DujV8YkJ.js +2 -0
- package/dist/assets/langs/groovy-gcz8RCvz.js +2 -0
- package/dist/assets/langs/haskell-Df6bDoY_.js +2 -0
- package/dist/assets/langs/hcl-BWvSN4gD.js +2 -0
- package/dist/assets/langs/html-derivative-DOyKdj44.js +2 -0
- package/dist/assets/langs/html-fwsONPVS.js +2 -0
- package/dist/assets/langs/http-DcV90OkR.js +2 -0
- package/dist/assets/langs/javascript-DI5JR1nB.js +2 -0
- package/dist/assets/langs/julia-BpJ6DjL_.js +2 -0
- package/dist/assets/langs/latex-B4C7GdlO.js +2 -0
- package/dist/assets/langs/log-2UxHyX5q.js +2 -0
- package/dist/assets/langs/make-CHLpvVh8.js +2 -0
- package/dist/assets/langs/nix-CwoSXNpI.js +2 -0
- package/dist/assets/langs/perl-DsWkoyyU.js +2 -0
- package/dist/assets/langs/php-LEPfNACG.js +2 -0
- package/dist/assets/langs/powershell-Dpen1YoG.js +2 -0
- package/dist/assets/langs/proto-C7zT0LnQ.js +2 -0
- package/dist/assets/langs/r-Dspwwk_N.js +2 -0
- package/dist/assets/langs/rst-BbocfKWr.js +2 -0
- package/dist/assets/langs/ruby-R292Iif0.js +2 -0
- package/dist/assets/langs/scala-C151Ov-r.js +2 -0
- package/dist/assets/langs/svelte-DNMY6jOf.js +2 -0
- package/dist/assets/langs/system-verilog-CnnmHF94.js +2 -0
- package/dist/assets/langs/vb-D17OF-Vu.js +2 -0
- package/dist/assets/langs/verilog-BQ8w6xss.js +2 -0
- package/dist/assets/langs/vue-Dq2x6432.js +2 -0
- package/dist/favicon-dark.svg +3 -0
- package/dist/favicon.svg +0 -5
- package/dist/index.html +5 -4
- package/dist/manifest.webmanifest +3 -4
- package/dist/plugins/@deepseek-ai/dsh-api-gateway/client.js +353 -101
- package/dist/plugins/@deepseek-ai/dsh-api-job-controller/client.js +367 -0
- package/dist/plugins/@deepseek-ai/dsh-api-remotes/client.js +7223 -3584
- package/dist/plugins/@deepseek-ai/dsh-api-session-controller/client.js +1107 -991
- package/dist/plugins/@deepseek-ai/dsh-api-workspace-controller/client.js +119 -6
- package/dist/plugins/@deepseek-ai/dsh-api-workspace-files/client.js +41 -35
- package/dist/plugins/@deepseek-ai/dsh-client-connection/client.js +354 -5279
- package/dist/plugins/@deepseek-ai/dsh-client-file-upload/client.js +10 -23
- package/dist/plugins/@deepseek-ai/dsh-client-locale/client.js +234 -80
- package/dist/plugins/@deepseek-ai/dsh-client-modules/client.js +554 -46
- package/dist/plugins/@deepseek-ai/dsh-client-shortcuts/client.js +2006 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-agent-preset/client.js +1090 -914
- package/dist/plugins/@deepseek-ai/dsh-client-ui-approval/client.js +79 -6
- package/dist/plugins/@deepseek-ai/dsh-client-ui-attachment/client.js +126 -155
- package/dist/plugins/@deepseek-ai/dsh-client-ui-chat/client.js +5776 -1593
- package/dist/plugins/@deepseek-ai/dsh-client-ui-commands/client.js +375 -121
- package/dist/plugins/@deepseek-ai/dsh-client-ui-conversation/client.js +3524 -1923
- package/dist/plugins/@deepseek-ai/dsh-client-ui-deliverables/client.js +1615 -258
- package/dist/plugins/@deepseek-ai/dsh-client-ui-directory-picker-browse/client.js +9 -9
- package/dist/plugins/@deepseek-ai/dsh-client-ui-goal/client.js +25 -10
- package/dist/plugins/@deepseek-ai/dsh-client-ui-input-trigger/client.js +169 -24
- package/dist/plugins/@deepseek-ai/dsh-client-ui-jobs/client.js +413 -63
- package/dist/plugins/@deepseek-ai/dsh-client-ui-layout/client.js +131 -14
- package/dist/plugins/@deepseek-ai/dsh-client-ui-message-feedback/client.js +24 -22
- package/dist/plugins/@deepseek-ai/dsh-client-ui-model-selection/client.js +281 -128
- package/dist/plugins/@deepseek-ai/dsh-client-ui-open-in-app/client.js +674 -223
- package/dist/plugins/@deepseek-ai/dsh-client-ui-plan/client.js +596 -18
- package/dist/plugins/@deepseek-ai/dsh-client-ui-reference/client.js +92 -9
- package/dist/plugins/@deepseek-ai/dsh-client-ui-renderer/client.js +467 -59
- package/dist/plugins/@deepseek-ai/dsh-client-ui-session/client.js +231 -72
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings/client.js +281 -117
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-general/client.js +642 -122
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-models/client.js +1565 -438
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugin-inventory/client.js +201 -75
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-plugins/client.js +30 -1628
- package/dist/plugins/@deepseek-ai/dsh-client-ui-shortcuts/client.js +1163 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar/client.js +165 -39
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-browser/client.js +1648 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-documentpreview/client.js +5515 -25622
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-files/client.js +419 -118
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar-right/client.js +5692 -260
- package/dist/plugins/@deepseek-ai/dsh-client-ui-skill/client.js +156 -41
- package/dist/plugins/@deepseek-ai/dsh-client-ui-subagent/client.js +386 -263
- package/dist/plugins/@deepseek-ai/dsh-client-ui-theme/client.js +183 -73
- package/dist/plugins/@deepseek-ai/dsh-client-ui-tool/client.js +2367 -429
- package/dist/plugins/@deepseek-ai/dsh-client-ui-trajectory/client.js +788 -270
- package/dist/plugins/@deepseek-ai/dsh-client-ui-user-questions/client.js +87 -79
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workflow-run/client.js +28 -14
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workspace/client.js +2647 -1044
- package/dist/plugins/@deepseek-ai/dsh-typert-registry/client.js +22 -7
- package/dist/plugins/dsh-edge-client-ui/client.js +1 -10
- package/package.json +96 -86
- package/scripts/cli.mjs +16 -4
- package/scripts/install.d.mts +12 -2
- package/scripts/install.mjs +36 -9
- package/scripts/legal-files.mjs +15 -0
- package/worker/direct/index.js +2564 -1822
- package/worker/isolated/index.js +2144 -1402
- package/dist/assets/index-BKQ_L1z6.js +0 -117
- package/dist/assets/index-DPX2bQLO.css +0 -1
- package/dist/assets/langs/html-CfGypltT.js +0 -2
- package/dist/assets/langs/php-DJl5gRdb.js +0 -2
- package/dist/assets/langs/ruby-5eNB0pDK.js +0 -2
- package/dist/plugins/@deepseek-ai/dsh-client-ui-permission-presets/client.js +0 -505
- package/dist/plugins/@deepseek-ai/dsh-client-ui-schedule/client.js +0 -307
|
@@ -1,505 +0,0 @@
|
|
|
1
|
-
window.__ModuleLoader__.load({
|
|
2
|
-
id: "@deepseek-ai/dsh-client-ui-permission-presets",
|
|
3
|
-
factory: (require) => {
|
|
4
|
-
var module = { exports: {} };
|
|
5
|
-
var exports = module.exports;
|
|
6
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
-
let react_jsx_runtime = require("react/jsx-runtime");
|
|
8
|
-
let react = require("react");
|
|
9
|
-
let _deepseek_ai_dsh_client_ui_primitives = require("@deepseek-ai/dsh-client-ui-primitives");
|
|
10
|
-
let _deepseek_ai_dsh_client_store = require("@deepseek-ai/dsh-client-store");
|
|
11
|
-
//#region lib/types/client/locales.js
|
|
12
|
-
/** `settings.permission` namespace dictionaries (the Permission row's copy). */
|
|
13
|
-
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
14
|
-
const zh = {
|
|
15
|
-
"title": "权限",
|
|
16
|
-
"description": "选择新会话的默认权限模式",
|
|
17
|
-
"loading": "加载中",
|
|
18
|
-
"unavailable": "不可用",
|
|
19
|
-
"preset.readOnly": "仅可查看",
|
|
20
|
-
"preset.workspaceWrite": "工作区内修改",
|
|
21
|
-
"preset.fullAccess": "完全权限",
|
|
22
|
-
"confirm.title": "确认启用完全权限?",
|
|
23
|
-
"confirm.description": "启用完全权限后,新会话将减少确认步骤,并且可以直接执行更多操作,包括敏感操作、文件修改或外部命令。仅建议在你信任后续任务时使用。",
|
|
24
|
-
"confirm.acknowledge": "我已了解风险,并愿意继续",
|
|
25
|
-
"confirm.cancel": "取消",
|
|
26
|
-
"confirm.enable": "启用完全权限"
|
|
27
|
-
};
|
|
28
|
-
/** English dictionary, checked complete against the zh key set. */
|
|
29
|
-
const en = {
|
|
30
|
-
"title": "Permission",
|
|
31
|
-
"description": "Choose the default permission mode for new sessions",
|
|
32
|
-
"loading": "Loading",
|
|
33
|
-
"unavailable": "Unavailable",
|
|
34
|
-
"preset.readOnly": "Read Only",
|
|
35
|
-
"preset.workspaceWrite": "Workspace Write",
|
|
36
|
-
"preset.fullAccess": "Full access",
|
|
37
|
-
"confirm.title": "Enable Full access?",
|
|
38
|
-
"confirm.description": "Full access lets new sessions reduce confirmation steps and perform more actions directly, including sensitive operations, file changes, or external commands. Only use it when you trust subsequent tasks.",
|
|
39
|
-
"confirm.acknowledge": "I understand the risks and want to continue",
|
|
40
|
-
"confirm.cancel": "Cancel",
|
|
41
|
-
"confirm.enable": "Enable Full access"
|
|
42
|
-
};
|
|
43
|
-
/** Simplified Chinese dictionary for the current-session popup gate. */
|
|
44
|
-
const accessZh = {
|
|
45
|
-
"preset.readOnly": "仅可查看",
|
|
46
|
-
"preset.workspaceWrite": "工作区内修改",
|
|
47
|
-
"preset.fullAccess": "完全权限",
|
|
48
|
-
"confirm.title": "确认启用完全权限?",
|
|
49
|
-
"confirm.description": "启用完全权限后,智能体将减少确认步骤,并且可以直接执行更多操作,包括敏感操作、文件修改或外部命令。仅建议在你信任当前任务时使用。",
|
|
50
|
-
"confirm.acknowledge": "我已了解风险,并愿意继续",
|
|
51
|
-
"confirm.cancel": "取消",
|
|
52
|
-
"confirm.enable": "启用完全权限"
|
|
53
|
-
};
|
|
54
|
-
/** English dictionary for the current-session popup gate. */
|
|
55
|
-
const accessEn = {
|
|
56
|
-
"preset.readOnly": "Read Only",
|
|
57
|
-
"preset.workspaceWrite": "Workspace Write",
|
|
58
|
-
"preset.fullAccess": "Full access",
|
|
59
|
-
"confirm.title": "Enable Full access?",
|
|
60
|
-
"confirm.description": "Full access reduces confirmation steps and lets the agent perform more actions directly, including sensitive operations, file changes, or external commands. Only use it when you trust the current task.",
|
|
61
|
-
"confirm.acknowledge": "I understand the risks and want to continue",
|
|
62
|
-
"confirm.cancel": "Cancel",
|
|
63
|
-
"confirm.enable": "Enable Full access"
|
|
64
|
-
};
|
|
65
|
-
//#endregion
|
|
66
|
-
//#region lib/types/client/presentation.js
|
|
67
|
-
/** Machine value of the preset that requires an explicit GUI risk gate. */
|
|
68
|
-
const FULL_ACCESS_PRESET = "danger-full-access";
|
|
69
|
-
const PRESET_LABEL_KEYS = new Map([
|
|
70
|
-
["read-only", "preset.readOnly"],
|
|
71
|
-
["workspace-write", "preset.workspaceWrite"],
|
|
72
|
-
[FULL_ACCESS_PRESET, "preset.fullAccess"]
|
|
73
|
-
]);
|
|
74
|
-
const DEFAULT_PRESET_LABELS = {
|
|
75
|
-
"preset.readOnly": en["preset.readOnly"],
|
|
76
|
-
"preset.workspaceWrite": en["preset.workspaceWrite"],
|
|
77
|
-
"preset.fullAccess": en["preset.fullAccess"]
|
|
78
|
-
};
|
|
79
|
-
/**
|
|
80
|
-
* Convert conventional kebab-case preset names into user-facing title case.
|
|
81
|
-
* @param name - host-supplied preset label or key.
|
|
82
|
-
* @returns the title-cased conventional key, or a non-kebab label unchanged.
|
|
83
|
-
*/
|
|
84
|
-
function displayPresetName(name) {
|
|
85
|
-
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(name)) return name;
|
|
86
|
-
return name.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Render a permission preset under its product label.
|
|
90
|
-
* @param value - preset machine value.
|
|
91
|
-
* @param name - host-supplied preset name.
|
|
92
|
-
* @param t - optional locale dictionary lookup for built-in product labels.
|
|
93
|
-
* @returns the built-in product label or the conventional display name.
|
|
94
|
-
*/
|
|
95
|
-
function displayPermissionPreset(value, name, t) {
|
|
96
|
-
const key = PRESET_LABEL_KEYS.get(value);
|
|
97
|
-
if (key !== void 0 && (name === value || name === DEFAULT_PRESET_LABELS[key])) return t?.(key) ?? DEFAULT_PRESET_LABELS[key];
|
|
98
|
-
return displayPresetName(name);
|
|
99
|
-
}
|
|
100
|
-
//#endregion
|
|
101
|
-
//#region \0dsh-css:/home/runner/work/deepseek-harness/deepseek-harness/packages/client/ui-permission-presets/src/client/PermissionRow.module.css.mjs
|
|
102
|
-
const css = ".oY77xG_row{border-bottom:.5px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.oY77xG_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.oY77xG_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.oY77xG_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.oY77xG_selector{background:var(--dsw-alias-bg-module-platform);height:36px;font:inherit;color:var(--dsw-alias-label-primary);cursor:pointer;border:none;border-radius:18px;align-items:center;gap:12px;padding:0 14px;font-size:14px;line-height:22px;display:inline-flex}.oY77xG_selector:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.oY77xG_selector:disabled{cursor:default}.oY77xG_chevron{flex:none}";
|
|
103
|
-
const tagId = "@deepseek-ai/dsh-client-ui-permission-presets/PermissionRow.module.css";
|
|
104
|
-
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
105
|
-
const tag = document.createElement("style");
|
|
106
|
-
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-permission-presets";
|
|
107
|
-
tag.dataset.pluginCss = tagId;
|
|
108
|
-
tag.textContent = css;
|
|
109
|
-
document.head.appendChild(tag);
|
|
110
|
-
}
|
|
111
|
-
var PermissionRow_module_css_default = {
|
|
112
|
-
"chevron": "oY77xG_chevron",
|
|
113
|
-
"desc": "oY77xG_desc",
|
|
114
|
-
"row": "oY77xG_row",
|
|
115
|
-
"rowText": "oY77xG_rowText",
|
|
116
|
-
"selector": "oY77xG_selector",
|
|
117
|
-
"title": "oY77xG_title"
|
|
118
|
-
};
|
|
119
|
-
//#endregion
|
|
120
|
-
//#region lib/types/client/PermissionRow.js
|
|
121
|
-
/**
|
|
122
|
-
* Permission preference row: the default preset for subsequently created
|
|
123
|
-
* sessions. Current-session switches remain on the composer `/permission`
|
|
124
|
-
* control.
|
|
125
|
-
*/
|
|
126
|
-
/**
|
|
127
|
-
* Render the new-session Permission default selector.
|
|
128
|
-
* @param props - composed slot props.
|
|
129
|
-
* @returns the row, or null when the host does not expose permission settings.
|
|
130
|
-
*/
|
|
131
|
-
function PermissionRow({ load, select, usePermission, t }) {
|
|
132
|
-
const state = usePermission((snapshot) => snapshot);
|
|
133
|
-
const [open, setOpen] = (0, react.useState)(false);
|
|
134
|
-
const [confirmingFullAccess, setConfirmingFullAccess] = (0, react.useState)(false);
|
|
135
|
-
const [acknowledged, setAcknowledged] = (0, react.useState)(false);
|
|
136
|
-
(0, react.useEffect)(() => {
|
|
137
|
-
load();
|
|
138
|
-
}, [load]);
|
|
139
|
-
(0, react.useEffect)(() => {
|
|
140
|
-
if (state.writable && state.status !== "unavailable") return;
|
|
141
|
-
setOpen(false);
|
|
142
|
-
setAcknowledged(false);
|
|
143
|
-
setConfirmingFullAccess(false);
|
|
144
|
-
}, [state.status, state.writable]);
|
|
145
|
-
if (state.status === "unavailable") return null;
|
|
146
|
-
const selected = state.options.find((option) => option.id === state.currentValue);
|
|
147
|
-
const busy = state.status === "loading" || state.status === "saving" || confirmingFullAccess;
|
|
148
|
-
const optionLabel = (option) => displayPermissionPreset(option.id, option.label, t);
|
|
149
|
-
const label = selected !== void 0 ? optionLabel(selected) : busy ? t("loading") : t("unavailable");
|
|
150
|
-
const description = state.error ?? t("description");
|
|
151
|
-
return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
152
|
-
className: PermissionRow_module_css_default.row,
|
|
153
|
-
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
154
|
-
className: PermissionRow_module_css_default.rowText,
|
|
155
|
-
children: [(0, react_jsx_runtime.jsx)("div", {
|
|
156
|
-
className: PermissionRow_module_css_default.title,
|
|
157
|
-
children: t("title")
|
|
158
|
-
}), (0, react_jsx_runtime.jsx)("div", {
|
|
159
|
-
className: PermissionRow_module_css_default.desc,
|
|
160
|
-
role: state.error === null ? void 0 : "alert",
|
|
161
|
-
children: description
|
|
162
|
-
})]
|
|
163
|
-
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
164
|
-
open,
|
|
165
|
-
onClose: () => {
|
|
166
|
-
setOpen(false);
|
|
167
|
-
},
|
|
168
|
-
items: state.options.map((option) => ({
|
|
169
|
-
id: option.id,
|
|
170
|
-
label: optionLabel(option)
|
|
171
|
-
})),
|
|
172
|
-
selectedId: state.currentValue,
|
|
173
|
-
onSelect: (id) => {
|
|
174
|
-
setOpen(false);
|
|
175
|
-
if (id === state.currentValue) return;
|
|
176
|
-
if (id === "danger-full-access") {
|
|
177
|
-
setAcknowledged(false);
|
|
178
|
-
setConfirmingFullAccess(true);
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
select(id);
|
|
182
|
-
},
|
|
183
|
-
align: "end",
|
|
184
|
-
portal: true,
|
|
185
|
-
anchor: (0, react_jsx_runtime.jsxs)("button", {
|
|
186
|
-
type: "button",
|
|
187
|
-
className: PermissionRow_module_css_default.selector,
|
|
188
|
-
"aria-haspopup": "menu",
|
|
189
|
-
"aria-expanded": open,
|
|
190
|
-
disabled: busy || !state.writable || state.options.length === 0,
|
|
191
|
-
onClick: () => {
|
|
192
|
-
setOpen((value) => !value);
|
|
193
|
-
},
|
|
194
|
-
children: [label, (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { className: PermissionRow_module_css_default.chevron })]
|
|
195
|
-
})
|
|
196
|
-
})]
|
|
197
|
-
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.RiskConfirmation, {
|
|
198
|
-
open: confirmingFullAccess,
|
|
199
|
-
title: t("confirm.title"),
|
|
200
|
-
description: t("confirm.description"),
|
|
201
|
-
acknowledgeLabel: t("confirm.acknowledge"),
|
|
202
|
-
cancelLabel: t("confirm.cancel"),
|
|
203
|
-
closeLabel: t("close"),
|
|
204
|
-
confirmLabel: t("confirm.enable"),
|
|
205
|
-
acknowledged,
|
|
206
|
-
disabled: !state.writable || state.status === "saving",
|
|
207
|
-
onAcknowledgedChange: setAcknowledged,
|
|
208
|
-
onCancel: () => {
|
|
209
|
-
setAcknowledged(false);
|
|
210
|
-
setConfirmingFullAccess(false);
|
|
211
|
-
},
|
|
212
|
-
onConfirm: () => {
|
|
213
|
-
setAcknowledged(false);
|
|
214
|
-
setConfirmingFullAccess(false);
|
|
215
|
-
select(FULL_ACCESS_PRESET);
|
|
216
|
-
}
|
|
217
|
-
})] });
|
|
218
|
-
}
|
|
219
|
-
//#endregion
|
|
220
|
-
//#region lib/types/client/settings-store.js
|
|
221
|
-
/**
|
|
222
|
-
* Permission default-settings controller. The permission descriptor comes
|
|
223
|
-
* from the shared describe mirror (the dynamic preset enum lives in the
|
|
224
|
-
* namespace schema, which per-namespace scopes do not carry); writes target
|
|
225
|
-
* only `defaultPreset`, carry the descriptor revision, and fold their answer
|
|
226
|
-
* back into the mirror.
|
|
227
|
-
*/
|
|
228
|
-
/** Permission's settings namespace on the host wire. */
|
|
229
|
-
const PERMISSION_SETTINGS_NS = "permission";
|
|
230
|
-
/**
|
|
231
|
-
* Read the dynamic preset enum encoded by the host's `defaultPreset` schema.
|
|
232
|
-
* @param view - permission namespace descriptor.
|
|
233
|
-
* @param schema - settings schema operations.
|
|
234
|
-
* @returns current value and selectable options.
|
|
235
|
-
*/
|
|
236
|
-
function permissionDefaultOf(view, schema) {
|
|
237
|
-
const value = view.value?.defaultPreset;
|
|
238
|
-
if (typeof value !== "string") throw new Error("permission settings has no defaultPreset value");
|
|
239
|
-
const node = schema.nodeAtPath(schema.rehydrate(view.schema), ["defaultPreset"]);
|
|
240
|
-
if (node === void 0) throw new Error("permission settings schema has no defaultPreset field");
|
|
241
|
-
const options = (node.type === "union" ? node.list ?? [] : [node]).flatMap((candidate) => {
|
|
242
|
-
const choice = candidate;
|
|
243
|
-
if (choice.type !== "const" || typeof choice.value !== "string") return [];
|
|
244
|
-
const described = choice.meta?.description;
|
|
245
|
-
return [{
|
|
246
|
-
id: choice.value,
|
|
247
|
-
label: typeof described === "string" && described.length > 0 ? displayPermissionPreset(choice.value, described) : displayPermissionPreset(choice.value, choice.value)
|
|
248
|
-
}];
|
|
249
|
-
});
|
|
250
|
-
if (options.length === 0 || !options.some((option) => option.id === value)) throw new Error("permission settings schema does not advertise its current preset");
|
|
251
|
-
return {
|
|
252
|
-
currentValue: value,
|
|
253
|
-
options
|
|
254
|
-
};
|
|
255
|
-
}
|
|
256
|
-
/** Controller deriving the row from the shared mirror and writing the default through it. */
|
|
257
|
-
var PermissionPresetSettingsController = class {
|
|
258
|
-
describeFace;
|
|
259
|
-
ctx;
|
|
260
|
-
schema;
|
|
261
|
-
/** Row snapshot consumed through a bound selector hook. */
|
|
262
|
-
store = (0, _deepseek_ai_dsh_client_store.createSnapshotStore)({
|
|
263
|
-
status: "idle",
|
|
264
|
-
error: null,
|
|
265
|
-
writable: false,
|
|
266
|
-
currentValue: "",
|
|
267
|
-
options: [],
|
|
268
|
-
revision: 0
|
|
269
|
-
});
|
|
270
|
-
following;
|
|
271
|
-
saving = false;
|
|
272
|
-
disposed = false;
|
|
273
|
-
/**
|
|
274
|
-
* @param describeFace - the shared mirror's read/fold face (descriptor and schema source).
|
|
275
|
-
* @param ctx - the row plugin's context, whose `remote.settings` namespace
|
|
276
|
-
* carries the `defaultPreset` write.
|
|
277
|
-
* @param schema - settings-owned schema operations.
|
|
278
|
-
*/
|
|
279
|
-
constructor(describeFace, ctx, schema) {
|
|
280
|
-
this.describeFace = describeFace;
|
|
281
|
-
this.ctx = ctx;
|
|
282
|
-
this.schema = schema;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Begin following the mirror (idempotent) and reflect its current answer.
|
|
286
|
-
* @returns settlement once the snapshot reflects the mirror.
|
|
287
|
-
*/
|
|
288
|
-
async load() {
|
|
289
|
-
if (this.disposed) return;
|
|
290
|
-
this.following ??= this.describeFace.subscribe(() => {
|
|
291
|
-
this.derive();
|
|
292
|
-
});
|
|
293
|
-
this.store.update((state) => {
|
|
294
|
-
state.status = "loading";
|
|
295
|
-
state.error = null;
|
|
296
|
-
});
|
|
297
|
-
await this.describeFace.ensure();
|
|
298
|
-
this.derive();
|
|
299
|
-
}
|
|
300
|
-
/**
|
|
301
|
-
* Persist one preset as the default for subsequently created sessions.
|
|
302
|
-
* A selection made while one is already saving is ignored — the row's
|
|
303
|
-
* control is disabled during the save, so this only drops programmatic
|
|
304
|
-
* double-submits rather than user intent.
|
|
305
|
-
* @param preset - advertised preset key.
|
|
306
|
-
* @returns nothing; {@link store} carries success or failure.
|
|
307
|
-
*/
|
|
308
|
-
async select(preset) {
|
|
309
|
-
const state = this.store.getSnapshot();
|
|
310
|
-
const view = this.describeFace.getSnapshot().view?.namespaces.find((entry) => entry.ns === PERMISSION_SETTINGS_NS);
|
|
311
|
-
if (view === void 0 || !state.writable || this.saving) return;
|
|
312
|
-
this.saving = true;
|
|
313
|
-
this.store.update((draft) => {
|
|
314
|
-
draft.status = "saving";
|
|
315
|
-
draft.error = null;
|
|
316
|
-
});
|
|
317
|
-
let response;
|
|
318
|
-
try {
|
|
319
|
-
response = await this.ctx.remote.settings.mutate(PERMISSION_SETTINGS_NS, [{
|
|
320
|
-
op: "set",
|
|
321
|
-
path: ["defaultPreset"],
|
|
322
|
-
value: preset
|
|
323
|
-
}], view.revision);
|
|
324
|
-
} finally {
|
|
325
|
-
this.saving = false;
|
|
326
|
-
}
|
|
327
|
-
if (this.disposed) return;
|
|
328
|
-
if (!response.ok) {
|
|
329
|
-
this.fail(response.error);
|
|
330
|
-
return;
|
|
331
|
-
}
|
|
332
|
-
this.describeFace.acceptView(response.value);
|
|
333
|
-
}
|
|
334
|
-
/** Stop following the mirror; later publishes leave the snapshot alone. */
|
|
335
|
-
dispose() {
|
|
336
|
-
this.disposed = true;
|
|
337
|
-
this.following?.();
|
|
338
|
-
this.following = void 0;
|
|
339
|
-
}
|
|
340
|
-
derive() {
|
|
341
|
-
if (this.disposed || this.saving) return;
|
|
342
|
-
const mirrored = this.describeFace.getSnapshot();
|
|
343
|
-
if (mirrored.status === "unavailable") {
|
|
344
|
-
this.store.update((state) => {
|
|
345
|
-
state.status = "unavailable";
|
|
346
|
-
state.writable = false;
|
|
347
|
-
state.currentValue = "";
|
|
348
|
-
state.options = [];
|
|
349
|
-
});
|
|
350
|
-
return;
|
|
351
|
-
}
|
|
352
|
-
if (mirrored.view === void 0) {
|
|
353
|
-
if (mirrored.error !== null) this.fail(new Error(mirrored.error));
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
const view = mirrored.view.namespaces.find((entry) => entry.ns === PERMISSION_SETTINGS_NS);
|
|
357
|
-
if (view === void 0) {
|
|
358
|
-
this.store.update((state) => {
|
|
359
|
-
state.status = "unavailable";
|
|
360
|
-
state.writable = false;
|
|
361
|
-
state.currentValue = "";
|
|
362
|
-
state.options = [];
|
|
363
|
-
});
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
try {
|
|
367
|
-
const resolved = permissionDefaultOf(view, this.schema);
|
|
368
|
-
const { writable } = mirrored.view;
|
|
369
|
-
this.store.update((state) => {
|
|
370
|
-
state.status = "ready";
|
|
371
|
-
state.error = null;
|
|
372
|
-
state.writable = writable;
|
|
373
|
-
state.currentValue = resolved.currentValue;
|
|
374
|
-
state.options = resolved.options;
|
|
375
|
-
state.revision = view.revision;
|
|
376
|
-
});
|
|
377
|
-
} catch (error) {
|
|
378
|
-
this.fail(error);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
fail(error) {
|
|
382
|
-
this.store.update((state) => {
|
|
383
|
-
state.status = "error";
|
|
384
|
-
state.error = error instanceof Error ? error.message : String(error);
|
|
385
|
-
});
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
//#endregion
|
|
389
|
-
//#region lib/types/client/index.js
|
|
390
|
-
/** Required services (cordis fiber inject). */
|
|
391
|
-
const inject = [
|
|
392
|
-
"commandUi",
|
|
393
|
-
"sessions",
|
|
394
|
-
"slots",
|
|
395
|
-
"locale",
|
|
396
|
-
"remote",
|
|
397
|
-
"remote.settings",
|
|
398
|
-
"settingsScope",
|
|
399
|
-
"settingsSchema"
|
|
400
|
-
];
|
|
401
|
-
const ACCESS_NS = "permission.access";
|
|
402
|
-
/** Read one session's current permissions projection value (undefined = capability absent). */
|
|
403
|
-
function selectOf(session) {
|
|
404
|
-
return session?.projections.faceOf("permissions").getSnapshot();
|
|
405
|
-
}
|
|
406
|
-
/** Flatten the projection select into popup rows; `custom` is display state, never a target. */
|
|
407
|
-
function optionsOf(value, t) {
|
|
408
|
-
return value.options.filter((option) => option.value !== "custom").map((option) => ({
|
|
409
|
-
id: option.value,
|
|
410
|
-
label: displayPermissionPreset(option.value, option.name, t),
|
|
411
|
-
...option.description !== void 0 ? { detail: option.description } : {},
|
|
412
|
-
...option.value === value.currentValue ? { active: true } : {},
|
|
413
|
-
...option.value === "danger-full-access" ? { confirmation: {
|
|
414
|
-
title: t("confirm.title"),
|
|
415
|
-
description: t("confirm.description"),
|
|
416
|
-
acknowledgeLabel: t("confirm.acknowledge"),
|
|
417
|
-
cancelLabel: t("confirm.cancel"),
|
|
418
|
-
confirmLabel: t("confirm.enable")
|
|
419
|
-
} } : {}
|
|
420
|
-
}));
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Client plugin body: register the /permission popup picker over the
|
|
424
|
-
* permissions projection.
|
|
425
|
-
* @param ctx - client root context.
|
|
426
|
-
*/
|
|
427
|
-
function apply(ctx) {
|
|
428
|
-
const command = ctx.get("commandUi");
|
|
429
|
-
const sessions = ctx.sessions;
|
|
430
|
-
ctx.effect(() => {
|
|
431
|
-
const disposers = [ctx.locale.register(ACCESS_NS, "zh", {
|
|
432
|
-
"preset.readOnly": accessZh["preset.readOnly"],
|
|
433
|
-
"preset.workspaceWrite": accessZh["preset.workspaceWrite"],
|
|
434
|
-
"preset.fullAccess": accessZh["preset.fullAccess"],
|
|
435
|
-
"confirm.title": accessZh["confirm.title"],
|
|
436
|
-
"confirm.description": accessZh["confirm.description"],
|
|
437
|
-
"confirm.acknowledge": accessZh["confirm.acknowledge"],
|
|
438
|
-
"confirm.cancel": accessZh["confirm.cancel"],
|
|
439
|
-
"confirm.enable": accessZh["confirm.enable"]
|
|
440
|
-
}), ctx.locale.register(ACCESS_NS, "en", {
|
|
441
|
-
"preset.readOnly": accessEn["preset.readOnly"],
|
|
442
|
-
"preset.workspaceWrite": accessEn["preset.workspaceWrite"],
|
|
443
|
-
"preset.fullAccess": accessEn["preset.fullAccess"],
|
|
444
|
-
"confirm.title": accessEn["confirm.title"],
|
|
445
|
-
"confirm.description": accessEn["confirm.description"],
|
|
446
|
-
"confirm.acknowledge": accessEn["confirm.acknowledge"],
|
|
447
|
-
"confirm.cancel": accessEn["confirm.cancel"],
|
|
448
|
-
"confirm.enable": accessEn["confirm.enable"]
|
|
449
|
-
})];
|
|
450
|
-
return () => {
|
|
451
|
-
for (const dispose of disposers) dispose();
|
|
452
|
-
};
|
|
453
|
-
}, "ui-permission: Full access confirmation dictionaries");
|
|
454
|
-
const t = ctx.locale.bind(ACCESS_NS);
|
|
455
|
-
const sessionFor = (session) => sessions.binding(session.sessionId)?.session;
|
|
456
|
-
ctx.effect(() => ctx.locale.register("settings.permission", {
|
|
457
|
-
zh,
|
|
458
|
-
en
|
|
459
|
-
}), "ui-permission: settings row dictionaries");
|
|
460
|
-
const controller = new PermissionPresetSettingsController(ctx.settingsScope.describe(), ctx, ctx.settingsSchema);
|
|
461
|
-
const load = () => controller.load();
|
|
462
|
-
const select = (preset) => controller.select(preset);
|
|
463
|
-
const injected = () => ({
|
|
464
|
-
hooks: { permission: controller.store },
|
|
465
|
-
load,
|
|
466
|
-
select
|
|
467
|
-
});
|
|
468
|
-
ctx.effect(() => () => {
|
|
469
|
-
controller.dispose();
|
|
470
|
-
}, "ui-permission: settings row directory");
|
|
471
|
-
ctx.slots.inject("settings.general.item", () => ctx.slots.register({
|
|
472
|
-
name: "settings.general.item",
|
|
473
|
-
id: "permission",
|
|
474
|
-
order: -20,
|
|
475
|
-
locale: "settings.permission",
|
|
476
|
-
inject: injected
|
|
477
|
-
}, PermissionRow));
|
|
478
|
-
ctx.effect(() => command.decorate({
|
|
479
|
-
name: "permission",
|
|
480
|
-
available: (session) => selectOf(sessionFor(session)) !== void 0,
|
|
481
|
-
ui: {
|
|
482
|
-
kind: "popupSelect",
|
|
483
|
-
options: (session) => {
|
|
484
|
-
const value = selectOf(sessionFor(session));
|
|
485
|
-
if (value === void 0) throw new Error("permission presets are not available on this host");
|
|
486
|
-
return Promise.resolve(optionsOf(value, t));
|
|
487
|
-
},
|
|
488
|
-
onSelect: async (option, session) => {
|
|
489
|
-
const live = sessionFor(session);
|
|
490
|
-
if (live === void 0) throw new Error("this session is not materialized yet");
|
|
491
|
-
const result = await live.command(`/permission ${option.id}`);
|
|
492
|
-
if (!result.ok) throw new Error(`permission switch failed: ${result.error.code}: ${result.error.message}`);
|
|
493
|
-
if (!result.value.matched) throw new Error("the host offers no /permission command");
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}), "ui-permission: /permission decoration");
|
|
497
|
-
}
|
|
498
|
-
//#endregion
|
|
499
|
-
exports.apply = apply;
|
|
500
|
-
exports.inject = inject;
|
|
501
|
-
return module.exports;
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
|
|
505
|
-
//# sourceMappingURL=client.js.map
|