dsh-x-core 0.1.21 → 0.1.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/assets/dsh-preview.png +0 -0
  2. package/assets/dsh.ico +0 -0
  3. package/assets/icon.ico +0 -0
  4. package/assets/tray.ico +0 -0
  5. package/assets/tray.png +0 -0
  6. package/core-npm.js +201 -183
  7. package/desktop-plugins.js +86 -0
  8. package/desktop.js +200 -0
  9. package/filemanager-base.js +7 -8
  10. package/filemanager-linux.js +124 -0
  11. package/filemanager.js +4 -7
  12. package/native-notify.js +74 -0
  13. package/node/node +2 -1
  14. package/package.json +1 -1
  15. package/packs/dsh-x-workbench/README.md +61 -0
  16. package/packs/dsh-x-workbench/dspack.json +4 -0
  17. package/packs/dsh-x-workbench/home/skills/agent-browser/LICENSE-APACHE-2.0.txt +202 -0
  18. package/packs/dsh-x-workbench/home/skills/agent-browser/NOTICE.md +6 -0
  19. package/packs/dsh-x-workbench/home/skills/agent-browser/SKILL.md +697 -0
  20. package/packs/dsh-x-workbench/home/skills/agent-browser/references/authentication.md +313 -0
  21. package/packs/dsh-x-workbench/home/skills/agent-browser/references/commands.md +300 -0
  22. package/packs/dsh-x-workbench/home/skills/agent-browser/references/profiling.md +120 -0
  23. package/packs/dsh-x-workbench/home/skills/agent-browser/references/proxy-support.md +194 -0
  24. package/packs/dsh-x-workbench/home/skills/agent-browser/references/session-management.md +201 -0
  25. package/packs/dsh-x-workbench/home/skills/agent-browser/references/snapshot-refs.md +229 -0
  26. package/packs/dsh-x-workbench/home/skills/agent-browser/references/video-recording.md +173 -0
  27. package/packs/dsh-x-workbench/home/skills/agent-browser/templates/authenticated-session.sh +105 -0
  28. package/packs/dsh-x-workbench/home/skills/agent-browser/templates/capture-workflow.sh +69 -0
  29. package/packs/dsh-x-workbench/home/skills/agent-browser/templates/form-automation.sh +62 -0
  30. package/packs/dsh-x-workbench/home/skills/electron/LICENSE-APACHE-2.0.txt +202 -0
  31. package/packs/dsh-x-workbench/home/skills/electron/NOTICE.md +6 -0
  32. package/packs/dsh-x-workbench/home/skills/electron/SKILL.md +243 -0
  33. package/packs/dsh-x-workbench/manifest.json +35 -0
  34. package/perf/patch-hooks.mjs +14 -1
  35. package/perf/plugin-profile.mjs +204 -0
  36. package/perf/register.mjs +4 -0
  37. package/platform.js +2 -1
  38. package/public/booting.html +475 -0
  39. package/public/favicon.ico +0 -0
  40. package/public/favicon.png +0 -0
  41. package/public/icon.png +0 -0
  42. package/public/index.html +9277 -8173
  43. package/public/internal-tabs.js +45 -41
  44. package/public/launcher.css +285 -98
  45. package/public/mascot.js +1 -1
  46. package/public/theme.css +33 -6
  47. package/public/water.js +1 -1
  48. package/registry.js +38 -3
  49. package/server.js +1060 -119
  50. package/settings.js +78 -1
