dsh-builtin-browser 1.0.1 → 1.0.4

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 (222) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +1 -1
  3. package/assets/browser-panel-locales.mjs +37 -5
  4. package/assets/browser-policy.d.mts +29 -0
  5. package/assets/browser-policy.mjs +40 -0
  6. package/desktop-bridge/desktop-discovery.d.mts +1 -1
  7. package/desktop-bridge/desktop-discovery.mjs +59 -9
  8. package/desktop-bridge/desktop-identity.json +12 -0
  9. package/desktop-bridge/install.mjs +14 -7
  10. package/desktop-bridge/plugin-browser-bridge.js +19 -7
  11. package/docs/acceptance-2026-11-27.md +67 -0
  12. package/docs/architecture.md +1 -1
  13. package/docs/development.md +33 -4
  14. package/docs/dsh-0.2.3-host-patch-task.md +34 -0
  15. package/docs/hardcoding-audit.md +28 -8
  16. package/docs/known-issues.md +26 -0
  17. package/docs/limitations.md +6 -2
  18. package/docs/tool-reference.md +1 -1
  19. package/docs/v1.1.0-bu-data-batching-task.md +66 -0
  20. package/docs/v1.1.0-compat-hardcoding-task.md +85 -0
  21. package/dsh-host-patch/README.md +4 -0
  22. package/dsh-host-patch/apply.mjs +61 -13
  23. package/dsh-host-patch/rc3-revision9.json.gz +0 -0
  24. package/dsh-host-patch/rc5-revision9.json.gz +0 -0
  25. package/dsh-host-patch/tauri/desktop-main.cjs +62 -0
  26. package/dsh-host-patch/tauri/sidebar-session.cjs +104 -0
  27. package/dsh-host-patch/tauri-revision1.json +39 -0
  28. package/dsh-host-patch/tauri.json +43 -0
  29. package/dsh-host-patch/v023-alpha2.json +153 -0
  30. package/lib/browser/anti-bot.js +215 -0
  31. package/lib/browser/deep-dom.js +39 -0
  32. package/lib/browser/runtime.js +15 -0
  33. package/lib/browser/takeover-target.js +13 -6
  34. package/lib/browser/types.js +30 -1
  35. package/lib/browser-electron/authenticated-route.js +16 -2
  36. package/lib/browser-electron/automatic-maintenance.js +16 -10
  37. package/lib/browser-electron/bridge-connection.js +3 -8
  38. package/lib/browser-electron/bridge-install.js +2 -1
  39. package/lib/browser-electron/bridge-status.js +55 -26
  40. package/lib/browser-electron/desktop-bridge-host.js +7 -6
  41. package/lib/browser-electron/desktop-identity.js +28 -5
  42. package/lib/browser-electron/desktop-shell.js +64 -0
  43. package/lib/browser-electron/electron-provision.js +105 -18
  44. package/lib/browser-electron/entry.js +129 -44
  45. package/lib/browser-electron/extension-browser.js +4 -4
  46. package/lib/browser-electron/foreground-watch.js +134 -0
  47. package/lib/browser-electron/guest-cookie-jar.js +13 -13
  48. package/lib/browser-electron/guest-route.js +181 -32
  49. package/lib/browser-electron/guest-runtime.js +61 -10
  50. package/lib/browser-electron/guest-storage.js +2 -2
  51. package/lib/browser-electron/history-store.js +1 -5
  52. package/lib/browser-electron/host-main.js +8 -4
  53. package/lib/browser-electron/host-patch-maintenance.js +14 -8
  54. package/lib/browser-electron/maintenance-route.js +2 -1
  55. package/lib/browser-electron/missing-system-browser.js +5 -9
  56. package/lib/browser-electron/preferred-browser.js +7 -3
  57. package/lib/browser-electron/preview-route.js +9 -13
  58. package/lib/browser-electron/process-ownership.js +1 -1
  59. package/lib/browser-electron/profile-command.js +2 -1
  60. package/lib/browser-electron/profile-extension.js +5 -0
  61. package/lib/browser-electron/profile-lease.js +152 -47
  62. package/lib/browser-electron/provider-core.js +527 -0
  63. package/lib/browser-electron/provider-interaction.js +963 -0
  64. package/lib/browser-electron/provider-media.js +518 -0
  65. package/lib/browser-electron/provider-navigation.js +301 -0
  66. package/lib/browser-electron/provider-observation.js +623 -0
  67. package/lib/browser-electron/provider-tabs.js +372 -0
  68. package/lib/browser-electron/provider.js +150 -3301
  69. package/lib/browser-electron/reference-route.js +9 -18
  70. package/lib/browser-electron/remote-host.js +79 -34
  71. package/lib/browser-electron/runtime-status.js +56 -6
  72. package/lib/browser-electron/settings-store.js +3 -6
  73. package/lib/browser-electron/sidebar-only-host.js +1 -1
  74. package/lib/browser-electron/system-browser.js +539 -172
  75. package/lib/browser-electron/tauri-host.js +208 -0
  76. package/lib/browser-electron/virtual-cursor.js +23 -13
  77. package/lib/browser-reference/service.js +22 -4
  78. package/lib/browser-reference/web-sources.js +1 -1
  79. package/lib/client.js +43409 -0
  80. package/lib/compat/host-features.js +75 -0
  81. package/lib/reference-source.js +1 -1
  82. package/lib/reference-text.js +23 -1
  83. package/lib/takeover-protocol.js +1 -1
  84. package/lib/tool-browser/block-recovery.js +69 -0
  85. package/lib/tool-browser/code-tool.js +170 -19
  86. package/lib/tool-browser/code-worker.js +115 -20
  87. package/lib/tool-browser/errors.js +34 -0
  88. package/lib/tool-browser/index.js +66 -3593
  89. package/lib/tool-browser/page-probe.js +227 -28
  90. package/lib/tool-browser/panel-page.js +2 -1
  91. package/lib/tool-browser/probe-client.js +157 -0
  92. package/lib/tool-browser/screenshot-annotations.js +108 -0
  93. package/lib/tool-browser/state.js +337 -0
  94. package/lib/tool-browser/takeover.js +1 -1
  95. package/lib/tool-browser/tools-debug.js +862 -0
  96. package/lib/tool-browser/tools-interaction.js +993 -0
  97. package/lib/tool-browser/tools-navigation.js +807 -0
  98. package/lib/tool-browser/tools-observation.js +461 -0
  99. package/lib/tool-browser/tools-reference.js +293 -0
  100. package/lib/web-guest.js +1 -0
  101. package/package.json +16 -36
  102. package/scripts/build-client.mjs +305 -0
  103. package/scripts/build.mjs +15 -12
  104. package/scripts/fix-exports.mjs +6 -16
  105. package/scripts/install-electron.mjs +55 -5
  106. package/scripts/pack.mjs +99 -0
  107. package/scripts/publish-manifest.mjs +56 -0
  108. package/scripts/verify-exports.mjs +26 -15
  109. package/skills/dsh-builtin-browser/SKILL.md +27 -2
  110. package/skills/dsh-builtin-browser/references/batch.md +15 -0
  111. package/src/browser/anti-bot.ts +251 -0
  112. package/src/browser/deep-dom.ts +40 -0
  113. package/src/browser/runtime.ts +18 -0
  114. package/src/browser/takeover-target.ts +16 -7
  115. package/src/browser/types.ts +56 -3
  116. package/src/browser-electron/authenticated-route.ts +29 -4
  117. package/src/browser-electron/automatic-maintenance.ts +23 -13
  118. package/src/browser-electron/bridge-connection.ts +11 -10
  119. package/src/browser-electron/bridge-install.ts +2 -1
  120. package/src/browser-electron/bridge-status.ts +61 -22
  121. package/src/browser-electron/desktop-bridge-host.ts +9 -7
  122. package/src/browser-electron/desktop-identity.ts +38 -5
  123. package/src/browser-electron/desktop-shell.ts +100 -0
  124. package/src/browser-electron/electron-provision.ts +104 -18
  125. package/src/browser-electron/entry.ts +1378 -1299
  126. package/src/browser-electron/extension-browser.ts +11 -4
  127. package/src/browser-electron/foreground-watch.ts +142 -0
  128. package/src/browser-electron/guest-cookie-jar.ts +3 -2
  129. package/src/browser-electron/guest-route.ts +180 -32
  130. package/src/browser-electron/guest-runtime.ts +61 -10
  131. package/src/browser-electron/guest-storage.ts +5 -2
  132. package/src/browser-electron/history-store.ts +3 -6
  133. package/src/browser-electron/host-main.ts +8 -4
  134. package/src/browser-electron/host-patch-maintenance.ts +18 -9
  135. package/src/browser-electron/maintenance-route.ts +2 -1
  136. package/src/browser-electron/missing-system-browser.ts +11 -10
  137. package/src/browser-electron/preferred-browser.ts +13 -3
  138. package/src/browser-electron/preview-route.ts +9 -12
  139. package/src/browser-electron/process-ownership.ts +9 -3
  140. package/src/browser-electron/profile-command.ts +2 -1
  141. package/src/browser-electron/profile-extension.ts +5 -0
  142. package/src/browser-electron/profile-lease.ts +131 -35
  143. package/src/browser-electron/provider-core.ts +1107 -0
  144. package/src/browser-electron/provider-interaction.ts +1034 -0
  145. package/src/browser-electron/provider-media.ts +589 -0
  146. package/src/browser-electron/provider-navigation.ts +323 -0
  147. package/src/browser-electron/provider-observation.ts +664 -0
  148. package/src/browser-electron/provider-tabs.ts +372 -0
  149. package/src/browser-electron/provider.ts +158 -4063
  150. package/src/browser-electron/reference-route.ts +598 -608
  151. package/src/browser-electron/remote-host.ts +118 -42
  152. package/src/browser-electron/runtime-status.ts +80 -13
  153. package/src/browser-electron/settings-store.ts +10 -6
  154. package/src/browser-electron/sidebar-only-host.ts +4 -2
  155. package/src/browser-electron/system-browser.ts +537 -184
  156. package/src/browser-electron/tauri-host.ts +194 -0
  157. package/src/browser-electron/virtual-cursor.ts +24 -14
  158. package/src/browser-reference/service.ts +38 -7
  159. package/src/browser-reference/web-sources.ts +4 -1
  160. package/src/client/apply-guard.ts +22 -0
  161. package/src/client/browser/BrowserController.ts +3 -3
  162. package/src/client/browser/IframeImpl.ts +182 -176
  163. package/src/client/browser/frame-history.ts +125 -0
  164. package/src/client/browser/frame-state.ts +27 -0
  165. package/src/client/browser/web-reference-source.ts +5 -1
  166. package/src/client/definition.tsx +36 -30
  167. package/src/client/electron/ElectronWebViewImpl.ts +20 -13
  168. package/src/client/electron/ElectronWebviewPresentation.ts +4 -2
  169. package/src/client/electron/NativeChildPresentation.ts +11 -3
  170. package/src/client/electron/NativeViewPage.ts +19 -5
  171. package/src/client/index.ts +333 -293
  172. package/src/client/locales.ts +9 -6
  173. package/src/client/reference/client/plugin.ts +21 -2
  174. package/src/client/reference/client/production/ReferenceCapsules.tsx +3 -3
  175. package/src/client/reference/client/production/assembly.ts +4 -28
  176. package/src/client/reference/client/production/availability.ts +0 -2
  177. package/src/client/reference/client/production/composer-attachments.ts +44 -0
  178. package/src/client/reference/client/production/draft-adapter.ts +4 -0
  179. package/src/client/reference/client/production/http-transport.ts +0 -5
  180. package/src/client/reference/client/production/production-submission.ts +50 -290
  181. package/src/client/reference/client/production/protocol.ts +7 -4
  182. package/src/client/reference/client/production/runtime.ts +41 -86
  183. package/src/client/reference/client/production/source-marker.ts +49 -13
  184. package/src/client/reference/client/production/user-text-rule.ts +10 -1
  185. package/src/client/reference/client/reveal.ts +3 -1
  186. package/src/client/reference/client/session-schedule.ts +36 -0
  187. package/src/client/settings/index.ts +8 -0
  188. package/src/client/settings/mount-guard.ts +31 -0
  189. package/src/client/settings/panel.ts +163 -52
  190. package/src/client/startpage/controller.ts +3 -6
  191. package/src/client/view/BrowserBody.tsx +2 -1
  192. package/src/client/view/IframePresentation.ts +37 -16
  193. package/src/client/view/StartPage.tsx +2 -1
  194. package/src/compat/host-features.ts +92 -0
  195. package/src/reference-source.ts +1 -1
  196. package/src/reference-text.ts +23 -1
  197. package/src/takeover-protocol.ts +11 -2
  198. package/src/tool-browser/block-recovery.ts +85 -0
  199. package/src/tool-browser/code-tool.ts +173 -19
  200. package/src/tool-browser/code-worker.ts +101 -15
  201. package/src/tool-browser/errors.ts +40 -0
  202. package/src/tool-browser/index.ts +66 -3534
  203. package/src/tool-browser/page-probe.ts +229 -28
  204. package/src/tool-browser/panel-page.ts +3 -1
  205. package/src/tool-browser/probe-client.ts +183 -0
  206. package/src/tool-browser/screenshot-annotations.ts +131 -0
  207. package/src/tool-browser/state.ts +375 -0
  208. package/src/tool-browser/takeover.ts +3 -2
  209. package/src/tool-browser/tools-debug.ts +806 -0
  210. package/src/tool-browser/tools-interaction.ts +956 -0
  211. package/src/tool-browser/tools-navigation.ts +786 -0
  212. package/src/tool-browser/tools-observation.ts +474 -0
  213. package/src/tool-browser/tools-reference.ts +294 -0
  214. package/src/web-guest.ts +35 -34
  215. package/dist/client.cjs +0 -43167
  216. package/dist/client.d.cts +0 -516
  217. package/dist/client.d.mts +0 -516
  218. package/dist/index.cjs +0 -92
  219. package/dist/index.d.mts +0 -2960
  220. package/dist/index.mjs +0 -24
  221. package/lib/browser-reference/submission-receipts.js +0 -139
  222. package/src/browser-reference/submission-receipts.ts +0 -122
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Authenticate plugin HTTP routes with the browser session owned by DSH.
3
- * The connection service verifies its signed cookie and completes denied responses.
3
+ * On DSH >= 0.2.3, `webServer` admits requests before dispatch and passes the
4
+ * live Peer as the third handler argument; on older hosts, the connection
5
+ * service verifies its signed cookie and completes denied responses.
4
6
  * @module dsh-browser/browser-electron/authenticated-route
