dsh-builtin-browser 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (305) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/README.en.md +89 -0
  3. package/browser-extension/constants.mjs +20 -0
  4. package/browser-extension/controller.mjs +293 -0
  5. package/browser-extension/locales.mjs +15 -0
  6. package/browser-extension/manifest.json +12 -0
  7. package/browser-extension/options.html +14 -0
  8. package/browser-extension/options.mjs +9 -0
  9. package/browser-extension/permission-guard.mjs +13 -0
  10. package/browser-extension/worker.mjs +74 -0
  11. package/desktop-bridge/desktop-identity.json +10 -2
  12. package/desktop-bridge/install.mjs +28 -2
  13. package/docs/issue-replies-2026-11-28.md +141 -0
  14. package/dsh-host-patch/apply.mjs +1 -1
  15. package/dsh-host-patch/rc3.json +4 -4
  16. package/dsh-host-patch/rc5.json +4 -4
  17. package/dsh-host-patch/v023-alpha2.json +2 -2
  18. package/lib/browser-electron/bridge-status.js +24 -1
  19. package/lib/browser-electron/desktop-identity.js +47 -8
  20. package/lib/client.js +2 -1
  21. package/native-host/install.mjs +5 -0
  22. package/package.json +20 -2
  23. package/scripts/build-client.mjs +305 -0
  24. package/scripts/build.mjs +69 -0
  25. package/scripts/bundle-host.mjs +28 -0
  26. package/scripts/fix-exports.mjs +40 -0
  27. package/scripts/install-electron.mjs +101 -0
  28. package/scripts/pack.mjs +99 -0
  29. package/scripts/publish-manifest.mjs +56 -0
  30. package/scripts/verify-exports.mjs +58 -0
  31. package/scripts/verify-preview-sdk.mjs +93 -0
  32. package/skills/dsh-builtin-browser/SKILL.md +98 -0
  33. package/skills/dsh-builtin-browser/references/batch.md +68 -0
  34. package/skills/dsh-builtin-browser/references/deliver.md +31 -0
  35. package/skills/dsh-builtin-browser/references/locate.md +11 -0
  36. package/skills/dsh-builtin-browser/references/recover.md +11 -0
  37. package/skills/dsh-builtin-browser/references/verify.md +13 -0
  38. package/skills/dsh-debug-host/SKILL.md +56 -0
  39. package/skills/dsh-debug-self/SKILL.md +50 -0
  40. package/src/bridge-compatibility.ts +39 -0
  41. package/src/browser/anti-bot.ts +251 -0
  42. package/src/browser/deep-dom.ts +40 -0
  43. package/src/browser/handles.ts +89 -0
  44. package/src/browser/runtime.ts +578 -0
  45. package/src/browser/takeover-target.ts +45 -0
  46. package/src/browser/types.ts +870 -0
  47. package/src/browser-electron/authenticated-route.ts +109 -0
  48. package/src/browser-electron/automatic-maintenance.ts +736 -0
  49. package/src/browser-electron/bridge-auto.ts +159 -0
  50. package/src/browser-electron/bridge-connection.ts +386 -0
  51. package/src/browser-electron/bridge-endpoint.ts +129 -0
  52. package/src/browser-electron/bridge-install.ts +290 -0
  53. package/src/browser-electron/bridge-maintenance.ts +189 -0
  54. package/src/browser-electron/bridge-status.ts +412 -0
  55. package/src/browser-electron/desktop-bridge-host.ts +253 -0
  56. package/src/browser-electron/desktop-identity.ts +400 -0
  57. package/src/browser-electron/desktop-shell.ts +100 -0
  58. package/src/browser-electron/document-readiness.ts +45 -0
  59. package/src/browser-electron/electron-provision.ts +347 -0
  60. package/src/browser-electron/entry.ts +1378 -0
  61. package/src/browser-electron/ephemeral-profile.ts +189 -0
  62. package/src/browser-electron/extension-browser.ts +230 -0
  63. package/src/browser-electron/extension-setup.ts +67 -0
  64. package/src/browser-electron/file-write.ts +31 -0
  65. package/src/browser-electron/foreground-watch.ts +142 -0
  66. package/src/browser-electron/guest-cookie-jar.ts +177 -0
  67. package/src/browser-electron/guest-cookie-store.ts +59 -0
  68. package/src/browser-electron/guest-css-runtime.ts +76 -0
  69. package/src/browser-electron/guest-css.ts +68 -0
  70. package/src/browser-electron/guest-route.ts +716 -0
  71. package/src/browser-electron/guest-runtime.ts +408 -0
  72. package/src/browser-electron/guest-storage-runtime.ts +54 -0
  73. package/src/browser-electron/guest-storage.ts +120 -0
  74. package/src/browser-electron/history-store.ts +224 -0
  75. package/src/browser-electron/host-main.ts +1385 -0
  76. package/src/browser-electron/host-patch-maintenance.ts +121 -0
  77. package/src/browser-electron/http-body.ts +65 -0
  78. package/src/browser-electron/json-reply.ts +47 -0
  79. package/src/browser-electron/maintenance-broker.ts +166 -0
  80. package/src/browser-electron/maintenance-lifecycle.ts +91 -0
  81. package/src/browser-electron/maintenance-route.ts +68 -0
  82. package/src/browser-electron/missing-system-browser.ts +114 -0
  83. package/src/browser-electron/open-slot.ts +49 -0
  84. package/src/browser-electron/paths.ts +25 -0
  85. package/src/browser-electron/preferred-browser.ts +130 -0
  86. package/src/browser-electron/preview-route.ts +215 -0
  87. package/src/browser-electron/process-ownership.ts +174 -0
  88. package/src/browser-electron/process.ts +23 -0
  89. package/src/browser-electron/profile-checkpoint.ts +187 -0
  90. package/src/browser-electron/profile-command.ts +47 -0
  91. package/src/browser-electron/profile-extension.ts +129 -0
  92. package/src/browser-electron/profile-lease.ts +211 -0
  93. package/src/browser-electron/profile-residue.ts +49 -0
  94. package/src/browser-electron/provider-core.ts +1107 -0
  95. package/src/browser-electron/provider-interaction.ts +1034 -0
  96. package/src/browser-electron/provider-media.ts +589 -0
  97. package/src/browser-electron/provider-navigation.ts +323 -0
  98. package/src/browser-electron/provider-observation.ts +664 -0
  99. package/src/browser-electron/provider-tabs.ts +372 -0
  100. package/src/browser-electron/provider.ts +666 -0
  101. package/src/browser-electron/reference-route.ts +598 -0
  102. package/src/browser-electron/remote-host.ts +1538 -0
  103. package/src/browser-electron/rpc-input.ts +13 -0
  104. package/src/browser-electron/rpc-ops.ts +41 -0
  105. package/src/browser-electron/runtime-diagnostics.ts +38 -0
  106. package/src/browser-electron/runtime-route.ts +105 -0
  107. package/src/browser-electron/runtime-status.ts +309 -0
  108. package/src/browser-electron/settings-route.ts +64 -0
  109. package/src/browser-electron/settings-store.ts +593 -0
  110. package/src/browser-electron/shortcuts-route.ts +112 -0
  111. package/src/browser-electron/sidebar-only-host.ts +300 -0
  112. package/src/browser-electron/startpage-shortcuts.ts +213 -0
  113. package/src/browser-electron/system-browser.ts +1850 -0
  114. package/src/browser-electron/tauri-host.ts +194 -0
  115. package/src/browser-electron/timing.ts +16 -0
  116. package/src/browser-electron/virtual-cursor.ts +162 -0
  117. package/src/browser-electron/windows-system.ts +24 -0
  118. package/src/browser-reference/delivery.ts +384 -0
  119. package/src/browser-reference/entry.ts +631 -0
  120. package/src/browser-reference/export.ts +339 -0
  121. package/src/browser-reference/import.ts +303 -0
  122. package/src/browser-reference/page-script.ts +1537 -0
  123. package/src/browser-reference/service.ts +1346 -0
  124. package/src/browser-reference/store.ts +172 -0
  125. package/src/browser-reference/text-quote.ts +219 -0
  126. package/src/browser-reference/types.ts +195 -0
  127. package/src/browser-reference/visible.ts +367 -0
  128. package/src/browser-reference/web-sources.ts +106 -0
  129. package/src/client/apply-guard.ts +22 -0
  130. package/src/client/browser/BrowserController.ts +693 -0
  131. package/src/client/browser/BrowserFrame.ts +78 -0
  132. package/src/client/browser/BrowserNavigation.ts +169 -0
  133. package/src/client/browser/BrowserPage.ts +23 -0
  134. package/src/client/browser/BrowserPersistence.ts +44 -0
  135. package/src/client/browser/IframeImpl.ts +182 -0
  136. package/src/client/browser/child-tabs.ts +14 -0
  137. package/src/client/browser/frame-history.ts +125 -0
  138. package/src/client/browser/frame-state.ts +27 -0
  139. package/src/client/browser/iframe-reference.ts +67 -0
  140. package/src/client/browser/initialization.ts +262 -0
  141. package/src/client/browser/omnibox.ts +243 -0
  142. package/src/client/browser/store.ts +38 -0
  143. package/src/client/browser/takeover-channel.ts +72 -0
  144. package/src/client/browser/url.ts +46 -0
  145. package/src/client/browser/web-reference-source.ts +56 -0
  146. package/src/client/css-modules.d.ts +4 -0
  147. package/src/client/definition.tsx +36 -0
  148. package/src/client/electron/ElectronWebViewImpl.ts +371 -0
  149. package/src/client/electron/ElectronWebviewPresentation.ts +140 -0
  150. package/src/client/electron/NativeChildPresentation.ts +53 -0
  151. package/src/client/electron/NativeViewPage.ts +265 -0
  152. package/src/client/electron/pages.ts +23 -0
  153. package/src/client/electron/reference-overlay.ts +53 -0
  154. package/src/client/electron/workspace.ts +33 -0
  155. package/src/client/index.ts +333 -0
  156. package/src/client/locales.ts +860 -0
  157. package/src/client/pages.ts +28 -0
  158. package/src/client/reference/client/BrowserRefLink.tsx +142 -0
  159. package/src/client/reference/client/draft-reference.ts +167 -0
  160. package/src/client/reference/client/index.ts +7 -0
  161. package/src/client/reference/client/ordered-submission.ts +108 -0
  162. package/src/client/reference/client/pending-delivery.ts +216 -0
  163. package/src/client/reference/client/plugin.ts +208 -0
  164. package/src/client/reference/client/production/ReferenceCapsules.tsx +345 -0
  165. package/src/client/reference/client/production/ReferenceDock.module.css +193 -0
  166. package/src/client/reference/client/production/ReferenceDock.tsx +6 -0
  167. package/src/client/reference/client/production/ReferenceFeedback.tsx +15 -0
  168. package/src/client/reference/client/production/ReferenceMath.tsx +44 -0
  169. package/src/client/reference/client/production/ReferenceText.tsx +36 -0
  170. package/src/client/reference/client/production/assembly.ts +447 -0
  171. package/src/client/reference/client/production/asset-store.ts +144 -0
  172. package/src/client/reference/client/production/availability.ts +72 -0
  173. package/src/client/reference/client/production/bytes.ts +36 -0
  174. package/src/client/reference/client/production/composer-attachments.ts +44 -0
  175. package/src/client/reference/client/production/delivery-client.ts +211 -0
  176. package/src/client/reference/client/production/draft-adapter.ts +512 -0
  177. package/src/client/reference/client/production/http-transport.ts +212 -0
  178. package/src/client/reference/client/production/production-submission.ts +70 -0
  179. package/src/client/reference/client/production/protocol.ts +234 -0
  180. package/src/client/reference/client/production/reference-card.ts +240 -0
  181. package/src/client/reference/client/production/reference-labels.ts +29 -0
  182. package/src/client/reference/client/production/reply-link-bridge.ts +222 -0
  183. package/src/client/reference/client/production/reveal.ts +215 -0
  184. package/src/client/reference/client/production/runtime.ts +1056 -0
  185. package/src/client/reference/client/production/snapshot-adapter.ts +154 -0
  186. package/src/client/reference/client/production/source-marker.ts +99 -0
  187. package/src/client/reference/client/production/source-opener.ts +55 -0
  188. package/src/client/reference/client/production/styles.ts +104 -0
  189. package/src/client/reference/client/production/user-text-rule.ts +67 -0
  190. package/src/client/reference/client/reveal.ts +109 -0
  191. package/src/client/reference/client/scheme.ts +114 -0
  192. package/src/client/reference/client/session-schedule.ts +36 -0
  193. package/src/client/reference/client/types.ts +168 -0
  194. package/src/client/reference/css-modules.d.ts +4 -0
  195. package/src/client/reference/index.ts +11 -0
  196. package/src/client/reference-capture-owner.ts +162 -0
  197. package/src/client/reference-intents.ts +36 -0
  198. package/src/client/settings/index.ts +42 -0
  199. package/src/client/settings/mount-guard.ts +31 -0
  200. package/src/client/settings/panel.ts +2773 -0
  201. package/src/client/shortcut-open.ts +30 -0
  202. package/src/client/startpage/binding.ts +99 -0
  203. package/src/client/startpage/controller.ts +300 -0
  204. package/src/client/startpage/model.ts +279 -0
  205. package/src/client/view/Browser.module.css +751 -0
  206. package/src/client/view/BrowserBody.tsx +315 -0
  207. package/src/client/view/BrowserPresentation.ts +9 -0
  208. package/src/client/view/BrowserTitle.tsx +17 -0
  209. package/src/client/view/IframePresentation.ts +365 -0
  210. package/src/client/view/StartPage.tsx +598 -0
  211. package/src/client/view/TakeoverBanner.tsx +21 -0
  212. package/src/compat/host-features.ts +92 -0
  213. package/src/index.ts +110 -0
  214. package/src/reference-owner.ts +5 -0
  215. package/src/reference-page.ts +9 -0
  216. package/src/reference-source.ts +3 -0
  217. package/src/reference-text.ts +219 -0
  218. package/src/startpage-settings.ts +103 -0
  219. package/src/startpage.ts +71 -0
  220. package/src/takeover-protocol.ts +28 -0
  221. package/src/tool-browser/block-recovery.ts +85 -0
  222. package/src/tool-browser/code-tool.ts +555 -0
  223. package/src/tool-browser/code-worker.ts +725 -0
  224. package/src/tool-browser/element-fields.ts +167 -0
  225. package/src/tool-browser/errors.ts +40 -0
  226. package/src/tool-browser/index.ts +265 -0
  227. package/src/tool-browser/page-probe.ts +675 -0
  228. package/src/tool-browser/panel-page.ts +126 -0
  229. package/src/tool-browser/probe-client.ts +183 -0
  230. package/src/tool-browser/screenshot-annotations.ts +131 -0
  231. package/src/tool-browser/screenshot-image.ts +49 -0
  232. package/src/tool-browser/state.ts +375 -0
  233. package/src/tool-browser/takeover.ts +199 -0
  234. package/src/tool-browser/tools-debug.ts +806 -0
  235. package/src/tool-browser/tools-interaction.ts +956 -0
  236. package/src/tool-browser/tools-navigation.ts +786 -0
  237. package/src/tool-browser/tools-observation.ts +474 -0
  238. package/src/tool-browser/tools-reference.ts +294 -0
  239. package/src/types/electron-shim.d.ts +144 -0
  240. package/src/types.ts +85 -0
  241. package/src/web-guest.ts +35 -0
  242. package/tools/accept-desktop.mjs +148 -0
  243. package/dist/client.d.cts +0 -516
  244. package/dist/client.d.mts +0 -516
  245. package/dist/index.cjs +0 -92
  246. package/dist/index.d.mts +0 -2960
  247. package/dist/index.mjs +0 -24
  248. package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
  249. package/dsh-builtin-browser-1.0.3.tgz +0 -0
  250. package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  251. package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  252. package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  253. package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  254. package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  255. package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  256. package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  257. package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  258. package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  259. package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  260. package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  261. package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  262. package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  263. package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  264. package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  265. package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  266. package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  267. package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  268. package/dsh-host-patch/sources/manifest.json +0 -218
  269. package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  270. package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  271. package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  272. package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  273. package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  274. package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  275. package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  276. package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  277. package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  278. package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  279. package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  280. package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  281. package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  282. package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  283. package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  284. package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  285. package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  286. package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  287. package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  288. package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  289. package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  290. package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  291. package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  292. package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  293. package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  294. package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  295. package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  296. package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  297. package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  298. package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  299. package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  300. package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  301. package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  302. package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  303. package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  304. package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  305. package/dsh-host-patch/sources/series.json +0 -260
@@ -65,7 +65,7 @@
65
65
  "id": "main",
66
66
  "packageName": "@deepseek-ai/dsh-desktop",
67
67
  "file": "lib/main.js",
68
- "marker": "async savedCookies()",
68
+ "marker": "clearTimeout(force)",
69
69
  "sha256": "837418111658dcc404ab991957dc3143af4c25dacf2781362a8785ee368fbb25",