package/desktop.js ADDED
@@ -0,0 +1,200 @@
1
+ /**
2
+ * 插件桌面 API(/api/desktop/*)的请求校验。
3
+ *
4
+ * 插件跑在 dsh 子进程里,拿不到 Electron;能力走本机 HTTP:插件 → 管理服务 → 外壳的
5
+ * host.desktop(见 shell/main.mjs)。这个文件只决定「什么请求能过去、长度上限多少」,
6
+ * 真正执行 Notification / dialog / clipboard 的代码在外壳里。
7
+ *
8
+ * 不许 import Electron,也不许 import shell/:核心和外壳是分开更新的两层,核心目录
9
+ * (resources/core 或用户目录 core/current)里没有 shell/,外壳目录里也没有核心模块。
10
+ * 外壳侧另有 shell/desktop.mjs 做它自己的门控(通知开关、节流、Electron 对话框选项)。
11
+ */
12
+ import { isAbsolute } from 'node:path'
13
+
14
+ /** 协议版本:插件可以按 GET /api/desktop 的 api 字段决定用哪套接口。 */
15
+ export const DESKTOP_API_VERSION = 1
16
+
17
+ /** 外壳能做的事。没有 Electron 外壳时 GET 会返回空数组。 */
18
+ export const DESKTOP_CAPABILITIES = Object.freeze(['notify', 'open', 'reveal', 'clipboard', 'dialog'])
19
+
20
+ /**
21
+ * 请求上限。通知是给人看的,不是日志通道;剪贴板也不该被拿来做文件传输。
22
+ * 数字写在这里而不是外壳里:校验发生在核心,外壳按拿到的干净数据执行。
23
+ */
24
+ export const DESKTOP_LIMITS = Object.freeze({
25
+ title: 120,
26
+ body: 800,
27
+ url: 2048,
28
+ text: 100_000,
29
+ path: 4096,
30
+ filters: 8,
31
+ extensions: 10,
32
+ filterName: 60,
33
+ buttons: 4,
34
+ button: 40,
35
+ message: 500,
36
+ detail: 2000,
37
+ })
38
+
39
+ /** 单行文本:控制字符变空格,连续空白压成一个,别让标题把通知撑成两行。 */
40
+ function oneLine(value, max) {
41
+ return String(value ?? '')
42
+ .replace(/[\u0000-\u001f\u007f]+/g, ' ')
43
+ .replace(/\s+/g, ' ')
44
+ .trim()
45
+ .slice(0, max)
46
+ }
47
+
48
+ /** 多行文本:保留换行与制表,掉其余控制字符(通知正文可以有多段)。 */
49
+ function multiLine(value, max) {
50
+ return String(value ?? '')
51
+ .replace(/\r\n?/g, '\n')
52
+ .replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, '')
53
+ .trim()
54
+ .slice(0, max)
55
+ }
56
+
57
+ /** 路径文本:只去控制字符和首尾空白,不压空格——路径里的空格是内容,不是格式。 */
58
+ function pathText(value, max = DESKTOP_LIMITS.path) {
59
+ return String(value ?? '')
60
+ .replace(/[\u0000-\u001f\u007f]/g, '')
61
+ .trim()
62
+ .slice(0, max)
63
+ }
64
+
65
+ /** 只认 http(s):`file:` / `javascript:` / `data:` 都不能进系统浏览器或标签页。 */
66
+ function httpUrl(value) {
67
+ const text = String(value ?? '').trim()
68
+ if (!text || text.length > DESKTOP_LIMITS.url) return ''
69
+ try {
70
+ const url = new URL(text)
71
+ return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : ''
72
+ } catch {
73
+ return ''
74
+ }
75
+ }
76
+
77
+ /** Electron 对话框的筛选器:扩展名不带点、只留字母数字和 `*`(全部文件)。 */
78
+ function fileFilters(value) {
79
+ if (!Array.isArray(value)) return []
80
+ const filters = []
81
+ for (const item of value.slice(0, DESKTOP_LIMITS.filters)) {
82
+ if (!item || typeof item !== 'object') continue
83
+ const extensions = (Array.isArray(item.extensions) ? item.extensions : [])
84
+ .slice(0, DESKTOP_LIMITS.extensions)
85
+ .map((ext) => String(ext ?? '').trim().replace(/^\./, '').toLowerCase())
86
+ .filter((ext) => /^[a-z0-9*]+$/.test(ext))
87
+ if (!extensions.length) continue
88
+ filters.push({ name: oneLine(item.name, DESKTOP_LIMITS.filterName) || extensions.join('、'), extensions })
89
+ }
90
+ return filters
91
+ }
92
+
93
+ /** 按钮/默认项的下标:越界或非整数就退回给定的默认值。 */
94
+ function boundedIndex(value, length, fallback) {
95
+ const index = Number(value)
96
+ return Number.isInteger(index) && index >= 0 && index < length ? index : fallback
97
+ }
98
+
99
+ function parseNotify(input) {
100
+ const title = oneLine(input.title, DESKTOP_LIMITS.title)
101
+ const body = multiLine(input.body, DESKTOP_LIMITS.body)
102
+ if (!title && !body) throw new Error('通知要有标题或内容')
103
+ const rawUrl = String(input.url ?? '').trim()
104
+ const url = rawUrl ? httpUrl(rawUrl) : ''
105
+ if (rawUrl && !url) throw new Error('通知的点击地址必须是 http(s) 链接')
106
+ return {
107
+ action: 'notify',
108
+ title: title || 'DSH-X',
109
+ body,
110
+ // 插件只能把通知关小声,不能打开用户关掉的提示音;最终静音与否由外壳按设置决定。
111
+ silent: input.silent === true,
112
+ url,
113
+ }
114
+ }
115
+
116
+ function parseOpen(input) {
117
+ const url = httpUrl(input.url)
118
+ if (!url) throw new Error('只能打开 http(s) 链接')
119
+ return { action: 'open', url }
120
+ }
121
+
122
+ function parseReveal(input) {
123
+ const path = pathText(input.path)
124
+ if (!path) throw new Error('要给一个路径')
125
+ if (!isAbsolute(path)) throw new Error('路径必须是绝对路径')
126
+ return { action: 'reveal', path }
127
+ }
128
+
129
+ function parseClipboard(input) {
130
+ if (typeof input.text !== 'string') throw new Error('text 必须是字符串')
131
+ if (input.text.length > DESKTOP_LIMITS.text) throw new Error(`剪贴板内容超过 ${DESKTOP_LIMITS.text} 个字符`)
132
+ return { action: 'clipboard', text: input.text }
133
+ }
134
+
135
+ const MESSAGE_TYPES = new Set(['none', 'info', 'warning', 'error', 'question'])
136
+
137
+ /**
138
+ * 文件/消息对话框。三种 kind 共用一条路由:插件的用法只有「选 / 存 / 问」三种,
139
+ * 拆成三条只会让客户端多写两个分支。
140
+ */
141
+ function parseDialog(input) {
142
+ const kind = String(input.kind ?? '')
143
+ if (kind !== 'open' && kind !== 'save' && kind !== 'message') throw new Error('kind 只能是 open / save / message')
144
+ if (kind === 'message') {
145
+ const message = multiLine(input.message, DESKTOP_LIMITS.message)
146
+ if (!message) throw new Error('对话框要有 message')
147
+ const buttons = (Array.isArray(input.buttons) ? input.buttons : [])
148
+ .slice(0, DESKTOP_LIMITS.buttons)
149
+ .map((label) => oneLine(label, DESKTOP_LIMITS.button))
150
+ .filter(Boolean)
151
+ const options = {
152
+ type: MESSAGE_TYPES.has(input.type) ? input.type : 'info',
153
+ message,
154
+ detail: multiLine(input.detail, DESKTOP_LIMITS.detail),
155
+ buttons,
156
+ }
157
+ if (buttons.length) {
158
+ options.defaultId = boundedIndex(input.defaultId, buttons.length, 0)
159
+ options.cancelId = boundedIndex(input.cancelId, buttons.length, buttons.length - 1)
160
+ }
161
+ return { action: 'dialog', kind: 'message', options }
162
+ }
163
+
164
+ const options = {}
165
+ const title = oneLine(input.title, DESKTOP_LIMITS.title)
166
+ if (title) options.title = title
167
+ // 保存对话框的 defaultPath 可以只是个文件名,所以这里不要求绝对路径。
168
+ const defaultPath = pathText(input.defaultPath)
169
+ if (defaultPath) options.defaultPath = defaultPath
170
+
171
+ if (kind === 'open') {
172
+ const directory = input.directory === true
173
+ const properties = [directory ? 'openDirectory' : 'openFile']
174
+ if (input.multiple === true) properties.push('multiSelections')
175
+ options.properties = properties
176
+ }
177
+ // 目录选择不吃筛选器;Electron 传了也会忽略,干脆不传。
178
+ const filters = fileFilters(input.filters)
179
+ if (filters.length && !(kind === 'open' && input.directory === true)) options.filters = filters
180
+ return { action: 'dialog', kind, options }
181
+ }
182
+
183
+ const PARSERS = {
184
+ notify: parseNotify,
185
+ open: parseOpen,
186
+ reveal: parseReveal,
187
+ clipboard: parseClipboard,
188
+ dialog: parseDialog,
189
+ }
190
+
191
+ /**
192
+ * 路由里的 action + JSON 正文 → 给外壳的干净请求;不认识的 action 返回 null。
193
+ * 校验失败直接抛(路由转 400),错误文案是给插件作者看的。
194
+ */
195
+ export function parseDesktopRequest(action, input) {
196
+ const parser = PARSERS[String(action ?? '')]
197
+ if (!parser) return null
198
+ const body = input && typeof input === 'object' && !Array.isArray(input) ? input : {}
199
+ return parser(body)
200
+ }
@@ -15,14 +15,13 @@ import { RUNTIME_NODE } from './platform.js'
15
15
  * 里,每处各写一次 `process.platform === 'win32' ? … : …`,加一个平台就得把整份仓库
