dsh-builtin-browser 0.4.14 → 0.5.1
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/CHANGELOG.md +72 -0
- package/README.en.md +17 -9
- package/README.md +48 -10
- package/client.js +410 -6
- package/desktop-bridge/install-and-start.cmd +36 -0
- package/desktop-bridge/install.mjs +166 -3
- package/desktop-bridge/plugin-browser-bridge.js +133 -11
- package/docs/development.md +19 -0
- package/docs/limitations.md +7 -3
- package/docs/user-guide.md +46 -18
- package/lib/browser/runtime.d.ts +21 -2
- package/lib/browser/runtime.js +30 -0
- package/lib/browser/types.d.ts +54 -0
- package/lib/browser-electron/bridge-status.d.ts +41 -0
- package/lib/browser-electron/bridge-status.js +164 -0
- package/lib/browser-electron/desktop-bridge-host.d.ts +15 -2
- package/lib/browser-electron/desktop-bridge-host.js +75 -44
- package/lib/browser-electron/entry.js +130 -11
- package/lib/browser-electron/file-write.d.ts +2 -0
- package/lib/browser-electron/file-write.js +39 -0
- package/lib/browser-electron/history-store.d.ts +8 -19
- package/lib/browser-electron/history-store.js +37 -58
- package/lib/browser-electron/host-main.js +15 -22
- package/lib/browser-electron/preview-route.d.ts +89 -0
- package/lib/browser-electron/preview-route.js +172 -0
- package/lib/browser-electron/provider.d.ts +62 -3
- package/lib/browser-electron/provider.js +246 -12
- package/lib/browser-electron/remote-host.js +5 -1
- package/lib/browser-electron/rpc-input.d.ts +4 -0
- package/lib/browser-electron/rpc-input.js +11 -0
- package/lib/browser-electron/runtime-diagnostics.d.ts +12 -0
- package/lib/browser-electron/runtime-diagnostics.js +29 -0
- package/lib/browser-electron/settings-store.d.ts +15 -2
- package/lib/browser-electron/settings-store.js +25 -5
- package/lib/browser-electron/system-browser.d.ts +18 -0
- package/lib/browser-electron/system-browser.js +158 -37
- package/lib/tool-browser/index.js +10 -1
- package/package.json +8 -3
- package/scripts/install-electron.mjs +66 -0
- package/scripts/verify-preview-route.mjs +150 -0
- package/src/browser/runtime.ts +36 -0
- package/src/browser/types.ts +55 -0
- package/src/browser-electron/bridge-status.ts +180 -0
- package/src/browser-electron/desktop-bridge-host.ts +75 -41
- package/src/browser-electron/entry.ts +119 -11
- package/src/browser-electron/file-write.ts +31 -0
- package/src/browser-electron/history-store.ts +36 -57
- package/src/browser-electron/host-main.ts +16 -18
- package/src/browser-electron/preview-route.ts +222 -0
- package/src/browser-electron/provider.ts +286 -16
- package/src/browser-electron/remote-host.ts +5 -1
- package/src/browser-electron/rpc-input.ts +13 -0
- package/src/browser-electron/runtime-diagnostics.ts +38 -0
- package/src/browser-electron/settings-store.ts +37 -5
- package/src/browser-electron/system-browser.ts +149 -32
- package/src/tool-browser/index.ts +13 -1
|
@@ -58,10 +58,16 @@
|
|
|
58
58
|
*
|
|
59
59
|
* USAGE
|
|
60
60
|
* node desktop-bridge/install.mjs [path-to-DeepSeek-Harness-install]
|
|
61
|
-
* Default path: %LOCALAPPDATA%\Programs
|
|
61
|
+
* Default path: probed under %LOCALAPPDATA%\Programs (see findDefaultInstall)
|
|
62
62
|
* Pass --revert to restore the pre-bridge state instead.
|
|
63
|
+
*
|
|
64
|
+
* Pass --restart to have THIS process close DSH, install, and start it again. That is the supported
|
|
65
|
+
* way to install while the shell is running: the archive cannot be moved while the shell holds it,
|
|
66
|
+
* and nothing started from outside survives the exit far enough to install afterwards (issue #36).
|
|
67
|
+
* --restart asks for confirmation on a console; add --yes for an unattended run.
|
|
63
68
|
*/
|
|
64
69
|
import { copyFileSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
70
|
+
import { execFileSync, spawn } from 'node:child_process'
|
|
65
71
|
import { dirname, join } from 'node:path'
|
|
66
72
|
|
|
67
73
|
const DEFAULT_INSTALL = findDefaultInstall()
|
|
@@ -111,8 +117,121 @@ function withoutOurSnippet(text) {
|
|
|
111
117
|
return text.slice(0, at) + text.slice(at + SNIPPET.length)
|
|
112
118
|
}
|
|
113
119
|
|
|
120
|
+
/**
|
|
121
|
+
* Every process whose image is the desktop shell.
|
|
122
|
+
*
|
|
123
|
+
* Matched by executable name because that is what the installed product uses, and because a
|
|
124
|
+
* process-id based approach would miss the children Electron spawns for the renderer and GPU — any
|
|
125
|
+
* of which holds the archive. The install root's own path is checked where a command line is
|
|
126
|
+
* readable, so a second installation of the same product is not closed by mistake.
|
|
127
|
+
* @param root - the install directory whose processes count as this shell.
|
|
128
|
+
* @returns the matching process ids and names.
|
|
129
|
+
*/
|
|
130
|
+
function shellProcesses(root) {
|
|
131
|
+
const text = runCapture('powershell.exe', [
|
|
132
|
+
'-NoProfile', '-NonInteractive', '-Command',
|
|
133
|
+
'Get-CimInstance Win32_Process -Filter "Name=\'DeepSeek Harness.exe\'" | '
|
|
134
|
+
+ 'Select-Object ProcessId,ExecutablePath | ConvertTo-Json -Compress',
|
|
135
|
+
])
|
|
136
|
+
if (text === undefined || text.trim() === '') return []
|
|
137
|
+
let parsed
|
|
138
|
+
try { parsed = JSON.parse(text) } catch { return [] }
|
|
139
|
+
const rows = Array.isArray(parsed) ? parsed : [parsed]
|
|
140
|
+
return rows
|
|
141
|
+
.filter(row => typeof row?.ProcessId === 'number')
|
|
142
|
+
.filter(row => typeof row.ExecutablePath !== 'string'
|
|
143
|
+
|| row.ExecutablePath.toLowerCase().startsWith(root.toLowerCase()))
|
|
144
|
+
.map(row => row.ProcessId)
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Run a command and return its stdout, or undefined when it could not run.
|
|
149
|
+
* @param command - the executable.
|
|
150
|
+
* @param argv - its arguments.
|
|
151
|
+
* @returns stdout text, or undefined.
|
|
152
|
+
*/
|
|
153
|
+
function runCapture(command, argv) {
|
|
154
|
+
try {
|
|
155
|
+
return execFileSync(command, argv, { encoding: 'utf8', stdio: 'pipe', timeout: 30_000 })
|
|
156
|
+
} catch {
|
|
157
|
+
return undefined
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Close the desktop shell and wait until nothing holds the archive.
|
|
163
|
+
*
|
|
164
|
+
* Asks first and forces only if the polite request is ignored: a forced kill can lose work in
|
|
165
|
+
* progress, and the user was told the shell would be closed, not that it would be killed. The wait
|
|
166
|
+
* is bounded — a process that refuses to die must not hang the installer forever.
|
|
167
|
+
* @param root - the install directory whose processes to close.
|
|
168
|
+
* @param graceMs - how long to wait after the polite request before forcing.
|
|
169
|
+
* @returns whether nothing is left running.
|
|
170
|
+
*/
|
|
171
|
+
async function stopShell(root, graceMs) {
|
|
172
|
+
const before = shellProcesses(root)
|
|
173
|
+
if (before.length === 0) return true
|
|
174
|
+
console.log(` closing DSH Desktop (${before.length} process(es))…`)
|
|
175
|
+
// No /F: this is a normal window close, so the shell can flush and prompt.
|
|
176
|
+
runCapture('taskkill.exe', ['/PID', ...before.map(String), '/T'])
|
|
177
|
+
const deadline = Date.now() + graceMs
|
|
178
|
+
while (Date.now() < deadline) {
|
|
179
|
+
if (shellProcesses(root).length === 0) return true
|
|
180
|
+
await new Promise(resolve => setTimeout(resolve, 250))
|
|
181
|
+
}
|
|
182
|
+
const left = shellProcesses(root)
|
|
183
|
+
if (left.length > 0) {
|
|
184
|
+
console.log(` ${left.length} process(es) still running after ${String(graceMs)} ms; forcing`)
|
|
185
|
+
runCapture('taskkill.exe', ['/IM', 'DeepSeek Harness.exe', '/F', '/T'])
|
|
186
|
+
const forcedBy = Date.now() + 15_000
|
|
187
|
+
while (Date.now() < forcedBy) {
|
|
188
|
+
if (shellProcesses(root).length === 0) return true
|
|
189
|
+
await new Promise(resolve => setTimeout(resolve, 250))
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return shellProcesses(root).length === 0
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Start the desktop shell again, detached from this process.
|
|
197
|
+
*
|
|
198
|
+
* Detached on purpose: the installer exits immediately afterwards, and a child that dies with its
|
|
199
|
+
* parent would take the shell with it — the same trap the wait-for-exit daemons fell into.
|
|
200
|
+
* @param root - the install directory.
|
|
201
|
+
* @returns whether the executable was spawned.
|
|
202
|
+
*/
|
|
203
|
+
function startShell(root) {
|
|
204
|
+
const exe = join(root, 'DeepSeek Harness.exe')
|
|
205
|
+
if (!existsSync(exe)) {
|
|
206
|
+
console.error(`could not start DSH Desktop: ${exe} does not exist; start it yourself.`)
|
|
207
|
+
return false
|
|
208
|
+
}
|
|
209
|
+
try {
|
|
210
|
+
const child = spawn(exe, [], { detached: true, stdio: 'ignore', cwd: root })
|
|
211
|
+
child.unref()
|
|
212
|
+
console.log(` started ${exe}`)
|
|
213
|
+
return true
|
|
214
|
+
} catch (error) {
|
|
215
|
+
console.error(`could not start DSH Desktop: ${String(error)}; start it yourself.`)
|
|
216
|
+
return false
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
114
220
|
const args = process.argv.slice(2)
|
|
115
221
|
const revert = args.includes('--revert')
|
|
222
|
+
/**
|
|
223
|
+
* Close DSH, install, then start it again — all in THIS process.
|
|
224
|
+
*
|
|
225
|
+
* Reported as issue #36: moving `app.asar` aside fails with EBUSY while the shell is running, and
|
|
226
|
+
* every "wait for the user to close it" arrangement loses the waiter. Two arrangements were measured
|
|
227
|
+
* on Windows and both died at the moment the shell exited: a hidden PowerShell started through WMI
|
|
228
|
+
* vanished with the process tree, and a scheduled task reported `LastTaskResult = 0xC000013A`
|
|
229
|
+
* (STATUS_CONTROL_C_EXIT). The lesson is that nothing may straddle the exit — so this process closes
|
|
230
|
+
* the shell itself, does the work, and starts it again.
|
|
231
|
+
*/
|
|
232
|
+
const restart = args.includes('--restart')
|
|
233
|
+
/** Skip the interactive confirmation; required for an unattended run. */
|
|
234
|
+
const assumeYes = args.includes('--yes') || args.includes('-y')
|
|
116
235
|
const installRoot = args.find(arg => !arg.startsWith('--')) ?? DEFAULT_INSTALL
|
|
117
236
|
|
|
118
237
|
const resourcesDir = join(installRoot, 'resources')
|
|
@@ -316,6 +435,37 @@ function installCliCompatibility() {
|
|
|
316
435
|
console.log(` cli runtime resolution: ${patchHostCli()}`)
|
|
317
436
|
}
|
|
318
437
|
|
|
438
|
+
// `--restart` closes the shell BEFORE anything else, because the archive cannot be moved while the
|
|
439
|
+
// shell holds it (EBUSY), and because there is no safe way to wait across the exit from outside —
|
|
440
|
+
// both arrangements measured in issue #36 died at that moment. Doing it here keeps the whole
|
|
441
|
+
// sequence inside one front-facing process.
|
|
442
|
+
let shellStopped = false
|
|
443
|
+
if (restart && !revert) {
|
|
444
|
+
if (!assumeYes) {
|
|
445
|
+
console.log('')
|
|
446
|
+
console.log('--restart will CLOSE DSH Desktop, install the bridge, and start it again.')
|
|
447
|
+
console.log('Any unsaved work in a conversation is lost. Re-run with --yes to skip this notice.')
|
|
448
|
+
console.log('')
|
|
449
|
+
try {
|
|
450
|
+
const answer = readFileSync(0, 'utf8').trim().toLowerCase()
|
|
451
|
+
if (answer !== '' && answer !== 'y' && answer !== 'yes') {
|
|
452
|
+
console.error('cancelled; nothing was changed.')
|
|
453
|
+
process.exit(1)
|
|
454
|
+
}
|
|
455
|
+
} catch {
|
|
456
|
+
// No stdin (a service, a detached shell): refuse rather than close a window nobody agreed to.
|
|
457
|
+
console.error('--restart needs confirmation; pass --yes when there is no console to ask.')
|
|
458
|
+
process.exit(1)
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
shellStopped = await stopShell(installRoot, 20_000)
|
|
462
|
+
if (!shellStopped) {
|
|
463
|
+
console.error('DSH Desktop did not exit, so the archive cannot be replaced.')
|
|
464
|
+
console.error('Close it yourself and run this again without --restart.')
|
|
465
|
+
process.exit(1)
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
319
469
|
// The archive wins whenever it exists, so ITS presence — not the absence of the
|
|
320
470
|
// directory — decides the layout. After a desktop update the archive is back
|
|
321
471
|
// (a new build) while an older extraction is still lying around, and keying off
|
|
@@ -333,7 +483,12 @@ if (!existsSync(mainPath) && !existsSync(asarPath)) {
|
|
|
333
483
|
if (revert) {
|
|
334
484
|
let reverted = false
|
|
335
485
|
if (existsSync(asarMoved)) {
|
|
336
|
-
if (existsSync(asarPath))
|
|
486
|
+
if (existsSync(asarPath)) {
|
|
487
|
+
console.error('refusing to replace an app archive that already exists: a desktop upgrade may have installed a newer build')
|
|
488
|
+
console.error(` current archive: ${asarPath}`)
|
|
489
|
+
console.error(` preserved backup: ${asarMoved}`)
|
|
490
|
+
process.exit(1)
|
|
491
|
+
}
|
|
337
492
|
renameSync(asarMoved, asarPath)
|
|
338
493
|
console.log(`restored the app archive: app.asar.before-bridge -> app.asar`)
|
|
339
494
|
reverted = true
|
|
@@ -475,4 +630,12 @@ console.log(`installed bridge into ${appDir}`)
|
|
|
475
630
|
console.log(` module: ${bridgeTarget}`)
|
|
476
631
|
console.log(` patch: ${mainPath} (+${SNIPPET.split('\n').length} lines)`)
|
|
477
632
|
installCliCompatibility()
|
|
478
|
-
|
|
633
|
+
if (restart && shellStopped) {
|
|
634
|
+
// Started detached and unref'd: this process exits on the next line, and a child that died with
|
|
635
|
+
// its parent would leave the user with nothing running — the trap the wait-for-exit daemons hit.
|
|
636
|
+
if (startShell(installRoot)) {
|
|
637
|
+
console.log('DSH Desktop was restarted; the bridge is active.')
|
|
638
|
+
}
|
|
639
|
+
} else {
|
|
640
|
+
console.log('restart DSH Desktop to activate it.')
|
|
641
|
+
}
|
|
@@ -28,6 +28,30 @@ import { homedir } from 'node:os'
|
|
|
28
28
|
import { join } from 'node:path'
|
|
29
29
|
import { app, webContents } from 'electron'
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* The conversation's sidebar panel exists but the shell is not displaying that conversation, so no
|
|
33
|
+
* webview has attached yet. A TRANSIENT display state, not a lost carrier (issue #37).
|
|
34
|
+
*
|
|
35
|
+
* Carried across the socket so the plugin can tell it apart from "this panel can never work": the
|
|
36
|
+
* two used to share one `sidebar unavailable (...)` string, and the plugin treated both as a dead
|
|
37
|
+
* carrier — switching to a self-hosted window and losing the open page, when showing the
|
|
38
|
+
* conversation would have brought the page back.
|
|
39
|
+
*/
|
|
40
|
+
const PANEL_NOT_DISPLAYED = 'panel-not-displayed'
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* An Error carrying a stable code, so the code survives the socket as a field rather than as text a
|
|
44
|
+
* caller has to pattern-match.
|
|
45
|
+
* @param {string} code - the stable identifier.
|
|
46
|
+
* @param {string} message - the human-readable explanation.
|
|
47
|
+
* @returns {Error} the error, with `code` set.
|
|
48
|
+
*/
|
|
49
|
+
function codedError(code, message) {
|
|
50
|
+
const error = new Error(message)
|
|
51
|
+
error.code = code
|
|
52
|
+
return error
|
|
53
|
+
}
|
|
54
|
+
|
|
31
55
|
/**
|
|
32
56
|
* Absolute path of the endpoint file the plugin reads.
|
|
33
57
|
*
|
|
@@ -360,6 +384,24 @@ async function sidebarFrameKind(shellId) {
|
|
|
360
384
|
}
|
|
361
385
|
}
|
|
362
386
|
|
|
387
|
+
/** Read the exact guest set from the named conversation's renderer, never from free globals. */
|
|
388
|
+
async function panelGuestIds(shell, owner) {
|
|
389
|
+
if (!/^session-/.test(owner)) return []
|
|
390
|
+
const value = await shell.executeJavaScript(`(() => {
|
|
391
|
+
const api = globalThis.__dshBuiltinBrowser;
|
|
392
|
+
if (!api || typeof api.panelGuests !== 'function') {
|
|
393
|
+
throw new Error('sidebar page identity API is unavailable; refresh or upgrade the browser plugin client');
|
|
394
|
+
}
|
|
395
|
+
return JSON.stringify(api.panelGuests(${JSON.stringify(owner)}));
|
|
396
|
+
})()`, true)
|
|
397
|
+
let ids
|
|
398
|
+
try { ids = JSON.parse(value) } catch { throw new Error('invalid sidebar page identity reply; refresh or upgrade the browser plugin client') }
|
|
399
|
+
if (!Array.isArray(ids) || ids.some(id => !Number.isSafeInteger(id) || id <= 0)) {
|
|
400
|
+
throw new Error('invalid sidebar page identity reply; refresh or upgrade the browser plugin client')
|
|
401
|
+
}
|
|
402
|
+
return ids
|
|
403
|
+
}
|
|
404
|
+
|
|
363
405
|
/** Handle one JSON request line; every answer is a JSON line too. */
|
|
364
406
|
async function handle(request) { const op = String(request?.op ?? '')
|
|
365
407
|
// Who is asking. Declared once, for every op, because the first attempt at this put `owner` in
|
|
@@ -372,19 +414,54 @@ async function handle(request) { const op = String(request?.op ?? '')
|
|
|
372
414
|
return { ok: true, loadedAt: LOADED_AT, protocol: PROTOCOL }
|
|
373
415
|
}
|
|
374
416
|
if (op === 'list') {
|
|
417
|
+
pruneClaims()
|
|
375
418
|
const all = webContents.getAllWebContents().map(describe)
|
|
376
419
|
// A guest claimed by another owner is not this caller's to see or to drive. Its id, url and
|
|
377
420
|
// title are that session's business; handing them over is how a session came to list pages it
|
|
378
421
|
// never opened. The shell window is always reported: it is what every op drives.
|
|
379
|
-
const
|
|
380
|
-
const
|
|
422
|
+
const shell = webContents.getAllWebContents().find(g => g.getType() === 'window')
|
|
423
|
+
const panelIds = shell === undefined ? [] : await panelGuestIds(shell, owner)
|
|
424
|
+
for (const id of panelIds) {
|
|
425
|
+
if (!claims.has(id) || claims.get(id) === owner) claims.set(id, owner)
|
|
426
|
+
}
|
|
427
|
+
const mineOrFree = all.filter(g => g.type !== 'webview'
|
|
428
|
+
|| (claims.get(g.id) === owner && (!/^session-/.test(owner) || panelIds.includes(g.id))))
|
|
381
429
|
return {
|
|
382
430
|
ok: true,
|
|
383
431
|
guests: mineOrFree,
|
|
384
432
|
sidebar: mineOrFree.filter(g => g.type === 'webview'),
|
|
385
|
-
frame: await sidebarFrameKind(shell?.id
|
|
433
|
+
frame: await sidebarFrameKind(shell?.id),
|
|
386
434
|
}
|
|
387
435
|
}
|
|
436
|
+
if (op === 'closePage') {
|
|
437
|
+
const id = Number(request.id)
|
|
438
|
+
if (!Number.isSafeInteger(id) || id <= 0) throw new Error('closePage requires a numeric guest id')
|
|
439
|
+
const shell = webContents.getAllWebContents().find(g => g.getType() === 'window')
|
|
440
|
+
if (shell === undefined) throw new Error('no shell window to drive')
|
|
441
|
+
if (!(await panelGuestIds(shell, owner)).includes(id)) throw new Error('the page does not belong to this conversation panel')
|
|
442
|
+
pruneClaims()
|
|
443
|
+
if (claims.has(id) && claims.get(id) !== owner) throw new Error('the page belongs to another session')
|
|
444
|
+
const value = await shell.executeJavaScript(`(() => {
|
|
445
|
+
const api = globalThis.__dshBuiltinBrowser;
|
|
446
|
+
if (!api || typeof api.closePanelGuest !== 'function') {
|
|
447
|
+
throw new Error('sidebar close API is unavailable; refresh or upgrade the browser plugin client');
|
|
448
|
+
}
|
|
449
|
+
return JSON.stringify(api.closePanelGuest(${JSON.stringify(owner)}, ${id}));
|
|
450
|
+
})()`, true)
|
|
451
|
+
let answer
|
|
452
|
+
try { answer = JSON.parse(value) } catch { throw new Error('invalid sidebar close reply') }
|
|
453
|
+
if (answer?.ok !== true || answer.closed !== 1) throw new Error(String(answer?.reason ?? 'the sidebar did not close the requested page'))
|
|
454
|
+
const deadline = Date.now() + 2_000
|
|
455
|
+
while (Date.now() < deadline) {
|
|
456
|
+
const guest = guestById(id)
|
|
457
|
+
if (guest === undefined || guest.isDestroyed()) {
|
|
458
|
+
claims.delete(id)
|
|
459
|
+
return { ok: true, closed: 1 }
|
|
460
|
+
}
|
|
461
|
+
await new Promise(resolve => setTimeout(resolve, 50))
|
|
462
|
+
}
|
|
463
|
+
throw new Error('the sidebar close action did not remove the requested page')
|
|
464
|
+
}
|
|
388
465
|
if (op === 'cdp') {
|
|
389
466
|
const id = Number(request.id)
|
|
390
467
|
if (!Number.isFinite(id)) throw new Error('cdp requires a numeric id')
|
|
@@ -447,7 +524,13 @@ async function handle(request) { const op = String(request?.op ?? '')
|
|
|
447
524
|
// would turn a true statement into a timeout, and the page is genuinely there: it appears the
|
|
448
525
|
// moment the conversation is shown.
|
|
449
526
|
if (first.panel === false) {
|
|
450
|
-
|
|
527
|
+
// Reported as issue #37. This is NOT a lost carrier: the tab exists in this conversation's own
|
|
528
|
+
// surface store, the conversation is simply not the one on screen, and the page appears the
|
|
529
|
+
// moment it is. A machine-readable code is what keeps the plugin from concluding the carrier
|
|
530
|
+
// died — a conclusion that swapped the surface to a separate window and took the open page with
|
|
531
|
+
// it, because the new window starts blank.
|
|
532
|
+
throw codedError(
|
|
533
|
+
PANEL_NOT_DISPLAYED,
|
|
451
534
|
'a panel was placed in this conversation\'s sidebar, but its page can only attach while the '
|
|
452
535
|
+ 'conversation is the one displayed — show it and the page appears',
|
|
453
536
|
)
|
|
@@ -533,10 +616,16 @@ async function handle(request) { const op = String(request?.op ?? '')
|
|
|
533
616
|
if (op === 'closeSidebarBrowser') {
|
|
534
617
|
// Release the sidebar's browser pages by closing the tabs that host them.
|
|
535
618
|
//
|
|
536
|
-
// This is the desktop equivalent of "close the browser window": the guests are
|
|
537
|
-
//
|
|
538
|
-
//
|
|
539
|
-
//
|
|
619
|
+
// This is the desktop equivalent of "close the browser window": the guests are destroyed, so
|
|
620
|
+
// that agent's session ends and its next use starts a fresh page. History survives — it is this
|
|
621
|
+
// plugin's own file on disk.
|
|
622
|
+
//
|
|
623
|
+
// Cookies do NOT survive on the shells measured so far, and this comment used to claim they did
|
|
624
|
+
// (reported as issue #36). The shell allocates the sidebar's partition as
|
|
625
|
+
// `dsh-sidebar-browser-<uuid>` with no `persist:` prefix, i.e. an in-memory session, so anything
|
|
626
|
+
// logged in inside the sidebar is logged out again at the next DSH start. That is the shell's
|
|
627
|
+
// choice, not something this bridge can change; a carrier whose cookies do persist is the
|
|
628
|
+
// installed Chrome/Edge one, which keeps its own profile.
|
|
540
629
|
//
|
|
541
630
|
// `titles` narrows the release to specific pages. It matters as soon as more
|
|
542
631
|
// than one session is running: each one owns its own tab (requirements §4), and
|
|
@@ -698,19 +787,41 @@ export function start() {
|
|
|
698
787
|
const server = createServer(socket => {
|
|
699
788
|
let buffer = ''
|
|
700
789
|
let authed = false
|
|
790
|
+
socket.setEncoding('utf8')
|
|
791
|
+
const authenticationDeadline = setTimeout(() => socket.destroy(), 5_000)
|
|
792
|
+
authenticationDeadline.unref?.()
|
|
793
|
+
socket.on('close', () => clearTimeout(authenticationDeadline))
|
|
701
794
|
socket.on('data', chunk => {
|
|
702
|
-
buffer
|
|
795
|
+
if (Buffer.byteLength(buffer, 'utf8') + Buffer.byteLength(chunk, 'utf8') > 128 * 1024 * 1024) {
|
|
796
|
+
socket.destroy()
|
|
797
|
+
return
|
|
798
|
+
}
|
|
799
|
+
buffer += chunk
|
|
703
800
|
let newline = buffer.indexOf('\n')
|
|
704
801
|
while (newline !== -1) {
|
|
705
802
|
const line = buffer.slice(0, newline).trim()
|
|
803
|
+
if (Buffer.byteLength(line, 'utf8') > (authed ? 128 * 1024 * 1024 : 64 * 1024)) {
|
|
804
|
+
socket.destroy()
|
|
805
|
+
return
|
|
806
|
+
}
|
|
706
807
|
buffer = buffer.slice(newline + 1)
|
|
707
808
|
newline = buffer.indexOf('\n')
|
|
708
809
|
if (line === '') continue
|
|
709
810
|
let request
|
|
710
|
-
try { request = JSON.parse(line) } catch {
|
|
811
|
+
try { request = JSON.parse(line) } catch {
|
|
812
|
+
socket.write(JSON.stringify({ ok: false, error: 'bad json' }) + '\n')
|
|
813
|
+
if (!authed) { socket.destroy(); return }
|
|
814
|
+
continue
|
|
815
|
+
}
|
|
816
|
+
if (request === null || typeof request !== 'object' || Array.isArray(request)) {
|
|
817
|
+
socket.write(JSON.stringify({ ok: false, error: 'request must be a JSON object' }) + '\n')
|
|
818
|
+
socket.destroy()
|
|
819
|
+
return
|
|
820
|
+
}
|
|
711
821
|
if (!authed) {
|
|
712
822
|
if (request.token !== token) { socket.write(JSON.stringify({ ok: false, error: 'bad token' }) + '\n'); socket.destroy(); return }
|
|
713
823
|
authed = true
|
|
824
|
+
clearTimeout(authenticationDeadline)
|
|
714
825
|
// The authenticating message is NOT a command: a client that sends the
|
|
715
826
|
// token on its own line would otherwise be answered `unknown op ""`.
|
|
716
827
|
// (A client may also put the token on its first real request; both work.)
|
|
@@ -726,8 +837,19 @@ export function start() {
|
|
|
726
837
|
// arrives. Only two of this bridge's nine reply paths carried the field, so most
|
|
727
838
|
// operations permanently degraded the connection they used.
|
|
728
839
|
.then(answer => socket.write(JSON.stringify({ ...answer, bridgeRequestId: request.bridgeRequestId }) + '\n'))
|
|
729
|
-
.catch(error => socket.write(JSON.stringify({
|
|
840
|
+
.catch(error => socket.write(JSON.stringify({
|
|
841
|
+
ok: false,
|
|
842
|
+
error: String(error?.message ?? error),
|
|
843
|
+
// The code travels as a field, not as text: a caller must not have to recognize an
|
|
844
|
+
// English sentence to know whether the carrier died or the conversation is just not on
|
|
845
|
+
// screen (issue #37).
|
|
846
|
+
...error?.code === undefined ? {} : { code: String(error.code) },
|
|
847
|
+
bridgeRequestId: request.bridgeRequestId,
|
|
848
|
+
}) + '\n'))
|
|
730
849
|
}
|
|
850
|
+
// Authentication may share a TCP chunk with the first real (larger) command. Apply the
|
|
851
|
+
// unauthenticated cap to that frame, not to bytes belonging to an authenticated successor.
|
|
852
|
+
if (Buffer.byteLength(buffer, 'utf8') > (authed ? 128 * 1024 * 1024 : 64 * 1024)) socket.destroy()
|
|
731
853
|
})
|
|
732
854
|
socket.on('error', () => { /* client went away */ })
|
|
733
855
|
})
|
package/docs/development.md
CHANGED
|
@@ -3,12 +3,31 @@
|
|
|
3
3
|
## 构建与测试
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
|
+
pnpm install --frozen-lockfile --ignore-scripts # CI 使用 pnpm 11.7.0,不下载 Electron 二进制
|
|
6
7
|
npm run build # 类型检查 + 构建到 lib/
|
|
7
8
|
npm test # tsc -p tsconfig.json + node --test "tests/*.test.mjs"
|
|
8
9
|
```
|
|
9
10
|
|
|
10
11
|
测试用**假 host**(`tests/` 里的 stub),**不需要 Electron、也不需要网络** —— 所以它可以在 CI 与任何开发机上跑。
|
|
11
12
|
|
|
13
|
+
本插件从 0.4.16 起用 `postinstall` 调用 `scripts/install-electron.mjs`,明确解析所依赖 electron 包的 `install.js`。上述 `--ignore-scripts` 会跳过此步骤,适合不启动浏览器的 CI。需要真实浏览器时,可在源码目录运行 `node scripts/install-electron.mjs`,或在安装插件的 profile 目录运行 `npx --no dsh-browser-install-electron`;命令使用本地安装,不应临时下载同名包。它们遵守 `ELECTRON_SKIP_BINARY_DOWNLOAD`,下载失败返回非零并保留错误。
|
|
14
|
+
|
|
15
|
+
DSH rc.5 的 pnpm 11.7 使用 `strict-dep-builds`,依赖脚本未批准时应经宿主原生插件管理器批准并重试。插件不自动改写 profile 的 `allowBuilds`;不要以全局放开依赖脚本替代宿主审批流程。
|
|
16
|
+
|
|
17
|
+
## 0.5.0 发布前验证
|
|
18
|
+
|
|
19
|
+
0.4.16 的验证范围仍然有效;0.5.0 在其上加了远程观看与三处实测修复,新增要核的是:
|
|
20
|
+
|
|
21
|
+
- **被动采集的被动性**:`capturePassive` 不得调用 `showActive`/`show`/`focus`,不得恢复载体。这不是读代码能确认的,要在真机上看焦点窗口句柄与 target 集合在采集前后是否逐字不变。
|
|
22
|
+
- **观看端点**:`remoteView.enabled` 关闭时必须不返回图像、不透露会话;`session` 必须是插件发出去的那个。逐条对着 `tests/preview-route.test.mjs` 核。
|
|
23
|
+
- **bridge `--restart`**:关闭是温和优先(`taskkill /PID` 无 `/F`),重启必须 `detached` + `unref`。真机验证会关闭桌面端,不在 CI 里跑。
|
|
24
|
+
- **侧栏显示状态**:切到另一个会话后调用工具,必须得到 `BrowserPanelNotDisplayedError` 而不是载体损失;会话 id 不变、不弹新窗口。
|
|
25
|
+
- **canvas 与图片链接**:`snapshot` 对 canvas 页面报 `CANVAS PAGE:`,对图片链接用 `img[alt]` 取名。两条都要在真实页面上核 —— 单测只断言了实现存在。
|
|
26
|
+
|
|
27
|
+
`npm test` 是必要条件,不是充分条件:假 host 不能证明真实浏览器、侧栏、无显示服务器或 canvas 页面的端到端行为。
|
|
28
|
+
|
|
29
|
+
依赖声明 Electron `^44.10.0`,锁文件为 `44.10.0`;安全最低阈值为 `44.9.1`,`undici` override 为 `7.30.1`。升级插件不会替换桌面外壳内核、安装侧 bridge 或用户的环境变量覆盖。
|
|
30
|
+
|
|
12
31
|
## 代码结构
|
|
13
32
|
|
|
14
33
|
| 目录 | 职责 |
|
package/docs/limitations.md
CHANGED
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
|
|
28
28
|
- `dsh_browser_download` 在页面上下文内 `fetch`(带登录态),受同源/CORS 约束;仅允许 HTTP(S) 目标。
|
|
29
29
|
- `savePath` 必须为**绝对路径**且位于 `downloadDir` 内(默认系统下载目录,自动识别 `Downloads`/`下载`/`下載` 与 `XDG_DOWNLOAD_DIR`,可用 `downloadDir` 覆盖),**不覆盖已存在文件**;`dsh_browser_screenshot` 的 `savePath` 走同一准入门。
|
|
30
|
-
- 单文件上限 **256MB**(流式限流,按 Content-Length 提前拒绝)
|
|
30
|
+
- 单文件上限 **256MB**(流式限流,按 Content-Length 提前拒绝),文件由浏览器子进程直接落盘。下载与截图使用独占的随机临时文件,不会覆盖既有 `.part` 或最终文件;支持硬链接的文件系统原子提交,不支持时用独占复制提交,该回退在进程崩溃时可能留下未完成的新文件。
|
|
31
31
|
- 准入还会解析路径的**真实归属**:`downloadDir` 里的符号链接无法把写入带出目录,悬空链接同样被拒(它读作"名字已被占用",而不是"路径空闲")。
|
|
32
32
|
|
|
33
33
|
## 载体行为
|
|
34
34
|
|
|
35
|
-
-
|
|
35
|
+
- **本机 Chrome / Edge 载体**在无显示环境会自动改用 headless。`browser.headless` 仅作用于这个载体:默认 `auto` 是"有显示开窗口,没显示走 headless"。使用 systemd、容器或 SSH 服务器时,应选择已安装的 Chrome / Edge;默认内置 Electron 和桌面侧栏没有接入此设置,不能据此保证无显示启动。修改后重新选择载体或重启 DSH 生效。
|
|
36
36
|
|
|
37
37
|
想显式控制时:
|
|
38
38
|
|
|
@@ -54,6 +54,8 @@
|
|
|
54
54
|
|
|
55
55
|
插件从 0.4.10 起**在接管之前先读面板形态**(面板自己带的 `data-sidebar-browser-frame` 属性),判到 `iframe` 就不接管,直接用自托管载体,并在日志里说明原因。**结果是"能用但多一个窗口",而不是"装完就坏"。**
|
|
56
56
|
|
|
57
|
+
0.4.16 适配 rc.5 的嵌套会话标记和无 React fiber 的 webview。列页和关闭仍须能确认请求会话与 tab 身份;归属缺失、身份冲突或未知宿主结构会明确拒绝。**插件更新不会更新外壳或外壳内的 bridge**,使用侧栏需另行备份并重装新版 bridge。
|
|
58
|
+
|
|
57
59
|
- **侧栏载体不上报"用户操作"事件**:人在那个页面里点击是外壳自己的事件,而 bridge 没有用于回报它的操作。因此依赖该事件的功能(如自定义的接管提示)在桌面端侧栏下不会触发;换到自托管载体则可以。
|
|
58
60
|
- **本机 Chrome / Edge 载体使用插件自己的 profile**:插件用它自己的用户数据目录启动浏览器(`$DSH_HOME/dsh-builtin-browser-host/<chrome|edge>-profile`),所以你日常浏览器里的书签、扩展与登录态**不会自动继承** —— 这是刻意的,避免插件操作与你的个人会话混在一起;登录态是否跨重启保留由 `cookies.persist` 决定。
|
|
59
61
|
- 页面弹窗(`window.open` / `target=_blank`)不再覆盖当前视图:HTTP(S) 弹窗会在同一会话窗口**新开一个标签页**并计入历史,原页面与 opener 上下文保留;非 HTTP(S) 弹窗(空 URL 弹窗承接、`mailto:`、自定义协议)仍**放行原生窗口**,交给系统处理 —— 这类弹窗不纳入会话模型。
|
|
@@ -68,4 +70,6 @@
|
|
|
68
70
|
|
|
69
71
|
## Electron 运行时
|
|
70
72
|
|
|
71
|
-
- Electron
|
|
73
|
+
- Electron 包自身在 44+ 使用懒下载。0.4.16 通过**本插件的 `postinstall`**明确准备二进制(约 100MB,需网络);这要求宿主允许构建脚本且下载可用,不保证所有环境自动完成。DSH rc.5 的 pnpm 11.7 `strict-dep-builds` 首次可能需在原生插件管理器批准脚本,插件不会改写 `allowBuilds`。
|
|
74
|
+
- `--ignore-scripts` 或显式跳过下载会保留未下载状态。可在正确 profile 目录运行 `npx --no dsh-browser-install-electron`,它也遵守 `ELECTRON_SKIP_BINARY_DOWNLOAD`;需要下载时先撤销跳过设置。运行时探测仍为纯文件系统操作,不自动下载。离线时可用 `ELECTRON_PATH` 指定预装二进制,详见[用户指南](user-guide.md#准备-electron-二进制)。
|
|
75
|
+
- 0.4.16 的依赖为 `^44.10.0`,锁文件解析到 `44.10.0`,安全最低阈值为 `44.9.1`。**已有且有效的 `ELECTRON_PATH` 优先于这份依赖**,升级插件不会更改该覆盖;旧覆盖可能让实际使用的内核继续停在旧版。侧栏使用的是桌面外壳的内核,也不随插件升级。
|
package/docs/user-guide.md
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
- DeepSeek Harness(dsh),已安装对应 profile(`web` / `desktop` 等)
|
|
6
6
|
- **Electron 运行时**(必装依赖,随插件自动安装):
|
|
7
|
-
- **DSH Desktop
|
|
8
|
-
- **纯 `dsh web`
|
|
7
|
+
- **DSH Desktop**:侧栏可驱动时使用外壳的页面;自托管回退使用插件的 electron。打包宿主 exe(`DSH Desktop.exe`)**不能作为自托管运行时复用**——打包应用无法按脚本参数拉起,误用会秒退(issue #6);开发模式的**裸** Electron 宿主仍可复用;
|
|
8
|
+
- **纯 `dsh web` 自托管**:使用随插件安装的 electron 包。0.4.16 声明 `^44.10.0`(即 `>=44.10.0 <45`),锁文件解析到 `44.10.0`;本插件在获准执行安装脚本时准备二进制,需网络,详见下节。
|
|
9
9
|
|
|
10
10
|
## 安装
|
|
11
11
|
|
|
@@ -28,6 +28,20 @@ dsh plugin --profile web add <本仓库路径>
|
|
|
28
28
|
|
|
29
29
|
> 没有桌面外壳时插件**自托管**:自己拉起一个标题为 `dsh-browser` 的 Electron 窗口,`dsh_browser_*` 工具照常可用。
|
|
30
30
|
|
|
31
|
+
### 准备 Electron 二进制
|
|
32
|
+
|
|
33
|
+
Electron 44 将二进制下载改为懒下载,仅安装 npm 包并不保证已有可执行文件。0.4.16 增加本插件的 `postinstall`:宿主允许安装脚本且下载可用时,明确运行所依赖 electron 包的 `install.js`,通常在安装阶段就准备好二进制。下载失败会保留错误并返回非零退出码,应先处理错误再重试。
|
|
34
|
+
|
|
35
|
+
**DSH rc.5 使用 pnpm 11.7 的 `strict-dep-builds`。** 首次安装若提示构建脚本尚未批准,请在宿主原生插件管理器中审阅并批准 `dsh-builtin-browser` 的构建脚本,再按宿主提示重试安装或构建。插件不会自行改写 `allowBuilds`;审批和宿主策略仍由用户控制。
|
|
36
|
+
|
|
37
|
+
使用 `--ignore-scripts`、明确跳过下载,或需要重试下载时,进入**安装本插件的 profile 目录**(通常为 `$DSH_HOME/profiles/web` 或 `$DSH_HOME/profiles/desktop`),运行本插件已经安装的本地命令:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
npx --no dsh-browser-install-electron
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`--no` 用于拒绝临时下载缺失命令;命令不存在时先检查 profile 与插件安装,不要改用同名第三方包。该命令与安装脚本都遵守 `ELECTRON_SKIP_BINARY_DOWNLOAD`:若之前有意设置该变量,需要下载时先撤销跳过设置,否则继续跳过。离线部署可保留跳过设置并预装合适的裸 Electron,通过 `ELECTRON_PATH` 指向它。只有明确知道本插件所依赖 electron 包目录时,才可改用 `node "<已安装的 electron 包目录>/install.js"`。
|
|
44
|
+
|
|
31
45
|
## 配置
|
|
32
46
|
|
|
33
47
|
| 行 | 配置项 | 类型 | 默认 | 说明 |
|
|
@@ -125,10 +139,10 @@ dsh plugin --profile web add <本仓库路径>
|
|
|
125
139
|
**Q:找不到 Electron?**
|
|
126
140
|
插件按顺序自动定位:① `ELECTRON_PATH` 环境变量(显式覆盖,优先于一切自动发现)→ ② 随插件安装的 electron 包(纯文件系统探测,不触发 44+ 懒下载)→ ③ DSH 锚点(profile / 全局 prefix 中单独安装的 electron)中版本最新者 → ④ 当前进程就是**裸** Electron(dev 模式)时复用宿主二进制 → ⑤ 进程祖先树中的裸 Electron 二进制。**打包应用不参与复用**:旁有 `resources/app.asar` 的可执行文件(如 DSH Desktop.exe)无法按脚本参数拉起,spawn 会启动应用本体并秒退(单实例锁)——一律跳过。
|
|
127
141
|
|
|
128
|
-
DSH Desktop
|
|
142
|
+
DSH Desktop 上②命中即可用;dev 模式宿主仍可走④复用。插件在运行时只探测现有文件,不会在 DSH 启动时隐式下载。0.4.16 的安装脚本通常提前准备二进制,但脚本批准、网络、`--ignore-scripts` 与下载跳过设置都可能影响结果。缺失时按[准备 Electron 二进制](#准备-electron-二进制)在正确 profile 执行 `npx --no dsh-browser-install-electron`。必要时可把 `ELECTRON_PATH` 指向已核验版本的裸 Electron 二进制,不能指向 `DSH Desktop.exe`。
|
|
129
143
|
|
|
130
144
|
**Q:截图失败或挂起?**
|
|
131
|
-
|
|
145
|
+
先核对实际使用的 Electron 版本和 `ELECTRON_PATH`。0.4.16 依赖为 `^44.10.0`;旧覆盖仍可能选中旧内核,安全最低阈值为 `44.9.1`。自托管截图优先走原生 `capturePage`,多视图/窗口未激活时自动兜底到 CDP。
|
|
132
146
|
|
|
133
147
|
**Q:浏览器窗口不见了?**
|
|
134
148
|
窗口标题为 `dsh-browser`(自托管)。若子进程崩溃(或宿主 DSH 重启)会自动重启;崩溃前已打开的会话在**下一次调用时自动重建**——仅页面状态丢失,无需手动 `dsh_browser_reset_session`。`dsh_browser_reset_session` 仍可用于主动重置。
|
|
@@ -156,17 +170,17 @@ DSH Desktop 上②命中即可用(0.1.18+ 插件自带 electron 包;44+ 二进
|
|
|
156
170
|
| 导航被拒 | 非 HTTP(S) 协议 | 检查 URL;`httpOnly` 配置 |
|
|
157
171
|
| 快照为空 | 页面尚未加载 | 等待后重试 `dsh_browser_snapshot` |
|
|
158
172
|
|
|
159
|
-
##
|
|
173
|
+
## 兼容范围与验证记录
|
|
160
174
|
|
|
161
175
|
| 组件 | 版本 |
|
|
162
176
|
| --- | --- |
|
|
163
|
-
| DeepSeek Harness(dsh) | `
|
|
164
|
-
| Electron | `44.0.0`(
|
|
177
|
+
| DeepSeek Harness(dsh) | `engines.dsh` 声明 `>=0.1.1-rc.2 <0.3.0`;rc.5 已做真实宿主 peer 的 34 工具注册和两个假 provider 调用验证,以及对应 DOM 结构的侧栏回归测试;较早的 `0.2.1-rc.1` 等版本有历史验证记录 |
|
|
178
|
+
| Electron | 0.4.16 依赖为 `^44.10.0`,锁文件 `44.10.0`;真实 `44.10.0` 已通过隔离自托管烟测,详见[变更记录](../CHANGELOG.md#发布准备验证2026-10-31);安全最低阈值 `44.9.1` |
|
|
165
179
|
| Node.js | `22.20.0` |
|
|
166
180
|
| 本机 Chrome / Edge(可选载体) | `154.0.8037.58` / `154.0.4258.37` |
|
|
167
181
|
| 操作系统 | Windows 10 (10.0.26200) |
|
|
168
182
|
|
|
169
|
-
>
|
|
183
|
+
> 本表区分依赖声明与验证证据,不表示每种宿主/载体组合都做过端到端测试。系统浏览器的查找已适配 Linux 与 macOS(先查 `PATH`,再查各平台的惯例安装位置,均可用 `DSH_BROWSER_CHROME_PATH` / `DSH_BROWSER_EDGE_PATH` 覆盖),但这两个平台上的**端到端链路尚未实测**。
|
|
170
184
|
|
|
171
185
|
> **宿主兼容性可以随时复验**:`node scripts/verify-host-compat.mjs` 会用某个 profile 里**真实安装**的 `@deepseek-ai/*` 包组装一个宿主,加载本插件的编译产物并真调两个工具。详见[开发](development.md)。
|
|
172
186
|
|
|
@@ -174,6 +188,18 @@ DSH Desktop 上②命中即可用(0.1.18+ 插件自带 electron 包;44+ 二进
|
|
|
174
188
|
|
|
175
189
|
插件在两种宿主里各有一份安装,更新路径也不同 —— **更新其中一端不会连带更新另一端**。
|
|
176
190
|
|
|
191
|
+
### 升级到 0.4.16
|
|
192
|
+
|
|
193
|
+
0.4.16 正在本地准备,尚未发布到 npm。它集中修复并发选页、下载/截图覆盖风险、bridge 边界、设置门控、载体切换与桌面 rc.5 侧栏适配。**所有现有用户都建议在发布后更新**,包括只安装本插件的用户。更新时按下列顺序处理:
|
|
194
|
+
|
|
195
|
+
1. 先保存正在进行的任务并关闭相关浏览器。备份实际 `$DSH_HOME` 下的对应 profile 和 `dsh-builtin-browser-host/`(设置、历史与浏览器登录数据)。若使用侧栏 bridge,还要关闭 DSH Desktop 并备份其安装目录的 `resources/`。
|
|
196
|
+
2. 按下节对实际使用的 `web` 或 `desktop` profile **先移除插件、再安装目标版本**。版本发布后目标版本填 `0.4.16`;测试本地候选包时,`add` 后传入已提供的 `.tgz` 绝对路径。按宿主提示批准构建脚本;脚本被跳过或二进制缺失时按上方说明手动准备。这里移除的是 profile 中的插件,不涉及卸载 DSH Desktop。
|
|
197
|
+
3. 检查启动 DSH 的环境中的 `ELECTRON_PATH`。它是最高优先级的显式覆盖,**旧路径仍存在就会盖过新版插件依赖**。需要自托管时,清除不再使用的覆盖或改指向已核验的裸 Electron `44.10.0` 等 `44.x` 二进制(安全最低阈值为 `44.9.1`);环境变量改变后重启 DSH 进程。
|
|
198
|
+
4. 使用侧栏时,从**新版插件目录**运行下节的 bridge 安装脚本并重启桌面端。插件更新不会更新外壳或外壳内 bridge;外壳升级也不会更新 profile 中的插件。外壳缺少可驱动的 `<webview>` 时仍回退自托管。
|
|
199
|
+
5. 重启对应宿主后,让 agent 打开测试页、列出本任务标签并保存一张截图,确认载体、页面归属与保存路径符合预期。原有设置与数据通常保留;先保留备份,再继续正式任务。
|
|
200
|
+
|
|
201
|
+
本次未扩展服务器上的内置 Electron 无头能力。`browser.headless` 与 `cookies.persist` 仍只控制本机 Chrome / Edge,详见[已知限制](limitations.md)。
|
|
202
|
+
|
|
177
203
|
### 先移除,再安装
|
|
178
204
|
|
|
179
205
|
**DSH 0.2.1-alpha.2 起,对已经装着的包再执行一次安装会直接失败**,报 `already-installed`,并且在跑 pnpm 之前就失败、不改任何 profile 文件(官方迁移指南:`docs/upgrade-guide/v0.2.1-alpha.2/plugin-install-over-installed/`)。这条在启用 HMR 的 profile 上生效,而自带 profile 都启用 HMR。
|
|
@@ -185,9 +211,9 @@ dsh plugin --profile web remove dsh-builtin-browser
|
|
|
185
211
|
dsh plugin --profile web add dsh-builtin-browser@<目标版本>
|
|
186
212
|
```
|
|
187
213
|
|
|
188
|
-
移除会停掉该 bundle
|
|
214
|
+
移除会停掉该 bundle 的插件并清掉它的包映射,新版本随即重新映射。更新完成后重启对应宿主,确保客户端、bridge 与浏览器子进程使用同一版代码。
|
|
189
215
|
|
|
190
|
-
|
|
216
|
+
若宿主的插件管理页提供适用于该插件的更新按钮,也可使用它;已安装的包不能直接重复 `add`。
|
|
191
217
|
|
|
192
218
|
## 桌面端细节
|
|
193
219
|
|
|
@@ -196,11 +222,11 @@ dsh plugin --profile web add dsh-builtin-browser@<目标版本>
|
|
|
196
222
|
- 插件是桌面端 profile 里的依赖(profile 目录通常是 `$DSH_HOME/profiles/desktop`)。更新它 = 把该 profile 里的依赖更新到新版本,然后**重启 DSH Desktop**,客户端设置栏与工具才会换成新代码。
|
|
197
223
|
- **桌面端还多一步,而 Web 端没有**:让插件驱动侧栏的那条 bridge 装在**桌面端自己的安装目录**里(`resources/app/`),插件更新**不会**带上它。桌面端升级会替换该目录、bridge 随之消失,所以请重跑一次:
|
|
198
224
|
```bash
|
|
199
|
-
node desktop-bridge/install.mjs
|
|
200
|
-
node desktop-bridge/install.mjs --revert # 回滚
|
|
225
|
+
node desktop-bridge/install.mjs "<DSH Desktop 安装目录>"
|
|
201
226
|
```
|
|
202
|
-
bridge
|
|
203
|
-
|
|
227
|
+
从新版插件目录运行,先关闭桌面端并备份 `resources/`。插件升级后也要重跑以刷新 bridge 模块。安装脚本会维护 `.before-bridge` 备份;保留这些文件。若需要回滚,使用新版脚本的 `--revert`,遇到已有 `app.asar` 或无法确认补丁归属的拒绝应停止,保留当前应用与备份。不要手动删除当前 `app.asar` 来强行回滚。
|
|
228
|
+
bridge 不在时插件自动退回自托管(多出一个独立窗口);载体差异见[已知限制](limitations.md)。
|
|
229
|
+
- 使用侧栏时浏览器内核来自桌面外壳,**插件更新不会升级这份内核**;自托管回退使用插件依赖的 Electron。也可以在设置里改用自己安装的 Chrome / Edge。
|
|
204
230
|
- **升级桌面端本身不会带上插件**,按上面的方法单独更新它。
|
|
205
231
|
|
|
206
232
|
## Web 端细节
|
|
@@ -208,23 +234,25 @@ dsh plugin --profile web add dsh-builtin-browser@<目标版本>
|
|
|
208
234
|
**Web 端(`dsh web`)**
|
|
209
235
|
|
|
210
236
|
- 插件是 web profile 里的依赖(`$DSH_HOME/profiles/web`),更新后**重启 `dsh web`** 生效。
|
|
211
|
-
- Web 端**没有侧栏、也没有 bridge
|
|
237
|
+
- Web 端**没有侧栏、也没有 bridge**:共享浏览器由插件自托管拉起。Electron 包自身使用懒下载,0.4.16 由本插件的安装脚本提前准备二进制;是否执行受宿主脚本批准与跳过设置控制。缺失时在该 profile 目录执行 `npx --no dsh-browser-install-electron`,见[准备 Electron 二进制](#准备-electron-二进制)。
|
|
212
238
|
- 同样可以在设置里改用本机 Chrome / Edge —— 这是两端**行为一致**的选项。
|
|
213
239
|
- 更新方式与首次安装它时一致(按 npm 包名 `dsh-builtin-browser`、按 GitHub 仓库 `wqty123/dsh-browser`,或本地目录),但**已安装时先按上面的两步移除再装**。
|
|
214
240
|
|
|
215
241
|
**两端一致的体验**
|
|
216
242
|
|
|
217
|
-
-
|
|
218
|
-
-
|
|
243
|
+
- 两端提供相同的工具集、浏览器设置页和浏览历史功能。`cookies.persist` 与 `browser.headless` 仅控制设置中选择的本机 Chrome / Edge,修改后重新选择载体或重启 DSH 生效;内置 Electron 与官方侧栏的登录态由各自载体保存。
|
|
244
|
+
- 插件的数据目录独立于包安装目录:浏览历史与设置都在 `$DSH_HOME/dsh-builtin-browser-host/`(`history.jsonl`、`settings.json`),本机浏览器的登录状态在其中的 `<chrome|edge>-profile`。更新前仍应备份;侧栏登录态保存在桌面外壳自己的数据目录,需单独保留。
|
|
219
245
|
- 升级后如果历史记录不符合预期,先去「设置 → 浏览器」确认这些开关:历史默认**开**、侧栏自动展开默认**开**、会话结束时自动关闭浏览器默认**关**、载体默认**内置**。
|
|
220
246
|
|
|
221
247
|
## 从 0.4.7 升级到 0.4.8
|
|
222
248
|
|
|
249
|
+
> 以下为历史改名说明,不代表当前版本的升级建议。当前请参照[升级到 0.4.16](#升级到-0416)。
|
|
250
|
+
|
|
223
251
|
**这是一个改名版本:34 个工具从 `browser_*` 移入 `dsh_browser_*`,功能一字未改。**
|
|
224
252
|
|
|
225
253
|
| | |
|
|
226
254
|
| --- | --- |
|
|
227
|
-
| **只装这一个浏览器插件** |
|
|
255
|
+
| **只装这一个浏览器插件** | 当时的 0.4.8 仅改工具名;当前版本另有安全与稳定性修复,请按上方说明升级。 |
|
|
228
256
|
| **还装了别的浏览器插件**(尤其腾讯 BrowserSkill) | **建议更新**,否则对方那套工具注册不上。 |
|
|
229
257
|
|
|
230
258
|
改名原因见 [README 的工具名空间一节](../README.md#工具名空间)。更新后 `browser_open` → `dsh_browser_open`(其余同理),并**重启 DSH** 使其生效。
|