70
70
  "edits": [
71
71
  {
@@ -78,7 +78,7 @@
78
78
  },
79
79
  {
80
80
  "before": "\n}\n//#endregion\n//#region lib/types/core-package-set.js\n/** Private package installed beside dsh to boot the Desktop Host process. */\nconst DESKTOP_HOST_PACKAGE = \"@deepseek-ai/dsh-desktop-host\";",
81
- "after": "\n}\n//#endregion\n//#region lib/types/main-extensions.js\n/** Explicitly installed, trusted profile extensions running in Electron main. */\nvar __rewriteRelativeImportExtension$2 = function(path, preserveJsx) {\n\tif (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {\n\t\treturn tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : d + ext + \".\" + cm.toLowerCase() + \"js\";\n\t});\n\treturn path;\n};\nasync function fingerprint(profile, name, entry) {\n\tconst directory = await realpath(join(profile, \"node_modules\", name));\n\tconst text = await readFile$1(join(directory, \"package.json\"), \"utf8\");\n\tconst pkg = JSON.parse(text);\n\tconst hash = createHash(\"sha256\").update(entry).update(text);\n\tconst visit = async (path) => {\n\t\tfor (const item of (await readdir(path, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {\n\t\t\tif (item.name === \"node_modules\" || item.name === \".git\") continue;\n\t\t\tconst child = join(path, item.name);\n\t\t\tif (item.isSymbolicLink()) throw new Error(\"extension package contains a symbolic link\");\n\t\t\tif (item.isDirectory()) await visit(child);\n\t\t\telse if (item.isFile()) {\n\t\t\t\tconst content = await readFile$1(child);\n\t\t\t\thash.update(JSON.stringify([relative(directory, child), content.length])).update(content);\n\t\t\t}\n\t\t}\n\t};\n\tawait visit(directory);\n\treturn {\n\t\tfingerprint: hash.digest(\"hex\"),\n\t\t...record$6(pkg) && typeof pkg.version === \"string\" ? { version: pkg.version } : {}\n\t};\n}\nfunction record$6(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction inside(root, path) {\n\tconst child = relative(root, path);\n\treturn child !== \"\" && !isAbsolute(child) && child !== \"..\" && !child.startsWith(\"../\") && !child.startsWith(\"..\\\\\");\n}\n/**\n* Discover opt-in entries from direct installed profile dependencies; reject escaping paths, including symlinks.\n* Invalid dependencies are reported individually and do not suppress other entries.\n* @param profile - desktop profile directory.\n* @param report - diagnostic sink receiving the failing package name and error.\n* @returns validated main entry paths; an absent profile manifest yields no entries.\n*/\nasync function discoverDesktopMainExtensions(profile, report) {\n\tlet manifest;\n\ttry {\n\t\tmanifest = JSON.parse(await readFile$1(join(profile, \"package.json\"), \"utf8\"));\n\t} catch (error) {\n\t\tif (!record$6(error) || error.code !== \"ENOENT\") report(\"profile\", error);\n\t\treturn [];\n\t}\n\tif (!record$6(manifest) || !record$6(manifest.dependencies)) return [];\n\tconst entries = [];\n\tfor (const name of Object.keys(manifest.dependencies)) try {\n\t\tif (!/^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/u.test(name)) throw new Error(\"invalid dependency name\");\n\t\tconst directory = await realpath(join(profile, \"node_modules\", name));\n\t\tconst pkg = JSON.parse(await readFile$1(join(directory, \"package.json\"), \"utf8\"));\n\t\tif (!record$6(pkg) || !record$6(pkg.dsh) || !record$6(pkg.dsh.desktop) || pkg.dsh.desktop.main === void 0) continue;\n\t\tconst main = pkg.dsh.desktop.main;\n\t\tif (typeof main !== \"string\" || !main.startsWith(\"./\") || !inside(directory, resolve(directory, main))) throw new Error(\"dsh.desktop.main must be a relative entry inside its package\");\n\t\tconst entry = await realpath(resolve(directory, main));\n\t\tif (!inside(directory, entry)) throw new Error(\"dsh.desktop.main resolves outside its package\");\n\t\tentries.push({\n\t\t\tname,\n\t\t\tentry\n\t\t});\n\t} catch (error) {\n\t\treport(name, error);\n\t}\n\treturn entries;\n}\n/**\n* Start trusted extensions independently and register synchronous cleanup on will-quit.\n* @param profile - desktop profile containing installed dependencies.\n* @param api - Electron capabilities and shared Harness home.\n* @returns idempotent disposer that also removes the quit listener.\n*/\nasync function startDesktopMainExtensions(profile, api) {\n\tconst report = (name, error) => {\n\t\tconsole.error(`desktop main extension ${name}:`, error);\n\t};\n\tconst disposers = [];\n\tconst running = /* @__PURE__ */ new Map();\n\tlet stopped = false;\n\tconst dispose = () => {\n\t\tstopped = true;\n\t\tapi.app.off(\"will-quit\", dispose);\n\t\tfor (const extension of disposers.splice(0).reverse()) try {\n\t\t\textension.dispose();\n\t\t} catch (error) {\n\t\t\treport(extension.name, error);\n\t\t}\n\t};\n\tapi.app.on(\"will-quit\", dispose);\n\tconst entries = await discoverDesktopMainExtensions(profile, report);\n\tfor (const { name, entry } of entries) {\n\t\tif (stopped) break;\n\t\tlet installed;\n\t\ttry {\n\t\t\tinstalled = await fingerprint(profile, name, entry);\n\t\t} catch (error) {\n\t\t\treport(name, error);\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst extension = await import(__rewriteRelativeImportExtension$2(pathToFileURL(entry).href));\n\t\t\tif (stopped) break;\n\t\t\tif (!record$6(extension) || typeof extension.start !== \"function\") throw new Error(\"entry must export start(api)\");\n\t\t\tconst result = await extension.start(api);\n\t\t\tif (typeof result === \"function\") disposers.push({\n\t\t\t\tname,\n\t\t\t\tdispose: () => {\n\t\t\t\t\tresult();\n\t\t\t\t}\n\t\t\t});\n\t\t\telse if (record$6(result) && typeof result.dispose === \"function\") {\n\t\t\t\tconst dispose = result.dispose.bind(result);\n\t\t\t\tdisposers.push({\n\t\t\t\t\tname,\n\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\tdispose();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (stopped) dispose();\n\t\t\trunning.set(name, {\n\t\t\t\tfingerprint: installed.fingerprint,\n\t\t\t\tstatus: {\n\t\t\t\t\tstate: \"loaded\",\n\t\t\t\t\t...installed.version === void 0 ? {} : { version: installed.version },\n\t\t\t\t\tloadedAt: (/* @__PURE__ */ new Date()).toISOString()\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\treport(name, error);\n\t\t\trunning.set(name, {\n\t\t\t\tfingerprint: installed.fingerprint,\n\t\t\t\tstatus: {\n\t\t\t\t\tstate: \"failed\",\n\t\t\t\t\tcode: \"EXTENSION_START_FAILED\",\n\t\t\t\t\t...installed.version === void 0 ? {} : { version: installed.version }\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\treturn Object.assign(dispose, { status: async (name) => {\n\t\tif (!/^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/u.test(name)) return {\n\t\t\tstate: \"failed\",\n\t\t\tcode: \"EXTENSION_ENTRY_INVALID\"\n\t\t};\n\t\tconst errors = /* @__PURE__ */ new Set();\n\t\tconst current = (await discoverDesktopMainExtensions(profile, (failed) => {\n\t\t\terrors.add(failed);\n\t\t})).find((item) => item.name === name);\n\t\tif (errors.has(name) || errors.has(\"profile\")) return {\n\t\t\tstate: \"failed\",\n\t\t\tcode: \"EXTENSION_ENTRY_INVALID\"\n\t\t};\n\t\tconst loaded = running.get(name);\n\t\tif (current === void 0) return loaded === void 0 ? {\n\t\t\tstate: \"not-installed\",\n\t\t\tcode: \"EXTENSION_NOT_INSTALLED\"\n\t\t} : {\n\t\t\tstate: \"pending-restart\",\n\t\t\tcode: \"EXTENSION_RESTART_REQUIRED\"\n\t\t};\n\t\ttry {\n\t\t\tconst installed = await fingerprint(profile, name, current.entry);\n\t\t\tif (loaded?.fingerprint === installed.fingerprint) return loaded.status;\n\t\t\treturn {\n\t\t\t\tstate: \"pending-restart\",\n\t\t\t\tcode: \"EXTENSION_RESTART_REQUIRED\",\n\t\t\t\t...installed.version === void 0 ? {} : { version: installed.version }\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treport(name, error);\n\t\t\treturn {\n\t\t\t\tstate: \"failed\",\n\t\t\t\tcode: \"EXTENSION_ENTRY_INVALID\"\n\t\t\t};\n\t\t}\n\t} });\n}\n//#endregion\n//#region ../../packages/util/error/lib/index.js\n/**\n* Harness error base with a stable machine-routable code and chained cause.\n* Package errors extend it so tool results and replay can retain failure class.\n* @module @deepseek-ai/dsh-error\n*/\n/**\n* Base class for all harness errors. Carries a `code` (stable, programmatic \u2014\n* e.g. `NO_ADAPTER`, `INVALID_ARGS`) distinct from the\n* human-readable `message`, and supports `cause` chaining via the standard\n* `ErrorOptions`. `name` defaults to the subclass constructor name.\n*/\nvar HarnessError = class extends Error {\n\t/** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never by parsing `message`. */\n\tcode;\n\tconstructor(message, code, options) {\n\t\tsuper(message, options);\n\t\tthis.code = code;\n\t\tthis.name = new.target.name;\n\t}\n};\n//#endregion\n//#region lib/types/native-views.js\n/** Primary-renderer slot admission and main-owned native Sidebar presentation. */\nvar DesktopNativeViewError = class extends HarnessError {\n\tconstructor(code) {\n\t\tsuper(code, code);\n\t}\n};\nfunction refuse(code) {\n\tthrow new DesktopNativeViewError(code);\n}\nfunction record$5(value) {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return refuse(\"BROWSER_COMMAND_DENIED\");\n\treturn value;\n}\n/** Parse the plugin's canonical address without treating its owner field as authorization. */\nfunction tab(value) {\n\tif (typeof value !== \"string\" || !value.startsWith(\"dsh-tab:v1:\") || value.length > 16384) return refuse(\"BROWSER_HANDLE_STALE\");\n\tlet parts;\n\ttry {\n\t\tparts = JSON.parse(decodeURIComponent(value.slice(11)));\n\t} catch (_error) {\n\t\treturn refuse(\"BROWSER_HANDLE_STALE\");\n\t}\n\tif (!Array.isArray(parts) || parts.length !== 3 || parts.some((part) => typeof part !== \"string\" || part.length === 0) || `dsh-tab:v1:${encodeURIComponent(JSON.stringify(parts))}` !== value) return refuse(\"BROWSER_HANDLE_STALE\");\n\tconst [owner, session, id] = parts;\n\treturn {\n\t\towner,\n\t\tsession,\n\t\ttab: id,\n\t\twire: value\n\t};\n}\nconst methods = new Set([\n\t\"Page.navigate\",\n\t\"Page.reload\",\n\t\"Page.stopLoading\",\n\t\"Page.getFrameTree\",\n\t\"Page.createIsolatedWorld\",\n\t\"Page.getNavigationHistory\",\n\t\"Page.navigateToHistoryEntry\",\n\t\"Page.getLayoutMetrics\",\n\t\"Page.captureScreenshot\",\n\t\"Runtime.evaluate\",\n\t\"Runtime.terminateExecution\",\n\t\"Input.dispatchMouseEvent\",\n\t\"Input.dispatchKeyEvent\",\n\t\"Input.insertText\",\n\t\"Network.getCookies\",\n\t\"Storage.setCookies\"\n]);\n/** Owns slots, leases, native objects and document generations for one product window. */\nvar DesktopNativeViews = class {\n\twindow;\n\tpolicy;\n\tadmissions = /* @__PURE__ */ new Map();\n\tslots = /* @__PURE__ */ new Map();\n\tviews = /* @__PURE__ */ new Map();\n\treleasing = /* @__PURE__ */ new Map();\n\tchildOwners = /* @__PURE__ */ new Map();\n\tchildren = /* @__PURE__ */ new Map();\n\tendedChildren = /* @__PURE__ */ new Map();\n\tconstructor(window, policy) {\n\t\tthis.window = window;\n\t\tthis.policy = policy;\n\t}\n\t/** Authenticate in main.ts before dispatch; errors are serialized without private exceptions. */\n\tasync request(renderer, input) {\n\t\ttry {\n\t\t\tconst request = record$5(input);\n\t\t\tlet result;\n\t\t\tswitch (request.op) {\n\t\t\t\tcase \"enter\":\n\t\t\t\t\tresult = this.enter(renderer, request.owner);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"leave\":\n\t\t\t\t\tresult = await this.leave(renderer, request.admission);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"register\":\n\t\t\t\t\tresult = this.register(renderer, request.admission, request.scope);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"update\":\n\t\t\t\t\tresult = this.update(renderer, request.slot, request.placement);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"revoke\":\n\t\t\t\t\tresult = await this.revoke(renderer, request.slot);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"acquire\":\n\t\t\t\t\tif (request.persistent === true) await this.policy.preparePersistent();\n\t\t\t\t\tresult = this.acquire(renderer, request.scope, request.workspace, request.persistent === true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"attach\":\n\t\t\t\t\tresult = this.attach(renderer, request.lease, request.slot);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"command\":\n\t\t\t\t\tresult = await this.command(renderer, request.lease, request.method, request.params);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"release\":\n\t\t\t\t\tresult = await this.release(renderer, request.lease);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"child-register\":\n\t\t\t\t\tresult = this.registerChildOwner(renderer, request.parent, request.slot);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"child-unregister\":\n\t\t\t\t\tresult = await this.unregisterChildOwner(renderer, request.parent, request.token);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"child-adopt\":\n\t\t\t\t\tresult = this.adoptChild(renderer, request.request, request.slot);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: return refuse(\"BROWSER_COMMAND_DENIED\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tresult\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (error instanceof HarnessError && error.code === \"BROWSER_PERSISTENT_SESSION_UNAVAILABLE\") return {\n\t\t\t\tok: false,\n\t\t\t\tcode: error.code,\n\t\t\t\tmessage: \"Persistent Sidebar storage is unavailable\"\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tcode: error instanceof DesktopNativeViewError ? error.code : \"BROWSER_NATIVE_SURFACE_UNAVAILABLE\",\n\t\t\t\tmessage: error instanceof DesktopNativeViewError ? error.message : \"Native Sidebar operation failed\"\n\t\t\t};\n\t\t}\n\t}\n\tenter(renderer, owner) {\n\t\tif (typeof owner !== \"string\" || owner.length === 0 || owner.length > 4096) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tconst id = randomUUID();\n\t\tthis.admissions.set(id, {\n\t\t\trenderer,\n\t\t\towner\n\t\t});\n\t\treturn id;\n\t}\n\tasync leave(renderer, id) {\n\t\tif (typeof id !== \"string\") return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tconst admission = this.admissions.get(id);\n\t\tif (admission === void 0) return;\n\t\tif (admission.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tthis.admissions.delete(id);\n\t\tfor (const [key, slot] of this.slots) if (slot.admission === id) await this.revoke(renderer, key);\n\t}\n\tregister(renderer, admission, scope) {\n\t\tconst address = tab(scope);\n\t\tconst admitted = typeof admission === \"string\" ? this.admissions.get(admission) : void 0;\n\t\tif (admitted === void 0 || admitted.renderer !== renderer || admitted.owner !== address.owner) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif ([...this.slots.values()].some((slot) => slot.renderer === renderer && slot.scope === address.wire)) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tconst id = randomUUID();\n\t\tthis.slots.set(id, {\n\t\t\trenderer,\n\t\t\tscope: address.wire,\n\t\t\tadmission: String(admission)\n\t\t});\n\t\treturn id;\n\t}\n\tslot(renderer, id) {\n\t\tconst slot = typeof id === \"string\" ? this.slots.get(id) : void 0;\n\t\tif (slot === void 0) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tif (slot.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\treturn slot;\n\t}\n\tnative(renderer, id) {\n\t\tconst native = typeof id === \"string\" ? this.views.get(id) : void 0;\n\t\tif (native === void 0 || native.view.webContents.isDestroyed()) return refuse(\"BROWSER_GUEST_CLOSED\");\n\t\tif (native.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\treturn native;\n\t}\n\tupdate(renderer, id, value) {\n\t\tconst slot = this.slot(renderer, id);\n\t\tconst { x, y, width, height, visible, background } = record$5(value);\n\t\tif ([\n\t\t\tx,\n\t\t\ty,\n\t\t\twidth,\n\t\t\theight\n\t\t].some((part) => typeof part !== \"number\" || !Number.isFinite(part)) || Number(width) < 0 || Number(height) < 0 || Number(width) > 1e5 || Number(height) > 1e5 || typeof visible !== \"boolean\" || typeof background !== \"boolean\" || visible && background) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tslot.placement = {\n\t\t\tx: Number(x),\n\t\t\ty: Number(y),\n\t\t\twidth: Number(width),\n\t\t\theight: Number(height),\n\t\t\tvisible,\n\t\t\tbackground\n\t\t};\n\t\tif (slot.lease !== void 0) this.compose(this.native(renderer, slot.lease), slot);\n\t}\n\tacquire(renderer, scope, workspace, persistent) {\n\t\tconst address = tab(scope);\n\t\tif ([...this.slots.values()].find((item) => item.scope === address.wire && item.renderer === renderer) === void 0) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif ([...this.views.values()].some((view) => view.scope === address.wire)) return refuse(\"BROWSER_HANDLE_STALE\");\n\t\tconst window = this.window();\n\t\tif (window === void 0 || window.isDestroyed() || window.webContents !== renderer) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tconst reservation = this.policy.acquire(renderer, workspace, persistent);\n\t\tlet view;\n\t\ttry {\n\t\t\tview = new WebContentsView({ webPreferences: {\n\t\t\t\tpartition: reservation.partition,\n\t\t\t\tsandbox: true,\n\t\t\t\tcontextIsolation: true,\n\t\t\t\tnodeIntegration: false,\n\t\t\t\tnodeIntegrationInWorker: false,\n\t\t\t\tnodeIntegrationInSubFrames: false,\n\t\t\t\twebSecurity: true,\n\t\t\t\tallowRunningInsecureContent: false,\n\t\t\t\twebviewTag: false,\n\t\t\t\tplugins: false,\n\t\t\t\tnavigateOnDragDrop: false,\n\t\t\t\tdisableDialogs: true,\n\t\t\t\tbackgroundThrottling: false\n\t\t\t} });\n\t\t\tthis.policy.bindNative(renderer, reservation.lease, view.webContents);\n\t\t} catch (_error) {\n\t\t\tthis.policy.release(renderer, reservation.lease).catch((error) => console.error(error));\n\t\t\treturn refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\t}\n\t\treturn this.install(renderer, address.wire, workspace, reservation.lease, view);\n\t}\n\tinstall(renderer, scope, workspace, reservation, view) {\n\t\tconst lease = randomUUID();\n\t\tconst generation = randomUUID();\n\t\tconst native = {\n\t\t\trenderer,\n\t\t\tscope,\n\t\t\tworkspace,\n\t\t\treservation,\n\t\t\tview,\n\t\t\tcontainer: new View(),\n\t\t\tgeneration,\n\t\t\tstate: {\n\t\t\t\tstage: \"attached\",\n\t\t\t\tgeneration\n\t\t\t},\n\t\t\tqueue: Promise.resolve()\n\t\t};\n\t\tnative.container.addChildView(view);\n\t\tthis.views.set(lease, native);\n\t\tnative.documentTimer = setTimeout(() => {\n\t\t\tthis.fail(lease, native, \"BROWSER_SLOT_UNAVAILABLE\");\n\t\t}, 15e3);\n\t\tview.webContents.on(\"did-start-navigation\", (_event, _url, inPlace, mainFrame) => {\n\t\t\tif (mainFrame && !inPlace && this.views.get(lease) === native) {\n\t\t\t\tnative.generation = randomUUID();\n\t\t\t\tclearTimeout(native.documentTimer);\n\t\t\t\tnative.documentTimer = setTimeout(() => {\n\t\t\t\t\tthis.fail(lease, native, \"BROWSER_DOCUMENT_TIMEOUT\");\n\t\t\t\t}, 15e3);\n\t\t\t\tthis.publish(lease, native, {\n\t\t\t\t\tstage: \"attached\",\n\t\t\t\t\tgeneration: native.generation\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tconst committed = () => {\n\t\t\tconst generation = native.generation;\n\t\t\tthis.send(native, \"Page.getFrameTree\").then(async (value) => {\n\t\t\t\tawait this.policy.reconcilePersistent().catch(() => {\n\t\t\t\t\tconsole.error(\"Sidebar cookie reconciliation failed\");\n\t\t\t\t});\n\t\t\t\tconst frame = record$5(record$5(record$5(value).frameTree).frame);\n\t\t\t\tif (this.views.get(lease) === native && generation === native.generation && typeof frame.id === \"string\" && typeof frame.loaderId === \"string\") {\n\t\t\t\t\tclearTimeout(native.documentTimer);\n\t\t\t\t\tthis.publish(lease, native, {\n\t\t\t\t\t\tstage: \"document\",\n\t\t\t\t\t\tgeneration,\n\t\t\t\t\t\tframeId: frame.id,\n\t\t\t\t\t\tloaderId: frame.loaderId\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}).catch((_error) => {\n\t\t\t\tif (this.views.get(lease) === native) this.fail(lease, native, \"BROWSER_DOCUMENT_UNACKNOWLEDGED\");\n\t\t\t});\n\t\t};\n\t\tnative.acknowledge = committed;\n\t\tview.webContents.on(\"did-navigate\", committed);\n\t\tview.webContents.on(\"did-navigate-in-page\", (_event, _url, mainFrame) => {\n\t\t\tif (mainFrame) committed();\n\t\t});\n\t\tview.webContents.on(\"did-fail-load\", (_event, code, _description, _url, mainFrame) => {\n\t\t\tif (mainFrame && code !== -3) this.fail(lease, native, \"BROWSER_DOCUMENT_UNACKNOWLEDGED\");\n\t\t});\n\t\tview.webContents.on(\"render-process-gone\", () => {\n\t\t\tthis.fail(lease, native, \"BROWSER_GUEST_CLOSED\");\n\t\t});\n\t\tview.webContents.once(\"destroyed\", () => {\n\t\t\tthis.endChild(lease, \"BROWSER_GUEST_CLOSED\");\n\t\t\tthis.closeChildren(renderer, lease).catch((error) => console.error(error));\n\t\t\tclearTimeout(native.documentTimer);\n\t\t\tif (this.views.get(lease) === native) {\n\t\t\t\tthis.publish(lease, native, {\n\t\t\t\t\tstage: \"closed\",\n\t\t\t\t\tgeneration: native.generation\n\t\t\t\t});\n\t\t\t\tthis.views.delete(lease);\n\t\t\t\tif (native.slot !== void 0) this.slots.delete(native.slot);\n\t\t\t}\n\t\t\tthis.detach(native);\n\t\t});\n\t\treturn { lease };\n\t}\n\tregisterChildOwner(renderer, parent, slotId) {\n\t\tconst scope = tab(parent).wire;\n\t\tconst slot = this.slot(renderer, slotId);\n\t\tif (slot.scope !== scope || slot.lease === void 0) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tconst lease = slot.lease, native = this.native(renderer, lease);\n\t\tif (native.scope !== scope || native.slot !== slotId) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif (this.childOwners.has(lease)) return refuse(\"BROWSER_HANDLE_STALE\");\n\t\tconst registration = {\n\t\t\ttoken: randomUUID(),\n\t\t\tslot: slotId\n\t\t};\n\t\tthis.childOwners.set(lease, registration);\n\t\tnative.view.webContents.setWindowOpenHandler((details) => {\n\t\t\tif (this.childOwners.get(lease) !== registration || this.views.get(lease) !== native || this.slots.get(registration.slot) !== slot || renderer.isDestroyed() || [...this.children.values()].filter((child) => child.parent === lease && child.slot === void 0).length >= 32 || details.url !== \"about:blank\" && !this.policy.allowedNavigation(details.url)) return { action: \"deny\" };\n\t\t\treturn {\n\t\t\t\taction: \"allow\",\n\t\t\t\toutlivesOpener: false,\n\t\t\t\toverrideBrowserWindowOptions: { webPreferences: {\n\t\t\t\t\tsession: native.view.webContents.session,\n\t\t\t\t\tsandbox: true,\n\t\t\t\t\tcontextIsolation: true,\n\t\t\t\t\tnodeIntegration: false,\n\t\t\t\t\tnodeIntegrationInWorker: false,\n\t\t\t\t\tnodeIntegrationInSubFrames: false,\n\t\t\t\t\twebSecurity: true,\n\t\t\t\t\tallowRunningInsecureContent: false,\n\t\t\t\t\twebviewTag: false,\n\t\t\t\t\tplugins: false,\n\t\t\t\t\tnavigateOnDragDrop: false,\n\t\t\t\t\tdisableDialogs: true,\n\t\t\t\t\tbackgroundThrottling: false\n\t\t\t\t} },\n\t\t\t\tcreateWindow: (options) => {\n\t\t\t\t\tif (this.childOwners.get(lease) !== registration || this.views.get(lease) !== native) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\t\t\t\tconst address = tab(scope);\n\t\t\t\t\tconst child = `dsh-tab:v1:${encodeURIComponent(JSON.stringify([\n\t\t\t\t\t\taddress.owner,\n\t\t\t\t\t\taddress.session,\n\t\t\t\t\t\trandomUUID()\n\t\t\t\t\t]))}`;\n\t\t\t\t\tconst reservation = this.policy.acquire(renderer, native.workspace);\n\t\t\t\t\tlet view;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tview = new WebContentsView(options);\n\t\t\t\t\t\tthis.policy.bindNative(renderer, reservation.lease, view.webContents);\n\t\t\t\t\t\tconst created = this.install(renderer, child, native.workspace, reservation.lease, view);\n\t\t\t\t\t\tconst event = {\n\t\t\t\t\t\t\trequest: randomUUID(),\n\t\t\t\t\t\t\topener: scope,\n\t\t\t\t\t\t\tchild,\n\t\t\t\t\t\t\tlease: created.lease,\n\t\t\t\t\t\t\ttarget: details.frameName,\n\t\t\t\t\t\t\turl: details.url,\n\t\t\t\t\t\t\tdisposition: details.disposition\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\t\t\tthis.endChild(created.lease, \"BROWSER_CHILD_ADOPTION_TIMEOUT\");\n\t\t\t\t\t\t\tthis.release(renderer, created.lease).catch((error) => console.error(error));\n\t\t\t\t\t\t}, 1e4);\n\t\t\t\t\t\tthis.children.set(event.request, {\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\trenderer,\n\t\t\t\t\t\t\tparent: lease,\n\t\t\t\t\t\t\ttimer\n\t\t\t\t\t\t});\n\t\t\t\t\t\trenderer.send(DESKTOP_IPC.nativeChildEvent, {\n\t\t\t\t\t\t\ttype: \"created\",\n\t\t\t\t\t\t\tparent: scope,\n\t\t\t\t\t\t\tchild: event\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn view.webContents;\n\t\t\t\t\t} catch (_error) {\n\t\t\t\t\t\tconst guest = view?.webContents ?? options.webContents;\n\t\t\t\t\t\tif (guest !== void 0 && !guest.isDestroyed()) guest.close({ waitForBeforeUnload: false });\n\t\t\t\t\t\tthis.policy.release(renderer, reservation.lease).catch((error) => console.error(error));\n\t\t\t\t\t\treturn refuse(\"BROWSER_NATIVE_CHILD_UNAVAILABLE\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t\treturn registration.token;\n\t}\n\tadoptChild(renderer, request, slotId) {\n\t\tif (typeof request !== \"string\") return refuse(\"BROWSER_HANDLE_STALE\");\n\t\tconst child = this.children.get(request);\n\t\tif (child === void 0) {\n\t\t\tconst ended = this.endedChildren.get(request);\n\t\t\tif (ended !== void 0 && ended.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\t\treturn refuse(ended?.code ?? \"BROWSER_HANDLE_STALE\");\n\t\t}\n\t\tif (child.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tconst slot = this.slot(renderer, slotId);\n\t\tif (child.slot !== void 0 && child.slot !== slotId) return refuse(\"BROWSER_CHILD_ALREADY_ADOPTED\");\n\t\tconst parent = this.native(renderer, child.parent);\n\t\tconst owner = this.childOwners.get(child.parent);\n\t\tif (owner === void 0 || parent.slot !== owner.slot || !this.slots.has(owner.slot)) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif (slot.scope !== child.event.child || this.slots.get(owner.slot)?.admission !== slot.admission) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tthis.attach(renderer, child.event.lease, slotId);\n\t\tchild.slot = slotId;\n\t\tclearTimeout(child.timer);\n\t\treturn {\n\t\t\tchild: child.event.child,\n\t\t\tlease: child.event.lease\n\t\t};\n\t}\n\tendChild(lease, code) {\n\t\tfor (const [request, child] of this.children) {\n\t\t\tif (child.event.lease !== lease) continue;\n\t\t\tclearTimeout(child.timer);\n\t\t\tthis.children.delete(request);\n\t\t\tthis.endedChildren.set(request, {\n\t\t\t\trenderer: child.renderer,\n\t\t\t\tcode\n\t\t\t});\n\t\t\tif (this.endedChildren.size > 256) {\n\t\t\t\tconst oldest = this.endedChildren.keys().next().value;\n\t\t\t\tif (oldest !== void 0) this.endedChildren.delete(oldest);\n\t\t\t}\n\t\t\tif (!child.renderer.isDestroyed()) child.renderer.send(DESKTOP_IPC.nativeChildEvent, {\n\t\t\t\ttype: \"closed\",\n\t\t\t\tparent: child.event.opener,\n\t\t\t\tchild: child.event\n\t\t\t});\n\t\t}\n\t}\n\tasync closeChildren(renderer, lease) {\n\t\tthis.childOwners.delete(lease);\n\t\tconst children = [...this.children.values()].filter((child) => child.parent === lease);\n\t\tfor (const child of children) await this.release(renderer, child.event.lease);\n\t}\n\tasync unregisterChildOwner(renderer, parent, token) {\n\t\tconst scope = tab(parent).wire;\n\t\tconst entry = [...this.views].find(([, native]) => native.scope === scope);\n\t\tif (entry === void 0) return;\n\t\tconst [lease, native] = entry;\n\t\tif (native.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif (this.childOwners.get(lease)?.token !== token) return refuse(\"BROWSER_HANDLE_STALE\");\n\t\tnative.view.webContents.setWindowOpenHandler(() => ({ action: \"deny\" }));\n\t\tawait this.closeChildren(renderer, lease);\n\t}\n\tpublish(lease, native, state) {\n\t\tnative.state = state;\n\t\tif (!native.renderer.isDestroyed()) native.renderer.send(DESKTOP_IPC.nativeViewState, {\n\t\t\tlease,\n\t\t\tstate\n\t\t});\n\t}\n\tfail(lease, native, code) {\n\t\tif (this.views.get(lease) !== native) return;\n\t\tthis.publish(lease, native, {\n\t\t\tstage: \"failed\",\n\t\t\tgeneration: native.generation,\n\t\t\tcode\n\t\t});\n\t\tthis.release(native.renderer, lease).catch((error) => console.error(error));\n\t}\n\tattach(renderer, id, slotId) {\n\t\tconst native = this.native(renderer, id);\n\t\tconst slot = this.slot(renderer, slotId);\n\t\tif (slot.scope !== native.scope || slot.lease !== void 0 && slot.lease !== id || native.slot !== void 0 && native.slot !== slotId || slot.placement === void 0) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tnative.slot = slotId;\n\t\tslot.lease = id;\n\t\tthis.compose(native, slot);\n\t\tclearTimeout(native.documentTimer);\n\t\tthis.publish(id, native, native.state);\n\t\tif (native.state.stage === \"attached\" && native.view.webContents.getURL() === \"about:blank\" && [...this.children.values()].some((child) => child.event.lease === id)) native.acknowledge?.();\n\t}\n\tcompose(native, slot) {\n\t\tconst window = this.window(), placement = slot.placement;\n\t\tif (window === void 0 || window.isDestroyed() || placement === void 0 || native.renderer !== window.webContents) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tconst zoom = window.webContents.getZoomFactor();\n\t\tconst bounds = window.getContentBounds();\n\t\tconst x = Math.max(0, Math.min(bounds.width, Math.round(placement.x * zoom)));\n\t\tconst y = Math.max(0, Math.min(bounds.height, Math.round(placement.y * zoom)));\n\t\tconst width = Math.max(0, Math.min(bounds.width - x, Math.round(placement.width * zoom)));\n\t\tconst height = Math.max(0, Math.min(bounds.height - y, Math.round(placement.height * zoom)));\n\t\tnative.container.setBounds({\n\t\t\tx,\n\t\t\ty,\n\t\t\twidth,\n\t\t\theight\n\t\t});\n\t\tnative.view.setBounds({\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\twidth,\n\t\t\theight\n\t\t});\n\t\twindow.contentView.addChildView(native.container, placement.background ? 0 : void 0);\n\t\tnative.container.setVisible(width > 0 && height > 0 && (placement.visible || placement.background));\n\t}\n\tasync command(renderer, id, method, params) {\n\t\tconst native = this.native(renderer, id);\n\t\tif (native.slot === void 0) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tthis.slot(renderer, native.slot);\n\t\tif (typeof method !== \"string\" || !methods.has(method)) return refuse(\"BROWSER_COMMAND_DENIED\");\n\t\tconst input = params === void 0 ? {} : record$5(params);\n\t\tif (method === \"Storage.setCookies\" && (!Array.isArray(input.cookies) || Object.keys(input).some((key) => key !== \"cookies\"))) return refuse(\"BROWSER_COMMAND_DENIED\");\n\t\tif (method === \"Page.createIsolatedWorld\" && input.grantUniveralAccess === true) return refuse(\"BROWSER_COMMAND_DENIED\");\n\t\tif (method === \"Page.navigate\" && (typeof input.url !== \"string\" || !this.policy.allowedNavigation(input.url))) return refuse(\"BROWSER_URL_DENIED\");\n\t\tif (native.state.stage !== \"document\" && ![\n\t\t\t\"Page.navigate\",\n\t\t\t\"Page.stopLoading\",\n\t\t\t\"Page.getFrameTree\"\n\t\t].includes(method)) return refuse(\"BROWSER_DOCUMENT_UNACKNOWLEDGED\");\n\t\tconst expectedGeneration = [\n\t\t\t\"Page.navigate\",\n\t\t\t\"Page.stopLoading\",\n\t\t\t\"Page.getFrameTree\"\n\t\t].includes(method) ? void 0 : native.generation;\n\t\ttry {\n\t\t\tconst result = await this.send(native, method === \"Storage.setCookies\" ? \"Network.setCookies\" : method, input, expectedGeneration);\n\t\t\tif (method === \"Storage.setCookies\" || method === \"Runtime.evaluate\") await this.policy.reconcilePersistent();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (error instanceof DesktopNativeViewError && error.code === \"BROWSER_DOCUMENT_TIMEOUT\") this.fail(id, native, \"BROWSER_DOCUMENT_TIMEOUT\");\n\t\t\tthrow error;\n\t\t}\n\t}\n\tsend(native, method, params = {}, expectedGeneration) {\n\t\tconst pending = native.queue.then(async () => {\n\t\t\tif (![...this.views.values()].includes(native) || native.view.webContents.isDestroyed()) return refuse(\"BROWSER_GUEST_CLOSED\");\n\t\t\tif (expectedGeneration !== void 0 && (native.generation !== expectedGeneration || native.state.stage !== \"document\")) return refuse(\"BROWSER_DOCUMENT_UNACKNOWLEDGED\");\n\t\t\tconst debugger_ = native.view.webContents.debugger;\n\t\t\tif (!debugger_.isAttached()) debugger_.attach(\"1.3\");\n\t\t\tlet timer;\n\t\t\ttry {\n\t\t\t\treturn await Promise.race([debugger_.sendCommand(method, params), new Promise((_resolve, reject) => {\n\t\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\t\treject(new DesktopNativeViewError(\"BROWSER_DOCUMENT_TIMEOUT\"));\n\t\t\t\t\t}, 15e3);\n\t\t\t\t})]);\n\t\t\t} finally {\n\t\t\t\tclearTimeout(timer);\n\t\t\t}\n\t\t});\n\t\tnative.queue = pending.catch((_error) => {});\n\t\treturn pending;\n\t}\n\tasync release(renderer, id) {\n\t\tif (typeof id !== \"string\") return refuse(\"BROWSER_GUEST_CLOSED\");\n\t\tconst native = this.views.get(id);\n\t\tif (native === void 0) {\n\t\t\tconst pending = this.releasing.get(id);\n\t\t\tif (pending !== void 0 && pending.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\t\treturn pending?.completion;\n\t\t}\n\t\tif (native.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tthis.views.delete(id);\n\t\tthis.endChild(id, \"BROWSER_GUEST_CLOSED\");\n\t\tconst children = this.closeChildren(renderer, id);\n\t\tclearTimeout(native.documentTimer);\n\t\tthis.detach(native);\n\t\tif (native.slot !== void 0) this.slots.delete(native.slot);\n\t\tconst completion = Promise.resolve().then(async () => {\n\t\t\tawait children;\n\t\t\tawait this.policy.release(renderer, native.reservation);\n\t\t\tthis.publish(id, native, {\n\t\t\t\tstage: \"closed\",\n\t\t\t\tgeneration: native.generation\n\t\t\t});\n\t\t}).finally(() => {\n\t\t\tthis.releasing.delete(id);\n\t\t});\n\t\tthis.releasing.set(id, {\n\t\t\trenderer,\n\t\t\tcompletion\n\t\t});\n\t\treturn completion;\n\t}\n\t/** Trusted main extensions can enumerate only admitted native surfaces of the primary window. */\n\tsnapshot() {\n\t\tconst renderer = this.window()?.webContents;\n\t\treturn [...this.views].filter(([, native]) => native.renderer === renderer && native.slot !== void 0).map(([lease, native]) => ({\n\t\t\tscope: native.scope,\n\t\t\tlease,\n\t\t\tstate: { ...native.state },\n\t\t\turl: native.view.webContents.getURL(),\n\t\t\ttitle: native.view.webContents.getTitle()\n\t\t}));\n\t}\n\t/** Release only the lease bound to this canonical scope. */\n\tasync scopedRelease(scope, lease) {\n\t\tconst renderer = this.window()?.webContents;\n\t\tif (renderer === void 0) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tconst native = this.views.get(lease);\n\t\tif (native === void 0) return;\n\t\tif (native.scope !== tab(scope).wire || native.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tawait this.release(renderer, lease);\n\t}\n\t/** Download through the same scoped guest session and its network policy. */\n\tasync scopedFetch(scope, lease, url, signal) {\n\t\tconst renderer = this.window()?.webContents;\n\t\tif (renderer === void 0) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tconst native = this.native(renderer, lease);\n\t\tif (native.scope !== tab(scope).wire) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif (!this.policy.allowedNavigation(url)) return refuse(\"BROWSER_URL_DENIED\");\n\t\tconst response = await native.view.webContents.session.fetch(url, {\n\t\t\tcredentials: \"include\",\n\t\t\tsignal\n\t\t});\n\t\tawait this.policy.reconcilePersistent();\n\t\treturn response;\n\t}\n\t/** Resolve the scoped binding again at dispatch, rather than exposing Electron guests. */\n\tasync scopedCommand(scope, lease, method, params) {\n\t\tconst renderer = this.window()?.webContents;\n\t\tif (renderer === void 0) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tif (this.native(renderer, lease).scope !== tab(scope).wire) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\treturn this.command(renderer, lease, method, params);\n\t}\n\tdetach(native) {\n\t\tconst window = this.window();\n\t\tif (window !== void 0 && !window.isDestroyed()) window.contentView.removeChildView(native.container);\n\t}\n\tasync revoke(renderer, id) {\n\t\tif (typeof id !== \"string\" || !this.slots.has(id)) return;\n\t\tconst slot = this.slot(renderer, id);\n\t\tthis.slots.delete(id);\n\t\tfor (const [lease, native] of this.views) if (native.renderer === renderer && native.scope === slot.scope) await this.release(renderer, lease);\n\t}\n\t/** Revoke admissions before releasing native objects on owner navigation or death. */\n\tbind(window) {\n\t\tconst renderer = window.webContents;\n\t\tconst revoke = () => {\n\t\t\tfor (const [id, admission] of this.admissions) if (admission.renderer === renderer) this.admissions.delete(id);\n\t\t\tfor (const [id, slot] of this.slots) if (slot.renderer === renderer) this.slots.delete(id);\n\t\t\tfor (const [id, native] of this.views) if (native.renderer === renderer) this.release(renderer, id).catch((error) => console.error(error));\n\t\t};\n\t\trenderer.on(\"did-start-navigation\", (_event, _url, inPlace, mainFrame) => {\n\t\t\tif (mainFrame && !inPlace) revoke();\n\t\t});\n\t\trenderer.on(\"render-process-gone\", revoke);\n\t\trenderer.once(\"destroyed\", revoke);\n\t}\n};\n//#endregion\n//#region lib/types/core-package-set.js\n/** Private package installed beside dsh to boot the Desktop Host process. */\nconst DESKTOP_HOST_PACKAGE = \"@deepseek-ai/dsh-desktop-host\";"
81
+ "after": "\n}\n//#endregion\n//#region lib/types/main-extensions.js\n/** Explicitly installed, trusted profile extensions running in Electron main. */\nvar __rewriteRelativeImportExtension$2 = function(path, preserveJsx) {\n\tif (typeof path === \"string\" && /^\\.\\.?\\//.test(path)) return path.replace(/\\.(tsx)$|((?:\\.d)?)((?:\\.[^./]+?)?)\\.([cm]?)ts$/i, function(m, tsx, d, ext, cm) {\n\t\treturn tsx ? preserveJsx ? \".jsx\" : \".js\" : d && (!ext || !cm) ? m : d + ext + \".\" + cm.toLowerCase() + \"js\";\n\t});\n\treturn path;\n};\nasync function fingerprint(profile, name, entry) {\n\tconst directory = await realpath(join(profile, \"node_modules\", name));\n\tconst text = await readFile$1(join(directory, \"package.json\"), \"utf8\");\n\tconst pkg = JSON.parse(text);\n\tconst hash = createHash(\"sha256\").update(entry).update(text);\n\tconst visit = async (path) => {\n\t\tfor (const item of (await readdir(path, { withFileTypes: true })).sort((a, b) => a.name.localeCompare(b.name))) {\n\t\t\tif (item.name === \"node_modules\" || item.name === \".git\") continue;\n\t\t\tconst child = join(path, item.name);\n\t\t\tif (item.isSymbolicLink()) throw new Error(\"extension package contains a symbolic link\");\n\t\t\tif (item.isDirectory()) await visit(child);\n\t\t\telse if (item.isFile()) {\n\t\t\t\tconst content = await readFile$1(child);\n\t\t\t\thash.update(JSON.stringify([relative(directory, child), content.length])).update(content);\n\t\t\t}\n\t\t}\n\t};\n\tawait visit(directory);\n\treturn {\n\t\tfingerprint: hash.digest(\"hex\"),\n\t\t...record$6(pkg) && typeof pkg.version === \"string\" ? { version: pkg.version } : {}\n\t};\n}\nfunction record$6(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction inside(root, path) {\n\tconst child = relative(root, path);\n\treturn child !== \"\" && !isAbsolute(child) && child !== \"..\" && !child.startsWith(\"../\") && !child.startsWith(\"..\\\\\");\n}\n/**\n* Discover opt-in entries from direct installed profile dependencies; reject escaping paths, including symlinks.\n* Invalid dependencies are reported individually and do not suppress other entries.\n* @param profile - desktop profile directory.\n* @param report - diagnostic sink receiving the failing package name and error.\n* @returns validated main entry paths; an absent profile manifest yields no entries.\n*/\nasync function discoverDesktopMainExtensions(profile, report) {\n\tlet manifest;\n\ttry {\n\t\tmanifest = JSON.parse(await readFile$1(join(profile, \"package.json\"), \"utf8\"));\n\t} catch (error) {\n\t\tif (!record$6(error) || error.code !== \"ENOENT\") report(\"profile\", error);\n\t\treturn [];\n\t}\n\tif (!record$6(manifest) || !record$6(manifest.dependencies)) return [];\n\tconst entries = [];\n\tfor (const name of Object.keys(manifest.dependencies)) try {\n\t\tif (!/^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/u.test(name)) throw new Error(\"invalid dependency name\");\n\t\tconst directory = await realpath(join(profile, \"node_modules\", name));\n\t\tconst pkg = JSON.parse(await readFile$1(join(directory, \"package.json\"), \"utf8\"));\n\t\tif (!record$6(pkg) || !record$6(pkg.dsh) || !record$6(pkg.dsh.desktop) || pkg.dsh.desktop.main === void 0) continue;\n\t\tconst main = pkg.dsh.desktop.main;\n\t\tif (typeof main !== \"string\" || !main.startsWith(\"./\") || !inside(directory, resolve(directory, main))) throw new Error(\"dsh.desktop.main must be a relative entry inside its package\");\n\t\tconst entry = await realpath(resolve(directory, main));\n\t\tif (!inside(directory, entry)) throw new Error(\"dsh.desktop.main resolves outside its package\");\n\t\tentries.push({\n\t\t\tname,\n\t\t\tentry\n\t\t});\n\t} catch (error) {\n\t\treport(name, error);\n\t}\n\treturn entries;\n}\n/**\n* Start trusted extensions independently and register synchronous cleanup on will-quit.\n* @param profile - desktop profile containing installed dependencies.\n* @param api - Electron capabilities and shared Harness home.\n* @returns idempotent disposer that also removes the quit listener.\n*/\nasync function startDesktopMainExtensions(profile, api) {\n\tconst report = (name, error) => {\n\t\tconsole.error(`desktop main extension ${name}:`, error);\n\t};\n\tconst disposers = [];\n\tconst running = /* @__PURE__ */ new Map();\n\tlet stopped = false;\n\tconst dispose = () => {\n\t\tstopped = true;\n\t\tapi.app.off(\"will-quit\", dispose);\n\t\tfor (const extension of disposers.splice(0).reverse()) try {\n\t\t\textension.dispose();\n\t\t} catch (error) {\n\t\t\treport(extension.name, error);\n\t\t}\n\t};\n\tapi.app.on(\"will-quit\", dispose);\n\tconst entries = await discoverDesktopMainExtensions(profile, report);\n\tfor (const { name, entry } of entries) {\n\t\tif (stopped) break;\n\t\tlet installed;\n\t\ttry {\n\t\t\tinstalled = await fingerprint(profile, name, entry);\n\t\t} catch (error) {\n\t\t\treport(name, error);\n\t\t\tcontinue;\n\t\t}\n\t\ttry {\n\t\t\tconst extension = await import(__rewriteRelativeImportExtension$2(pathToFileURL(entry).href));\n\t\t\tif (stopped) break;\n\t\t\tif (!record$6(extension) || typeof extension.start !== \"function\") throw new Error(\"entry must export start(api)\");\n\t\t\tconst result = await extension.start(api);\n\t\t\tif (typeof result === \"function\") disposers.push({\n\t\t\t\tname,\n\t\t\t\tdispose: () => {\n\t\t\t\t\tresult();\n\t\t\t\t}\n\t\t\t});\n\t\t\telse if (record$6(result) && typeof result.dispose === \"function\") {\n\t\t\t\tconst dispose = result.dispose.bind(result);\n\t\t\t\tdisposers.push({\n\t\t\t\t\tname,\n\t\t\t\t\tdispose: () => {\n\t\t\t\t\t\tdispose();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (stopped) dispose();\n\t\t\trunning.set(name, {\n\t\t\t\tfingerprint: installed.fingerprint,\n\t\t\t\tstatus: {\n\t\t\t\t\tstate: \"loaded\",\n\t\t\t\t\t...installed.version === void 0 ? {} : { version: installed.version },\n\t\t\t\t\tloadedAt: (/* @__PURE__ */ new Date()).toISOString()\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\treport(name, error);\n\t\t\trunning.set(name, {\n\t\t\t\tfingerprint: installed.fingerprint,\n\t\t\t\tstatus: {\n\t\t\t\t\tstate: \"failed\",\n\t\t\t\t\tcode: \"EXTENSION_START_FAILED\",\n\t\t\t\t\t...installed.version === void 0 ? {} : { version: installed.version }\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\treturn Object.assign(dispose, { status: async (name) => {\n\t\tif (!/^(?:@[a-z0-9][a-z0-9._-]*\\/)?[a-z0-9][a-z0-9._-]*$/u.test(name)) return {\n\t\t\tstate: \"failed\",\n\t\t\tcode: \"EXTENSION_ENTRY_INVALID\"\n\t\t};\n\t\tconst errors = /* @__PURE__ */ new Set();\n\t\tconst current = (await discoverDesktopMainExtensions(profile, (failed) => {\n\t\t\terrors.add(failed);\n\t\t})).find((item) => item.name === name);\n\t\tif (errors.has(name) || errors.has(\"profile\")) return {\n\t\t\tstate: \"failed\",\n\t\t\tcode: \"EXTENSION_ENTRY_INVALID\"\n\t\t};\n\t\tconst loaded = running.get(name);\n\t\tif (current === void 0) return loaded === void 0 ? {\n\t\t\tstate: \"not-installed\",\n\t\t\tcode: \"EXTENSION_NOT_INSTALLED\"\n\t\t} : {\n\t\t\tstate: \"pending-restart\",\n\t\t\tcode: \"EXTENSION_RESTART_REQUIRED\"\n\t\t};\n\t\ttry {\n\t\t\tconst installed = await fingerprint(profile, name, current.entry);\n\t\t\tif (loaded?.fingerprint === installed.fingerprint) return loaded.status;\n\t\t\treturn {\n\t\t\t\tstate: \"pending-restart\",\n\t\t\t\tcode: \"EXTENSION_RESTART_REQUIRED\",\n\t\t\t\t...installed.version === void 0 ? {} : { version: installed.version }\n\t\t\t};\n\t\t} catch (error) {\n\t\t\treport(name, error);\n\t\t\treturn {\n\t\t\t\tstate: \"failed\",\n\t\t\t\tcode: \"EXTENSION_ENTRY_INVALID\"\n\t\t\t};\n\t\t}\n\t} });\n}\n//#endregion\n//#region ../../packages/util/error/lib/index.js\n/**\n* Harness error base with a stable machine-routable code and chained cause.\n* Package errors extend it so tool results and replay can retain failure class.\n* @module @deepseek-ai/dsh-error\n*/\n/**\n* Base class for all harness errors. Carries a `code` (stable, programmatic —\n* e.g. `NO_ADAPTER`, `INVALID_ARGS`) distinct from the\n* human-readable `message`, and supports `cause` chaining via the standard\n* `ErrorOptions`. `name` defaults to the subclass constructor name.\n*/\nvar HarnessError = class extends Error {\n\t/** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never by parsing `message`. */\n\tcode;\n\tconstructor(message, code, options) {\n\t\tsuper(message, options);\n\t\tthis.code = code;\n\t\tthis.name = new.target.name;\n\t}\n};\n//#endregion\n//#region lib/types/native-views.js\n/** Primary-renderer slot admission and main-owned native Sidebar presentation. */\nvar DesktopNativeViewError = class extends HarnessError {\n\tconstructor(code) {\n\t\tsuper(code, code);\n\t}\n};\nfunction refuse(code) {\n\tthrow new DesktopNativeViewError(code);\n}\nfunction record$5(value) {\n\tif (typeof value !== \"object\" || value === null || Array.isArray(value)) return refuse(\"BROWSER_COMMAND_DENIED\");\n\treturn value;\n}\n/** Parse the plugin's canonical address without treating its owner field as authorization. */\nfunction tab(value) {\n\tif (typeof value !== \"string\" || !value.startsWith(\"dsh-tab:v1:\") || value.length > 16384) return refuse(\"BROWSER_HANDLE_STALE\");\n\tlet parts;\n\ttry {\n\t\tparts = JSON.parse(decodeURIComponent(value.slice(11)));\n\t} catch (_error) {\n\t\treturn refuse(\"BROWSER_HANDLE_STALE\");\n\t}\n\tif (!Array.isArray(parts) || parts.length !== 3 || parts.some((part) => typeof part !== \"string\" || part.length === 0) || `dsh-tab:v1:${encodeURIComponent(JSON.stringify(parts))}` !== value) return refuse(\"BROWSER_HANDLE_STALE\");\n\tconst [owner, session, id] = parts;\n\treturn {\n\t\towner,\n\t\tsession,\n\t\ttab: id,\n\t\twire: value\n\t};\n}\nconst methods = new Set([\n\t\"Page.navigate\",\n\t\"Page.reload\",\n\t\"Page.stopLoading\",\n\t\"Page.getFrameTree\",\n\t\"Page.createIsolatedWorld\",\n\t\"Page.getNavigationHistory\",\n\t\"Page.navigateToHistoryEntry\",\n\t\"Page.getLayoutMetrics\",\n\t\"Page.captureScreenshot\",\n\t\"Runtime.evaluate\",\n\t\"Runtime.terminateExecution\",\n\t\"Input.dispatchMouseEvent\",\n\t\"Input.dispatchKeyEvent\",\n\t\"Input.insertText\",\n\t\"Network.getCookies\",\n\t\"Storage.setCookies\"\n]);\n/** Owns slots, leases, native objects and document generations for one product window. */\nvar DesktopNativeViews = class {\n\twindow;\n\tpolicy;\n\tadmissions = /* @__PURE__ */ new Map();\n\tslots = /* @__PURE__ */ new Map();\n\tviews = /* @__PURE__ */ new Map();\n\treleasing = /* @__PURE__ */ new Map();\n\tchildOwners = /* @__PURE__ */ new Map();\n\tchildren = /* @__PURE__ */ new Map();\n\tendedChildren = /* @__PURE__ */ new Map();\n\tconstructor(window, policy) {\n\t\tthis.window = window;\n\t\tthis.policy = policy;\n\t}\n\t/** Authenticate in main.ts before dispatch; errors are serialized without private exceptions. */\n\tasync request(renderer, input) {\n\t\ttry {\n\t\t\tconst request = record$5(input);\n\t\t\tlet result;\n\t\t\tswitch (request.op) {\n\t\t\t\tcase \"enter\":\n\t\t\t\t\tresult = this.enter(renderer, request.owner);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"leave\":\n\t\t\t\t\tresult = await this.leave(renderer, request.admission);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"register\":\n\t\t\t\t\tresult = this.register(renderer, request.admission, request.scope);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"update\":\n\t\t\t\t\tresult = this.update(renderer, request.slot, request.placement);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"revoke\":\n\t\t\t\t\tresult = await this.revoke(renderer, request.slot);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"acquire\":\n\t\t\t\t\tif (request.persistent === true) await this.policy.preparePersistent();\n\t\t\t\t\tresult = this.acquire(renderer, request.scope, request.workspace, request.persistent === true);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"attach\":\n\t\t\t\t\tresult = this.attach(renderer, request.lease, request.slot);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"command\":\n\t\t\t\t\tresult = await this.command(renderer, request.lease, request.method, request.params);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"release\":\n\t\t\t\t\tresult = await this.release(renderer, request.lease);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"child-register\":\n\t\t\t\t\tresult = this.registerChildOwner(renderer, request.parent, request.slot);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"child-unregister\":\n\t\t\t\t\tresult = await this.unregisterChildOwner(renderer, request.parent, request.token);\n\t\t\t\t\tbreak;\n\t\t\t\tcase \"child-adopt\":\n\t\t\t\t\tresult = this.adoptChild(renderer, request.request, request.slot);\n\t\t\t\t\tbreak;\n\t\t\t\tdefault: return refuse(\"BROWSER_COMMAND_DENIED\");\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tok: true,\n\t\t\t\tresult\n\t\t\t};\n\t\t} catch (error) {\n\t\t\tif (error instanceof HarnessError && error.code === \"BROWSER_PERSISTENT_SESSION_UNAVAILABLE\") return {\n\t\t\t\tok: false,\n\t\t\t\tcode: error.code,\n\t\t\t\tmessage: \"Persistent Sidebar storage is unavailable\"\n\t\t\t};\n\t\t\treturn {\n\t\t\t\tok: false,\n\t\t\t\tcode: error instanceof DesktopNativeViewError ? error.code : \"BROWSER_NATIVE_SURFACE_UNAVAILABLE\",\n\t\t\t\tmessage: error instanceof DesktopNativeViewError ? error.message : \"Native Sidebar operation failed\"\n\t\t\t};\n\t\t}\n\t}\n\tenter(renderer, owner) {\n\t\tif (typeof owner !== \"string\" || owner.length === 0 || owner.length > 4096) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tconst id = randomUUID();\n\t\tthis.admissions.set(id, {\n\t\t\trenderer,\n\t\t\towner\n\t\t});\n\t\treturn id;\n\t}\n\tasync leave(renderer, id) {\n\t\tif (typeof id !== \"string\") return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tconst admission = this.admissions.get(id);\n\t\tif (admission === void 0) return;\n\t\tif (admission.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tthis.admissions.delete(id);\n\t\tfor (const [key, slot] of this.slots) if (slot.admission === id) await this.revoke(renderer, key);\n\t}\n\tregister(renderer, admission, scope) {\n\t\tconst address = tab(scope);\n\t\tconst admitted = typeof admission === \"string\" ? this.admissions.get(admission) : void 0;\n\t\tif (admitted === void 0 || admitted.renderer !== renderer || admitted.owner !== address.owner) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif ([...this.slots.values()].some((slot) => slot.renderer === renderer && slot.scope === address.wire)) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tconst id = randomUUID();\n\t\tthis.slots.set(id, {\n\t\t\trenderer,\n\t\t\tscope: address.wire,\n\t\t\tadmission: String(admission)\n\t\t});\n\t\treturn id;\n\t}\n\tslot(renderer, id) {\n\t\tconst slot = typeof id === \"string\" ? this.slots.get(id) : void 0;\n\t\tif (slot === void 0) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tif (slot.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\treturn slot;\n\t}\n\tnative(renderer, id) {\n\t\tconst native = typeof id === \"string\" ? this.views.get(id) : void 0;\n\t\tif (native === void 0 || native.view.webContents.isDestroyed()) return refuse(\"BROWSER_GUEST_CLOSED\");\n\t\tif (native.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\treturn native;\n\t}\n\tupdate(renderer, id, value) {\n\t\tconst slot = this.slot(renderer, id);\n\t\tconst { x, y, width, height, visible, background } = record$5(value);\n\t\tif ([\n\t\t\tx,\n\t\t\ty,\n\t\t\twidth,\n\t\t\theight\n\t\t].some((part) => typeof part !== \"number\" || !Number.isFinite(part)) || Number(width) < 0 || Number(height) < 0 || Number(width) > 1e5 || Number(height) > 1e5 || typeof visible !== \"boolean\" || typeof background !== \"boolean\" || visible && background) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tslot.placement = {\n\t\t\tx: Number(x),\n\t\t\ty: Number(y),\n\t\t\twidth: Number(width),\n\t\t\theight: Number(height),\n\t\t\tvisible,\n\t\t\tbackground\n\t\t};\n\t\tif (slot.lease !== void 0) this.compose(this.native(renderer, slot.lease), slot);\n\t}\n\tacquire(renderer, scope, workspace, persistent) {\n\t\tconst address = tab(scope);\n\t\tif ([...this.slots.values()].find((item) => item.scope === address.wire && item.renderer === renderer) === void 0) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif ([...this.views.values()].some((view) => view.scope === address.wire)) return refuse(\"BROWSER_HANDLE_STALE\");\n\t\tconst window = this.window();\n\t\tif (window === void 0 || window.isDestroyed() || window.webContents !== renderer) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tconst reservation = this.policy.acquire(renderer, workspace, persistent);\n\t\tlet view;\n\t\ttry {\n\t\t\tview = new WebContentsView({ webPreferences: {\n\t\t\t\tpartition: reservation.partition,\n\t\t\t\tsandbox: true,\n\t\t\t\tcontextIsolation: true,\n\t\t\t\tnodeIntegration: false,\n\t\t\t\tnodeIntegrationInWorker: false,\n\t\t\t\tnodeIntegrationInSubFrames: false,\n\t\t\t\twebSecurity: true,\n\t\t\t\tallowRunningInsecureContent: false,\n\t\t\t\twebviewTag: false,\n\t\t\t\tplugins: false,\n\t\t\t\tnavigateOnDragDrop: false,\n\t\t\t\tdisableDialogs: true,\n\t\t\t\tbackgroundThrottling: false\n\t\t\t} });\n\t\t\tthis.policy.bindNative(renderer, reservation.lease, view.webContents);\n\t\t} catch (_error) {\n\t\t\tthis.policy.release(renderer, reservation.lease).catch((error) => console.error(error));\n\t\t\treturn refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\t}\n\t\treturn this.install(renderer, address.wire, workspace, reservation.lease, view);\n\t}\n\tinstall(renderer, scope, workspace, reservation, view) {\n\t\tconst lease = randomUUID();\n\t\tconst generation = randomUUID();\n\t\tconst native = {\n\t\t\trenderer,\n\t\t\tscope,\n\t\t\tworkspace,\n\t\t\treservation,\n\t\t\tview,\n\t\t\tcontainer: new View(),\n\t\t\tgeneration,\n\t\t\tstate: {\n\t\t\t\tstage: \"attached\",\n\t\t\t\tgeneration\n\t\t\t},\n\t\t\tqueue: Promise.resolve()\n\t\t};\n\t\tnative.container.addChildView(view);\n\t\tthis.views.set(lease, native);\n\t\tnative.documentTimer = setTimeout(() => {\n\t\t\tthis.fail(lease, native, \"BROWSER_SLOT_UNAVAILABLE\");\n\t\t}, 15e3);\n\t\tview.webContents.on(\"did-start-navigation\", (_event, _url, inPlace, mainFrame) => {\n\t\t\tif (mainFrame && !inPlace && this.views.get(lease) === native) {\n\t\t\t\tnative.generation = randomUUID();\n\t\t\t\tclearTimeout(native.documentTimer);\n\t\t\t\tnative.documentTimer = setTimeout(() => {\n\t\t\t\t\tthis.fail(lease, native, \"BROWSER_DOCUMENT_TIMEOUT\");\n\t\t\t\t}, 15e3);\n\t\t\t\tthis.publish(lease, native, {\n\t\t\t\t\tstage: \"attached\",\n\t\t\t\t\tgeneration: native.generation\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tconst committed = () => {\n\t\t\tconst generation = native.generation;\n\t\t\tthis.send(native, \"Page.getFrameTree\").then(async (value) => {\n\t\t\t\tawait this.policy.reconcilePersistent().catch(() => {\n\t\t\t\t\tconsole.error(\"Sidebar cookie reconciliation failed\");\n\t\t\t\t});\n\t\t\t\tconst frame = record$5(record$5(record$5(value).frameTree).frame);\n\t\t\t\tif (this.views.get(lease) === native && generation === native.generation && typeof frame.id === \"string\" && typeof frame.loaderId === \"string\") {\n\t\t\t\t\tclearTimeout(native.documentTimer);\n\t\t\t\t\tthis.publish(lease, native, {\n\t\t\t\t\t\tstage: \"document\",\n\t\t\t\t\t\tgeneration,\n\t\t\t\t\t\tframeId: frame.id,\n\t\t\t\t\t\tloaderId: frame.loaderId\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}).catch((_error) => {\n\t\t\t\tif (this.views.get(lease) === native) this.fail(lease, native, \"BROWSER_DOCUMENT_UNACKNOWLEDGED\");\n\t\t\t});\n\t\t};\n\t\tnative.acknowledge = committed;\n\t\tview.webContents.on(\"did-navigate\", committed);\n\t\tview.webContents.on(\"did-navigate-in-page\", (_event, _url, mainFrame) => {\n\t\t\tif (mainFrame) committed();\n\t\t});\n\t\tview.webContents.on(\"did-fail-load\", (_event, code, _description, _url, mainFrame) => {\n\t\t\tif (mainFrame && code !== -3) this.fail(lease, native, \"BROWSER_DOCUMENT_UNACKNOWLEDGED\");\n\t\t});\n\t\tview.webContents.on(\"render-process-gone\", () => {\n\t\t\tthis.fail(lease, native, \"BROWSER_GUEST_CLOSED\");\n\t\t});\n\t\tview.webContents.once(\"destroyed\", () => {\n\t\t\tthis.endChild(lease, \"BROWSER_GUEST_CLOSED\");\n\t\t\tthis.closeChildren(renderer, lease).catch((error) => console.error(error));\n\t\t\tclearTimeout(native.documentTimer);\n\t\t\tif (this.views.get(lease) === native) {\n\t\t\t\tthis.publish(lease, native, {\n\t\t\t\t\tstage: \"closed\",\n\t\t\t\t\tgeneration: native.generation\n\t\t\t\t});\n\t\t\t\tthis.views.delete(lease);\n\t\t\t\tif (native.slot !== void 0) this.slots.delete(native.slot);\n\t\t\t}\n\t\t\tthis.detach(native);\n\t\t});\n\t\treturn { lease };\n\t}\n\tregisterChildOwner(renderer, parent, slotId) {\n\t\tconst scope = tab(parent).wire;\n\t\tconst slot = this.slot(renderer, slotId);\n\t\tif (slot.scope !== scope || slot.lease === void 0) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tconst lease = slot.lease, native = this.native(renderer, lease);\n\t\tif (native.scope !== scope || native.slot !== slotId) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif (this.childOwners.has(lease)) return refuse(\"BROWSER_HANDLE_STALE\");\n\t\tconst registration = {\n\t\t\ttoken: randomUUID(),\n\t\t\tslot: slotId\n\t\t};\n\t\tthis.childOwners.set(lease, registration);\n\t\tnative.view.webContents.setWindowOpenHandler((details) => {\n\t\t\tif (this.childOwners.get(lease) !== registration || this.views.get(lease) !== native || this.slots.get(registration.slot) !== slot || renderer.isDestroyed() || [...this.children.values()].filter((child) => child.parent === lease && child.slot === void 0).length >= 32 || details.url !== \"about:blank\" && !this.policy.allowedNavigation(details.url)) return { action: \"deny\" };\n\t\t\treturn {\n\t\t\t\taction: \"allow\",\n\t\t\t\toutlivesOpener: false,\n\t\t\t\toverrideBrowserWindowOptions: { webPreferences: {\n\t\t\t\t\tsession: native.view.webContents.session,\n\t\t\t\t\tsandbox: true,\n\t\t\t\t\tcontextIsolation: true,\n\t\t\t\t\tnodeIntegration: false,\n\t\t\t\t\tnodeIntegrationInWorker: false,\n\t\t\t\t\tnodeIntegrationInSubFrames: false,\n\t\t\t\t\twebSecurity: true,\n\t\t\t\t\tallowRunningInsecureContent: false,\n\t\t\t\t\twebviewTag: false,\n\t\t\t\t\tplugins: false,\n\t\t\t\t\tnavigateOnDragDrop: false,\n\t\t\t\t\tdisableDialogs: true,\n\t\t\t\t\tbackgroundThrottling: false\n\t\t\t\t} },\n\t\t\t\tcreateWindow: (options) => {\n\t\t\t\t\tif (this.childOwners.get(lease) !== registration || this.views.get(lease) !== native) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\t\t\t\tconst address = tab(scope);\n\t\t\t\t\tconst child = `dsh-tab:v1:${encodeURIComponent(JSON.stringify([\n\t\t\t\t\t\taddress.owner,\n\t\t\t\t\t\taddress.session,\n\t\t\t\t\t\trandomUUID()\n\t\t\t\t\t]))}`;\n\t\t\t\t\tconst reservation = this.policy.acquire(renderer, native.workspace);\n\t\t\t\t\tlet view;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tview = new WebContentsView(options);\n\t\t\t\t\t\tthis.policy.bindNative(renderer, reservation.lease, view.webContents);\n\t\t\t\t\t\tconst created = this.install(renderer, child, native.workspace, reservation.lease, view);\n\t\t\t\t\t\tconst event = {\n\t\t\t\t\t\t\trequest: randomUUID(),\n\t\t\t\t\t\t\topener: scope,\n\t\t\t\t\t\t\tchild,\n\t\t\t\t\t\t\tlease: created.lease,\n\t\t\t\t\t\t\ttarget: details.frameName,\n\t\t\t\t\t\t\turl: details.url,\n\t\t\t\t\t\t\tdisposition: details.disposition\n\t\t\t\t\t\t};\n\t\t\t\t\t\tconst timer = setTimeout(() => {\n\t\t\t\t\t\t\tthis.endChild(created.lease, \"BROWSER_CHILD_ADOPTION_TIMEOUT\");\n\t\t\t\t\t\t\tthis.release(renderer, created.lease).catch((error) => console.error(error));\n\t\t\t\t\t\t}, 1e4);\n\t\t\t\t\t\tthis.children.set(event.request, {\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\trenderer,\n\t\t\t\t\t\t\tparent: lease,\n\t\t\t\t\t\t\ttimer\n\t\t\t\t\t\t});\n\t\t\t\t\t\trenderer.send(DESKTOP_IPC.nativeChildEvent, {\n\t\t\t\t\t\t\ttype: \"created\",\n\t\t\t\t\t\t\tparent: scope,\n\t\t\t\t\t\t\tchild: event\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn view.webContents;\n\t\t\t\t\t} catch (_error) {\n\t\t\t\t\t\tconst guest = view?.webContents ?? options.webContents;\n\t\t\t\t\t\tif (guest !== void 0 && !guest.isDestroyed()) guest.close({ waitForBeforeUnload: false });\n\t\t\t\t\t\tthis.policy.release(renderer, reservation.lease).catch((error) => console.error(error));\n\t\t\t\t\t\treturn refuse(\"BROWSER_NATIVE_CHILD_UNAVAILABLE\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t});\n\t\treturn registration.token;\n\t}\n\tadoptChild(renderer, request, slotId) {\n\t\tif (typeof request !== \"string\") return refuse(\"BROWSER_HANDLE_STALE\");\n\t\tconst child = this.children.get(request);\n\t\tif (child === void 0) {\n\t\t\tconst ended = this.endedChildren.get(request);\n\t\t\tif (ended !== void 0 && ended.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\t\treturn refuse(ended?.code ?? \"BROWSER_HANDLE_STALE\");\n\t\t}\n\t\tif (child.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tconst slot = this.slot(renderer, slotId);\n\t\tif (child.slot !== void 0 && child.slot !== slotId) return refuse(\"BROWSER_CHILD_ALREADY_ADOPTED\");\n\t\tconst parent = this.native(renderer, child.parent);\n\t\tconst owner = this.childOwners.get(child.parent);\n\t\tif (owner === void 0 || parent.slot !== owner.slot || !this.slots.has(owner.slot)) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif (slot.scope !== child.event.child || this.slots.get(owner.slot)?.admission !== slot.admission) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tthis.attach(renderer, child.event.lease, slotId);\n\t\tchild.slot = slotId;\n\t\tclearTimeout(child.timer);\n\t\treturn {\n\t\t\tchild: child.event.child,\n\t\t\tlease: child.event.lease\n\t\t};\n\t}\n\tendChild(lease, code) {\n\t\tfor (const [request, child] of this.children) {\n\t\t\tif (child.event.lease !== lease) continue;\n\t\t\tclearTimeout(child.timer);\n\t\t\tthis.children.delete(request);\n\t\t\tthis.endedChildren.set(request, {\n\t\t\t\trenderer: child.renderer,\n\t\t\t\tcode\n\t\t\t});\n\t\t\tif (this.endedChildren.size > 256) {\n\t\t\t\tconst oldest = this.endedChildren.keys().next().value;\n\t\t\t\tif (oldest !== void 0) this.endedChildren.delete(oldest);\n\t\t\t}\n\t\t\tif (!child.renderer.isDestroyed()) child.renderer.send(DESKTOP_IPC.nativeChildEvent, {\n\t\t\t\ttype: \"closed\",\n\t\t\t\tparent: child.event.opener,\n\t\t\t\tchild: child.event\n\t\t\t});\n\t\t}\n\t}\n\tasync closeChildren(renderer, lease) {\n\t\tthis.childOwners.delete(lease);\n\t\tconst children = [...this.children.values()].filter((child) => child.parent === lease);\n\t\tfor (const child of children) await this.release(renderer, child.event.lease);\n\t}\n\tasync unregisterChildOwner(renderer, parent, token) {\n\t\tconst scope = tab(parent).wire;\n\t\tconst entry = [...this.views].find(([, native]) => native.scope === scope);\n\t\tif (entry === void 0) return;\n\t\tconst [lease, native] = entry;\n\t\tif (native.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif (this.childOwners.get(lease)?.token !== token) return refuse(\"BROWSER_HANDLE_STALE\");\n\t\tnative.view.webContents.setWindowOpenHandler(() => ({ action: \"deny\" }));\n\t\tawait this.closeChildren(renderer, lease);\n\t}\n\tpublish(lease, native, state) {\n\t\tnative.state = state;\n\t\tif (!native.renderer.isDestroyed()) native.renderer.send(DESKTOP_IPC.nativeViewState, {\n\t\t\tlease,\n\t\t\tstate\n\t\t});\n\t}\n\tfail(lease, native, code) {\n\t\tif (this.views.get(lease) !== native) return;\n\t\tthis.publish(lease, native, {\n\t\t\tstage: \"failed\",\n\t\t\tgeneration: native.generation,\n\t\t\tcode\n\t\t});\n\t\tthis.release(native.renderer, lease).catch((error) => console.error(error));\n\t}\n\tattach(renderer, id, slotId) {\n\t\tconst native = this.native(renderer, id);\n\t\tconst slot = this.slot(renderer, slotId);\n\t\tif (slot.scope !== native.scope || slot.lease !== void 0 && slot.lease !== id || native.slot !== void 0 && native.slot !== slotId || slot.placement === void 0) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tnative.slot = slotId;\n\t\tslot.lease = id;\n\t\tthis.compose(native, slot);\n\t\tclearTimeout(native.documentTimer);\n\t\tthis.publish(id, native, native.state);\n\t\tif (native.state.stage === \"attached\" && native.view.webContents.getURL() === \"about:blank\" && [...this.children.values()].some((child) => child.event.lease === id)) native.acknowledge?.();\n\t}\n\tcompose(native, slot) {\n\t\tconst window = this.window(), placement = slot.placement;\n\t\tif (window === void 0 || window.isDestroyed() || placement === void 0 || native.renderer !== window.webContents) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tconst zoom = window.webContents.getZoomFactor();\n\t\tconst bounds = window.getContentBounds();\n\t\tconst x = Math.max(0, Math.min(bounds.width, Math.round(placement.x * zoom)));\n\t\tconst y = Math.max(0, Math.min(bounds.height, Math.round(placement.y * zoom)));\n\t\tconst width = Math.max(0, Math.min(bounds.width - x, Math.round(placement.width * zoom)));\n\t\tconst height = Math.max(0, Math.min(bounds.height - y, Math.round(placement.height * zoom)));\n\t\tnative.container.setBounds({\n\t\t\tx,\n\t\t\ty,\n\t\t\twidth,\n\t\t\theight\n\t\t});\n\t\tnative.view.setBounds({\n\t\t\tx: 0,\n\t\t\ty: 0,\n\t\t\twidth,\n\t\t\theight\n\t\t});\n\t\twindow.contentView.addChildView(native.container, placement.background ? 0 : void 0);\n\t\tnative.container.setVisible(width > 0 && height > 0 && (placement.visible || placement.background));\n\t}\n\tasync command(renderer, id, method, params) {\n\t\tconst native = this.native(renderer, id);\n\t\tif (native.slot === void 0) return refuse(\"BROWSER_SLOT_UNAVAILABLE\");\n\t\tthis.slot(renderer, native.slot);\n\t\tif (typeof method !== \"string\" || !methods.has(method)) return refuse(\"BROWSER_COMMAND_DENIED\");\n\t\tconst input = params === void 0 ? {} : record$5(params);\n\t\tif (method === \"Storage.setCookies\" && (!Array.isArray(input.cookies) || Object.keys(input).some((key) => key !== \"cookies\"))) return refuse(\"BROWSER_COMMAND_DENIED\");\n\t\tif (method === \"Page.createIsolatedWorld\" && input.grantUniveralAccess === true) return refuse(\"BROWSER_COMMAND_DENIED\");\n\t\tif (method === \"Page.navigate\" && (typeof input.url !== \"string\" || !this.policy.allowedNavigation(input.url))) return refuse(\"BROWSER_URL_DENIED\");\n\t\tif (native.state.stage !== \"document\" && ![\n\t\t\t\"Page.navigate\",\n\t\t\t\"Page.stopLoading\",\n\t\t\t\"Page.getFrameTree\"\n\t\t].includes(method)) return refuse(\"BROWSER_DOCUMENT_UNACKNOWLEDGED\");\n\t\tconst expectedGeneration = [\n\t\t\t\"Page.navigate\",\n\t\t\t\"Page.stopLoading\",\n\t\t\t\"Page.getFrameTree\"\n\t\t].includes(method) ? void 0 : native.generation;\n\t\ttry {\n\t\t\tconst result = await this.send(native, method === \"Storage.setCookies\" ? \"Network.setCookies\" : method, input, expectedGeneration);\n\t\t\tif (method === \"Storage.setCookies\" || method === \"Runtime.evaluate\") await this.policy.reconcilePersistent();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (error instanceof DesktopNativeViewError && error.code === \"BROWSER_DOCUMENT_TIMEOUT\") this.fail(id, native, \"BROWSER_DOCUMENT_TIMEOUT\");\n\t\t\tthrow error;\n\t\t}\n\t}\n\tsend(native, method, params = {}, expectedGeneration) {\n\t\tconst pending = native.queue.then(async () => {\n\t\t\tif (![...this.views.values()].includes(native) || native.view.webContents.isDestroyed()) return refuse(\"BROWSER_GUEST_CLOSED\");\n\t\t\tif (expectedGeneration !== void 0 && (native.generation !== expectedGeneration || native.state.stage !== \"document\")) return refuse(\"BROWSER_DOCUMENT_UNACKNOWLEDGED\");\n\t\t\tconst debugger_ = native.view.webContents.debugger;\n\t\t\tif (!debugger_.isAttached()) debugger_.attach(\"1.3\");\n\t\t\tlet timer;\n\t\t\ttry {\n\t\t\t\treturn await Promise.race([debugger_.sendCommand(method, params), new Promise((_resolve, reject) => {\n\t\t\t\t\ttimer = setTimeout(() => {\n\t\t\t\t\t\treject(new DesktopNativeViewError(\"BROWSER_DOCUMENT_TIMEOUT\"));\n\t\t\t\t\t}, 15e3);\n\t\t\t\t})]);\n\t\t\t} finally {\n\t\t\t\tclearTimeout(timer);\n\t\t\t}\n\t\t});\n\t\tnative.queue = pending.catch((_error) => {});\n\t\treturn pending;\n\t}\n\tasync release(renderer, id) {\n\t\tif (typeof id !== \"string\") return refuse(\"BROWSER_GUEST_CLOSED\");\n\t\tconst native = this.views.get(id);\n\t\tif (native === void 0) {\n\t\t\tconst pending = this.releasing.get(id);\n\t\t\tif (pending !== void 0 && pending.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\t\treturn pending?.completion;\n\t\t}\n\t\tif (native.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tthis.views.delete(id);\n\t\tthis.endChild(id, \"BROWSER_GUEST_CLOSED\");\n\t\tconst children = this.closeChildren(renderer, id);\n\t\tclearTimeout(native.documentTimer);\n\t\tthis.detach(native);\n\t\tif (native.slot !== void 0) this.slots.delete(native.slot);\n\t\tconst completion = Promise.resolve().then(async () => {\n\t\t\tawait children;\n\t\t\tawait this.policy.release(renderer, native.reservation);\n\t\t\tthis.publish(id, native, {\n\t\t\t\tstage: \"closed\",\n\t\t\t\tgeneration: native.generation\n\t\t\t});\n\t\t}).finally(() => {\n\t\t\tthis.releasing.delete(id);\n\t\t});\n\t\tthis.releasing.set(id, {\n\t\t\trenderer,\n\t\t\tcompletion\n\t\t});\n\t\treturn completion;\n\t}\n\t/** Trusted main extensions can enumerate only admitted native surfaces of the primary window. */\n\tsnapshot() {\n\t\tconst renderer = this.window()?.webContents;\n\t\treturn [...this.views].filter(([, native]) => native.renderer === renderer && native.slot !== void 0).map(([lease, native]) => ({\n\t\t\tscope: native.scope,\n\t\t\tlease,\n\t\t\tstate: { ...native.state },\n\t\t\turl: native.view.webContents.getURL(),\n\t\t\ttitle: native.view.webContents.getTitle()\n\t\t}));\n\t}\n\t/** Release only the lease bound to this canonical scope. */\n\tasync scopedRelease(scope, lease) {\n\t\tconst renderer = this.window()?.webContents;\n\t\tif (renderer === void 0) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tconst native = this.views.get(lease);\n\t\tif (native === void 0) return;\n\t\tif (native.scope !== tab(scope).wire || native.renderer !== renderer) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tawait this.release(renderer, lease);\n\t}\n\t/** Download through the same scoped guest session and its network policy. */\n\tasync scopedFetch(scope, lease, url, signal) {\n\t\tconst renderer = this.window()?.webContents;\n\t\tif (renderer === void 0) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tconst native = this.native(renderer, lease);\n\t\tif (native.scope !== tab(scope).wire) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\tif (!this.policy.allowedNavigation(url)) return refuse(\"BROWSER_URL_DENIED\");\n\t\tconst response = await native.view.webContents.session.fetch(url, {\n\t\t\tcredentials: \"include\",\n\t\t\tsignal\n\t\t});\n\t\tawait this.policy.reconcilePersistent();\n\t\treturn response;\n\t}\n\t/** Resolve the scoped binding again at dispatch, rather than exposing Electron guests. */\n\tasync scopedCommand(scope, lease, method, params) {\n\t\tconst renderer = this.window()?.webContents;\n\t\tif (renderer === void 0) return refuse(\"BROWSER_NATIVE_SURFACE_UNAVAILABLE\");\n\t\tif (this.native(renderer, lease).scope !== tab(scope).wire) return refuse(\"BROWSER_OWNER_UNKNOWN\");\n\t\treturn this.command(renderer, lease, method, params);\n\t}\n\tdetach(native) {\n\t\tconst window = this.window();\n\t\tif (window !== void 0 && !window.isDestroyed()) window.contentView.removeChildView(native.container);\n\t}\n\tasync revoke(renderer, id) {\n\t\tif (typeof id !== \"string\" || !this.slots.has(id)) return;\n\t\tconst slot = this.slot(renderer, id);\n\t\tthis.slots.delete(id);\n\t\tfor (const [lease, native] of this.views) if (native.renderer === renderer && native.scope === slot.scope) await this.release(renderer, lease);\n\t}\n\t/** Revoke admissions before releasing native objects on owner navigation or death. */\n\tbind(window) {\n\t\tconst renderer = window.webContents;\n\t\tconst revoke = () => {\n\t\t\tfor (const [id, admission] of this.admissions) if (admission.renderer === renderer) this.admissions.delete(id);\n\t\t\tfor (const [id, slot] of this.slots) if (slot.renderer === renderer) this.slots.delete(id);\n\t\t\tfor (const [id, native] of this.views) if (native.renderer === renderer) this.release(renderer, id).catch((error) => console.error(error));\n\t\t};\n\t\trenderer.on(\"did-start-navigation\", (_event, _url, inPlace, mainFrame) => {\n\t\t\tif (mainFrame && !inPlace) revoke();\n\t\t});\n\t\trenderer.on(\"render-process-gone\", revoke);\n\t\trenderer.once(\"destroyed\", revoke);\n\t}\n};\n//#endregion\n//#region lib/types/core-package-set.js\n/** Private package installed beside dsh to boot the Desktop Host process. */\nconst DESKTOP_HOST_PACKAGE = \"@deepseek-ai/dsh-desktop-host\";"
82
82
  },
83
83
  {
84
84
  "before": "\t\t\t...this.packageManager === void 0 ? [] : [this.packageManager.pnpm, this.packageManager.nodeBin]\n\t\t], {\n\t\t\tcwd: this.projectDir,\n\t\t\tenv: desktopNodeEnvironment(this.node, void 0, this.environment),\n\t\t\tstdio: [\n\t\t\t\t\"ignore\",\n\t\t\t\t\"pipe\",\n",
@@ -106,7 +106,7 @@
106
106
  },
107
107
  {
108
108
  "before": "\n\t});\n\tipcMain.handle(DESKTOP_IPC.browserAcquire, (event, workspace) => {\n\t\tassertProductSender(event);\n\t\treturn browserGuests.acquire(event.sender, workspace);\n\t});\n",
109
- "after": "\n\t});\n\tipcMain.handle(DESKTOP_IPC.browserAcquire, async (event, workspace, persistent) => {\n\t\tassertProductSender(event);\n\t\tif (persistent === true) await browserGuests.preparePersistent();\n\t\treturn browserGuests.acquire(event.sender, workspace, persistent === true);\n\t});\n\tlet sidebarStorageClosed = false;\n\tlet sidebarStorageClosing = false;\n\tapp.on(\"will-quit\", (event) => {\n\t\tif (sidebarStorageClosed) return;\n\t\tevent.preventDefault();\n\t\tif (sidebarStorageClosing) return;\n\t\tsidebarStorageClosing = true;\n\t\tbrowserGuests.shutdown().catch((error) => {\n\t\t\tconsole.error(error);\n\t\t}).finally(() => {\n\t\t\tsidebarStorageClosed = true;\n\t\t\tapp.quit();\n\t\t});\n\t});\n\tipcMain.handle(DESKTOP_IPC.nativeViewsRequest, (event, request) => {\n\t\tassertProductSender(event);\n\t\treturn nativeViews.request(event.sender, request);\n\t});\n\tipcMain.handle(DESKTOP_IPC.mainExtensionStatus, async (event, name) => {\n\t\tassertProductSender(event);\n\t\tif (typeof name !== \"string\") throw new Error(\"desktop main extension status requires a package name\");\n\t\tawait startup;\n\t\treturn mainExtensionStatus(name);\n\t});\n"
109
+ "after": "\n\t});\n\tipcMain.handle(DESKTOP_IPC.browserAcquire, async (event, workspace, persistent) => {\n\t\tassertProductSender(event);\n\t\tif (persistent === true) await browserGuests.preparePersistent();\n\t\treturn browserGuests.acquire(event.sender, workspace, persistent === true);\n\t});\n\tlet sidebarStorageClosed = false;\n\tlet sidebarStorageClosing = false;\n\tapp.on(\"will-quit\", (event) => {\n\t\tif (sidebarStorageClosed) return;\n\t\tevent.preventDefault();\n\t\tif (sidebarStorageClosing) return;\n\t\tsidebarStorageClosing = true;\n\t\t/* The quit is already prevented, so only this handler can start it again. A shutdown that\n\t\tnever settles would therefore cancel the quit permanently: the window and tray are gone but the\n\t\tmain process stays alive holding the single-instance lock. The watchdog makes the exit\n\t\tindependent of that promise. */\n\t\tconst force = setTimeout(() => {\n\t\t\tsidebarStorageClosed = true;\n\t\t\tapp.exit(0);\n\t\t}, 5e3);\n\t\tforce.unref?.();\n\t\tbrowserGuests.shutdown().catch((error) => {\n\t\t\tconsole.error(error);\n\t\t}).finally(() => {\n\t\t\tclearTimeout(force);\n\t\t\tsidebarStorageClosed = true;\n\t\t\tapp.quit();\n\t\t});\n\t});\n\tipcMain.handle(DESKTOP_IPC.nativeViewsRequest, (event, request) => {\n\t\tassertProductSender(event);\n\t\treturn nativeViews.request(event.sender, request);\n\t});\n\tipcMain.handle(DESKTOP_IPC.mainExtensionStatus, async (event, name) => {\n\t\tassertProductSender(event);\n\t\tif (typeof name !== \"string\") throw new Error(\"desktop main extension status requires a package name\");\n\t\tawait startup;\n\t\treturn mainExtensionStatus(name);\n\t});\n"
110
110
  },
111
111
  {
112
112
  "before": "\n\t\tbrowserGuests.bind(window, (guest, name) => shortcuts.attachGuest(window, guest, name));\n\t\tshortcuts.attach(window);\n\t\twindow.on(\"focus\", automaticCheck);",
@@ -131,7 +131,7 @@
131
131
  },
132
132
  {
133
133
  "before": "\n}\n//#endregion\n//#region lib/types/preload-browser.js\n/** Lease-scoped browser operations and one main-process event subscription per window. */\n/** @returns browser operations that expose neither IPC nor Electron objects. */\nfunction createDesktopBrowserBridge() {\n\tconst listeners = /* @__PURE__ */ new Map();\n\telectron.ipcRenderer.on(DESKTOP_IPC.browserOpenRequested, (_event, request) => {\n",
134
- "after": "\n}\n//#endregion\n//#region ../../packages/util/error/lib/index.js\n/**\n* Harness error base with a stable machine-routable code and chained cause.\n* Package errors extend it so tool results and replay can retain failure class.\n* @module @deepseek-ai/dsh-error\n*/\n/**\n* Base class for all harness errors. Carries a `code` (stable, programmatic \u2014\n* e.g. `NO_ADAPTER`, `INVALID_ARGS`) distinct from the\n* human-readable `message`, and supports `cause` chaining via the standard\n* `ErrorOptions`. `name` defaults to the subclass constructor name.\n*/\nvar HarnessError = class extends Error {\n\t/** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never by parsing `message`. */\n\tcode;\n\tconstructor(message, code, options) {\n\t\tsuper(message, options);\n\t\tthis.code = code;\n\t\tthis.name = new.target.name;\n\t}\n};\n//#endregion\n//#region lib/types/preload-browser.js\n/** Lease-scoped browser operations and one main-process event subscription per window. */\n/** @returns browser operations that expose neither IPC nor Electron objects. */\nfunction createDesktopBrowserBridge() {\n\tconst nativeListeners = /* @__PURE__ */ new Map();\n\telectron.ipcRenderer.on(DESKTOP_IPC.nativeViewState, (_event, input) => {\n\t\tif (typeof input !== \"object\" || input === null || !(\"lease\" in input) || typeof input.lease !== \"string\" || !(\"state\" in input) || typeof input.state !== \"object\" || input.state === null) return;\n\t\tconst state = input.state;\n\t\tif (!(\"stage\" in state) || ![\n\t\t\t\"attached\",\n\t\t\t\"document\",\n\t\t\t\"closed\",\n\t\t\t\"failed\"\n\t\t].includes(String(state.stage)) || !(\"generation\" in state) || typeof state.generation !== \"string\" || state.generation.length === 0 || state.stage === \"document\" && (!(\"frameId\" in state) || typeof state.frameId !== \"string\" || !(\"loaderId\" in state) || typeof state.loaderId !== \"string\") || state.stage === \"failed\" && (!(\"code\" in state) || typeof state.code !== \"string\")) return;\n\t\tconst lease = input.lease;\n\t\tfor (const listener of [...nativeListeners.get(lease) ?? []]) try {\n\t\t\tlistener(state);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Desktop native view listener failed\", error);\n\t\t}\n\t\tif (state.stage === \"closed\") nativeListeners.delete(lease);\n\t});\n\tconst invoke = async (request) => {\n\t\tconst answer = await electron.ipcRenderer.invoke(DESKTOP_IPC.nativeViewsRequest, request);\n\t\tif (!answer.ok) throw new HarnessError(answer.message, answer.code);\n\t\treturn answer.result;\n\t};\n\tconst created = /* @__PURE__ */ new Map();\n\tconst closed = /* @__PURE__ */ new Map();\n\telectron.ipcRenderer.on(DESKTOP_IPC.nativeChildEvent, (_event, input) => {\n\t\tif (typeof input !== \"object\" || input === null || !(\"parent\" in input) || typeof input.parent !== \"string\" || !(\"type\" in input) || !(\"child\" in input)) return;\n\t\tif (input.type === \"created\" || input.type === \"closed\") {\n\t\t\tconst child = input.child;\n\t\t\tif (typeof child !== \"object\" || child === null || ![\n\t\t\t\t\"request\",\n\t\t\t\t\"opener\",\n\t\t\t\t\"child\",\n\t\t\t\t\"lease\",\n\t\t\t\t\"target\",\n\t\t\t\t\"url\",\n\t\t\t\t\"disposition\"\n\t\t\t].every((key) => key in child && typeof Reflect.get(child, key) === \"string\")) return;\n\t\t\tif (child.opener !== input.parent) return;\n\t\t\tconst registry = input.type === \"created\" ? created : closed;\n\t\t\tfor (const listener of [...registry.get(input.parent) ?? []]) try {\n\t\t\t\tlistener(child);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\"Native child listener failed\", error);\n\t\t\t}\n\t\t}\n\t});\n\tconst subscribe = (registry, parent, listener) => {\n\t\tlet listeners = registry.get(parent);\n\t\tif (listeners === void 0) {\n\t\t\tlisteners = /* @__PURE__ */ new Set();\n\t\t\tregistry.set(parent, listeners);\n\t\t}\n\t\tlisteners.add(listener);\n\t\treturn () => {\n\t\t\tlisteners.delete(listener);\n\t\t\tif (listeners.size === 0 && registry.get(parent) === listeners) registry.delete(parent);\n\t\t};\n\t};\n\tconst nativeViews = {\n\t\tprotocolVersion: 1,\n\t\tpersistentSession: true,\n\t\tslots: {\n\t\t\tenter: (owner) => invoke({\n\t\t\t\top: \"enter\",\n\t\t\t\towner\n\t\t\t}),\n\t\t\tleave: (admission) => invoke({\n\t\t\t\top: \"leave\",\n\t\t\t\tadmission\n\t\t\t}),\n\t\t\tregister: (admission, scope) => invoke({\n\t\t\t\top: \"register\",\n\t\t\t\tadmission,\n\t\t\t\tscope\n\t\t\t}),\n\t\t\tupdate: (slot, placement) => invoke({\n\t\t\t\top: \"update\",\n\t\t\t\tslot,\n\t\t\t\tplacement\n\t\t\t}),\n\t\t\trevoke: (slot) => invoke({\n\t\t\t\top: \"revoke\",\n\t\t\t\tslot\n\t\t\t})\n\t\t},\n\t\tacquire: (scope, workspace, persistent) => invoke({\n\t\t\top: \"acquire\",\n\t\t\tscope,\n\t\t\tworkspace,\n\t\t\tpersistent\n\t\t}),\n\t\tattach: (lease, slot) => invoke({\n\t\t\top: \"attach\",\n\t\t\tlease,\n\t\t\tslot\n\t\t}),\n\t\tcommand: (lease, method, params) => invoke({\n\t\t\top: \"command\",\n\t\t\tlease,\n\t\t\tmethod,\n\t\t\tparams\n\t\t}),\n\t\trelease: (lease) => invoke({\n\t\t\top: \"release\",\n\t\t\tlease\n\t\t}),\n\t\tonState(lease, listener) {\n\t\t\tlet callbacks = nativeListeners.get(lease);\n\t\t\tif (callbacks === void 0) {\n\t\t\t\tcallbacks = /* @__PURE__ */ new Set();\n\t\t\t\tnativeListeners.set(lease, callbacks);\n\t\t\t}\n\t\t\tcallbacks.add(listener);\n\t\t\treturn () => {\n\t\t\t\tcallbacks.delete(listener);\n\t\t\t\tif (callbacks.size === 0 && nativeListeners.get(lease) === callbacks) nativeListeners.delete(lease);\n\t\t\t};\n\t\t}\n\t};\n\tconst listeners = /* @__PURE__ */ new Map();\n\telectron.ipcRenderer.on(DESKTOP_IPC.browserOpenRequested, (_event, request) => {\n"
134
+ "after": "\n}\n//#endregion\n//#region ../../packages/util/error/lib/index.js\n/**\n* Harness error base with a stable machine-routable code and chained cause.\n* Package errors extend it so tool results and replay can retain failure class.\n* @module @deepseek-ai/dsh-error\n*/\n/**\n* Base class for all harness errors. Carries a `code` (stable, programmatic —\n* e.g. `NO_ADAPTER`, `INVALID_ARGS`) distinct from the\n* human-readable `message`, and supports `cause` chaining via the standard\n* `ErrorOptions`. `name` defaults to the subclass constructor name.\n*/\nvar HarnessError = class extends Error {\n\t/** Stable machine-routable failure class (e.g. `RATE_LIMIT`); route on this, never by parsing `message`. */\n\tcode;\n\tconstructor(message, code, options) {\n\t\tsuper(message, options);\n\t\tthis.code = code;\n\t\tthis.name = new.target.name;\n\t}\n};\n//#endregion\n//#region lib/types/preload-browser.js\n/** Lease-scoped browser operations and one main-process event subscription per window. */\n/** @returns browser operations that expose neither IPC nor Electron objects. */\nfunction createDesktopBrowserBridge() {\n\tconst nativeListeners = /* @__PURE__ */ new Map();\n\telectron.ipcRenderer.on(DESKTOP_IPC.nativeViewState, (_event, input) => {\n\t\tif (typeof input !== \"object\" || input === null || !(\"lease\" in input) || typeof input.lease !== \"string\" || !(\"state\" in input) || typeof input.state !== \"object\" || input.state === null) return;\n\t\tconst state = input.state;\n\t\tif (!(\"stage\" in state) || ![\n\t\t\t\"attached\",\n\t\t\t\"document\",\n\t\t\t\"closed\",\n\t\t\t\"failed\"\n\t\t].includes(String(state.stage)) || !(\"generation\" in state) || typeof state.generation !== \"string\" || state.generation.length === 0 || state.stage === \"document\" && (!(\"frameId\" in state) || typeof state.frameId !== \"string\" || !(\"loaderId\" in state) || typeof state.loaderId !== \"string\") || state.stage === \"failed\" && (!(\"code\" in state) || typeof state.code !== \"string\")) return;\n\t\tconst lease = input.lease;\n\t\tfor (const listener of [...nativeListeners.get(lease) ?? []]) try {\n\t\t\tlistener(state);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"Desktop native view listener failed\", error);\n\t\t}\n\t\tif (state.stage === \"closed\") nativeListeners.delete(lease);\n\t});\n\tconst invoke = async (request) => {\n\t\tconst answer = await electron.ipcRenderer.invoke(DESKTOP_IPC.nativeViewsRequest, request);\n\t\tif (!answer.ok) throw new HarnessError(answer.message, answer.code);\n\t\treturn answer.result;\n\t};\n\tconst created = /* @__PURE__ */ new Map();\n\tconst closed = /* @__PURE__ */ new Map();\n\telectron.ipcRenderer.on(DESKTOP_IPC.nativeChildEvent, (_event, input) => {\n\t\tif (typeof input !== \"object\" || input === null || !(\"parent\" in input) || typeof input.parent !== \"string\" || !(\"type\" in input) || !(\"child\" in input)) return;\n\t\tif (input.type === \"created\" || input.type === \"closed\") {\n\t\t\tconst child = input.child;\n\t\t\tif (typeof child !== \"object\" || child === null || ![\n\t\t\t\t\"request\",\n\t\t\t\t\"opener\",\n\t\t\t\t\"child\",\n\t\t\t\t\"lease\",\n\t\t\t\t\"target\",\n\t\t\t\t\"url\",\n\t\t\t\t\"disposition\"\n\t\t\t].every((key) => key in child && typeof Reflect.get(child, key) === \"string\")) return;\n\t\t\tif (child.opener !== input.parent) return;\n\t\t\tconst registry = input.type === \"created\" ? created : closed;\n\t\t\tfor (const listener of [...registry.get(input.parent) ?? []]) try {\n\t\t\t\tlistener(child);\n\t\t\t} catch (error) {\n\t\t\t\tconsole.error(\"Native child listener failed\", error);\n\t\t\t}\n\t\t}\n\t});\n\tconst subscribe = (registry, parent, listener) => {\n\t\tlet listeners = registry.get(parent);\n\t\tif (listeners === void 0) {\n\t\t\tlisteners = /* @__PURE__ */ new Set();\n\t\t\tregistry.set(parent, listeners);\n\t\t}\n\t\tlisteners.add(listener);\n\t\treturn () => {\n\t\t\tlisteners.delete(listener);\n\t\t\tif (listeners.size === 0 && registry.get(parent) === listeners) registry.delete(parent);\n\t\t};\n\t};\n\tconst nativeViews = {\n\t\tprotocolVersion: 1,\n\t\tpersistentSession: true,\n\t\tslots: {\n\t\t\tenter: (owner) => invoke({\n\t\t\t\top: \"enter\",\n\t\t\t\towner\n\t\t\t}),\n\t\t\tleave: (admission) => invoke({\n\t\t\t\top: \"leave\",\n\t\t\t\tadmission\n\t\t\t}),\n\t\t\tregister: (admission, scope) => invoke({\n\t\t\t\top: \"register\",\n\t\t\t\tadmission,\n\t\t\t\tscope\n\t\t\t}),\n\t\t\tupdate: (slot, placement) => invoke({\n\t\t\t\top: \"update\",\n\t\t\t\tslot,\n\t\t\t\tplacement\n\t\t\t}),\n\t\t\trevoke: (slot) => invoke({\n\t\t\t\top: \"revoke\",\n\t\t\t\tslot\n\t\t\t})\n\t\t},\n\t\tacquire: (scope, workspace, persistent) => invoke({\n\t\t\top: \"acquire\",\n\t\t\tscope,\n\t\t\tworkspace,\n\t\t\tpersistent\n\t\t}),\n\t\tattach: (lease, slot) => invoke({\n\t\t\top: \"attach\",\n\t\t\tlease,\n\t\t\tslot\n\t\t}),\n\t\tcommand: (lease, method, params) => invoke({\n\t\t\top: \"command\",\n\t\t\tlease,\n\t\t\tmethod,\n\t\t\tparams\n\t\t}),\n\t\trelease: (lease) => invoke({\n\t\t\top: \"release\",\n\t\t\tlease\n\t\t}),\n\t\tonState(lease, listener) {\n\t\t\tlet callbacks = nativeListeners.get(lease);\n\t\t\tif (callbacks === void 0) {\n\t\t\t\tcallbacks = /* @__PURE__ */ new Set();\n\t\t\t\tnativeListeners.set(lease, callbacks);\n\t\t\t}\n\t\t\tcallbacks.add(listener);\n\t\t\treturn () => {\n\t\t\t\tcallbacks.delete(listener);\n\t\t\t\tif (callbacks.size === 0 && nativeListeners.get(lease) === callbacks) nativeListeners.delete(lease);\n\t\t\t};\n\t\t}\n\t};\n\tconst listeners = /* @__PURE__ */ new Map();\n\telectron.ipcRenderer.on(DESKTOP_IPC.browserOpenRequested, (_event, request) => {\n"
135
135
  },
136
136
  {
137
137
  "before": "\t});\n\treturn {\n\t\tacquire: (workspace) => electron.ipcRenderer.invoke(DESKTOP_IPC.browserAcquire, workspace),\n\t\trelease: (lease) => electron.ipcRenderer.invoke(DESKTOP_IPC.browserRelease, lease),\n\t\tonOpenRequested(lease, listener) {\n\t\t\tlet callbacks = listeners.get(lease);",
@@ -70,7 +70,7 @@
70
70
  "id": "main",
71
71
  "packageName": "@deepseek-ai/dsh-desktop",
72
72
  "file": "lib/main.js",
73
- "marker": "async savedCookies()",
73
+ "marker": "clearTimeout(force)",
74
74
  "sha256": "ec57e577243d7a312136c7204bca0faca98f0bc5310c924b5c82fa26b09ff95a",
75
75
  "edits": [
76
76
  {
@@ -111,7 +111,7 @@
111
111
  },
112
112
  {
113
113
  "before": "\n\t});\n\tipcMain.handle(DESKTOP_IPC.browserAcquire, (event, workspace) => {\n\t\tassertProductSender(event);\n\t\treturn browserGuests.acquire(event.sender, workspace);\n\t});\n",
114
- "after": "\n\t});\n\tipcMain.handle(DESKTOP_IPC.browserAcquire, async (event, workspace, persistent) => {\n\t\tassertProductSender(event);\n\t\tif (persistent === true) await browserGuests.preparePersistent();\n\t\treturn browserGuests.acquire(event.sender, workspace, persistent === true);\n\t});\n\tlet sidebarStorageClosed = false;\n\tlet sidebarStorageClosing = false;\n\tapp.on(\"will-quit\", (event) => {\n\t\tif (sidebarStorageClosed) return;\n\t\tevent.preventDefault();\n\t\tif (sidebarStorageClosing) return;\n\t\tsidebarStorageClosing = true;\n\t\tbrowserGuests.shutdown().catch((error) => {\n\t\t\tconsole.error(error);\n\t\t}).finally(() => {\n\t\t\tsidebarStorageClosed = true;\n\t\t\tapp.quit();\n\t\t});\n\t});\n\tipcMain.handle(DESKTOP_IPC.nativeViewsRequest, (event, request) => {\n\t\tassertProductSender(event);\n\t\treturn nativeViews.request(event.sender, request);\n\t});\n\tipcMain.handle(DESKTOP_IPC.mainExtensionStatus, async (event, name) => {\n\t\tassertProductSender(event);\n\t\tif (typeof name !== \"string\") throw new Error(\"desktop main extension status requires a package name\");\n\t\tawait startup;\n\t\treturn mainExtensionStatus(name);\n\t});\n"
114
+ "after": "\n\t});\n\tipcMain.handle(DESKTOP_IPC.browserAcquire, async (event, workspace, persistent) => {\n\t\tassertProductSender(event);\n\t\tif (persistent === true) await browserGuests.preparePersistent();\n\t\treturn browserGuests.acquire(event.sender, workspace, persistent === true);\n\t});\n\tlet sidebarStorageClosed = false;\n\tlet sidebarStorageClosing = false;\n\tapp.on(\"will-quit\", (event) => {\n\t\tif (sidebarStorageClosed) return;\n\t\tevent.preventDefault();\n\t\tif (sidebarStorageClosing) return;\n\t\tsidebarStorageClosing = true;\n\t\t/* The quit is already prevented, so only this handler can start it again. A shutdown that\n\t\tnever settles would therefore cancel the quit permanently: the window and tray are gone but the\n\t\tmain process stays alive holding the single-instance lock. The watchdog makes the exit\n\t\tindependent of that promise. */\n\t\tconst force = setTimeout(() => {\n\t\t\tsidebarStorageClosed = true;\n\t\t\tapp.exit(0);\n\t\t}, 5e3);\n\t\tforce.unref?.();\n\t\tbrowserGuests.shutdown().catch((error) => {\n\t\t\tconsole.error(error);\n\t\t}).finally(() => {\n\t\t\tclearTimeout(force);\n\t\t\tsidebarStorageClosed = true;\n\t\t\tapp.quit();\n\t\t});\n\t});\n\tipcMain.handle(DESKTOP_IPC.nativeViewsRequest, (event, request) => {\n\t\tassertProductSender(event);\n\t\treturn nativeViews.request(event.sender, request);\n\t});\n\tipcMain.handle(DESKTOP_IPC.mainExtensionStatus, async (event, name) => {\n\t\tassertProductSender(event);\n\t\tif (typeof name !== \"string\") throw new Error(\"desktop main extension status requires a package name\");\n\t\tawait startup;\n\t\treturn mainExtensionStatus(name);\n\t});\n"
115
115
  },
116
116
  {
117
117
  "before": "\n\t\tbrowserGuests.bind(window, (guest, name) => shortcuts.attachGuest(window, guest, name));\n\t\tshortcuts.attach(window);\n\t\twindow.on(\"focus\", automaticCheck);",
@@ -195,6 +195,11 @@ export function readBridgeStatus(installRoot, mainExtension) {
195
195
  state: mainExtension.state === 'loaded' ? 'installed' : mainExtension.state === 'not-installed' ? 'missing' : 'stale',
196
196
  code: mainExtension.code };
197
197
  }
198
+ /** The main entry the identity resolved for this install, when it can be read again cheaply. */
199
+ function identityEntry(installRoot) {
200
+ const identity = readDesktopIdentity(installRoot);
201
+ return identity.ok ? identity.mainEntry : undefined;
202
+ }
198
203
  function readBridgeInstallStatus(installRoot) {
199
204
  let resources;
200
205
  try {
@@ -204,7 +209,10 @@ function readBridgeInstallStatus(installRoot) {
204
209
  return { state: 'missing', present: false, installRoot, archivePresent: false, detail: `not a DSH Desktop install: ${String(error)}` };
205
210
  }
206
211
  const appDir = join(resources, 'app');
207
- const mainPath = join(appDir, 'lib', 'main.js');
212
+ // Follow the entry the identity actually resolved instead of assuming the legacy name. When it is
213
+ // not the entry our patch specs target, the install is recognized but cannot be patched yet — that
214
+ // is a distinct answer from "this is not DSH Desktop at all" (issue #112).
215
+ const mainPath = join(appDir, ...(identityEntry(installRoot) ?? 'lib/main.js').split('/'));
208
216
  const archivePath = join(resources, 'app.asar');
209
217
  const backupPath = `${mainPath}.before-bridge`;
210
218
  // Identity first, and before any other reading. Two reasons, both measured in issue #40: a
@@ -223,6 +231,21 @@ function readBridgeInstallStatus(installRoot) {
223
231
  }
224
232
  const archivePresent = safeExists(archivePath);
225
233
  const version = identity.version ?? 'unknown';
234
+ // A recognized DSH Desktop whose main entry we have no patch spec for. Reported as its own state so
235
+ // the panel can say "this desktop version has no patch yet, use the web sidebar" instead of either
236
+ // pretending the desktop is absent (#112) or offering an install that must fail.
237
+ const entry = identityEntry(installRoot) ?? 'lib/main.js';
238
+ if (entry !== 'lib/main.js') {
239
+ return {
240
+ state: 'unsupported-layout',
241
+ present: true,
242
+ installRoot,
243
+ archivePresent,
244
+ version,
245
+ entry,
246
+ detail: `DSH Desktop ${version} uses ${entry}, which this build has no host-patch spec for; the web sidebar works without it`,
247
+ };
248
+ }
226
249
  const mainPresent = safeExists(mainPath);
227
250
  if (!mainPresent && !archivePresent) {
228
251
  // Unreachable once identity has passed (identity requires the loaded main entry), kept as the
@@ -44,8 +44,16 @@ const archiveFs = (() => {
44
44
  export const FALLBACK_RULE = {
45
45
  packageNames: ['@deepseek-ai/dsh-desktop', 'dsh-desktop'],
46
46
  mainEntry: 'lib/main.js',
47
+ mainEntryCandidates: [
48
+ {
49
+ entry: 'out/main/index.js',
50
+ packageName: 'dsh-desktop',
51
+ requiresDependency: '@deepseek-ai/dsh',
52
+ note: 'electron-vite layout. The official DSH Desktop 0.14.0 ships this entry with `main: ./out/main/index.js` and no `lib` directory at all (issue #112), while the third-party electron-vite shell (dataelement/dsh-desktop, issue #62) shares the same shape. The `@deepseek-ai/dsh` dependency is what separates them: the official bundle carries it, the third-party shell does not.',
53
+ },
54
+ ],
47
55
  unsupportedMainEntries: {
48
- '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',
56
+ 'out/main/index.js': 'an electron-vite DSH Desktop without the @deepseek-ai/dsh dependency — the third-party shell from issue #62, which shares the package name but not the DeepSeek Harness Desktop bundle the bridge patches',
49
57
  },
50
58
  layouts: [
51
59
  { name: 'macos-bundle', marker: 'Contents/Info.plist', resources: 'Contents/Resources', executable: 'Contents/MacOS/DeepSeek Harness', cliLauncher: 'runtime/cli/bin/dsh' },
@@ -84,14 +92,24 @@ export function readIdentityRule() {
84
92
  || layouts[layouts.length - 1]?.marker !== undefined) {
85
93
  return { error: 'desktop-identity.json: layouts must be a non-empty array whose last entry has no marker' };
86
94
  }
95
+ const candidates = raw.mainEntryCandidates;
96
+ if (candidates !== undefined && (!Array.isArray(candidates) || candidates.some(c => c === null || typeof c !== 'object'
97
+ || !field(c.entry) || (c.requiresDependency !== undefined && !field(c.requiresDependency))))) {
98
+ return { error: 'desktop-identity.json: mainEntryCandidates must list entries with an optional requiresDependency' };
99
+ }
87
100
  const unsupported = raw.unsupportedMainEntries;
88
101
  if (unsupported !== undefined && (unsupported === null || typeof unsupported !== 'object' || Array.isArray(unsupported)
89
102
  || Object.entries(unsupported).some(([entry, reason]) => entry === '' || !field(reason)))) {
90
103
  return { error: 'desktop-identity.json: unsupportedMainEntries must map entry paths to reasons' };
91
104
  }
105
+ // The candidates are part of the rule; dropping them here is what made a valid candidate entry
106
+ // indistinguishable from an unsupported one.
107
+ const base = candidates === undefined
108
+ ? { packageNames: names, mainEntry: main }
109
+ : { packageNames: names, mainEntry: main, mainEntryCandidates: candidates };
92
110
  return unsupported === undefined
93
- ? { packageNames: names, mainEntry: main, layouts }
94
- : { packageNames: names, mainEntry: main, unsupportedMainEntries: unsupported, layouts };
111
+ ? { ...base, layouts }
112
+ : { ...base, unsupportedMainEntries: unsupported, layouts };
95
113
  }
96
114
  catch (error) {
97
115
  if (error instanceof Error && 'code' in error && error.code === 'ENOENT') {
@@ -242,7 +260,6 @@ export function readDesktopIdentity(installRoot) {
242
260
  }
243
261
  const layout = archivePresent ? 'packed' : 'unpacked';
244
262
  let manifestText;
245
- let mainPresent;
246
263
  let hasEntry;
247
264
  if (archivePresent) {
248
265
  const parsed = readAsarHeader(archive);
@@ -258,7 +275,6 @@ export function readDesktopIdentity(installRoot) {
258
275
  return { ok: false, reason: `${archive}: package.json is listed but its bytes cannot be read` };
259
276
  }
260
277
  hasEntry = entry => entryAt(parsed.header.files, entry) !== undefined;
261
- mainPresent = hasEntry(rule.mainEntry);
262
278
  }
263
279
  else {
264
280
  const manifestPath = join(appDir, 'package.json');
@@ -273,7 +289,6 @@ export function readDesktopIdentity(installRoot) {
273
289
  return { ok: false, reason: `${manifestPath} is missing; a directory without a package manifest is not a DSH Desktop install` };
274
290
  }
275
291
  hasEntry = entry => existsSync(join(appDir, ...entry.split('/')));
276
- mainPresent = hasEntry(rule.mainEntry);
277
292
  }
278
293
  let manifest;
279
294
  try {
@@ -290,19 +305,43 @@ export function readDesktopIdentity(installRoot) {
290
305
  + `${rule.packageNames.join(' / ')} — refusing to touch a different application`,
291
306
  };
292
307
  }
293
- // The main entry is the file the installer patches and the shell runs; if it is not there, this
294
- // is not an install this plugin can reason about even though the manifest looks right.
308
+ // The main entry is the file the installer patches and the shell runs. The default name comes
309
+ // first; the candidates cover layouts that later official builds adopted (0.14.0 ships
310
+ // "out/main/index.js" and no "lib" at all), and each candidate is gated on a dependency that the
311
+ // official bundle carries and the look-alike third-party shell does not.
312
+ let mainEntry = rule.mainEntry;
313
+ let mainPresent = hasEntry(mainEntry);
314
+ if (!mainPresent) {
315
+ const dependencies = manifest.dependencies;
316
+ for (const candidate of rule.mainEntryCandidates ?? []) {
317
+ if (!hasEntry(candidate.entry))
318
+ continue;
319
+ if (candidate.requiresDependency !== undefined && dependencies?.[candidate.requiresDependency] === undefined)
320
+ continue;
321
+ mainEntry = candidate.entry;
322
+ mainPresent = true;
323
+ break;
324
+ }
325
+ }
295
326
  if (!mainPresent) {
296
327
  const foreign = Object.entries(rule.unsupportedMainEntries ?? {}).find(([entry]) => hasEntry(entry));
297
328
  if (foreign !== undefined) {
298
329
  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` };
299
330
  }
331
+ // A candidate entry is present but its gate was not satisfied: the package name was borrowed by a
332
+ // look-alike shell. Naming that is more useful than reporting the missing default entry.
333
+ const lookAlike = (rule.mainEntryCandidates ?? []).find(candidate => hasEntry(candidate.entry));
334
+ if (lookAlike !== undefined) {
335
+ const gate = lookAlike.requiresDependency === undefined ? 'its identity gate' : `${lookAlike.requiresDependency}`;
336
+ return { ok: false, shell: 'third-party-shell', ...versionOf(manifest), reason: `${lookAlike.entry} instead of ${rule.mainEntry}, but ${gate} is absent, so this is not the DSH Desktop bundle (issue #62); use DSH Web or DeepSeek Harness Desktop` };
337
+ }
300
338
  return { ok: false, shell: 'official-unsupported', ...versionOf(manifest), reason: `${rule.mainEntry} is not present under ${archivePresent ? archive : appDir}` };
301
339
  }
302
340
  return {
303
341
  ok: true,
304
342
  root: installRoot,
305
343
  layout,
344
+ mainEntry,
306
345
  packageName: name,
307
346
  ...typeof manifest.version === 'string' ? { version: manifest.version } : {},
308
347
  };
package/lib/client.js CHANGED
@@ -32665,7 +32665,8 @@ function loadSettingsPanel(require$1) {
32665
32665
  disabled: controlsBusy,
32666
32666
  onClick: extensionAction
32667
32667
  }, t("extension.button"));
32668
- const canManageBridge = isDesktop && runtime.shell?.patchable !== false && runtime.bridge.present === true && runtime.bridge.state !== "absent";
32668
+ const canManageBridge = isDesktop && runtime.shell?.patchable !== false && runtime.bridge.present === true && runtime.bridge.state !== "absent" && runtime.bridge.state !== "unsupported-layout";
32669
+ runtime.bridge.state;
32669
32670
  const extensionUnsupported = runtime.bridge.code === "DESKTOP_MAIN_EXTENSION_UNSUPPORTED";
32670
32671
  const bridgeButtonBusy = bridgeBusy !== null || bridgeActive;
32671
32672
  const bridgeButtonStyle = controlsBusy || preparing ? {
@@ -53,6 +53,11 @@ export function launcherSource(nodePath, hostScript, configPath) {
53
53
  var info=new ProcessStartInfo(${literal(nodePath)});
54
54
  info.Arguments=QuoteArg(${literal(hostScript)})+" --config "+QuoteArg(${literal(configPath)})+" "+QuoteArg(args[0]);
55
55
  info.UseShellExecute=false; info.CreateNoWindow=true;
56
+ // nodePath is process.execPath, which is electron.exe inside DSH Desktop. Without this an
57
+ // Electron binary starts as a GUI app: every Native Messaging connect spawned a window and
58
+ // stole focus from whatever the user was doing (issue #129). A real node.exe ignores the
59
+ // variable, so setting it unconditionally is safe for both.
60
+ info.EnvironmentVariables["ELECTRON_RUN_AS_NODE"]="1";
56
61
  info.RedirectStandardInput=true; info.RedirectStandardOutput=true; info.RedirectStandardError=true;
57
62
  using(var process=Process.Start(info)) {
58
63
  Task.Run(()=>{try{Relay(Console.OpenStandardInput(),process.StandardInput.BaseStream);}catch{}finally{try{process.StandardInput.Close();}catch{}}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-builtin-browser",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "Sidebar browser for DeepSeek Harness with navigation, structured references and dsh_browser_* tools. Browser tools require a controllable host-provided sidebar. External Chrome or Edge requires explicit opt-in; no standalone Electron fallback.",
5
5
  "keywords": [
6
6
  "browser",
@@ -16,6 +16,24 @@
16
16
  "type": "git",
17
17
  "url": "https://github.com/wqty123/dsh-browser.git"
18
18
  },
19
+ "files": [
20
+ "lib",
21
+ "src",
22
+ "scripts",
23
+ "tools/accept-desktop.mjs",
24
+ "desktop-bridge",
25
+ "dsh-host-patch",
26
+ "!dsh-host-patch/sources",
27
+ "browser-extension",
28
+ "native-host",
29
+ "cordis.patch.yml",
30
+ "CHANGELOG.md",
31
+ "README.md",
32
+ "docs",
33
+ "skills",
34
+ "assets",
35
+ "!src/**/__tests__"
36
+ ],
19
37
  "type": "module",
20
38
  "packageManager": "pnpm@11.7.0",
21
39
  "exports": {
@@ -70,4 +88,4 @@
70
88
  ]
71
89
  }
72
90
  }
73
- }
91
+ }