dsh-edge 0.1.0
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/LICENSE +21 -0
- package/README.i18n.yaml +6 -0
- package/README.md +183 -0
- package/README.zh.md +183 -0
- package/THIRD_PARTY_NOTICES.md +199 -0
- package/dist/_headers +3 -0
- package/dist/assets/fonts/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/fonts/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/fonts/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/fonts/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/fonts/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/fonts/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/fonts/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/fonts/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/fonts/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/fonts/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/index-C-1AiF3k.js +112 -0
- package/dist/assets/index-CSGf6Qzd.css +1 -0
- package/dist/assets/langs/c-BIGW1oBm.js +2 -0
- package/dist/assets/langs/cpp-DIPi6g--.js +2 -0
- package/dist/assets/langs/csharp-DSvCPggb.js +2 -0
- package/dist/assets/langs/css-CLj8gQPS.js +2 -0
- package/dist/assets/langs/go-C27-OAKa.js +2 -0
- package/dist/assets/langs/html-CfGypltT.js +2 -0
- package/dist/assets/langs/ini-BEwlwnbL.js +2 -0
- package/dist/assets/langs/java-CylS5w8V.js +2 -0
- package/dist/assets/langs/kotlin-BdnUsdx6.js +2 -0
- package/dist/assets/langs/less-B1dDrJ26.js +2 -0
- package/dist/assets/langs/lua-BaeVxFsk.js +2 -0
- package/dist/assets/langs/markdown-Cvjx9yec.js +2 -0
- package/dist/assets/langs/mdx-Cmh6b_Ma.js +2 -0
- package/dist/assets/langs/php-D-uCvoST.js +2 -0
- package/dist/assets/langs/python-B6aJPvgy.js +2 -0
- package/dist/assets/langs/ruby-DEItuUFs.js +2 -0
- package/dist/assets/langs/rust-B1yitclQ.js +2 -0
- package/dist/assets/langs/scss-D5BDwBP9.js +2 -0
- package/dist/assets/langs/sql-CRqJ_cUM.js +2 -0
- package/dist/assets/langs/swift-D82vCrfD.js +2 -0
- package/dist/assets/langs/toml-vGWfd6FD.js +2 -0
- package/dist/assets/langs/xml-sdJ4AIDG.js +2 -0
- package/dist/assets/langs/yaml-Buea-lGh.js +2 -0
- package/dist/assets/vendor-Cjbwl5VI.js +411 -0
- package/dist/assets/vendor-CjyC-hUb.css +1 -0
- package/dist/favicon.svg +8 -0
- package/dist/index.html +35 -0
- package/dist/manifest.webmanifest +16 -0
- package/dist/plugins/@deepseek-ai/dsh-api-gateway/client.js +420 -0
- package/dist/plugins/@deepseek-ai/dsh-api-remotes/client.js +5937 -0
- package/dist/plugins/@deepseek-ai/dsh-client-connection/client.js +10207 -0
- package/dist/plugins/@deepseek-ai/dsh-client-locale/client.js +1231 -0
- package/dist/plugins/@deepseek-ai/dsh-client-modules/client.js +259 -0
- package/dist/plugins/@deepseek-ai/dsh-client-runtime/client.js +10539 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-agent-preset/client.js +1725 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-commands/client.js +1116 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-conversation/client.js +9832 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-deliverables/client.js +373 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-edge/client.js +549 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-input-trigger/client.js +859 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-jobs/client.js +280 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-layout/client.js +456 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-model-selection/client.js +804 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-permission-presets/client.js +461 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings/client.js +254 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-settings-general/client.js +609 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-sidebar/client.js +292 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-skill/client.js +327 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-subagent/client.js +710 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-theme/client.js +1312 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-tool/client.js +1630 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-trajectory/client.js +7370 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-user-questions/client.js +700 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workflow-run/client.js +474 -0
- package/dist/plugins/@deepseek-ai/dsh-client-ui-workspace/client.js +2426 -0
- package/dist/plugins/@deepseek-ai/dsh-typert-registry/client.js +1372 -0
- package/package.json +97 -0
- package/scripts/assemble-web.mjs +230 -0
- package/scripts/bundle-size.d.mts +2 -0
- package/scripts/bundle-size.mjs +26 -0
- package/scripts/bundle.mjs +53 -0
- package/scripts/cli.d.mts +39 -0
- package/scripts/cli.mjs +496 -0
- package/scripts/install.d.mts +149 -0
- package/scripts/install.mjs +989 -0
- package/scripts/legal-files.mjs +24 -0
- package/scripts/verify-packed.mjs +32 -0
- package/scripts/wrangler-config.d.mts +18 -0
- package/scripts/wrangler-config.mjs +84 -0
- package/src/agent.ts +119 -0
- package/src/auth.ts +352 -0
- package/src/deepseek.ts +231 -0
- package/src/deployment.ts +147 -0
- package/src/direct-shell-core-empty.ts +10 -0
- package/src/direct-shell-protocol.ts +5 -0
- package/src/direct-shell.ts +341 -0
- package/src/do-session-persistence.ts +1064 -0
- package/src/edge-api.ts +796 -0
- package/src/edge-credentials.ts +56 -0
- package/src/edge-remotes.ts +41 -0
- package/src/edge-workspace-store.ts +339 -0
- package/src/http.ts +212 -0
- package/src/index.ts +196 -0
- package/src/instance.ts +1007 -0
- package/src/isolated-direct-shell-unavailable.ts +11 -0
- package/src/protocol.ts +39 -0
- package/src/release.ts +9 -0
- package/src/session-store.ts +1110 -0
- package/src/sse.ts +86 -0
- package/src/web-search.ts +38 -0
- package/src/workspace.ts +270 -0
- package/wrangler.jsonc +56 -0
|
@@ -0,0 +1,461 @@
|
|
|
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_runtime_client = require("@deepseek-ai/dsh-client-runtime/client");
|
|
11
|
+
let _deepseek_ai_dsh_client_schema_form = require("@deepseek-ai/dsh-client-schema-form");
|
|
12
|
+
//#region lib/types/client/presentation.js
|
|
13
|
+
/** Machine value of the preset that requires an explicit GUI risk gate. */
|
|
14
|
+
const FULL_ACCESS_PRESET = "danger-full-access";
|
|
15
|
+
/**
|
|
16
|
+
* Convert conventional kebab-case preset names into user-facing title case.
|
|
17
|
+
* @param name - host-supplied preset label or key.
|
|
18
|
+
* @returns the title-cased conventional key, or a non-kebab label unchanged.
|
|
19
|
+
*/
|
|
20
|
+
function displayPresetName(name) {
|
|
21
|
+
if (!/^[a-z0-9]+(-[a-z0-9]+)*$/.test(name)) return name;
|
|
22
|
+
return name.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Render a permission preset under its product label.
|
|
26
|
+
* @param value - preset machine value.
|
|
27
|
+
* @param name - host-supplied preset name.
|
|
28
|
+
* @returns the Full access product label or the conventional display name.
|
|
29
|
+
*/
|
|
30
|
+
function displayPermissionPreset(value, name) {
|
|
31
|
+
return value === "danger-full-access" ? "Full access" : displayPresetName(name);
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region \0dsh-css:/private/var/folders/nm/n5smty9962gf5rhjc5855kt80000gn/T/dsh-edge-release-worktree.XXXXXX.RcJjogaGt4/repo/packages/client/ui-permission-presets/src/client/PermissionRow.module.css.mjs
|
|
35
|
+
const css = ".dSjoLq_row{border-bottom:1px solid var(--dsw-alias-border-l2);align-items:center;gap:8px;padding:16px 0;display:flex}.dSjoLq_rowText{flex-direction:column;flex:1;gap:4px;min-width:0;padding-right:48px;display:flex}.dSjoLq_title{color:var(--dsw-alias-label-primary);font-size:14px;font-weight:400;line-height:22px}.dSjoLq_desc{color:var(--dsw-alias-label-tertiary);font-size:12px;font-weight:400;line-height:18px}.dSjoLq_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}.dSjoLq_selector:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}.dSjoLq_selector:disabled{cursor:default}.dSjoLq_chevron{flex:none}";
|
|
36
|
+
const tagId = "@deepseek-ai/dsh-client-ui-permission-presets/PermissionRow.module.css";
|
|
37
|
+
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
|
|
38
|
+
const tag = document.createElement("style");
|
|
39
|
+
tag.dataset.plugin = "@deepseek-ai/dsh-client-ui-permission-presets";
|
|
40
|
+
tag.dataset.pluginCss = tagId;
|
|
41
|
+
tag.textContent = css;
|
|
42
|
+
document.head.appendChild(tag);
|
|
43
|
+
}
|
|
44
|
+
var PermissionRow_module_css_default = {
|
|
45
|
+
"chevron": "dSjoLq_chevron",
|
|
46
|
+
"title": "dSjoLq_title",
|
|
47
|
+
"desc": "dSjoLq_desc",
|
|
48
|
+
"rowText": "dSjoLq_rowText",
|
|
49
|
+
"row": "dSjoLq_row",
|
|
50
|
+
"selector": "dSjoLq_selector"
|
|
51
|
+
};
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region lib/types/client/PermissionRow.js
|
|
54
|
+
/**
|
|
55
|
+
* Permission preference row: the default preset for subsequently created
|
|
56
|
+
* sessions. Current-session switches remain on the composer `/permission`
|
|
57
|
+
* control.
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* Render the new-session Permission default selector.
|
|
61
|
+
* @param props - composed slot props.
|
|
62
|
+
* @returns the row, or null when the host does not expose permission settings.
|
|
63
|
+
*/
|
|
64
|
+
function PermissionRow({ load, select, usePermission, t }) {
|
|
65
|
+
const state = usePermission((snapshot) => snapshot);
|
|
66
|
+
const [open, setOpen] = (0, react.useState)(false);
|
|
67
|
+
const [confirmingFullAccess, setConfirmingFullAccess] = (0, react.useState)(false);
|
|
68
|
+
const [acknowledged, setAcknowledged] = (0, react.useState)(false);
|
|
69
|
+
(0, react.useEffect)(() => {
|
|
70
|
+
load();
|
|
71
|
+
}, [load]);
|
|
72
|
+
(0, react.useEffect)(() => {
|
|
73
|
+
if (state.writable && state.status !== "unavailable") return;
|
|
74
|
+
setOpen(false);
|
|
75
|
+
setAcknowledged(false);
|
|
76
|
+
setConfirmingFullAccess(false);
|
|
77
|
+
}, [state.status, state.writable]);
|
|
78
|
+
if (state.status === "unavailable") return null;
|
|
79
|
+
const selected = state.options.find((option) => option.id === state.currentValue);
|
|
80
|
+
const busy = state.status === "loading" || state.status === "saving" || confirmingFullAccess;
|
|
81
|
+
const label = selected?.label ?? (busy ? t("loading") : t("unavailable"));
|
|
82
|
+
const description = state.error ?? t("description");
|
|
83
|
+
return (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
84
|
+
className: PermissionRow_module_css_default.row,
|
|
85
|
+
children: [(0, react_jsx_runtime.jsxs)("div", {
|
|
86
|
+
className: PermissionRow_module_css_default.rowText,
|
|
87
|
+
children: [(0, react_jsx_runtime.jsx)("div", {
|
|
88
|
+
className: PermissionRow_module_css_default.title,
|
|
89
|
+
children: t("title")
|
|
90
|
+
}), (0, react_jsx_runtime.jsx)("div", {
|
|
91
|
+
className: PermissionRow_module_css_default.desc,
|
|
92
|
+
role: state.error === null ? void 0 : "alert",
|
|
93
|
+
children: description
|
|
94
|
+
})]
|
|
95
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Menu, {
|
|
96
|
+
open,
|
|
97
|
+
onClose: () => {
|
|
98
|
+
setOpen(false);
|
|
99
|
+
},
|
|
100
|
+
items: state.options.map((option) => ({
|
|
101
|
+
id: option.id,
|
|
102
|
+
label: option.label
|
|
103
|
+
})),
|
|
104
|
+
selectedId: state.currentValue,
|
|
105
|
+
onSelect: (id) => {
|
|
106
|
+
setOpen(false);
|
|
107
|
+
if (id === state.currentValue) return;
|
|
108
|
+
if (id === "danger-full-access") {
|
|
109
|
+
setAcknowledged(false);
|
|
110
|
+
setConfirmingFullAccess(true);
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
select(id);
|
|
114
|
+
},
|
|
115
|
+
align: "end",
|
|
116
|
+
portal: true,
|
|
117
|
+
anchor: (0, react_jsx_runtime.jsxs)("button", {
|
|
118
|
+
type: "button",
|
|
119
|
+
className: PermissionRow_module_css_default.selector,
|
|
120
|
+
"aria-haspopup": "menu",
|
|
121
|
+
"aria-expanded": open,
|
|
122
|
+
disabled: busy || !state.writable || state.options.length === 0,
|
|
123
|
+
onClick: () => {
|
|
124
|
+
setOpen((value) => !value);
|
|
125
|
+
},
|
|
126
|
+
children: [label, (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.IconChevronDownOutline14, { className: PermissionRow_module_css_default.chevron })]
|
|
127
|
+
})
|
|
128
|
+
})]
|
|
129
|
+
}), (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.RiskConfirmation, {
|
|
130
|
+
open: confirmingFullAccess,
|
|
131
|
+
title: t("confirm.title"),
|
|
132
|
+
description: t("confirm.description"),
|
|
133
|
+
acknowledgeLabel: t("confirm.acknowledge"),
|
|
134
|
+
cancelLabel: t("confirm.cancel"),
|
|
135
|
+
confirmLabel: t("confirm.enable"),
|
|
136
|
+
acknowledged,
|
|
137
|
+
disabled: !state.writable || state.status === "saving",
|
|
138
|
+
onAcknowledgedChange: setAcknowledged,
|
|
139
|
+
onCancel: () => {
|
|
140
|
+
setAcknowledged(false);
|
|
141
|
+
setConfirmingFullAccess(false);
|
|
142
|
+
},
|
|
143
|
+
onConfirm: () => {
|
|
144
|
+
setAcknowledged(false);
|
|
145
|
+
setConfirmingFullAccess(false);
|
|
146
|
+
select(FULL_ACCESS_PRESET);
|
|
147
|
+
}
|
|
148
|
+
})] });
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region lib/types/client/locales.js
|
|
152
|
+
/** `settings.permission` namespace dictionaries (the Permission row's copy). */
|
|
153
|
+
/** Simplified Chinese dictionary (the key-set source of truth). */
|
|
154
|
+
const zh = {
|
|
155
|
+
"title": "权限",
|
|
156
|
+
"description": "选择新会话的默认权限模式",
|
|
157
|
+
"loading": "加载中",
|
|
158
|
+
"unavailable": "不可用",
|
|
159
|
+
"confirm.title": "确认启用 Full access?",
|
|
160
|
+
"confirm.description": "启用 Full access 后,新会话将减少确认步骤,并且可以直接执行更多操作,包括敏感操作、文件修改或外部命令。仅建议在你信任后续任务时使用。",
|
|
161
|
+
"confirm.acknowledge": "我已了解风险,并愿意继续",
|
|
162
|
+
"confirm.cancel": "取消",
|
|
163
|
+
"confirm.enable": "启用 Full access"
|
|
164
|
+
};
|
|
165
|
+
/** English dictionary, checked complete against the zh key set. */
|
|
166
|
+
const en = {
|
|
167
|
+
"title": "Permission",
|
|
168
|
+
"description": "Choose the default permission mode for new sessions",
|
|
169
|
+
"loading": "Loading",
|
|
170
|
+
"unavailable": "Unavailable",
|
|
171
|
+
"confirm.title": "Enable Full access?",
|
|
172
|
+
"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.",
|
|
173
|
+
"confirm.acknowledge": "I understand the risks and want to continue",
|
|
174
|
+
"confirm.cancel": "Cancel",
|
|
175
|
+
"confirm.enable": "Enable Full access"
|
|
176
|
+
};
|
|
177
|
+
/** Simplified Chinese dictionary for the current-session popup gate. */
|
|
178
|
+
const accessZh = {
|
|
179
|
+
"confirm.title": "确认启用 Full access?",
|
|
180
|
+
"confirm.description": "启用 Full access 后,agent 将减少确认步骤,并且可以直接执行更多操作,包括敏感操作、文件修改或外部命令。仅建议在你信任当前任务时使用。",
|
|
181
|
+
"confirm.acknowledge": "我已了解风险,并愿意继续",
|
|
182
|
+
"confirm.cancel": "取消",
|
|
183
|
+
"confirm.enable": "启用 Full access"
|
|
184
|
+
};
|
|
185
|
+
/** English dictionary for the current-session popup gate. */
|
|
186
|
+
const accessEn = {
|
|
187
|
+
"confirm.title": "Enable Full access?",
|
|
188
|
+
"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.",
|
|
189
|
+
"confirm.acknowledge": "I understand the risks and want to continue",
|
|
190
|
+
"confirm.cancel": "Cancel",
|
|
191
|
+
"confirm.enable": "Enable Full access"
|
|
192
|
+
};
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region lib/types/client/settings-store.js
|
|
195
|
+
/**
|
|
196
|
+
* Permission default-settings controller. The host descriptor supplies the
|
|
197
|
+
* current value and the dynamic preset enum; writes target only
|
|
198
|
+
* `defaultPreset` and carry the descriptor revision.
|
|
199
|
+
*/
|
|
200
|
+
/** Permission's settings namespace on the host wire. */
|
|
201
|
+
const PERMISSION_SETTINGS_NS = "permission";
|
|
202
|
+
/**
|
|
203
|
+
* Read the dynamic preset enum encoded by the host's `defaultPreset` schema.
|
|
204
|
+
* @param view - permission namespace descriptor.
|
|
205
|
+
* @returns current value and selectable options.
|
|
206
|
+
*/
|
|
207
|
+
function permissionDefaultOf(view) {
|
|
208
|
+
const value = view.value?.defaultPreset;
|
|
209
|
+
if (typeof value !== "string") throw new Error("permission settings has no defaultPreset value");
|
|
210
|
+
const node = (0, _deepseek_ai_dsh_client_schema_form.nodeAtPath)((0, _deepseek_ai_dsh_client_schema_form.rehydrateSchema)(view.schema), ["defaultPreset"]);
|
|
211
|
+
if (node === void 0) throw new Error("permission settings schema has no defaultPreset field");
|
|
212
|
+
const options = (node.type === "union" ? node.list ?? [] : [node]).flatMap((candidate) => {
|
|
213
|
+
const choice = candidate;
|
|
214
|
+
if (choice.type !== "const" || typeof choice.value !== "string") return [];
|
|
215
|
+
const described = choice.meta?.description;
|
|
216
|
+
return [{
|
|
217
|
+
id: choice.value,
|
|
218
|
+
label: typeof described === "string" && described.length > 0 ? displayPermissionPreset(choice.value, described) : displayPermissionPreset(choice.value, choice.value)
|
|
219
|
+
}];
|
|
220
|
+
});
|
|
221
|
+
if (options.length === 0 || !options.some((option) => option.id === value)) throw new Error("permission settings schema does not advertise its current preset");
|
|
222
|
+
return {
|
|
223
|
+
currentValue: value,
|
|
224
|
+
options
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
/** Controller joining Settings reads, writes, and pushed invalidations. */
|
|
228
|
+
var PermissionPresetSettingsController = class {
|
|
229
|
+
api;
|
|
230
|
+
/** Row snapshot consumed through a bound selector hook. */
|
|
231
|
+
store = (0, _deepseek_ai_dsh_client_runtime_client.createSnapshotStore)({
|
|
232
|
+
status: "idle",
|
|
233
|
+
error: null,
|
|
234
|
+
writable: false,
|
|
235
|
+
currentValue: "",
|
|
236
|
+
options: [],
|
|
237
|
+
revision: 0
|
|
238
|
+
});
|
|
239
|
+
generation = 0;
|
|
240
|
+
view;
|
|
241
|
+
/** @param api - Settings wire face. */
|
|
242
|
+
constructor(api) {
|
|
243
|
+
this.api = api;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Refresh the permission descriptor. Latest request wins.
|
|
247
|
+
* @returns nothing; {@link store} carries success or failure.
|
|
248
|
+
*/
|
|
249
|
+
async load() {
|
|
250
|
+
const generation = ++this.generation;
|
|
251
|
+
this.store.update((state) => {
|
|
252
|
+
state.status = "loading";
|
|
253
|
+
state.error = null;
|
|
254
|
+
});
|
|
255
|
+
try {
|
|
256
|
+
const response = await this.api.settings.describe({});
|
|
257
|
+
if (!response.result.ok) throw new Error(response.result.error.message);
|
|
258
|
+
if (generation !== this.generation) return;
|
|
259
|
+
const view = response.result.value.namespaces.find((entry) => entry.ns === PERMISSION_SETTINGS_NS);
|
|
260
|
+
if (view === void 0) {
|
|
261
|
+
this.view = void 0;
|
|
262
|
+
this.store.update((state) => {
|
|
263
|
+
state.status = "unavailable";
|
|
264
|
+
state.writable = false;
|
|
265
|
+
state.currentValue = "";
|
|
266
|
+
state.options = [];
|
|
267
|
+
});
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
this.accept(view, response.result.value.writable);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
if (generation !== this.generation) return;
|
|
273
|
+
this.fail(error);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Persist one preset as the default for subsequently created sessions.
|
|
278
|
+
* @param preset - advertised preset key.
|
|
279
|
+
* @returns nothing; {@link store} carries success or failure.
|
|
280
|
+
*/
|
|
281
|
+
async select(preset) {
|
|
282
|
+
const view = this.view;
|
|
283
|
+
const state = this.store.getSnapshot();
|
|
284
|
+
if (view === void 0 || !state.writable) return;
|
|
285
|
+
const generation = ++this.generation;
|
|
286
|
+
this.store.update((draft) => {
|
|
287
|
+
draft.status = "saving";
|
|
288
|
+
draft.error = null;
|
|
289
|
+
});
|
|
290
|
+
try {
|
|
291
|
+
const response = await this.api.settings.mutate({
|
|
292
|
+
ns: PERMISSION_SETTINGS_NS,
|
|
293
|
+
ops: [{
|
|
294
|
+
op: "set",
|
|
295
|
+
path: ["defaultPreset"],
|
|
296
|
+
value: preset
|
|
297
|
+
}],
|
|
298
|
+
expectedRevision: view.revision
|
|
299
|
+
});
|
|
300
|
+
if (generation !== this.generation) return;
|
|
301
|
+
if (!response.result.ok) throw new Error(response.result.error.message);
|
|
302
|
+
this.accept(response.result.value, true);
|
|
303
|
+
} catch (error) {
|
|
304
|
+
if (generation !== this.generation) return;
|
|
305
|
+
this.fail(error);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
/** Stop in-flight responses from publishing after plugin disposal. */
|
|
309
|
+
dispose() {
|
|
310
|
+
this.generation += 1;
|
|
311
|
+
this.view = void 0;
|
|
312
|
+
}
|
|
313
|
+
accept(view, writable) {
|
|
314
|
+
const resolved = permissionDefaultOf(view);
|
|
315
|
+
this.view = view;
|
|
316
|
+
this.store.update((state) => {
|
|
317
|
+
state.status = "ready";
|
|
318
|
+
state.error = null;
|
|
319
|
+
state.writable = writable;
|
|
320
|
+
state.currentValue = resolved.currentValue;
|
|
321
|
+
state.options = resolved.options;
|
|
322
|
+
state.revision = view.revision;
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
fail(error) {
|
|
326
|
+
this.store.update((state) => {
|
|
327
|
+
state.status = "error";
|
|
328
|
+
state.error = error instanceof Error ? error.message : String(error);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* Refetch only after the row has opened once.
|
|
334
|
+
* @param controller - permission settings controller.
|
|
335
|
+
*/
|
|
336
|
+
function refreshPermissionIfLoaded(controller) {
|
|
337
|
+
if (controller.store.getSnapshot().status === "idle") return;
|
|
338
|
+
controller.load();
|
|
339
|
+
}
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region lib/types/client/index.js
|
|
342
|
+
/** Required services (cordis fiber inject). */
|
|
343
|
+
const inject = [
|
|
344
|
+
"commandUi",
|
|
345
|
+
"sessions",
|
|
346
|
+
"slots",
|
|
347
|
+
"locale",
|
|
348
|
+
"connection",
|
|
349
|
+
"remote"
|
|
350
|
+
];
|
|
351
|
+
const ACCESS_NS = "permission.access";
|
|
352
|
+
/** Read one session's current permissions projection value (undefined = capability absent). */
|
|
353
|
+
function selectOf(session) {
|
|
354
|
+
return session?.projections.faceOf("permissions").getSnapshot();
|
|
355
|
+
}
|
|
356
|
+
/** Flatten the projection select into popup rows; `custom` is display state, never a target. */
|
|
357
|
+
function optionsOf(value, t) {
|
|
358
|
+
return value.options.filter((option) => option.value !== "custom").map((option) => ({
|
|
359
|
+
id: option.value,
|
|
360
|
+
label: displayPermissionPreset(option.value, option.name),
|
|
361
|
+
...option.description !== void 0 ? { detail: option.description } : {},
|
|
362
|
+
...option.value === value.currentValue ? { active: true } : {},
|
|
363
|
+
...option.value === "danger-full-access" ? { confirmation: {
|
|
364
|
+
title: t("confirm.title"),
|
|
365
|
+
description: t("confirm.description"),
|
|
366
|
+
acknowledgeLabel: t("confirm.acknowledge"),
|
|
367
|
+
cancelLabel: t("confirm.cancel"),
|
|
368
|
+
confirmLabel: t("confirm.enable")
|
|
369
|
+
} } : {}
|
|
370
|
+
}));
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Client plugin body: register the /permission popup picker over the
|
|
374
|
+
* permissions projection.
|
|
375
|
+
* @param ctx - client root context.
|
|
376
|
+
*/
|
|
377
|
+
function apply(ctx) {
|
|
378
|
+
const command = ctx.get("commandUi");
|
|
379
|
+
const sessions = ctx.sessions;
|
|
380
|
+
ctx.effect(() => {
|
|
381
|
+
const disposers = [ctx.locale.register(ACCESS_NS, "zh", {
|
|
382
|
+
"confirm.title": accessZh["confirm.title"],
|
|
383
|
+
"confirm.description": accessZh["confirm.description"],
|
|
384
|
+
"confirm.acknowledge": accessZh["confirm.acknowledge"],
|
|
385
|
+
"confirm.cancel": accessZh["confirm.cancel"],
|
|
386
|
+
"confirm.enable": accessZh["confirm.enable"]
|
|
387
|
+
}), ctx.locale.register(ACCESS_NS, "en", {
|
|
388
|
+
"confirm.title": accessEn["confirm.title"],
|
|
389
|
+
"confirm.description": accessEn["confirm.description"],
|
|
390
|
+
"confirm.acknowledge": accessEn["confirm.acknowledge"],
|
|
391
|
+
"confirm.cancel": accessEn["confirm.cancel"],
|
|
392
|
+
"confirm.enable": accessEn["confirm.enable"]
|
|
393
|
+
})];
|
|
394
|
+
return () => {
|
|
395
|
+
for (const dispose of disposers) dispose();
|
|
396
|
+
};
|
|
397
|
+
}, "ui-permission: Full access confirmation dictionaries");
|
|
398
|
+
const t = ctx.locale.bind(ACCESS_NS);
|
|
399
|
+
const sessionFor = (session) => sessions.binding(session.sessionId)?.session;
|
|
400
|
+
ctx.effect(() => ctx.locale.register("settings.permission", {
|
|
401
|
+
zh,
|
|
402
|
+
en
|
|
403
|
+
}), "ui-permission: settings row dictionaries");
|
|
404
|
+
const controller = new PermissionPresetSettingsController(ctx.get("connection").api);
|
|
405
|
+
const load = () => controller.load();
|
|
406
|
+
const select = (preset) => controller.select(preset);
|
|
407
|
+
const injected = () => ({
|
|
408
|
+
hooks: { permission: controller.store },
|
|
409
|
+
load,
|
|
410
|
+
select
|
|
411
|
+
});
|
|
412
|
+
ctx.effect(() => {
|
|
413
|
+
const refresh = () => {
|
|
414
|
+
refreshPermissionIfLoaded(controller);
|
|
415
|
+
};
|
|
416
|
+
const disposers = [ctx.remote.$on("settings/document-updated", (ns) => {
|
|
417
|
+
if (ns !== "permission") return;
|
|
418
|
+
refresh();
|
|
419
|
+
}), ctx.on("connection/reset", () => {
|
|
420
|
+
refresh();
|
|
421
|
+
})];
|
|
422
|
+
return () => {
|
|
423
|
+
controller.dispose();
|
|
424
|
+
for (const dispose of disposers) dispose();
|
|
425
|
+
};
|
|
426
|
+
}, "ui-permission: settings invalidations");
|
|
427
|
+
ctx.slots.inject("settings.general.item", () => ctx.slots.register({
|
|
428
|
+
name: "settings.general.item",
|
|
429
|
+
id: "permission",
|
|
430
|
+
order: -20,
|
|
431
|
+
locale: "settings.permission",
|
|
432
|
+
inject: injected
|
|
433
|
+
}, PermissionRow));
|
|
434
|
+
ctx.effect(() => command.decorate({
|
|
435
|
+
name: "permission",
|
|
436
|
+
available: (session) => selectOf(sessionFor(session)) !== void 0,
|
|
437
|
+
ui: {
|
|
438
|
+
kind: "popupSelect",
|
|
439
|
+
options: (session) => {
|
|
440
|
+
const value = selectOf(sessionFor(session));
|
|
441
|
+
if (value === void 0) throw new Error("permission presets are not available on this host");
|
|
442
|
+
return Promise.resolve(optionsOf(value, t));
|
|
443
|
+
},
|
|
444
|
+
onSelect: async (option, session) => {
|
|
445
|
+
const live = sessionFor(session);
|
|
446
|
+
if (live === void 0) throw new Error("this session is not materialized yet");
|
|
447
|
+
const result = await live.command(`/permission ${option.id}`);
|
|
448
|
+
if (!result.ok) throw new Error(`permission switch failed: ${result.error.code}: ${result.error.message}`);
|
|
449
|
+
if (!result.value.matched) throw new Error("the host offers no /permission command");
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}), "ui-permission: /permission decoration");
|
|
453
|
+
}
|
|
454
|
+
//#endregion
|
|
455
|
+
exports.apply = apply;
|
|
456
|
+
exports.inject = inject;
|
|
457
|
+
return module.exports;
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
//# sourceMappingURL=client.js.map
|