16
16
  * 重新翻一遍。现在业务代码只认 `fileManager.xxx()`,平台差异全压在实现类里。
17
17
  *
18
- * 实现类分开打包:`filemanager-windows.js` 只进 Windows 安装包,`filemanager-mac.js`
19
- * 只进 macOS 的 .app(见 scripts/pack-common.mjs 的 APP_FILES)。所以这里只能用动态
20
- * import —— 静态 import 会在「另一套实现没被打进来」的那一侧直接报模块找不到。
18
+ * 实现类都随核心包发:Windows / mac / Linux 各一套,运行时由 filemanager.js
19
+ * 动态 import 当前平台那一套;核心 npm 包本身是跨平台的(见 scripts/pack-common.mjs
20
+ * 的 FILE_MANAGERS)。
21
21
  *
22
- * 要加 Linux:照着两个实现类写一个 `filemanager-linux.js`(整份契约都在下面这个基类
23
- * 的注释里),在 `pickFileManager()` 里挂上,再把它加进 `APP_FILES` 的平台分支。
24
- * 在那之前 Linux 落到 PosixFileManager:xdg-open 能用,系统对话框和自启直接报不支持——
25
- * 和这次重构之前的行为一致。
22
+ * 要加新平台:照着三个实现类写一个 `filemanager-<平台>.js`(整份契约都在下面这个基类
23
+ * 的注释里),在 `pickFileManager()` 里挂上,再把它加进 FILE_MANAGERS。没有专门实现的
24
+ * POSIX 平台落到 PosixFileManager:xdg-open 能用,系统对话框和自启直接报不支持。
26
25
  */
