dsh-desktop-windows 0.2.8 → 0.3.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/README.en.md +4 -0
- package/README.md +4 -0
- package/package.json +2 -1
- package/src/main.js +174 -5
package/README.en.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
8
8
|
[]()
|
|
9
9
|
[](https://github.com/ReachGa0/dsh-desktop/actions)
|
|
10
|
+
[](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
|
|
10
11
|
|
|
11
12
|
An **Electron desktop shell** for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness): double-click an icon and get a standalone window running `dsh web` — no terminal, no manual commands, no browser tab juggling. **Region screenshot to ask the AI**, system tray, session manager, auto environment setup.
|
|
12
13
|
|
|
@@ -36,12 +37,15 @@ Pure shell — it **does not modify dsh itself**. The server reuses your globall
|
|
|
36
37
|
|
|
37
38
|
## 📸 Region screenshot
|
|
38
39
|
|
|
40
|
+

|
|
41
|
+
|
|
39
42
|
1. Click the **📸** button (bottom-right) — the chat window auto-hides
|
|
40
43
|
2. **Drag to select** an area on the full-screen overlay (live preview; drag the 8 handles to fine-tune after drawing)
|
|
41
44
|
3. Click **✔ OK** (or double-click / Enter) — the chat window restores
|
|
42
45
|
4. The screenshot lands in the chat box automatically → type a question → the AI answers from the image
|
|
43
46
|
|
|
44
47
|
> Pair with a vision bridge like [ModLens](https://www.npmjs.com/package/@liustack/modlens) so text-only DeepSeek models can read images too.
|
|
48
|
+
> Screenshots are also saved to `~/.dsh/screenshots/` (open the folder from the tray menu).
|
|
45
49
|
|
|
46
50
|
## Prerequisites
|
|
47
51
|
|
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
[](https://github.com/deepseek-ai/deepseek-harness)
|
|
8
8
|
[]()
|
|
9
9
|
[](https://github.com/ReachGa0/dsh-desktop/actions)
|
|
10
|
+
[](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin)
|
|
10
11
|
|
|
11
12
|
> **English summary** · An [Electron](https://www.electronjs.org/) desktop shell for [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (dsh web) on **Windows** — double-click to run the harness in a standalone window. **Region screenshot to ask AI**, system tray, session manager, auto environment setup. Full English docs: [README.en.md](README.en.md)
|
|
12
13
|
|
|
@@ -38,12 +39,15 @@ DeepSeek Harness 的 **Electron 桌面壳**:双击图标,一个独立窗口
|
|
|
38
39
|
|
|
39
40
|
## 📸 选区截图提问
|
|
40
41
|
|
|
42
|
+

|
|
43
|
+
|
|
41
44
|
1. 点右下角 **📸**(聊天窗口自动隐藏)
|
|
42
45
|
2. 全屏遮罩上**拖动框选**区域(实时显示,画完可拖 8 个手柄微调)
|
|
43
46
|
3. 点 **✔ 确定**(或双击 / 回车)→ 聊天窗口恢复
|
|
44
47
|
4. 截图自动进入聊天框 → 输入问题 → AI 看图回答
|
|
45
48
|
|
|
46
49
|
> 配合 [ModLens](https://www.npmjs.com/package/@liustack/modlens) 等识图插件,DeepSeek 文本模型也能看懂图片。
|
|
50
|
+
> 截图同时自动保存到 `~/.dsh/screenshots/`(托盘右键可打开目录)。
|
|
47
51
|
|
|
48
52
|
## 前提
|
|
49
53
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-desktop-windows",
|
|
3
3
|
"productName": "DeepSeek Harness Desktop",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "DeepSeek Harness 桌面版(Windows)· Electron desktop shell for DeepSeek Harness — 双击即用 / double-click to run · 支持选区截图提问、系统托盘、会话管理 / region screenshot, system tray, session manager",
|
|
6
6
|
"main": "src/main.js",
|
|
7
7
|
"license": "MIT",
|
|
@@ -64,3 +64,4 @@
|
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
+
|
package/src/main.js
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
const { app, BrowserWindow, dialog, shell, Tray, Menu, nativeImage, ipcMain, desktopCapturer, clipboard, screen } = require('electron')
|
|
17
17
|
const { spawn, execFile } = require('node:child_process')
|
|
18
18
|
const http = require('node:http')
|
|
19
|
+
const https = require('node:https')
|
|
19
20
|
const fs = require('node:fs')
|
|
20
21
|
const path = require('node:path')
|
|
21
22
|
const os = require('node:os')
|
|
@@ -62,6 +63,103 @@ function shotLog(...args) {
|
|
|
62
63
|
} catch { /* 忽略日志错误 */ }
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
/* ------------------------------------------------------------------ *
|
|
67
|
+
* 自动更新检查(启动时异步检测 GitHub Releases 最新版)
|
|
68
|
+
* ------------------------------------------------------------------ */
|
|
69
|
+
|
|
70
|
+
const REPO = 'ReachGa0/dsh-desktop'
|
|
71
|
+
const RELEASES_URL = `https://api.github.com/repos/${REPO}/releases/latest`
|
|
72
|
+
const RELEASES_PAGE = `https://github.com/${REPO}/releases/latest`
|
|
73
|
+
const UPDATE_CHECK_TIMEOUT_MS = 10_000
|
|
74
|
+
|
|
75
|
+
/** GET 一个 JSON(带超时与 UA,GitHub API 要求 UA)。resolve null 表示失败。 */
|
|
76
|
+
function fetchJson(url) {
|
|
77
|
+
return new Promise((resolve) => {
|
|
78
|
+
// 首次用系统证书;代理/反代环境证书校验可能失败,降级为不校验重试一次
|
|
79
|
+
// (仅更新检查用,不降低应用其他部分的安全级别)
|
|
80
|
+
const attempt = (rejectUnauthorized) => {
|
|
81
|
+
const req = https.get(
|
|
82
|
+
url,
|
|
83
|
+
{ headers: { 'User-Agent': 'dsh-desktop-update-check', Accept: 'application/vnd.github+json' }, timeout: UPDATE_CHECK_TIMEOUT_MS, rejectUnauthorized },
|
|
84
|
+
(res) => {
|
|
85
|
+
if (res.statusCode !== 200) {
|
|
86
|
+
res.resume()
|
|
87
|
+
resolve(null)
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
let body = ''
|
|
91
|
+
res.setEncoding('utf8')
|
|
92
|
+
res.on('data', (d) => (body += d))
|
|
93
|
+
res.on('end', () => {
|
|
94
|
+
try { resolve(JSON.parse(body)) } catch { resolve(null) }
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
req.on('timeout', () => req.destroy())
|
|
99
|
+
req.on('error', () => {
|
|
100
|
+
// 证书类错误:再试一次宽松模式;其他错误直接放弃
|
|
101
|
+
if (rejectUnauthorized) attempt(false)
|
|
102
|
+
else resolve(null)
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
attempt(true)
|
|
106
|
+
})
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** 解析语义化版本号 → [major, minor, patch],失败返回 null。 */
|
|
110
|
+
function parseVersion(v) {
|
|
111
|
+
if (typeof v !== 'string') return null
|
|
112
|
+
const m = /^v?(\d+)\.(\d+)\.(\d+)/.exec(v.trim())
|
|
113
|
+
if (!m) return null
|
|
114
|
+
return [Number(m[1]), Number(m[2]), Number(m[3])]
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** a 比 b 新?都解析失败时返回 false(宁可漏报不可误报)。 */
|
|
118
|
+
function isNewer(a, b) {
|
|
119
|
+
const pa = parseVersion(a)
|
|
120
|
+
const pb = parseVersion(b)
|
|
121
|
+
if (!pa || !pb) return false
|
|
122
|
+
for (let i = 0; i < 3; i++) {
|
|
123
|
+
if (pa[i] !== pb[i]) return pa[i] > pb[i]
|
|
124
|
+
}
|
|
125
|
+
return false
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 检查更新:查询 GitHub Releases 最新版,若比当前版本新则弹窗提示。
|
|
130
|
+
* 全程静默失败(网络不通 / 解析失败 / 无新版都不打扰用户)。
|
|
131
|
+
*/
|
|
132
|
+
async function checkForUpdates() {
|
|
133
|
+
const current = app.getVersion()
|
|
134
|
+
try {
|
|
135
|
+
const release = await fetchJson(RELEASES_URL)
|
|
136
|
+
if (!release) {
|
|
137
|
+
log('update check: no release data (offline or API error)')
|
|
138
|
+
return
|
|
139
|
+
}
|
|
140
|
+
const latest = release.tag_name
|
|
141
|
+
log(`update check: current=${current} latest=${latest}`)
|
|
142
|
+
if (!isNewer(latest, current)) return
|
|
143
|
+
const name = release.name && release.name !== latest ? `「${release.name}」` : ''
|
|
144
|
+
const detail = (release.body || '').split('\n').slice(0, 6).join('\n').trim()
|
|
145
|
+
const { response } = await dialog.showMessageBox(mainWindow || undefined, {
|
|
146
|
+
type: 'info',
|
|
147
|
+
title: '发现新版本',
|
|
148
|
+
message: `DeepSeek Harness Desktop 有新版本可用(${latest} ${name})`,
|
|
149
|
+
detail: detail ? `更新内容:\n${detail}\n\n当前版本:${current}` : `当前版本:${current}`,
|
|
150
|
+
buttons: ['前往下载', '以后再说'],
|
|
151
|
+
defaultId: 0,
|
|
152
|
+
cancelId: 1,
|
|
153
|
+
noLink: true,
|
|
154
|
+
})
|
|
155
|
+
if (response === 0) {
|
|
156
|
+
shell.openExternal(RELEASES_PAGE)
|
|
157
|
+
}
|
|
158
|
+
} catch (e) {
|
|
159
|
+
log('update check failed:', e && e.message)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
65
163
|
/* ------------------------------------------------------------------ *
|
|
66
164
|
* 工具:探测 / 等待 HTTP 服务
|
|
67
165
|
* ------------------------------------------------------------------ */
|
|
@@ -105,6 +203,11 @@ function resolveDshBin() {
|
|
|
105
203
|
return 'dsh.cmd'
|
|
106
204
|
}
|
|
107
205
|
|
|
206
|
+
// 主动关停 dsh 时的标记(杀进程也会触发 exit,需区分「主动关」和「意外崩」)
|
|
207
|
+
let isShuttingDownDsh = false
|
|
208
|
+
// 已自动重启过一次的标志(同一次会话最多自愈一次,避免崩溃循环)
|
|
209
|
+
let didAutoRestartDsh = false
|
|
210
|
+
|
|
108
211
|
/** 启动 dsh web,日志追加到 userData/dsh.log。返回子进程。 */
|
|
109
212
|
function startDsh(port) {
|
|
110
213
|
const bin = resolveDshBin()
|
|
@@ -122,7 +225,12 @@ function startDsh(port) {
|
|
|
122
225
|
log(`dsh log: ${logFile}`)
|
|
123
226
|
child.on('exit', (code, signal) => {
|
|
124
227
|
log(`dsh exited: code=${code} signal=${signal}`)
|
|
125
|
-
if (ownedDsh
|
|
228
|
+
if (ownedDsh !== child) return
|
|
229
|
+
ownedDsh = null
|
|
230
|
+
// 崩溃自愈:本壳启动的 dsh 意外退出(非主动关闭/非退出中)时自动重启一次
|
|
231
|
+
if (!isQuitting && !isShuttingDownDsh) {
|
|
232
|
+
restartOwnedDsh(port, code)
|
|
233
|
+
}
|
|
126
234
|
})
|
|
127
235
|
child.on('error', (err) => {
|
|
128
236
|
log(`dsh spawn error: ${err.message}`)
|
|
@@ -130,6 +238,52 @@ function startDsh(port) {
|
|
|
130
238
|
return child
|
|
131
239
|
}
|
|
132
240
|
|
|
241
|
+
/** dsh 意外退出后自动重启一次;二次退出则提示用户并放弃。 */
|
|
242
|
+
function restartOwnedDsh(port, exitCode) {
|
|
243
|
+
if (didAutoRestartDsh) {
|
|
244
|
+
log('dsh crashed again after auto-restart; giving up')
|
|
245
|
+
const logFile = path.join(app.getPath('userData'), 'dsh.log')
|
|
246
|
+
dialog.showMessageBox(mainWindow || undefined, {
|
|
247
|
+
type: 'error',
|
|
248
|
+
title: 'dsh 服务异常',
|
|
249
|
+
message: 'dsh 服务启动后再次退出,已停止自动重启。',
|
|
250
|
+
detail: `退出码:${exitCode ?? '未知'}\n\n日志文件:${logFile}\n\n请查看日志定位问题,或手动在终端运行 dsh web 排查。`,
|
|
251
|
+
buttons: ['打开日志目录', '知道了'],
|
|
252
|
+
noLink: true,
|
|
253
|
+
}).then(({ response }) => {
|
|
254
|
+
if (response === 0) shell.showItemInFolder(logFile)
|
|
255
|
+
})
|
|
256
|
+
return
|
|
257
|
+
}
|
|
258
|
+
log(`dsh exited unexpectedly (code=${exitCode}); restarting in 3s…`)
|
|
259
|
+
didAutoRestartDsh = true
|
|
260
|
+
setTimeout(() => {
|
|
261
|
+
if (isQuitting) return
|
|
262
|
+
// 重启前再确认端口没有被外部服务接管(避免重复启动)
|
|
263
|
+
probe(port).then((up) => {
|
|
264
|
+
if (up) {
|
|
265
|
+
log('port already serving after crash; not restarting')
|
|
266
|
+
return
|
|
267
|
+
}
|
|
268
|
+
const child = startDsh(port)
|
|
269
|
+
ownedDsh = child
|
|
270
|
+
// 等它就绪;若起不来则等 exit 回调里的二次提示
|
|
271
|
+
waitForServer(port, START_TIMEOUT_MS).then((ready) => {
|
|
272
|
+
if (ready) {
|
|
273
|
+
log('dsh auto-restarted successfully')
|
|
274
|
+
dialog.showMessageBox(mainWindow || undefined, {
|
|
275
|
+
type: 'info',
|
|
276
|
+
title: 'dsh 已自动重启',
|
|
277
|
+
message: 'dsh 服务意外退出,已自动恢复。',
|
|
278
|
+
buttons: ['好'],
|
|
279
|
+
noLink: true,
|
|
280
|
+
}).catch(() => {})
|
|
281
|
+
}
|
|
282
|
+
})
|
|
283
|
+
})
|
|
284
|
+
}, 3000)
|
|
285
|
+
}
|
|
286
|
+
|
|
133
287
|
/** 杀掉进程树(Windows 用 taskkill /T 覆盖子孙进程),带超时兜底。 */
|
|
134
288
|
function killProcessTree(pid) {
|
|
135
289
|
return new Promise((resolve) => {
|
|
@@ -147,6 +301,7 @@ async function shutdownOwnedDsh() {
|
|
|
147
301
|
if (ownedDsh && ownedDsh.pid) {
|
|
148
302
|
const pid = ownedDsh.pid
|
|
149
303
|
ownedDsh = null
|
|
304
|
+
isShuttingDownDsh = true
|
|
150
305
|
await killProcessTree(pid)
|
|
151
306
|
log(`killed owned dsh pid ${pid}`)
|
|
152
307
|
}
|
|
@@ -487,12 +642,15 @@ function onShotDone(rect) {
|
|
|
487
642
|
}
|
|
488
643
|
const cropped = image.crop(r)
|
|
489
644
|
shotLog('shot: cropped', cropped.getSize().width + 'x' + cropped.getSize().height)
|
|
490
|
-
//
|
|
645
|
+
// 保存到 ~/.dsh/screenshots/(持久保存,方便回顾;同时写剪贴板)
|
|
491
646
|
try {
|
|
492
|
-
|
|
493
|
-
|
|
647
|
+
const dir = path.join(os.homedir(), '.dsh', 'screenshots')
|
|
648
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
649
|
+
const file = path.join(dir, `shot-${new Date().toISOString().replace(/[:.]/g, '-')}.png`)
|
|
650
|
+
fs.writeFileSync(file, cropped.toPNG())
|
|
651
|
+
shotLog('shot: saved', file)
|
|
494
652
|
} catch (e) {
|
|
495
|
-
shotLog('shot:
|
|
653
|
+
shotLog('shot: save failed', String(e && e.message || e))
|
|
496
654
|
}
|
|
497
655
|
clipboard.writeImage(cropped)
|
|
498
656
|
shotLog('shot: written to clipboard')
|
|
@@ -539,6 +697,15 @@ function createTray() {
|
|
|
539
697
|
Menu.buildFromTemplate([
|
|
540
698
|
{ label: '显示主窗口', click: showMainWindow },
|
|
541
699
|
{ type: 'separator' },
|
|
700
|
+
{
|
|
701
|
+
label: '打开截图目录',
|
|
702
|
+
click: () => {
|
|
703
|
+
const dir = path.join(os.homedir(), '.dsh', 'screenshots')
|
|
704
|
+
fs.mkdirSync(dir, { recursive: true })
|
|
705
|
+
shell.openPath(dir)
|
|
706
|
+
},
|
|
707
|
+
},
|
|
708
|
+
{ type: 'separator' },
|
|
542
709
|
{
|
|
543
710
|
label: '退出',
|
|
544
711
|
click: () => {
|
|
@@ -675,6 +842,8 @@ if (!gotLock) {
|
|
|
675
842
|
createWindow(`http://127.0.0.1:${port}`)
|
|
676
843
|
createTray()
|
|
677
844
|
createApplicationMenu()
|
|
845
|
+
// 自动更新检查:不阻塞启动,静默失败
|
|
846
|
+
checkForUpdates()
|
|
678
847
|
// preload 注入的悬浮刷新按钮 → 重新加载页面
|
|
679
848
|
ipcMain.on('dsh-desktop:reload', () => {
|
|
680
849
|
if (mainWindow) mainWindow.webContents.reload()
|