5
7
  */
6
8
  import type { IncomingMessage, ServerResponse } from 'node:http'
@@ -15,8 +17,17 @@ export interface BrowserPairingConnection {
15
17
  requestRejection(request: IncomingMessage): 401 | 403 | undefined
16
18
  }
17
19
 
20
+ /** Host-admitted peer passed as the third handler argument on DSH >= 0.2.3. */
21
+ export interface BrowserHttpPeer {
22
+ readonly signal?: AbortSignal
23
+ }
24
+
18
25
  /** An exact HTTP route registered with the DSH web server. */
19
- export type BrowserHttpHandler = (request: IncomingMessage, response: ServerResponse) => void | Promise<void>
26
+ export type BrowserHttpHandler = (
27
+ request: IncomingMessage,
28
+ response: ServerResponse,
29
+ peer?: BrowserHttpPeer,
30
+ ) => void | Promise<void>
20
31
 
21
32
  /**
22
33
  * Check the current host credential on every request before reading settings, capturing a frame,
@@ -29,7 +40,14 @@ export function authenticatedRoute(
29
40
  connection: () => BrowserConnection | undefined,
30
41
  handler: BrowserHttpHandler,
31
42
  ): BrowserHttpHandler {
32
- return (request, response) => {
43
+ return (request, response, peer) => {
44
+ if (peer !== undefined) {
45
+ if (peer.signal?.aborted) {
46
+ replyJson(response, 401, { error: 'unauthorized' })
47
+ return
48
+ }
49
+ return handler(request, response, peer)
50
+ }
33
51
  let host: BrowserConnection | undefined
34
52
  try {
35
53
  host = connection()
@@ -51,7 +69,14 @@ export function pairedRoute(
51
69
  connection: () => BrowserPairingConnection | undefined,
52
70
  handler: BrowserHttpHandler,
53
71
  ): BrowserHttpHandler {
54
- return (request, response) => {
72
+ return (request, response, peer) => {
73
+ if (peer !== undefined) {
74
+ if (peer.signal?.aborted) {
75
+ replyJson(response, 401, { error: 'unauthorized' })
76
+ return
77
+ }
78
+ return handler(request, response, peer)
79
+ }
55
80
  let rejection: 401 | 403 | undefined
56
81
  try {
57
82
  const host = connection()
@@ -1,4 +1,4 @@
1
- import { BROWSER_PROFILE_DIR } from '../../assets/browser-policy.mjs'
1
+ import { BROWSER_PROFILE_DIR, MAINTENANCE_PLAN_MAX_AGE_MS, MAINTENANCE_QUIT_WAIT_MS, MAINTENANCE_RESULT_CACHE_MS } from '../../assets/browser-policy.mjs'
2
2
  /** User-requested Desktop maintenance (Windows and macOS), coordinated outside the Desktop process tree. */