27
26
  export class FileManager {
28
27
  /**
@@ -184,5 +183,5 @@ export class FileManager {
184
183
  ignoreOpenError() { return false }
185
184
  }
186
185
 
187
- /** 还没有专门实现的平台(现在是 Linux):xdg-open 这条路能走,其余照契约报不支持。 */
186
+ /** 没有专门实现的其他 POSIX 平台:xdg-open 这条路能走,其余照契约报不支持。 */
188
187
  export class PosixFileManager extends FileManager {}
@@ -0,0 +1,124 @@
1
+ import { mkdir, rm, writeFile } from 'node:fs/promises'
2
+ import { dirname, join } from 'node:path'
3
+ import { PosixFileManager } from './filemanager-base.js'
4
+ import { APP_DIR_NAME, IN_ELECTRON } from './platform.js'
5
+
6
+ /** 对话框等用户的时间:目录 5 分钟、文件 10 分钟,和其他平台一致。 */
7
+ const DIRECTORY_TIMEOUT = 5 * 60 * 1000
8
+ const FILE_TIMEOUT = 10 * 60 * 1000
9
+
10
+ /**
11
+ * Linux 这一套:xdg-open、zenity/kdialog 的系统对话框、XDG autostart。
12
+ *
13
+ * 目录放在 $XDG_CONFIG_HOME/DSH(默认 ~/.config/DSH),和 AppImage 的只读挂载分开。
14
+ * 对话框优先 zenity,其次 kdialog;两个都没装时提示用户直接输入路径。
15
+ * 自启写 ~/.config/autostart/dsh-x.desktop,不依赖 systemd。
16
+ */
17
+ export class LinuxFileManager extends PosixFileManager {
18
+ constructor(deps = {}) {
19
+ super(deps)
20
+ this.writeFile = deps.writeFile || writeFile
21
+ this.mkdir = deps.mkdir || mkdir
22
+ this.rm = deps.rm || rm
23
+ }
24
+
25
+ get platform() { return 'linux' }
26
+
27
+ get directoryOpener() { return 'xdg-open' }
28
+
29
+ /** $XDG_CONFIG_HOME/DSH(默认 ~/.config/DSH)。 */
30
+ userAppDir() {
31
+ return join(this.env.XDG_CONFIG_HOME || join(this.home, '.config'), APP_DIR_NAME)
32
+ }
33
+
34
+ /**
35
+ * 登录自启要执行的外壳:AppImage 用 APPIMAGE 本身(挂载目录每次启动都会变),
36
+ * 安装版用当前 Electron 可执行文件;源码运行返回空串。
37
+ */
38
+ launcherExecutable() {
39
+ const appImage = String(this.env.APPIMAGE || '').trim()
40
+ if (appImage && this.exists(appImage)) return appImage
41
+ if (IN_ELECTRON && !process.defaultApp) return process.execPath
42
+ return ''
43
+ }
44
+
45
+ /** XDG autostart 的 .desktop 文件。 */
46
+ get autoStartPath() {
47
+ return join(this.env.XDG_CONFIG_HOME || join(this.home, '.config'), 'autostart', 'dsh-x.desktop')
48
+ }
49
+
50
+ autoStartEntry() {
51
+ return [
52
+ '[Desktop Entry]',
53
+ 'Type=Application',
54
+ 'Name=DSH-X',
55
+ 'Comment=DeepSeek Harness launcher',
56
+ `Exec=${this.launchCommand()}`,
57
+ 'Terminal=false',
58
+ 'X-GNOME-Autostart-enabled=true',
59
+ '',
60
+ ].join('\n')
61
+ }
62
+
63
+ async autoStartEnabled() {
64
+ return this.exists(this.autoStartPath)
65
+ }
66
+
67
+ async setAutoStart(enabled) {
68
+ if (!enabled) {
69
+ await this.rm(this.autoStartPath, { force: true })
70
+ return
71
+ }
72
+ await this.mkdir(dirname(this.autoStartPath), { recursive: true })
73
+ await this.writeFile(this.autoStartPath, this.autoStartEntry())
74
+ }
75
+
76
+ async pickDirectory(initialPath = '') {
77
+ const start = initialPath && this.exists(initialPath) ? initialPath : ''
78
+ const zenity = await this.dialog('zenity', [
79
+ '--file-selection', '--directory', '--title=选择目录',
80
+ ...(start ? [`--filename=${start}${start.endsWith('/') ? '' : '/'}`] : []),
81
+ ], DIRECTORY_TIMEOUT)
82
+ if (zenity !== null) return zenity
83
+ const kdialog = await this.dialog('kdialog', ['--getexistingdirectory', start || this.home, '--title', '选择目录'], DIRECTORY_TIMEOUT)
84
+ if (kdialog !== null) return kdialog
85
+ throw new Error('目录选择需要安装 zenity 或 kdialog;也可以直接输入路径')
86
+ }
87
+
88
+ async pickFile({ save = false, defaultName = '', title = '', prompt = '' } = {}) {
89
+ const ask = prompt || title || (save ? '选择保存位置' : '选择文件')
90
+ const zenity = await this.dialog('zenity', [
91
+ '--file-selection', '--title', ask,
92
+ ...(save ? ['--save', '--confirm-overwrite'] : []),
93
+ ...(defaultName ? [`--filename=${defaultName}`] : []),
94
+ ], FILE_TIMEOUT)
95
+ if (zenity !== null) return zenity
96
+ const kdialog = await this.dialog('kdialog', save
97
+ ? ['--getsavefilename', defaultName || this.home, '--title', ask]
98
+ : ['--getopenfilename', this.home, '--title', ask], FILE_TIMEOUT)
99
+ if (kdialog !== null) return kdialog
100
+ throw new Error('文件选择需要安装 zenity 或 kdialog;也可以直接输入路径')
101
+ }
102
+
103
+ async revealPath(path) {
104
+ await this.openWith('xdg-open', [dirname(String(path))], { windowsHide: true })
105
+ }
106
+
107
+ async openUrl(url) {
108
+ await this.openWith('xdg-open', [String(url)], {})
109
+ }
110
+
111
+ /**
112
+ * 跑 zenity / kdialog:返回路径;用户取消返回空串;命令不存在返回 null(换下一个)。
113
+ * 两个都没装时调用方给出明确提示。
114
+ */
115
+ async dialog(command, args, timeout) {
116
+ try {
117
+ return String(await this.exec(command, args, { timeout, encoding: 'utf8' })).trim()
118
+ } catch (error) {
119
+ if (error?.code === 'ENOENT') return null
120
+ if (error?.code === 1) return ''
121
+ throw error
122
+ }
123
+ }
124
+ }
package/filemanager.js CHANGED
@@ -1,23 +1,20 @@
1
- import { IS_MAC, IS_WINDOWS } from './platform.js'
1
+ import { IS_LINUX, IS_MAC, IS_WINDOWS } from './platform.js'
2
2
  import { FileManager, PosixFileManager } from './filemanager-base.js'
3
3
 
4
4
  /**
5
5
  * 按平台挑一套文件管理实现,业务代码只认这里导出的 `fileManager`。
6
6
  *
7
- * 两套实现都随核心包发(核心 npm 包是跨平台的,见 scripts/pack-common.mjs 的
7
+ * 三套实现都随核心包发(核心 npm 包是跨平台的,见 scripts/pack-common.mjs 的
8
8
  * FILE_MANAGERS);运行时用动态 import 只加载当前平台那一套。这样同一个 dsh-x-core
9
- * 在 Windows 和 mac 上都能用,只有外壳/Electron 按平台分开。
9
+ * 在 Windows / mac / Linux 上都能用,只有外壳/Electron 按平台分开。
10
10
  *
11
11
  * 契约、基类和 Linux 的兜底实现都在 filemanager-base.js:实现类静态 import 的是它,
12
12
  * 不是本文件——本文件有顶层 await,实现类再回头 import 它就会死锁。
13
- *
14
- * 要加 Linux:照着两个实现类写一个 `filemanager-linux.js`(整份契约在基类的注释里),
15
- * 在下面挂上,再把它加进 FILE_MANAGERS。在那之前 Linux 落到 PosixFileManager:
16
- * xdg-open 能用,系统对话框和自启直接报不支持——和这次重构之前的行为一致。
17
13
  */
18
14
  async function pickFileManager() {
19
15
  if (IS_WINDOWS) return (await import('./filemanager-windows.js')).WindowsFileManager
20
16
  if (IS_MAC) return (await import('./filemanager-mac.js')).MacFileManager
17
+ if (IS_LINUX) return (await import('./filemanager-linux.js')).LinuxFileManager
21
18
  return PosixFileManager
22
19
  }
23
20
 
@@ -0,0 +1,74 @@
1
+ /**
2
+ * 原生通知总开关:设置里的「任务通知」同时管 `dsh-x-desktop-notify` 的 loader 行。
3
+ *
4
+ * 外壳本来就按这个开关拦截 `/api/desktop/notify`;这里再把插件行一并停掉,让「关」
5
+ * 变成插件不再监听会话事件,而不只是通知被外壳丢掉。开 = 删掉禁用块,关 = 写禁用块。
6
+ * 不卸载包、不动依赖和别的插件开关。
7
+ *
8
+ * 只管装了下面两个包之一的环境:单体插件(dsh-x-desktop-notify)或桌面组
9
+ * (dsh-x-desktop-bundle)。没装的环境不会被写上过期覆盖,以后装组也不会一上来就是停用。
10
+ */
11
+ import { existsSync, readdirSync, readFileSync } from 'node:fs'
12
+ import { join } from 'node:path'
13
+ import { disableRowId, enableRowId } from './plugins.js'
14
+
15
+ /** 原生通知的 loader 行 id:插件自己的 patch 与桌面组 patch 用的是同一个 id。 */
16
+ export const NATIVE_NOTIFY_ROW_ID = 'x-desktop-notify'
17
+
18
+ /** 装了其中任意一个包的环境才归这个开关管。 */
19
+ export const NATIVE_NOTIFY_PACKAGES = Object.freeze(['dsh-x-desktop-notify', 'dsh-x-desktop-bundle'])
20
+
21
+ /**
22
+ * 这个 profile 装没装原生通知(单体或组)。
23
+ * @param {object} manifest - profile 的 package.json 内容。
24
+ * @returns {boolean} 装了为 true。
25
+ */
26
+ export function profileHasNativeNotify(manifest) {
27
+ const dependencies = manifest?.dependencies && typeof manifest.dependencies === 'object' ? manifest.dependencies : {}
28
+ return NATIVE_NOTIFY_PACKAGES.some((name) => Object.hasOwn(dependencies, name))
29
+ }
30
+
31
+ /**
32
+ * 把原生通知开关落到一个 DSH_HOME 下的所有 profile。
33
+ *
34
+ * 单个环境读不动或补丁层写不进去(不是合法条目数组)只记失败,不影响其它环境——
35
+ * 开关是全局动作,不能因为一个坏环境就一个都关不掉。
36
+ *
37
+ * @param {string} home - DSH_HOME。
38
+ * @param {boolean} enabled - true 恢复插件行;false 停用。
39
+ * @returns {{ home: string, changed: number, profiles: string[], failed: { profile: string, error: string }[] }} 改动结果。
40
+ */
41
+ export function applyNativeNotify(home, enabled) {
42
+ const result = { home, changed: 0, profiles: [], failed: [] }
43
+ const dir = join(home, 'profiles')
44
+ let names = []
45
+ try {
46
+ names = readdirSync(dir, { withFileTypes: true })
47
+ .filter((entry) => entry.isDirectory() && !entry.name.startsWith('.') && entry.name !== 'node_modules')
48
+ .map((entry) => entry.name)
49
+ } catch {
50
+ return result
51
+ }
52
+ for (const name of names) {
53
+ const profileDir = join(dir, name)
54
+ const file = join(profileDir, 'package.json')
55
+ if (!existsSync(file)) continue
56
+ let manifest
57
+ try {
58
+ manifest = JSON.parse(readFileSync(file, 'utf8'))
59
+ } catch {
60
+ continue
61
+ }
62
+ if (!profileHasNativeNotify(manifest)) continue
63
+ try {
64
+ const outcome = enabled ? enableRowId(profileDir, NATIVE_NOTIFY_ROW_ID) : disableRowId(profileDir, NATIVE_NOTIFY_ROW_ID)
65
+ if (outcome.changed) {
66
+ result.changed += 1
67
+ result.profiles.push(name)
68
+ }
69
+ } catch (error) {
70
+ result.failed.push({ profile: name, error: error instanceof Error ? error.message : String(error) })
71
+ }
72
+ }
73
+ return result
74
+ }
package/node/node CHANGED
@@ -2,4 +2,5 @@
2
2
  if [ -n "$DSH_ELECTRON_BIN" ]; then ELECTRON_RUN_AS_NODE=1 exec "$DSH_ELECTRON_BIN" "$@"; fi
3
3
  dir="$(cd "$(dirname "$0")" && pwd)"
4
4
  if [ -x "$dir/../../../DSH.exe" ]; then ELECTRON_RUN_AS_NODE=1 exec "$dir/../../../DSH.exe" "$@"; fi
5
- ELECTRON_RUN_AS_NODE=1 exec "$dir/../../../MacOS/DSH" "$@"
5
+ if [ -x "$dir/../../../MacOS/DSH" ]; then ELECTRON_RUN_AS_NODE=1 exec "$dir/../../../MacOS/DSH" "$@"; fi
6
+ ELECTRON_RUN_AS_NODE=1 exec "$dir/../../../DSH" "$@"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dsh-x-core",
3
3
  "productName": "DSH",
4
- "version": "0.1.21",
4
+ "version": "0.1.23",
5
5
  "private": false,
6
6
  "type": "module",
7
7
  "main": "server.js",
@@ -0,0 +1,61 @@
1
+ # DSH-X 桌面工作台
2
+
3
+ DSH-X 的第二套整合包:**把 [dsh-tauri 桌面版](https://github.com/dsh-tauri/deepseek-harness-desktop) 最常用的几项能力,在纯 dsh 生态里凑齐;再把 [ZCode](https://github.com/zai-org/ZCode) 的两份通用技能带过来。** 装它 = 得到一个独立 profile(默认名 `workbench`),和现有环境互不打扰。
4
+
5
+ > 为什么不是直接装 dsh-tauri 的插件:dsh-tauri 的 12 个内置插件都声明了 `external: ["dsh-tauri/client"]`,依赖 Tauri 宿主桥,在纯 dsh(包括 DSH-X 的 Electron 壳)里加载不到模块。所以这里选的是生态里同能力的独立插件,不是移植。
6
+
7
+ ## 里面有什么
8
+
9
+ ### 插件(装进 `workbench`,可在插件页单独开关)
10
+
11
+ | 插件 | 干什么 | 对应 dsh-tauri 的 |
12
+ |---|---|---|
13
+ | [`dsh-better-sidebar`](https://github.com/omdsh-dev/DSH-better-sidebar) | 右侧栏完整工作台:懒加载文件树(Git 状态着色、目录监听、全局搜索、拖拽上传)、CodeMirror 编辑器、终端、Source Control(暂存/提交/提交图)、本会话 AI 改动透镜、子代理 | 可选预设 DSH Better Sidebar |
14
+ | [`@cerbur/clutch-dsh-worktree`](https://github.com/Cerbur/clutch-dsh) | 按 Workspace → Worktree → Session 分组的 Git 工作树视图;工作树关系存 Host 自有文件,不改 dsh 的会话元数据 | `dsh-tauri-worktree` |
15
+ | [`dsh-plugin-cron-scheduler`](https://github.com/LittleBlackTong/dsh-plugin-cron) | 定时任务:cron 表达式或侧栏表单建任务,到点向新建/固定会话注入一条 user 消息触发完整 agent 轮次;有执行历史、手动运行、并发与错过不补跑保护 | `dsh-tauri-scheduler` |
16
+ | [`dsh-archived-conversations`](https://github.com/AKS1st/dsh-archived-conversations) | 设置页里的「已归档对话」列表与只读预览(最近 6 条消息)。dsh 目前没有取消归档 API,所以只读、不恢复 | `dsh-tauri-archive` |
17
+ | [`dsh-plugin-notify-sounds`](https://github.com/BillCx330/dsh-plugin-notify-sounds) | 需要你决策或任务完成时的提示音 + 系统通知(点通知跳回窗口),任务栏标题标记「等待你 / 已完成」,看过就安静 | `dsh-tauri-notification` |
18
+
19
+ ### 技能(写到 `~/.dsh/skills`,所有 profile 共用)
20
+
21
+ | 技能 | 干什么 | 来源 |
22
+ |---|---|---|
23
+ | `agent-browser` | 浏览器自动化 CLI:导航、填表、点击、截图、抓数据、测 Web 应用;模型按 `agent-browser` 命令驱动 | ZCode 收录自 vercel-labs/agent-browser(Apache-2.0) |
24
+ | `electron` | 通过 Chrome DevTools Protocol 驱动 Electron 应用(VS Code、Slack 等);对 DSH-X 自己的 Electron 壳同样适用 | 同上(ZCode 的 `electron` 技能) |
25
+
26
+ `agent-browser` / `electron` 需要本机有 CLI:`npm i -g agent-browser`、`brew install agent-browser` 或 `cargo install agent-browser`,也可以直接 `npx agent-browser`。技能目录里附了完整参考文档和脚本模板,模型按需读,不会一次性灌进上下文。
27
+
28
+ ## 和「DSH-X 推荐整合包」的区别
29
+
30
+ - 推荐包管的是**环境**:配置备份/迁移、记忆、同步、装饰。
31
+ - 这个包管的是**干活**:编辑与 Git、工作树、定时任务、归档、通知,外加浏览器/Electron 自动化技能。
32
+ - 两者装到不同 profile 可以并存;技能同名时后装的覆盖先装的(安装前会备份)。
33
+
34
+ ## 怎么装
35
+
36
+ 三种方式,任选:
37
+
38
+ 1. **本地文件**:把 `.dspack` 拖进插件页的「整合包」区(或点安装选文件)。
39
+ 2. **直链**:填这个包的下载地址。
40
+ 3. **GitHub 仓库**:填 `owner/repo`(取最新 Release 里的 `.dspack`)。
41
+
42
+ 装之前会把「要装什么、要改哪些文件、什么不会装」列给你看,确认了才动手;装失败自动回滚。装完在插件页切到 `workbench`、重启 dsh 生效;技能在「技能」页能看到,改完不用重启。
43
+
44
+ ## 需要什么
45
+
46
+ - dsh `>= 0.2.1-rc.1 < 0.3.0`(`dsh-better-sidebar` 从这个版本起支持)。
47
+ - Windows / macOS / Linux;`better-sidebar` 的终端用 dsh 自带的能力,不需要额外 shell 配置。
48
+ - 浏览器/Electron 自动化要另装 `agent-browser` CLI,Electron 应用启动时要带 `--remote-debugging-port`。
49
+ - 定时任务按 dsh 进程存活计时:进程关着的时间段不补跑。
50
+
51
+ ## 许可与出处
52
+
53
+ - 整合包本身 MIT。
54
+ - `agent-browser`、`electron` 技能:Copyright 2025 Vercel Inc.,Apache-2.0;本副本取自 zai-org/ZCode(Apache-2.0,commit `3c5b227649371507ddc4eb46ac5133afe6db1cab`)。DSH-X 原样收录未修改,每个技能目录里附了 `NOTICE.md` 与许可全文。
55
+ - 五个插件各自许可见对应 npm 包。
56
+
57
+ ## 自己打包
58
+
59
+ ```sh
60
+ node scripts/make-pack.mjs packs/dsh-x-workbench # 产出 release/packs/dsh-x-workbench-1.0.0.dspack
61
+ ```
@@ -0,0 +1,4 @@
1
+ {
2
+ "format": "dspack",
3
+ "version": 3
4
+ }