3
3
  import { execFile, spawn } from 'node:child_process'
4
4
  import * as fs from 'node:fs'
@@ -31,7 +31,7 @@ export interface AutomaticMaintenanceOptions {
31
31
  interface AutomaticPlan {
32
32
  readonly version: 1
33
33
  readonly id: string
34
- readonly action: 'reinstall'
34
+ readonly action: 'reinstall' | 'uninstall'
35
35
  readonly root: string
36
36
  readonly nodePath: string
37
37
  readonly electronNode: boolean
@@ -45,7 +45,11 @@ interface AutomaticPlan {
45
45
  }
46
46
 
47
47
  export class ReinstallPreflightError extends Error {
48
- constructor(readonly code: string, message: string) { super(message) }
48
+ readonly code: string
49
+ constructor(code: string, message: string) {
50
+ super(message)
51
+ this.code = code
52
+ }
49
53
  }
50
54
 
51
55
  function archiveExists(path: string): boolean {
@@ -197,7 +201,7 @@ export interface ReinstallSteps {
197
201
  }
198
202
 
199
203
  /** Called under the automatic job lock, only after the closed-process barrier. */
200
- export async function runReinstallTransaction(steps: ReinstallSteps): Promise<BridgeActionResult> {
204
+ export async function runReinstallTransaction(steps: ReinstallSteps, action: 'reinstall' | 'uninstall' = 'reinstall'): Promise<BridgeActionResult> {
201
205
  const removed = await steps.absent() ? undefined : await steps.remove()
202
206
  if (removed && !removed.ok) throw new Error(`REINSTALL_REMOVE_FAILED: ${removed.output}`)
203
207
  if (!await steps.absent()) throw new Error('REINSTALL_REMOVE_FAILED: profile dependency remains installed')
@@ -206,6 +210,11 @@ export async function runReinstallTransaction(steps: ReinstallSteps): Promise<Br
206
210
  if (!reverted.ok && !(wasAbsent && steps.hostAbsent() && reverted.code === 1 && /^nothing to revert in /m.test(reverted.output)
207
211
  && !/error|refus|incomplete|EACCES|EPERM/i.test(reverted.output))) throw new Error(`REINSTALL_REVERT_FAILED: ${reverted.output}`)
208
212
  if (!steps.hostAbsent()) throw new Error('REINSTALL_REVERT_FAILED: host patch is still present')
213
+ // uninstall stops here on purpose: the machine is now free of the bridge and of the host patch,
214
+ // which is the only exit a user has when the desktop integration itself is the problem (#126).
215
+ if (action === 'uninstall') {
216
+ return { ...reverted, output: [removed?.output, reverted.output].filter(Boolean).join('\n').slice(-20_000) }
217
+ }
209
218
  const applied = await steps.apply()
210
219
  if (!applied.ok || applied.hostPatch?.status !== 'applied') throw new Error(`REINSTALL_APPLY_FAILED: ${applied.output}`)
211
220
  const added = await steps.add()
@@ -322,7 +331,7 @@ export async function waitForDesktopExit(deps: {
322
331
  readonly now?: () => number
323
332
  }): Promise<void> {
324
333
  const now = deps.now ?? Date.now
325
- const deadline = now() + 60_000
334
+ const deadline = now() + MAINTENANCE_QUIT_WAIT_MS
326
335
  let incomplete = false
327
336
  while (now() < deadline) {
328
337
  deps.checkCancelled()
@@ -444,7 +453,7 @@ async function clearStaleLock(lockPath: string, home: string): Promise<boolean>
444
453
  try {
445
454
  const info = await statAsync(lockPath)
446
455
  // Never touch a lock another request may still be preparing (concurrent start window).
447
- if (Date.now() - info.mtimeMs < 5 * 60_000) return false
456
+ if (Date.now() - info.mtimeMs < MAINTENANCE_RESULT_CACHE_MS) return false
448
457
  const id = (await readFile(lockPath, 'utf8')).trim()
449
458
  if (!/^(?:install|uninstall|reinstall)-[A-Za-z0-9]+$/.test(id)) return false
450
459
  const prior = readAutomaticMaintenance(home)
@@ -473,11 +482,11 @@ function validatePlan(value: unknown, path: string, now = Date.now()): Automatic
473
482
  if (value === null || typeof value !== 'object') throw new Error('invalid automatic maintenance plan')
474
483
  const plan = value as Partial<AutomaticPlan>
475
484
  const created = typeof plan.createdAt === 'string' ? Date.parse(plan.createdAt) : NaN
476
- if (plan.version !== 1 || plan.action !== 'reinstall'
485
+ if (plan.version !== 1 || (plan.action !== 'reinstall' && plan.action !== 'uninstall')
477
486
  || typeof plan.dependency !== 'string' || plan.dependency.trim() === ''
478
- || typeof plan.id !== 'string' || !/^reinstall-[A-Za-z0-9]+$/.test(plan.id)
487
+ || typeof plan.id !== 'string' || !/^(?:reinstall|uninstall)-[A-Za-z0-9]+$/.test(plan.id)
479
488
  || ![plan.root, plan.home, plan.nodePath, plan.directory].every(p => typeof p === 'string' && isAbsolute(p))
480
- || typeof plan.electronNode !== 'boolean' || !Number.isFinite(created) || created > now || now - created > 30_000
489
+ || typeof plan.electronNode !== 'boolean' || !Number.isFinite(created) || created > now || now - created > MAINTENANCE_PLAN_MAX_AGE_MS
481
490
  || (plan.locale !== undefined && !['zh', 'en'].includes(plan.locale))) {
482
491
  throw new Error('invalid or expired automatic maintenance plan')
483
492
  }
@@ -524,9 +533,9 @@ export async function commitAutomaticMaintenance(jobId: string, home = homePath(
524
533
  }
525
534
 
526
535
  /** Only the new, authenticated explicit-click endpoint calls this function. */
527
- export async function startAutomaticMaintenance(action: 'reinstall', root: string, options: AutomaticMaintenanceOptions = {}): Promise<AutomaticMaintenanceJob> {
536
+ export async function startAutomaticMaintenance(action: 'reinstall' | 'uninstall', root: string, options: AutomaticMaintenanceOptions = {}): Promise<AutomaticMaintenanceJob> {
528
537
  requireLiveDesktop()
529
- if (action !== 'reinstall') throw new Error('invalid bridge maintenance action')
538
+ if (action !== 'reinstall' && action !== 'uninstall') throw new Error('invalid bridge maintenance action')
530
539
  if (options.locale !== undefined && !['zh', 'en'].includes(options.locale)) throw new Error('invalid bridge maintenance locale')
531
540
  const dependency = await preflightReinstall(root, homePath())
532
541
  if (!readDesktopIdentity(root).ok) throw new Error('the maintenance target is not a verified DSH Desktop installation')
@@ -549,7 +558,7 @@ export async function startAutomaticMaintenance(action: 'reinstall', root: strin
549
558
  try {
550
559
  const prepared = await prepareBridgeMaintenance('install', root, { directory: base })
551
560
  const original = JSON.parse(await readFile(prepared.planPath, 'utf8')) as { nodePath: string; electronNode: boolean }
552
- const id = basename(prepared.directory).replace(/^install-/, 'reinstall-')
561
+ const id = basename(prepared.directory).replace(/^install-/, action === 'uninstall' ? 'uninstall-' : 'reinstall-')
553
562
  const directory = join(base, id)
554
563
  await renameMaintenanceFile(prepared.directory, directory)
555
564
  const stagedWorker = await stageReinstallRuntime(directory)
@@ -673,6 +682,7 @@ async function runWorker(path: string): Promise<void> {
673
682
  return await withProfileCheckpoint(plan.home, plan.directory, async () => {
674
683
  const residue = await cleanProfileResidue(plan.home)
675
684
  const result = await runReinstallTransaction({
685
+ // The action rides on the plan; the worker only executes what it was committed to.
676
686
  remove: () => profile('uninstall'),
677
687
  absent: async () => {
678
688
  const manifest = JSON.parse(await readFile(join(plan.home, 'profiles', 'desktop', 'package.json'), 'utf8')) as { dependencies?: Record<string, unknown> }
@@ -681,7 +691,7 @@ async function runWorker(path: string): Promise<void> {
681
691
  revert: () => bridge('uninstall'),
682
692
  hostAbsent: () => inspectReinstallHost(plan.root).status === 'absent',
683
693
  apply: () => bridge('install'), add: () => profile('install'),
684
- })
694
+ }, plan.action)
685
695
  extension = await installedProfileExtension(plan.home)
686
696
  return { ...result, output: [residue, result.output].filter(Boolean).join('\n') }
687
697
  }, { reconcile: () => reconcileProfile(plan.root, plan.home) })
@@ -110,17 +110,18 @@ export class BridgeConnection {
110
110
  private serialisable = false
111
111
  /** True once the shell behind this connection has been reported gone. */
112
112
  private lostNotified = false
113
-
114
- /**
115
- * @param endpoint - the shell's published bridge endpoint.
116
- * @param endpointPath - where that endpoint is republished, so a moved port can be followed.
117
- * @param onLost - called once when this connection concludes the shell behind it is gone.
118
- */
113
+ private endpoint: BridgeEndpoint
114
+ private readonly endpointPath?: string
115
+ private readonly onLost?: () => void
119
116
  constructor(
120
- private endpoint: BridgeEndpoint,
121
- private readonly endpointPath?: string,
122
- private readonly onLost?: () => void,
123
- ) {}
117
+ endpoint: BridgeEndpoint,
118
+ endpointPath?: string,
119
+ onLost?: () => void,
120
+ ) {
121
+ this.endpoint = endpoint
122
+ this.endpointPath = endpointPath
123
+ this.onLost = onLost
124
+ }
124
125
 
125
126
  /**
126
127
  * Re-read the published endpoint, and adopt it if the shell has moved.
@@ -1,3 +1,4 @@
1
+ import { MAINTENANCE_PROCESS_TIMEOUT_MS } from '../../assets/browser-policy.mjs'
1
2
  /**
2
3
  * Install, repair or remove the desktop bridge from the settings panel.
3
4
  *
@@ -98,7 +99,7 @@ export interface BridgeReadyOptions {
98
99
  */
99
100
  export async function waitForRestartedBridge(pid: number, options: BridgeReadyOptions = {}): Promise<void> {
100
101
  const path = options.endpointPath ?? bridgeEndpointPath()
101
- const timeoutMs = options.timeoutMs ?? 30_000
102
+ const timeoutMs = options.timeoutMs ?? MAINTENANCE_PROCESS_TIMEOUT_MS
102
103
  const deadline = Date.now() + timeoutMs
103
104
  while (Date.now() < deadline) {
104
105
  try {
@@ -21,6 +21,8 @@ import { fileURLToPath } from 'node:url'
21
21
  import { createRequire } from 'node:module'
22
22
 
23
23
  import { desktopPaths, readDesktopIdentity } from './desktop-identity.ts'
24
+ import { classifyDesktopShell, noDesktopShell, tauriShell, type DesktopShellReport } from './desktop-shell.ts'
25
+ import { findTauriRuntime, runningTauriRuntime, tauriHostPatchStatus } from './tauri-host.ts'
24
26
  import { MAIN_EXTENSION_UNSUPPORTED, type MainExtensionStatus } from './profile-extension.ts'
25
27
  import { BRIDGE_VERSION_MESSAGE } from '../bridge-compatibility.ts'
26
28
  import { conventionalInstallRoots, registeredInstallLocations } from '../../desktop-bridge/desktop-discovery.mjs'
@@ -48,19 +50,64 @@ export function findDesktopInstall(
48
50
  registry: () => readonly string[] = registeredInstallLocations,
49
51
  conventions: () => readonly string[] = conventionalInstallRoots,
50
52
  ): string | undefined {
51
- // Not every install lives in %LOCALAPPDATA%\\Programs: people put the app on another drive, under
52
- // Program Files, or in their own folder. DSH_DESKTOP_PATH names one explicitly, and the usual roots
53
- // are all probed. A test or a caller that passes a base directory gets exactly that base, so the
54
- // behaviour stays pinnable.
55
- const isDesktop = (candidate: string): boolean => readDesktopIdentity(candidate).ok
53
+ for (const candidate of desktopInstallCandidates(localAppData, registry, conventions)) {
54
+ if (readDesktopIdentity(candidate).ok) return candidate
55
+ }
56
+ return undefined
57
+ }
58
+
59
+ /**
60
+ * Classify the desktop shell on this machine.
61
+ *
62
+ * The DSH Tauri hosting this process wins; then a verified official install found by the same walk as
63
+ * {@link findDesktopInstall}; then an installed DSH Tauri; else the first recognised DSH-named shell
64
+ * (third-party or unsupported) is reported, so the settings page can say what it found instead of
65
+ * "no install" — and never offer to patch it.
66
+ * @param options - discovery overrides and the browser to recommend when the sidebar is unavailable.
67
+ * @returns the structured report.
68
+ */
69
+ export function detectDesktopShell(options: {
70
+ readonly localAppData?: string
71
+ readonly registry?: () => readonly string[]
72
+ readonly conventions?: () => readonly string[]
73
+ readonly preferredBrowser?: string
74
+ readonly platform?: NodeJS.Platform
75
+ readonly execPath?: string
76
+ readonly tauriRegistry?: () => readonly string[]
77
+ } = {}): DesktopShellReport {
78
+ const running = runningTauriRuntime(options.execPath)
79
+ if (running !== undefined) return tauriShell(running, tauriHostPatchStatus(running.runtime))
80
+ let recognised: DesktopShellReport | undefined
81
+ for (const candidate of desktopInstallCandidates(options.localAppData, options.registry, options.conventions)) {
82
+ const report = classifyDesktopShell(candidate, readDesktopIdentity(candidate), options)
83
+ if (report.kind === 'official-supported') return report
84
+ if (report.kind !== 'none' && recognised === undefined) recognised = report
85
+ }
86
+ const tauri = findTauriRuntime({ execPath: options.execPath, localAppData: options.localAppData, registry: options.tauriRegistry ?? options.registry })
87
+ if (tauri !== undefined) return tauriShell(tauri, tauriHostPatchStatus(tauri.runtime))
88
+ return recognised ?? noDesktopShell(options)
89
+ }
90
+
91
+ /**
92
+ * Every directory that might hold a desktop install, most specific first.
93
+ *
94
+ * Not every install lives in %LOCALAPPDATA%\\Programs: people put the app on another drive, under
95
+ * Program Files, or in their own folder. DSH_DESKTOP_PATH names one explicitly, and the usual roots
96
+ * are all probed. A test or a caller that passes a base directory gets exactly that base, so the
97
+ * behaviour stays pinnable. Candidates are unverified; callers check identity.
98
+ */
99
+ function* desktopInstallCandidates(
100
+ localAppData?: string,
101
+ registry: () => readonly string[] = registeredInstallLocations,
102
+ conventions: () => readonly string[] = conventionalInstallRoots,
103
+ ): Generator<string> {
56
104
  for (const explicit of [process.env.DSH_DESKTOP_PATH, process.env.DSH_DESKTOP_APP]) {
57
105
  if (explicit !== undefined && explicit !== '') {
58
- const named = explicit
59
- if (isDesktop(named)) return named
106
+ yield explicit
60
107
  // A parent directory is a reasonable thing to point at too: look one level down.
61
108
  try {
62
- for (const entry of readdirSync(named, { withFileTypes: true })) {
63
- if (entry.isDirectory() && isDesktop(join(named, entry.name))) return join(named, entry.name)
109
+ for (const entry of readdirSync(explicit, { withFileTypes: true })) {
110
+ if (entry.isDirectory()) yield join(explicit, entry.name)
64
111
  }
65
112
  } catch {
66
113
  // Not a directory: fall through to the usual roots.
@@ -69,28 +116,20 @@ export function findDesktopInstall(
69
116
  }
70
117
  const roots = localAppData === undefined ? desktopInstallRoots() : [join(localAppData, 'Programs')]
71
118
  for (const base of roots) {
72
- for (const named of DESKTOP_INSTALL_NAMES) {
73
- const candidate = join(base, named)
74
- if (isDesktop(candidate)) return candidate
75
- }
119
+ for (const named of DESKTOP_INSTALL_NAMES) yield join(base, named)
76
120
  try {
77
121
  for (const entry of readdirSync(base, { withFileTypes: true })) {
78
- if (!entry.isDirectory()) continue
79
- const candidate = join(base, entry.name)
80
- if (isDesktop(candidate)) return candidate
122
+ if (entry.isDirectory()) yield join(base, entry.name)
81
123
  }
82
124
  } catch {
83
125
  // A root that does not exist is a state, not an error.
84
126
  }
85
127
  }
86
128
  for (const source of [registry, conventions]) {
87
- try {
88
- for (const candidate of source()) {
89
- if (isDesktop(candidate)) return candidate
90
- }
91
- } catch {}
129
+ let found: readonly string[] = []
130
+ try { found = source() } catch {}
131
+ yield* found
92
132
  }
93
- return undefined
94
133
  }
95
134
 
96
135
  /** Directory names an install is given: a plain directory on Windows, an `.app` bundle on macOS. */
@@ -1,3 +1,4 @@
1
+ import { CARRIER_CALL_TIMEOUT_MS, CARRIER_DOWNLOAD_TIMEOUT_MS, CARRIER_PROBE_TIMEOUT_MS } from '../../assets/browser-policy.mjs'
1
2
  /** Drive the visible sidebar guest through canonical, bridge-bound handles. */
2
3
  import { BridgeConnection, type BridgeEndpoint } from './bridge-connection.ts'
3
4
  import { readFileSync } from 'node:fs'
@@ -38,8 +39,9 @@ export class DesktopBridgeViewHost implements ElectronBrowserViewHost {
38
39
  private lostListener: ((reason: CarrierLossReason) => void) | undefined
39
40
  private static refuseIframe = false
40
41
  private static versionError: string | undefined
41
-
42
- private constructor(endpoint: BridgeEndpoint, private readonly isQuiet: () => boolean = () => false) {
42
+ private readonly isQuiet: () => boolean
43
+ private constructor(endpoint: BridgeEndpoint, isQuiet: () => boolean = () => false) {
44
+ this.isQuiet = isQuiet
43
45
  this.connection = new BridgeConnection(endpoint, bridgeEndpointPath(), () => this.lostListener?.('shell-exited'))
44
46
  }
45
47
 
@@ -59,7 +61,7 @@ export class DesktopBridgeViewHost implements ElectronBrowserViewHost {
59
61
  } catch { return undefined }
60
62
  const probe = new BridgeConnection(endpoint, bridgeEndpointPath())
61
63
  try {
62
- const answer = await probe.call({ op: 'list' }, 5_000)
64
+ const answer = await probe.call({ op: 'list' }, CARRIER_PROBE_TIMEOUT_MS)
63
65
  if (isBridgeVersionMismatch(answer)) throw new BridgeVersionError()
64
66
  if (answer.ok !== true) return undefined
65
67
  if (typeof answer.protocol !== 'number' || !Number.isInteger(answer.protocol)) throw new BridgeVersionError()
@@ -78,7 +80,7 @@ export class DesktopBridgeViewHost implements ElectronBrowserViewHost {
78
80
 
79
81
  async listPages(scope: BrowserSessionWireId, _options: { readonly requireRunning?: boolean } = {}): Promise<readonly CarrierPage[]> {
80
82
  resolveSessionHandle(scope)
81
- const answer = await this.connection.call({ op: 'list', handle: scope }, 5_000)
83
+ const answer = await this.connection.call({ op: 'list', handle: scope }, CARRIER_PROBE_TIMEOUT_MS)
82
84
  if (answer.ok !== true) throw new Error(String(answer.error ?? 'sidebar page listing failed'))
83
85
  if (!Array.isArray(answer.sidebar)) throw new Error('invalid sidebar page listing')
84
86
  const pages: CarrierPage[] = []
@@ -124,7 +126,7 @@ export class DesktopBridgeViewHost implements ElectronBrowserViewHost {
124
126
  throw new BrowserPanelNotDisplayedError('this view has no attached guest yet', PANEL_INITIALIZING)
125
127
  }
126
128
  if (entry.adopted) throw new Error('dsh-builtin-browser: the sidebar page this view was adopted from is gone')
127
- const deadline = options?.deadline ?? Date.now() + 30_000
129
+ const deadline = options?.deadline ?? Date.now() + CARRIER_CALL_TIMEOUT_MS
128
130
  const transactionId = randomUUID()
129
131
  const cancel = (): void => { void this.connection.call({ op: 'cancelSidebar', handle: id, transactionId }, 2_000).catch(() => {}) }
130
132
  options?.signal?.addEventListener('abort', cancel, { once: true })
@@ -158,7 +160,7 @@ export class DesktopBridgeViewHost implements ElectronBrowserViewHost {
158
160
  id,
159
161
  download: async (url, savePath) => {
160
162
  await this.guestFor(id)
161
- const answer = await this.connection.call({ op: 'download', handle: id, url, savePath }, 60_000)
163
+ const answer = await this.connection.call({ op: 'download', handle: id, url, savePath }, CARRIER_DOWNLOAD_TIMEOUT_MS)
162
164
  if (answer.ok !== true) throw new Error(`dsh-builtin-browser: sidebar download failed: ${String(answer.error)}`)
163
165
  },
164
166
  sendCommand: async (method, params, options) => {
@@ -186,7 +188,7 @@ export class DesktopBridgeViewHost implements ElectronBrowserViewHost {
186
188
  showView(handle: ElectronViewHandle, _label?: string, options?: { readonly quiet?: boolean; readonly select?: boolean }): void {
187
189
  if ((options?.quiet ?? this.isQuiet()) && options?.select !== true) return
188
190
  if (!this.views.get(handle.id)?.bound) return
189
- void this.connection.call({ op: 'showTab', handle: tabWireId(readTabHandle(handle.id)) }, 5_000).catch(() => {})
191
+ void this.connection.call({ op: 'showTab', handle: tabWireId(readTabHandle(handle.id)) }, CARRIER_PROBE_TIMEOUT_MS).catch(() => {})
190
192
  }
191
193
 
192
194
  onUserAction(_handler: (action: BrowserUserAction) => void): void {}
@@ -47,6 +47,8 @@ export interface DesktopLayout {
47
47
  interface IdentityRule {
48
48
  readonly packageNames: readonly string[]
49
49
  readonly mainEntry: string
50
+ /** Main entries of look-alike Desktops that are recognized only to be refused, with the reason. */
51
+ readonly unsupportedMainEntries?: Readonly<Record<string, string>>
50
52
  readonly layouts: readonly DesktopLayout[]
51
53
  }
52
54
 
@@ -59,6 +61,9 @@ interface IdentityRule {
59
61
  export const FALLBACK_RULE: IdentityRule = {
60
62
  packageNames: ['@deepseek-ai/dsh-desktop', 'dsh-desktop'],
61
63
  mainEntry: 'lib/main.js',
64
+ unsupportedMainEntries: {
65
+ 'out/main/index.js': 'the electron-vite layout of a third-party DSH Desktop (dataelement/dsh-desktop, issue #62), which shares the package name but not the DeepSeek Harness Desktop shell the bridge patches',
66
+ },
62
67
  layouts: [
63
68
  { name: 'macos-bundle', marker: 'Contents/Info.plist', resources: 'Contents/Resources', executable: 'Contents/MacOS/DeepSeek Harness', cliLauncher: 'runtime/cli/bin/dsh' },
64
69
  { name: 'directory', resources: 'resources', executable: 'DeepSeek Harness.exe', cliLauncher: 'runtime/cli/bin/dsh.cmd' },
@@ -82,6 +87,17 @@ export interface DesktopIdentity {
82
87
  export interface IdentityRefusal {
83
88
  readonly ok: false
84
89
  readonly reason: string
90
+ /**
91
+ * Set once the manifest has named a DSH Desktop package: `third-party-shell` for a layout the rule
92
+ * attributes to another shell, `official-unsupported` for an official package without the patched entry.
93
+ */
94
+ readonly shell?: 'third-party-shell' | 'official-unsupported'
95
+ /** The manifest version, when the refusal came after reading it. */
96
+ readonly version?: string
97
+ }
98
+
99
+ function versionOf(manifest: { version?: unknown }): { version?: string } {
100
+ return typeof manifest.version === 'string' ? { version: manifest.version } : {}
85
101
  }
86
102
 
87
103
  /**
@@ -113,7 +129,14 @@ export function readIdentityRule(): IdentityRule | { readonly error: string } {
113
129
  || layouts[layouts.length - 1]?.marker !== undefined) {
114
130
  return { error: 'desktop-identity.json: layouts must be a non-empty array whose last entry has no marker' }
115
131
  }
116
- return { packageNames: names, mainEntry: main, layouts }
132
+ const unsupported = raw.unsupportedMainEntries
133
+ if (unsupported !== undefined && (unsupported === null || typeof unsupported !== 'object' || Array.isArray(unsupported)
134
+ || Object.entries(unsupported).some(([entry, reason]) => entry === '' || !field(reason)))) {
135
+ return { error: 'desktop-identity.json: unsupportedMainEntries must map entry paths to reasons' }
136
+ }
137
+ return unsupported === undefined
138
+ ? { packageNames: names, mainEntry: main, layouts }
139
+ : { packageNames: names, mainEntry: main, unsupportedMainEntries: unsupported, layouts }
117
140
  } catch (error) {
118
141
  if (error instanceof Error && 'code' in error && (error as NodeJS.ErrnoException).code === 'ENOENT') {
119
142
  return FALLBACK_RULE
@@ -264,6 +287,7 @@ export function readDesktopIdentity(installRoot: string): DesktopIdentity | Iden
264
287
  const layout: 'packed' | 'unpacked' = archivePresent ? 'packed' : 'unpacked'
265
288
  let manifestText: string | undefined
266
289
  let mainPresent: boolean
290
+ let hasEntry: (entry: string) => boolean
267
291
  if (archivePresent) {
268
292
  const parsed = readAsarHeader(archive)
269
293
  if ('error' in parsed) {
@@ -277,16 +301,21 @@ export function readDesktopIdentity(installRoot: string): DesktopIdentity | Iden
277
301
  if (manifestText === undefined) {
278
302
  return { ok: false, reason: `${archive}: package.json is listed but its bytes cannot be read` }
279
303
  }
280
- mainPresent = entryAt(parsed.header.files, rule.mainEntry) !== undefined
304
+ hasEntry = entry => entryAt(parsed.header.files, entry) !== undefined
305
+ mainPresent = hasEntry(rule.mainEntry)
281
306
  } else {
282
307
  const manifestPath = join(appDir, 'package.json')
283
308
  try {
284
309
  manifestText = readFileSync(manifestPath, 'utf8')
285
310
  } catch (error) {
286
- console.error(`[dsh-browser] cannot read the package manifest at ${manifestPath}: ${String(error)}`)
311
+ // Candidate probe directories routinely do not contain resources/app/package.json (issue #106).
312
+ if ((error as NodeJS.ErrnoException).code !== 'ENOENT') {
313
+ console.error(`[dsh-browser] cannot read the package manifest at ${manifestPath}: ${String(error)}`)
314
+ }
287
315
  return { ok: false, reason: `${manifestPath} is missing; a directory without a package manifest is not a DSH Desktop install` }
288
316
  }
289
- mainPresent = existsSync(join(appDir, ...rule.mainEntry.split('/')))
317
+ hasEntry = entry => existsSync(join(appDir, ...entry.split('/')))
318
+ mainPresent = hasEntry(rule.mainEntry)
290
319
  }
291
320
 
292
321
  let manifest: { name?: unknown; version?: unknown }
@@ -307,7 +336,11 @@ export function readDesktopIdentity(installRoot: string): DesktopIdentity | Iden
307
336
  // The main entry is the file the installer patches and the shell runs; if it is not there, this
308
337
  // is not an install this plugin can reason about even though the manifest looks right.
309
338
  if (!mainPresent) {
310
- return { ok: false, reason: `${rule.mainEntry} is not present under ${archivePresent ? archive : appDir}` }
339
+ const foreign = Object.entries(rule.unsupportedMainEntries ?? {}).find(([entry]) => hasEntry(entry))
340
+ if (foreign !== undefined) {
341
+ return { ok: false, shell: 'third-party-shell', ...versionOf(manifest), reason: `${foreign[0]} instead of ${rule.mainEntry}: ${foreign[1]}; use DSH Web or DeepSeek Harness Desktop` }
342
+ }
343
+ return { ok: false, shell: 'official-unsupported', ...versionOf(manifest), reason: `${rule.mainEntry} is not present under ${archivePresent ? archive : appDir}` }
311
344
  }
312
345
 
313
346
  return {
@@ -0,0 +1,100 @@
1
+ /**
2
+ * What kind of desktop shell an install is, and what the user should do with it.
3
+ *
4
+ * The bridge patches exactly one shell: DeepSeek Harness Desktop with its `lib/main.js` entry. A
5
+ * community shell that reuses the `dsh-desktop` package name (dataelement/dsh-desktop, issue #62)
6
+ * is recognised as such and never patched; the report tells the settings page to hide bridge
7
+ * install / repair and to point at the system browser first.
8
+ * @module dsh-browser/browser-electron/desktop-shell
9
+ */
10
+ import type { DesktopIdentity, IdentityRefusal } from './desktop-identity.ts'
11
+ import type { TauriHostPatch, TauriRuntime } from './tauri-host.ts'
12
+
13
+ export type DesktopShellKind = 'official-supported' | 'tauri' | 'official-unsupported' | 'third-party-shell' | 'none'
14
+ export type RecommendedCarrier = 'sidebar' | 'chrome' | 'edge'
15
+
16
+ /** One desktop shell, classified. `official-supported` takes the bridge; `tauri` takes only its sidebar host patch. */
17
+ export interface DesktopShellReport {
18
+ readonly kind: DesktopShellKind
19
+ readonly patchable: boolean
20
+ readonly reason: string
21
+ readonly recommendedCarrier: RecommendedCarrier
22
+ readonly root?: string
23
+ readonly version?: string
24
+ /** DSH Tauri only: its electron-rs runtime directory, whether it hosts this process, and its host patch. */
25
+ readonly runtime?: string
26
+ readonly running?: boolean
27
+ readonly hostPatch?: TauriHostPatch
28
+ }
29
+
30
+ interface CarrierHints {
31
+ /** The stored `browser.channel`; a system browser the user already chose is the one to recommend. */
32
+ readonly preferredBrowser?: string
33
+ readonly platform?: NodeJS.Platform
34
+ }
35
+
36
+ /**
37
+ * The system browser to recommend when the sidebar cannot carry the browser.
38
+ * @param hints - the user's current channel and platform.
39
+ * @returns `chrome` or `edge`.
40
+ */
41
+ export function systemCarrier(hints: CarrierHints = {}): 'chrome' | 'edge' {
42
+ if (hints.preferredBrowser === 'chrome' || hints.preferredBrowser === 'edge') return hints.preferredBrowser
43
+ return (hints.platform ?? process.platform) === 'win32' ? 'edge' : 'chrome'
44
+ }
45
+
46
+ /**
47
+ * Classify one candidate install from its identity reading.
48
+ * @param root - the install directory.
49
+ * @param identity - `readDesktopIdentity(root)`.
50
+ * @param hints - used for the recommended carrier of an unpatchable shell.
51
+ * @returns the report; `none` when the directory is not a DSH-named shell at all.
52
+ */
53
+ export function classifyDesktopShell(root: string, identity: DesktopIdentity | IdentityRefusal, hints: CarrierHints = {}): DesktopShellReport {
54
+ if (identity.ok) {
55
+ return { kind: 'official-supported', patchable: true, reason: `DeepSeek Harness Desktop ${identity.version} at ${root}`, recommendedCarrier: 'sidebar', root, version: identity.version }
56
+ }
57
+ if (identity.shell === undefined) return { ...noDesktopShell(hints), reason: identity.reason }
58
+ return {
59
+ kind: identity.shell,
60
+ patchable: false,
61
+ reason: identity.reason,
62
+ recommendedCarrier: systemCarrier(hints),
63
+ root,
64
+ ...identity.version === undefined ? {} : { version: identity.version },
65
+ }
66
+ }
67
+
68
+ /**
69
+ * The report when no DSH desktop shell was found.
70
+ * @param hints - used for the recommended carrier.
71
+ * @returns a `none` report.
72
+ */
73
+ export function noDesktopShell(hints: CarrierHints = {}): DesktopShellReport {
74
+ return {
75
+ kind: 'none',
76
+ patchable: false,
77
+ reason: 'no DSH Desktop install found in the usual roots, at DSH_DESKTOP_PATH or DSH_DESKTOP_APP, in the uninstall registry, or at this platform\'s conventional locations',
78
+ recommendedCarrier: systemCarrier(hints),
79
+ }
80
+ }
81
+
82
+ /**
83
+ * The report for DSH Tauri. Its sidebar is driven through its own `dshDesktop.browser`; what the
84
+ * plugin patches is only the sidebar partition (`dsh-host-patch/tauri.json`), never the bridge.
85
+ * @param runtime - the Tauri runtime.
86
+ * @param hostPatch - the runtime's host patch state.
87
+ * @returns a `tauri` report, patchable when the patch can be applied or is applied.
88
+ */
89
+ export function tauriShell(runtime: TauriRuntime, hostPatch: TauriHostPatch): DesktopShellReport {
90
+ return {
91
+ kind: 'tauri',
92
+ patchable: hostPatch.status === 'absent' || hostPatch.status === 'applied',
93
+ reason: `DSH Tauri at ${runtime.root ?? runtime.runtime}; sidebar host patch ${hostPatch.status}${hostPatch.reason === undefined ? '' : `: ${hostPatch.reason}`}`,
94
+ recommendedCarrier: 'sidebar',
95
+ ...runtime.root === undefined ? {} : { root: runtime.root },
96
+ runtime: runtime.runtime,
97
+ running: runtime.running,
98
+ hostPatch,
99
+ }
100
+ }