dsh-builtin-browser 1.0.0 → 1.0.3

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 (364) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +1 -1
  3. package/assets/browser-panel-locales.mjs +37 -5
  4. package/assets/browser-policy.d.mts +29 -0
  5. package/assets/browser-policy.mjs +40 -0
  6. package/desktop-bridge/desktop-discovery.d.mts +1 -1
  7. package/desktop-bridge/desktop-discovery.mjs +59 -9
  8. package/desktop-bridge/desktop-identity.json +12 -0
  9. package/desktop-bridge/install.mjs +14 -7
  10. package/desktop-bridge/plugin-browser-bridge.js +19 -7
  11. package/docs/acceptance-2026-11-27.md +67 -0
  12. package/docs/architecture.md +1 -1
  13. package/docs/development.md +33 -4
  14. package/docs/dsh-0.2.3-host-patch-task.md +34 -0
  15. package/docs/hardcoding-audit.md +28 -8
  16. package/docs/known-issues.md +26 -0
  17. package/docs/limitations.md +6 -2
  18. package/docs/pr64-maintenance.md +1 -1
  19. package/docs/tool-reference.md +1 -1
  20. package/docs/user-guide.md +1 -1
  21. package/docs/v1.1.0-bu-data-batching-task.md +66 -0
  22. package/docs/v1.1.0-compat-hardcoding-task.md +85 -0
  23. package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
  24. package/dsh-builtin-browser-1.0.3.tgz +0 -0
  25. package/dsh-host-patch/README.md +4 -0
  26. package/dsh-host-patch/apply.mjs +61 -13
  27. package/dsh-host-patch/rc3-revision9.json.gz +0 -0
  28. package/dsh-host-patch/rc5-revision9.json.gz +0 -0
  29. package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  30. package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  31. package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  32. package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  33. package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  34. package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  35. package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  36. package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  37. package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  38. package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  39. package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  40. package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  41. package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  42. package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  43. package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  44. package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  45. package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  46. package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  47. package/dsh-host-patch/sources/manifest.json +218 -0
  48. package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  49. package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  50. package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  51. package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  52. package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  53. package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  54. package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  55. package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  56. package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  57. package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  58. package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  59. package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  60. package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  61. package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  62. package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  63. package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  64. package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  65. package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  66. package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  67. package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  68. package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  69. package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  70. package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  71. package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  72. package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  73. package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  74. package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  75. package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  76. package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  77. package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  78. package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  79. package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  80. package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  81. package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  82. package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  83. package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  84. package/dsh-host-patch/sources/series.json +260 -0
  85. package/dsh-host-patch/tauri/desktop-main.cjs +62 -0
  86. package/dsh-host-patch/tauri/sidebar-session.cjs +104 -0
  87. package/dsh-host-patch/tauri-revision1.json +39 -0
  88. package/dsh-host-patch/tauri.json +43 -0
  89. package/dsh-host-patch/v023-alpha2.json +153 -0
  90. package/lib/browser/anti-bot.js +215 -0
  91. package/lib/browser/deep-dom.js +39 -0
  92. package/lib/browser/runtime.js +15 -0
  93. package/lib/browser/takeover-target.js +13 -6
  94. package/lib/browser/types.js +30 -1
  95. package/lib/browser-electron/authenticated-route.js +16 -2
  96. package/lib/browser-electron/automatic-maintenance.js +16 -10
  97. package/lib/browser-electron/bridge-connection.js +3 -8
  98. package/lib/browser-electron/bridge-install.js +2 -1
  99. package/lib/browser-electron/bridge-status.js +55 -26
  100. package/lib/browser-electron/desktop-bridge-host.js +7 -6
  101. package/lib/browser-electron/desktop-identity.js +28 -5
  102. package/lib/browser-electron/desktop-shell.js +64 -0
  103. package/lib/browser-electron/electron-provision.js +105 -18
  104. package/lib/browser-electron/entry.js +129 -46
  105. package/lib/browser-electron/extension-browser.js +4 -4
  106. package/lib/browser-electron/foreground-watch.js +134 -0
  107. package/lib/browser-electron/guest-cookie-jar.js +13 -13
  108. package/lib/browser-electron/guest-route.js +181 -32
  109. package/lib/browser-electron/guest-runtime.js +61 -10
  110. package/lib/browser-electron/guest-storage.js +2 -2
  111. package/lib/browser-electron/history-store.js +1 -5
  112. package/lib/browser-electron/host-main.js +8 -4
  113. package/lib/browser-electron/host-patch-maintenance.js +14 -8
  114. package/lib/browser-electron/maintenance-route.js +2 -1
  115. package/lib/browser-electron/missing-system-browser.js +5 -9
  116. package/lib/browser-electron/preferred-browser.js +7 -3
  117. package/lib/browser-electron/preview-route.js +9 -13
  118. package/lib/browser-electron/process-ownership.js +1 -1
  119. package/lib/browser-electron/profile-command.js +2 -1
  120. package/lib/browser-electron/profile-extension.js +5 -0
  121. package/lib/browser-electron/profile-lease.js +152 -47
  122. package/lib/browser-electron/provider-core.js +527 -0
  123. package/lib/browser-electron/provider-interaction.js +963 -0
  124. package/lib/browser-electron/provider-media.js +518 -0
  125. package/lib/browser-electron/provider-navigation.js +301 -0
  126. package/lib/browser-electron/provider-observation.js +623 -0
  127. package/lib/browser-electron/provider-tabs.js +372 -0
  128. package/lib/browser-electron/provider.js +150 -3301
  129. package/lib/browser-electron/reference-route.js +9 -18
  130. package/lib/browser-electron/remote-host.js +79 -34
  131. package/lib/browser-electron/runtime-status.js +56 -6
  132. package/lib/browser-electron/settings-store.js +3 -6
  133. package/lib/browser-electron/sidebar-only-host.js +1 -1
  134. package/lib/browser-electron/system-browser.js +539 -172
  135. package/lib/browser-electron/tauri-host.js +208 -0
  136. package/lib/browser-electron/virtual-cursor.js +23 -13
  137. package/lib/browser-reference/service.js +22 -4
  138. package/lib/browser-reference/web-sources.js +1 -1
  139. package/lib/client.js +43409 -0
  140. package/lib/compat/host-features.js +75 -0
  141. package/lib/reference-source.js +1 -1
  142. package/lib/reference-text.js +23 -1
  143. package/lib/takeover-protocol.js +1 -1
  144. package/lib/tool-browser/block-recovery.js +69 -0
  145. package/lib/tool-browser/code-tool.js +170 -19
  146. package/lib/tool-browser/code-worker.js +115 -20
  147. package/lib/tool-browser/errors.js +34 -0
  148. package/lib/tool-browser/index.js +66 -3593
  149. package/lib/tool-browser/page-probe.js +227 -28
  150. package/lib/tool-browser/panel-page.js +2 -1
  151. package/lib/tool-browser/probe-client.js +157 -0
  152. package/lib/tool-browser/screenshot-annotations.js +108 -0
  153. package/lib/tool-browser/state.js +337 -0
  154. package/lib/tool-browser/takeover.js +1 -1
  155. package/lib/tool-browser/tools-debug.js +862 -0
  156. package/lib/tool-browser/tools-interaction.js +993 -0
  157. package/lib/tool-browser/tools-navigation.js +807 -0
  158. package/lib/tool-browser/tools-observation.js +461 -0
  159. package/lib/tool-browser/tools-reference.js +293 -0
  160. package/lib/web-guest.js +1 -0
  161. package/package.json +16 -54
  162. package/README.en.md +0 -89
  163. package/browser-extension/constants.mjs +0 -20
  164. package/browser-extension/controller.mjs +0 -293
  165. package/browser-extension/locales.mjs +0 -15
  166. package/browser-extension/manifest.json +0 -12
  167. package/browser-extension/options.html +0 -14
  168. package/browser-extension/options.mjs +0 -9
  169. package/browser-extension/permission-guard.mjs +0 -13
  170. package/browser-extension/worker.mjs +0 -74
  171. package/dist/client.cjs +0 -43167
  172. package/lib/browser-electron/package-removal.js +0 -5
  173. package/lib/browser-reference/submission-receipts.js +0 -139
  174. package/scripts/build.mjs +0 -66
  175. package/scripts/bundle-host.mjs +0 -28
  176. package/scripts/fix-exports.mjs +0 -50
  177. package/scripts/install-electron.mjs +0 -51
  178. package/scripts/verify-exports.mjs +0 -47
  179. package/scripts/verify-preview-sdk.mjs +0 -93
  180. package/skills/dsh-builtin-browser/SKILL.md +0 -73
  181. package/skills/dsh-builtin-browser/references/batch.md +0 -53
  182. package/skills/dsh-builtin-browser/references/deliver.md +0 -31
  183. package/skills/dsh-builtin-browser/references/locate.md +0 -11
  184. package/skills/dsh-builtin-browser/references/recover.md +0 -11
  185. package/skills/dsh-builtin-browser/references/verify.md +0 -13
  186. package/skills/dsh-debug-host/SKILL.md +0 -56
  187. package/skills/dsh-debug-self/SKILL.md +0 -50
  188. package/src/bridge-compatibility.ts +0 -39
  189. package/src/browser/handles.ts +0 -89
  190. package/src/browser/runtime.ts +0 -560
  191. package/src/browser/takeover-target.ts +0 -36
  192. package/src/browser/types.ts +0 -817
  193. package/src/browser-electron/authenticated-route.ts +0 -84
  194. package/src/browser-electron/automatic-maintenance.ts +0 -726
  195. package/src/browser-electron/bridge-auto.ts +0 -159
  196. package/src/browser-electron/bridge-connection.ts +0 -385
  197. package/src/browser-electron/bridge-endpoint.ts +0 -129
  198. package/src/browser-electron/bridge-install.ts +0 -289
  199. package/src/browser-electron/bridge-maintenance.ts +0 -189
  200. package/src/browser-electron/bridge-status.ts +0 -347
  201. package/src/browser-electron/desktop-bridge-host.ts +0 -251
  202. package/src/browser-electron/desktop-identity.ts +0 -320
  203. package/src/browser-electron/document-readiness.ts +0 -45
  204. package/src/browser-electron/electron-provision.ts +0 -261
  205. package/src/browser-electron/entry.ts +0 -1301
  206. package/src/browser-electron/ephemeral-profile.ts +0 -189
  207. package/src/browser-electron/extension-browser.ts +0 -223
  208. package/src/browser-electron/extension-setup.ts +0 -67
  209. package/src/browser-electron/file-write.ts +0 -31
  210. package/src/browser-electron/guest-cookie-jar.ts +0 -176
  211. package/src/browser-electron/guest-cookie-store.ts +0 -59
  212. package/src/browser-electron/guest-css-runtime.ts +0 -76
  213. package/src/browser-electron/guest-css.ts +0 -68
  214. package/src/browser-electron/guest-route.ts +0 -568
  215. package/src/browser-electron/guest-runtime.ts +0 -357
  216. package/src/browser-electron/guest-storage-runtime.ts +0 -54
  217. package/src/browser-electron/guest-storage.ts +0 -117
  218. package/src/browser-electron/history-store.ts +0 -227
  219. package/src/browser-electron/host-main.ts +0 -1381
  220. package/src/browser-electron/host-patch-maintenance.ts +0 -112
  221. package/src/browser-electron/http-body.ts +0 -65
  222. package/src/browser-electron/json-reply.ts +0 -47
  223. package/src/browser-electron/maintenance-broker.ts +0 -166
  224. package/src/browser-electron/maintenance-lifecycle.ts +0 -91
  225. package/src/browser-electron/maintenance-route.ts +0 -67
  226. package/src/browser-electron/missing-system-browser.ts +0 -113
  227. package/src/browser-electron/open-slot.ts +0 -49
  228. package/src/browser-electron/package-removal.ts +0 -4
  229. package/src/browser-electron/paths.ts +0 -25
  230. package/src/browser-electron/preferred-browser.ts +0 -120
  231. package/src/browser-electron/preview-route.ts +0 -218
  232. package/src/browser-electron/process-ownership.ts +0 -168
  233. package/src/browser-electron/process.ts +0 -23
  234. package/src/browser-electron/profile-checkpoint.ts +0 -187
  235. package/src/browser-electron/profile-command.ts +0 -46
  236. package/src/browser-electron/profile-extension.ts +0 -124
  237. package/src/browser-electron/profile-lease.ts +0 -115
  238. package/src/browser-electron/profile-residue.ts +0 -49
  239. package/src/browser-electron/provider.ts +0 -4571
  240. package/src/browser-electron/reference-route.ts +0 -608
  241. package/src/browser-electron/remote-host.ts +0 -1462
  242. package/src/browser-electron/rpc-input.ts +0 -13
  243. package/src/browser-electron/rpc-ops.ts +0 -41
  244. package/src/browser-electron/runtime-diagnostics.ts +0 -38
  245. package/src/browser-electron/runtime-route.ts +0 -105
  246. package/src/browser-electron/runtime-status.ts +0 -242
  247. package/src/browser-electron/settings-route.ts +0 -64
  248. package/src/browser-electron/settings-store.ts +0 -589
  249. package/src/browser-electron/shortcuts-route.ts +0 -112
  250. package/src/browser-electron/sidebar-only-host.ts +0 -298
  251. package/src/browser-electron/startpage-shortcuts.ts +0 -213
  252. package/src/browser-electron/system-browser.ts +0 -1497
  253. package/src/browser-electron/timing.ts +0 -16
  254. package/src/browser-electron/virtual-cursor.ts +0 -152
  255. package/src/browser-electron/windows-system.ts +0 -24
  256. package/src/browser-reference/delivery.ts +0 -384
  257. package/src/browser-reference/entry.ts +0 -631
  258. package/src/browser-reference/export.ts +0 -339
  259. package/src/browser-reference/import.ts +0 -303
  260. package/src/browser-reference/page-script.ts +0 -1537
  261. package/src/browser-reference/service.ts +0 -1315
  262. package/src/browser-reference/store.ts +0 -172
  263. package/src/browser-reference/submission-receipts.ts +0 -122
  264. package/src/browser-reference/text-quote.ts +0 -219
  265. package/src/browser-reference/types.ts +0 -195
  266. package/src/browser-reference/visible.ts +0 -367
  267. package/src/browser-reference/web-sources.ts +0 -103
  268. package/src/client/browser/BrowserController.ts +0 -693
  269. package/src/client/browser/BrowserFrame.ts +0 -78
  270. package/src/client/browser/BrowserNavigation.ts +0 -169
  271. package/src/client/browser/BrowserPage.ts +0 -23
  272. package/src/client/browser/BrowserPersistence.ts +0 -44
  273. package/src/client/browser/IframeImpl.ts +0 -176
  274. package/src/client/browser/child-tabs.ts +0 -14
  275. package/src/client/browser/iframe-reference.ts +0 -67
  276. package/src/client/browser/initialization.ts +0 -262
  277. package/src/client/browser/omnibox.ts +0 -243
  278. package/src/client/browser/store.ts +0 -38
  279. package/src/client/browser/takeover-channel.ts +0 -72
  280. package/src/client/browser/url.ts +0 -46
  281. package/src/client/browser/web-reference-source.ts +0 -52
  282. package/src/client/css-modules.d.ts +0 -4
  283. package/src/client/definition.tsx +0 -30
  284. package/src/client/electron/ElectronWebViewImpl.ts +0 -364
  285. package/src/client/electron/ElectronWebviewPresentation.ts +0 -138
  286. package/src/client/electron/NativeChildPresentation.ts +0 -45
  287. package/src/client/electron/NativeViewPage.ts +0 -251
  288. package/src/client/electron/pages.ts +0 -23
  289. package/src/client/electron/reference-overlay.ts +0 -53
  290. package/src/client/electron/workspace.ts +0 -33
  291. package/src/client/index.ts +0 -293
  292. package/src/client/locales.ts +0 -857
  293. package/src/client/pages.ts +0 -28
  294. package/src/client/reference/client/BrowserRefLink.tsx +0 -142
  295. package/src/client/reference/client/draft-reference.ts +0 -167
  296. package/src/client/reference/client/index.ts +0 -7
  297. package/src/client/reference/client/ordered-submission.ts +0 -108
  298. package/src/client/reference/client/pending-delivery.ts +0 -216
  299. package/src/client/reference/client/plugin.ts +0 -189
  300. package/src/client/reference/client/production/ReferenceCapsules.tsx +0 -345
  301. package/src/client/reference/client/production/ReferenceDock.module.css +0 -193
  302. package/src/client/reference/client/production/ReferenceDock.tsx +0 -6
  303. package/src/client/reference/client/production/ReferenceFeedback.tsx +0 -15
  304. package/src/client/reference/client/production/ReferenceMath.tsx +0 -44
  305. package/src/client/reference/client/production/ReferenceText.tsx +0 -36
  306. package/src/client/reference/client/production/assembly.ts +0 -471
  307. package/src/client/reference/client/production/asset-store.ts +0 -144
  308. package/src/client/reference/client/production/availability.ts +0 -74
  309. package/src/client/reference/client/production/bytes.ts +0 -36
  310. package/src/client/reference/client/production/delivery-client.ts +0 -211
  311. package/src/client/reference/client/production/draft-adapter.ts +0 -508
  312. package/src/client/reference/client/production/http-transport.ts +0 -217
  313. package/src/client/reference/client/production/production-submission.ts +0 -310
  314. package/src/client/reference/client/production/protocol.ts +0 -231
  315. package/src/client/reference/client/production/reference-card.ts +0 -240
  316. package/src/client/reference/client/production/reference-labels.ts +0 -29
  317. package/src/client/reference/client/production/reply-link-bridge.ts +0 -222
  318. package/src/client/reference/client/production/reveal.ts +0 -215
  319. package/src/client/reference/client/production/runtime.ts +0 -1101
  320. package/src/client/reference/client/production/snapshot-adapter.ts +0 -154
  321. package/src/client/reference/client/production/source-marker.ts +0 -63
  322. package/src/client/reference/client/production/source-opener.ts +0 -55
  323. package/src/client/reference/client/production/styles.ts +0 -104
  324. package/src/client/reference/client/production/user-text-rule.ts +0 -58
  325. package/src/client/reference/client/reveal.ts +0 -107
  326. package/src/client/reference/client/scheme.ts +0 -114
  327. package/src/client/reference/client/types.ts +0 -168
  328. package/src/client/reference/css-modules.d.ts +0 -4
  329. package/src/client/reference/index.ts +0 -11
  330. package/src/client/reference-capture-owner.ts +0 -162
  331. package/src/client/reference-intents.ts +0 -36
  332. package/src/client/settings/index.ts +0 -34
  333. package/src/client/settings/panel.ts +0 -2657
  334. package/src/client/shortcut-open.ts +0 -30
  335. package/src/client/startpage/binding.ts +0 -99
  336. package/src/client/startpage/controller.ts +0 -303
  337. package/src/client/startpage/model.ts +0 -279
  338. package/src/client/view/Browser.module.css +0 -751
  339. package/src/client/view/BrowserBody.tsx +0 -314
  340. package/src/client/view/BrowserPresentation.ts +0 -9
  341. package/src/client/view/BrowserTitle.tsx +0 -17
  342. package/src/client/view/IframePresentation.ts +0 -344
  343. package/src/client/view/StartPage.tsx +0 -597
  344. package/src/client/view/TakeoverBanner.tsx +0 -21
  345. package/src/index.ts +0 -110
  346. package/src/reference-owner.ts +0 -5
  347. package/src/reference-page.ts +0 -9
  348. package/src/reference-source.ts +0 -3
  349. package/src/reference-text.ts +0 -197
  350. package/src/startpage-settings.ts +0 -103
  351. package/src/startpage.ts +0 -71
  352. package/src/takeover-protocol.ts +0 -19
  353. package/src/tool-browser/code-tool.ts +0 -401
  354. package/src/tool-browser/code-worker.ts +0 -639
  355. package/src/tool-browser/element-fields.ts +0 -167
  356. package/src/tool-browser/index.ts +0 -3733
  357. package/src/tool-browser/page-probe.ts +0 -474
  358. package/src/tool-browser/panel-page.ts +0 -124
  359. package/src/tool-browser/screenshot-image.ts +0 -49
  360. package/src/tool-browser/takeover.ts +0 -198
  361. package/src/types/electron-shim.d.ts +0 -144
  362. package/src/types.ts +0 -85
  363. package/src/web-guest.ts +0 -34
  364. package/tools/accept-desktop.mjs +0 -148
@@ -1,10 +1,13 @@
1
- /** Prepare an explicitly supplied external Electron runtime, never the plugin generation. */
1
+ /** Prepare an Electron runtime in the plugin-owned runtime directory (or an explicit external package), never the plugin dependency closure. */
2
2
  import { spawn } from 'node:child_process';
3
- import { existsSync, readFileSync } from 'node:fs';
3
+ import { randomUUID } from 'node:crypto';
4
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync } from 'node:fs';
4
5
  import { isAbsolute, join } from 'node:path';
5
- import { internals } from './remote-host.js';
6
+ import { internals, managedElectronDir } from './remote-host.js';
6
7
  /** How long a background provision may run before it is abandoned. */
7
8
  export const PROVISION_TIMEOUT_MS = 180_000;
9
+ /** Default Electron package version fetched into the managed runtime directory when none is already installed. */
10
+ export const MANAGED_ELECTRON_VERSION = '44.10.0';
8
11
  const IDLE = {
9
12
  state: 'idle',
10
13
  detail: 'the runtime has not been asked for yet',
@@ -43,13 +46,23 @@ export function hasElectronRuntime() {
43
46
  return false;
44
47
  }
45
48
  }
49
+ /** Resolve the target `electron` package directory: explicit external override, else plugin-managed runtime dir. */
50
+ function targetPackageDir() {
51
+ const override = process.env.DSH_BROWSER_ELECTRON_PACKAGE;
52
+ if (override !== undefined) {
53
+ if (!override || !isAbsolute(override))
54
+ return undefined;
55
+ return override;
56
+ }
57
+ return join(managedElectronDir(), 'node_modules', 'electron');
58
+ }
46
59
  /**
47
- * @returns the explicitly selected external package installer, or undefined.
60
+ * @returns the electron package's `install.js` path when present and valid, or undefined.
48
61
  */
49
62
  function electronInstallerScript() {
50
63
  try {
51
- const directory = process.env.DSH_BROWSER_ELECTRON_PACKAGE;
52
- if (!directory || !isAbsolute(directory))
64
+ const directory = targetPackageDir();
65
+ if (!directory)
53
66
  return undefined;
54
67
  const metadata = JSON.parse(readFileSync(join(directory, 'package.json'), 'utf8'));
55
68
  if (metadata.name !== 'electron')
@@ -64,14 +77,74 @@ function electronInstallerScript() {
64
77
  /** The Electron version the installed package asks for, for a log line that names the download. */
65
78
  function electronVersion() {
66
79
  try {
67
- const directory = process.env.DSH_BROWSER_ELECTRON_PACKAGE;
68
- if (!directory || !isAbsolute(directory))
69
- return 'unknown';
80
+ const directory = targetPackageDir();
81
+ if (!directory)
82
+ return MANAGED_ELECTRON_VERSION;
70
83
  const manifest = JSON.parse(readFileSync(join(directory, 'package.json'), 'utf8'));
71
- return typeof manifest.version === 'string' ? manifest.version : 'unknown';
84
+ return typeof manifest.version === 'string' ? manifest.version : MANAGED_ELECTRON_VERSION;
72
85
  }
73
86
  catch {
74
- return 'unknown';
87
+ return MANAGED_ELECTRON_VERSION;
88
+ }
89
+ }
90
+ /**
91
+ * Fetch the lightweight `electron` npm wrapper (`--ignore-scripts`, ~100 KB) into the managed runtime
92
+ * directory so its `install.js` can subsequently download the platform binary with full mirror/proxy support.
93
+ */
94
+ async function bootstrapManagedPackage(signal) {
95
+ if (process.env.DSH_BROWSER_ELECTRON_PACKAGE !== undefined) {
96
+ return { ok: false, detail: 'DSH_BROWSER_ELECTRON_PACKAGE is set; provide an existing absolute electron package directory' };
97
+ }
98
+ const runtimeDir = managedElectronDir();
99
+ const targetPkg = join(runtimeDir, 'node_modules', 'electron');
100
+ if (existsSync(join(targetPkg, 'install.js')))
101
+ return { ok: true };
102
+ mkdirSync(runtimeDir, { recursive: true });
103
+ const stagingDir = join(runtimeDir, `.staging-${process.pid}-${randomUUID()}`);
104
+ mkdirSync(stagingDir, { recursive: true });
105
+ const npm = process.platform === 'win32' ? 'npm.cmd' : 'npm';
106
+ const spec = `electron@${process.env.DSH_BROWSER_ELECTRON_VERSION || MANAGED_ELECTRON_VERSION}`;
107
+ try {
108
+ const outcome = await new Promise(resolve => {
109
+ const child = spawn(npm, ['install', '--no-save', '--no-package-lock', '--ignore-scripts', '--prefix', stagingDir, spec], {
110
+ env: { ...process.env, ELECTRON_SKIP_BINARY_DOWNLOAD: '1' },
111
+ stdio: ['ignore', 'ignore', 'pipe'],
112
+ shell: process.platform === 'win32',
113
+ windowsHide: true,
114
+ });
115
+ let stderr = '';
116
+ child.stderr?.on('data', chunk => { stderr = (stderr + String(chunk)).slice(-2048); });
117
+ let failure;
118
+ const abort = () => { try {
119
+ child.kill('SIGKILL');
120
+ }
121
+ catch { } };
122
+ signal?.addEventListener('abort', abort, { once: true });
123
+ if (signal?.aborted)
124
+ abort();
125
+ child.once('error', error => { failure = String(error); });
126
+ child.once('close', code => {
127
+ signal?.removeEventListener('abort', abort);
128
+ resolve({ code, detail: failure ?? (stderr.trim() || undefined) });
129
+ });
130
+ });
131
+ if (outcome.code !== 0) {
132
+ return { ok: false, detail: outcome.detail ?? `npm install ${spec} exited ${String(outcome.code)}` };
133
+ }
134
+ const stagedPkg = join(stagingDir, 'node_modules', 'electron');
135
+ if (!existsSync(join(stagedPkg, 'install.js'))) {
136
+ return { ok: false, detail: `downloaded ${spec} package is missing install.js` };
137
+ }
138
+ mkdirSync(join(runtimeDir, 'node_modules'), { recursive: true });
139
+ rmSync(targetPkg, { recursive: true, force: true });
140
+ renameSync(stagedPkg, targetPkg);
141
+ return { ok: true };
142
+ }
143
+ catch (error) {
144
+ return { ok: false, detail: String(error) };
145
+ }
146
+ finally {
147
+ rmSync(stagingDir, { recursive: true, force: true });
75
148
  }
76
149
  }
77
150
  let runningInstaller;
@@ -80,15 +153,18 @@ export function defaultDeps(log = () => { }) {
80
153
  return {
81
154
  hasBinary: hasElectronRuntime,
82
155
  installerScript: electronInstallerScript,
156
+ bootstrapPackage: bootstrapManagedPackage,
83
157
  run: (script, signal) => {
84
158
  if (runningInstaller !== undefined)
85
159
  return runningInstaller;
86
160
  const run = new Promise(resolve => {
87
161
  const child = spawn(process.execPath, [script], {
88
162
  env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' },
89
- stdio: ['ignore', 'ignore', 'ignore'],
163
+ stdio: ['ignore', 'ignore', 'pipe'],
90
164
  windowsHide: true,
91
165
  });
166
+ let stderr = '';
167
+ child.stderr?.on('data', chunk => { stderr = (stderr + String(chunk)).slice(-2048); });
92
168
  let failure;
93
169
  const abort = () => { child.kill('SIGKILL'); };
94
170
  signal?.addEventListener('abort', abort, { once: true });
@@ -97,7 +173,7 @@ export function defaultDeps(log = () => { }) {
97
173
  child.once('error', error => { failure = String(error); });
98
174
  child.once('close', code => {
99
175
  signal?.removeEventListener('abort', abort);
100
- resolve({ code, detail: failure });
176
+ resolve({ code, detail: failure ?? (stderr.trim() || undefined) });
101
177
  });
102
178
  });
103
179
  runningInstaller = run;
@@ -125,10 +201,6 @@ export async function ensureElectronRuntime(deps = defaultDeps()) {
125
201
  return record({ status: 'present', detail: 'an Electron runtime is already available' });
126
202
  if (deps.skip())
127
203
  return record({ status: 'skipped', detail: 'ELECTRON_SKIP_BINARY_DOWNLOAD is set' });
128
- const script = deps.installerScript();
129
- if (script === undefined) {
130
- return record({ status: 'failed', detail: 'the installed electron package has no install.js; reinstall the plugin in this profile' });
131
- }
132
204
  const version = electronVersion();
133
205
  latest = {
134
206
  state: 'preparing',
@@ -153,7 +225,22 @@ export async function ensureElectronRuntime(deps = defaultDeps()) {
153
225
  });
154
226
  let outcome;
155
227
  try {
156
- outcome = await Promise.race([deps.run(script, controller.signal), timeout]);
228
+ outcome = await Promise.race([
229
+ (async () => {
230
+ let script = deps.installerScript();
231
+ if (script === undefined && deps.bootstrapPackage !== undefined) {
232
+ const boot = await deps.bootstrapPackage(controller.signal);
233
+ if (!boot.ok)
234
+ return { code: 1, detail: boot.detail ?? 'could not fetch electron package' };
235
+ script = deps.installerScript();
236
+ }
237
+ if (script === undefined) {
238
+ return { code: 1, detail: 'the installed electron package has no install.js; retry from Settings → Browser → Readiness or run `npx --no dsh-browser-install-electron`' };
239
+ }
240
+ return await deps.run(script, controller.signal);
241
+ })(),
242
+ timeout,
243
+ ]);
157
244
  }
158
245
  catch (error) {
159
246
  return record({ status: 'failed', detail: `the download failed: ${String(error)}` });
@@ -1,10 +1,11 @@
1
1
  import { referenceCaptureMessages, referenceCaptureErrors } from '../../assets/browser-messages.mjs';
2
- import { BROWSER_PROFILE_DIR, SETTINGS_ROUTE, EXTENSION_INSTALL_ROUTE } from '../../assets/browser-policy.mjs';
2
+ import { BROWSER_PROFILE_DIR, SETTINGS_ROUTE, EXTENSION_INSTALL_ROUTE, OPEN_REQUEST_ROUTE, SURFACE_DECL_ROUTE, BRIDGE_ACTION_ROUTE } from '../../assets/browser-policy.mjs';
3
3
  import { fileURLToPath } from 'node:url';
4
4
  import { statSync } from 'node:fs';
5
5
  import z from '@deepseek-ai/schemastery';
6
6
  import { ElectronBrowserProvider } from './provider.js';
7
7
  import { provisionElectronInBackground, provisionSnapshot, hasElectronRuntime } from './electron-provision.js';
8
+ import { RemoteElectronViewHost, defaultHostMainPath } from './remote-host.js';
8
9
  import { randomUUID } from 'node:crypto';
9
10
  import { existsSync, mkdirSync, renameSync } from 'node:fs';
10
11
  import { homedir } from 'node:os';
@@ -27,11 +28,11 @@ import { overlayScript } from '../browser-reference/entry.js';
27
28
  import { getLastOpen } from './open-slot.js';
28
29
  import { resolveSessionHandle, sessionWireId } from '../browser/handles.js';
29
30
  import { handleBridgeStatus, handlePreviewFrame, handlePreviewSessions, BRIDGE_STATUS_ROUTE, PREVIEW_ROUTE, PREVIEW_SESSIONS_ROUTE } from './preview-route.js';
30
- import { findDesktopInstall, readBridgeStatus } from './bridge-status.js';
31
+ import { detectDesktopShell, findDesktopInstall, readBridgeStatus } from './bridge-status.js';
32
+ import { publishTauriDesktopMain, runningTauriRuntime } from './tauri-host.js';
31
33
  import { readHostExtensionStatus } from './profile-extension.js';
32
34
  import { readBridgeEndpoint } from './bridge-endpoint.js';
33
35
  import { runBridgeAction } from './bridge-install.js';
34
- import { enableElectronPackageRemoval } from './package-removal.js';
35
36
  import { prepareBridgeMaintenance } from './bridge-maintenance.js';
36
37
  import { automaticMaintenanceSupported, commitAutomaticMaintenance, readAutomaticMaintenance, startAutomaticMaintenance } from './automatic-maintenance.js';
37
38
  import { AUTOMATIC_MAINTENANCE_ROUTE, createAutomaticMaintenanceHandler } from './maintenance-route.js';
@@ -40,13 +41,18 @@ import { runWithManualBridgePreference } from './bridge-auto.js';
40
41
  import { replyJson, writeJsonText } from './json-reply.js';
41
42
  import { readJsonBody, readTextBody } from './http-body.js';
42
43
  import { readRuntimeStatus } from './runtime-status.js';
44
+ /**
45
+ * The last few carrier decisions, newest last (issue #106). "Which browser did it pick, and why" is
46
+ * the one fact the panel could not show, and the reason a Web user saw the sidebar after choosing
47
+ * Chrome was indistinguishable from the setting not being written at all.
48
+ */
49
+ const carrierHistory = [];
43
50
  import { handleRuntimeProvision, handleRuntimeStatus, RUNTIME_PROVISION_ROUTE, RUNTIME_STATUS_ROUTE } from './runtime-route.js';
44
51
  import { createShortcutRouteHandlers, SHORTCUT_ADD_ROUTE, SHORTCUT_REMOVE_ROUTE, SHORTCUTS_ROUTE } from './shortcuts-route.js';
45
52
  import { createShortcutStore } from './startpage-shortcuts.js';
46
53
  import { createReferenceService, setReferenceCaptureActionHandler } from '../browser-reference/service.js';
47
54
  import { WEB_SOURCE_ROUTE } from '../reference-source.js';
48
55
  import { createDeliveryQueue, resolveReferenceOwner } from '../browser-reference/delivery.js';
49
- import { createSubmissionReceipts } from '../browser-reference/submission-receipts.js';
50
56
  import { createReferenceRouteHandlers, REFERENCE_CAPTURE_ROUTE, REFERENCE_EXPORT_ROUTE, REFERENCE_GET_ROUTE, REFERENCE_IMPORT_ROUTE, REFERENCE_INSERT_ROUTE, REFERENCE_LIST_ROUTE, REFERENCE_REVEAL_ROUTE, REFERENCE_DELIVERIES_ROUTE, REFERENCE_DELIVERY_ACK_ROUTE, REFERENCE_DELIVERY_REMOVE_ROUTE, REFERENCE_ASSET_ROUTE, CLIENT_VERSION_ROUTE, REFERENCE_STATUS_ROUTE, } from './reference-route.js';
51
57
  function isPreferredCarrier(host) {
52
58
  return host instanceof ExtensionBrowserViewHost || host instanceof PreferredBrowserViewHost;
@@ -67,8 +73,8 @@ function overlayTag() {
67
73
  /**
68
74
  * The surface this host would use for an open, echoed to the client.
69
75
  *
70
- * The client must not place a tab when the host is in "builtin" mode, or when it is an older build that
71
- * always opens its own browser: that combination is the double-open.
76
+ * The client must not place a tab when the host is in "builtin" mode, or when an installed
77
+ * Chrome/Edge or standalone Electron channel is selected (issue #106): that combination is the double-open.
72
78
  * @returns "panel" or "builtin".
73
79
  */
74
80
  function readSurfaceForRoute() {
@@ -78,24 +84,28 @@ function readSurfaceForRoute() {
78
84
  const fs = process.getBuiltinModule?.('fs');
79
85
  if (fs === undefined)
80
86
  return 'panel';
81
- const parsed = JSON.parse(fs.readFileSync(settingsPath(), 'utf8'));
82
- return parsed.browser?.surface === 'builtin' ? 'builtin' : 'panel';
87
+ const parsed = JSON.parse(fs.readFileSync(settingsPath(), 'utf8').replace(/^\uFEFF/u, ''));
88
+ if (parsed.browser?.surface === 'builtin')
89
+ return 'builtin';
90
+ if (parsed.browser?.surface === 'panel')
91
+ return 'panel';
92
+ return parsed.browser?.channel === 'chrome' || parsed.browser?.channel === 'edge' || parsed.browser?.channel === 'electron' ? 'builtin' : 'panel';
83
93
  }
84
94
  catch {
85
95
  return 'panel';
86
96
  }
87
97
  }
88
- export const OPEN_REQUEST_ROUTE = '/dsh-builtin-browser/browser/open-request';
89
98
  /** open 记录的有效期:超过就不再重放。这是一次即时事件,客户端 2 秒轮询一次,10 秒足够送达;
90
99
  * 留得越久,「关掉侧栏后刷新又被拉起来」的窗口越大(实测复现过)。 */
91
100
  const OPEN_REQUEST_TTL_MS = 10_000;
92
101
  /** The client declares which surface it can host, so the host needs no file sniffing. */
93
- export const SURFACE_DECL_ROUTE = '/dsh-builtin-browser/browser/declare-surface';
94
102
  export { ELECTRON_BROWSER_PROVIDER_ID, ElectronBrowserProvider, } from './provider.js';
95
103
  /** Cordis plugin name used by loader diagnostics. */
96
104
  function carrierSettingsKey(settings) {
105
+ const usesPluginProfile = settings.browser.channel === 'electron'
106
+ || ((settings.browser.channel === 'chrome' || settings.browser.channel === 'edge') && settings.browser.systemProfile === 'plugin');
97
107
  return JSON.stringify([settings.browser.channel, settings.browser.systemProfile, settings.browser.headless,
98
- settings.browser.systemProfile === 'plugin' ? settings.cookies.persist : undefined]);
108
+ usesPluginProfile ? settings.cookies.persist : undefined]);
99
109
  }
100
110
  export const name = 'browser-electron';
101
111
  /** The browser seam this provider registers into. */
@@ -139,10 +149,17 @@ function readSessionId(ctx) {
139
149
  }
140
150
  /** Register the Electron browser provider with `ctx.browser`. */
141
151
  export function apply(ctx, config) {
142
- enableElectronPackageRemoval();
152
+ if (runningTauriRuntime() !== undefined) {
153
+ try {
154
+ publishTauriDesktopMain();
155
+ }
156
+ catch (error) {
157
+ ctx.logger?.warn?.(`dsh-builtin-browser: cannot name the sidebar bridge to DSH Tauri: ${String(error)}`);
158
+ }
159
+ }
143
160
  // Which session is this process serving?
144
161
  //
145
- // The desktop shell keeps ONE sidebar per conversation — measured: two `[class*=_tabStrip]`
162
+ // The desktop shell keeps ONE sidebar per conversation — measured: two sidebar tab-strip
146
163
  // containers sat in the DOM at once, each carrying its own session id on the React fiber, and
147
164
  // the invisible one's webview was unloaded. So the bridge CAN tell which sidebar belongs to
148
165
  // whom; what it lacked was the other half, this process's own identity. Without it, the bridge
@@ -346,6 +363,9 @@ export function apply(ctx, config) {
346
363
  // is right against two carriers racing in, and exactly wrong for a user changing the setting:
347
364
  // `chooseCarrier` runs again on purpose, and a refusal here is indistinguishable from the
348
365
  // write having done nothing. The previous carrier is now released by the replacement instead.
366
+ carrierHistory.push({ reason: note, at: Date.now() });
367
+ if (carrierHistory.length > 8)
368
+ carrierHistory.shift();
349
369
  const previous = adoptedCarrier;
350
370
  try {
351
371
  unregister();
@@ -359,6 +379,30 @@ export function apply(ctx, config) {
359
379
  })));
360
380
  void host.refreshStatus();
361
381
  }
382
+ else if (host instanceof SystemBrowserViewHost) {
383
+ const provider = referenceProvider;
384
+ unregisterTakeover = registerCarrierTakeover(ctx.browser, owner => provider.takeoverTargets(owner).map(target => ({
385
+ ...target, connected: () => adoptedCarrier === host && host.connectedView(target.tabId),
386
+ // A headless session is alive but has no window to hand over. Saying why beats falling back:
387
+ // a silent sidebar tab made the person act on an unrelated page (issue #103), and a bare
388
+ // "no target" made the caller retry a takeover that cannot succeed (issue #115).
389
+ unavailableReason: () => adoptedCarrier === host && host.headlessView(target.tabId)
390
+ ? 'Browser takeover needs a visible window, but this Chrome/Edge session is running headless. Launch it with a window (browser.headless = windowed) and retry.'
391
+ : undefined,
392
+ })), { exclusive: false });
393
+ }
394
+ else if (host instanceof RemoteElectronViewHost) {
395
+ const provider = referenceProvider;
396
+ unregisterTakeover = registerCarrierTakeover(ctx.browser, owner => provider.takeoverTargets(owner).map(target => ({
397
+ ...target,
398
+ connected: () => adoptedCarrier === host && host.available(),
399
+ reveal: async () => {
400
+ await provider.switchTab(target.session, target.tabId, { user: true }).catch(() => { });
401
+ host.showView({ id: target.tabId, sendCommand: async () => ({}) }, owner, { quiet: false });
402
+ return true;
403
+ },
404
+ })), { exclusive: false });
405
+ }
362
406
  ctx.logger?.info?.(`dsh-builtin-browser: ${note}`);
363
407
  // A borrowed carrier can lose the process behind it, and this is the only notification that
364
408
  // will ever arrive. Registering AFTER the swap succeeded means a listener can never fire
@@ -435,6 +479,20 @@ export function apply(ctx, config) {
435
479
  // spawns a browser window. (An earlier version launched it here, which meant a
436
480
  // browser appeared the moment the plugin loaded — reported and fixed.)
437
481
  const channel = settings.get().browser.channel;
482
+ if (channel === 'electron') {
483
+ const profileRoot = join(dshHome(), BROWSER_PROFILE_DIR);
484
+ adoptLegacyProfileRoot(profileRoot);
485
+ const persist = settings.get().cookies.persist;
486
+ const ephemeralDir = persist ? undefined : join(profileRoot, ephemeralProfileName('electron', randomUUID()));
487
+ if (!persist && ephemeralDir !== undefined) {
488
+ sweepAbandonedEphemeralProfiles(profileRoot, 'electron');
489
+ claimEphemeralProfile(ephemeralDir);
490
+ }
491
+ ;
492
+ globalThis.__dshBrowserCarrier = 'standalone-electron';
493
+ adopt(new RemoteElectronViewHost(defaultHostMainPath(), undefined, undefined, ephemeralDir), `will drive the standalone Electron browser window (on-demand runtime${persist ? '' : ', ephemeral profile'})`, choice);
494
+ return;
495
+ }
438
496
  // Naming a browser is a decision about which one to use, so it also decides whether the
439
497
  // desktop sidebar may take over. Skipping discovery for an explicit choice is what makes
440
498
  // that choice real — otherwise a user who picked Chrome would silently get the sidebar,
@@ -458,7 +516,7 @@ export function apply(ctx, config) {
458
516
  // Same profile root as settings-store, history-store and desktop-bridge-host: the
459
517
  // `?.dsh` component used to be missing HERE only, so a desktop launched from a
460
518
  // shortcut (no DSH_HOME in the environment) put its browser profile in
461
- // `C:\Users\<user>\dsh-builtin-browser-host\` while its settings and history lived in
519
+ // `%USERPROFILE%\dsh-builtin-browser-host\` while its settings and history lived in
462
520
  // `~/.dsh/dsh-builtin-browser-host/` — two half-profiles that never met, and a
463
521
  // settings panel whose switches appeared not to apply.
464
522
  const home = dshHome();
@@ -514,6 +572,7 @@ export function apply(ctx, config) {
514
572
  host.effect(() => host.webServer.register({
515
573
  kind: 'exact',
516
574
  path: PREVIEW_ROUTE,
575
+ auth: 'required',
517
576
  handler: paired(ctx, (request, response) => handlePreviewFrame(request, response, settings, browser)),
518
577
  }, 'dsh-builtin-browser: live view frame'));
519
578
  // The Web sidebar's iframe has no handle into a cross-origin guest, so the guest is served
@@ -524,6 +583,7 @@ export function apply(ctx, config) {
524
583
  host.effect(() => host.webServer.register({
525
584
  kind: 'exact',
526
585
  path: SURFACE_DECL_ROUTE,
586
+ auth: 'required',
527
587
  handler: authenticated(ctx, (request, response) => {
528
588
  readJsonBody(request).then((body) => {
529
589
  const surface = body !== null && typeof body === 'object' && body.surface;
@@ -538,6 +598,7 @@ export function apply(ctx, config) {
538
598
  host.effect(() => host.webServer.register({
539
599
  kind: 'exact',
540
600
  path: OPEN_REQUEST_ROUTE,
601
+ auth: 'required',
541
602
  handler: authenticated(ctx, (request, response) => {
542
603
  // 这条记录**不能被第一个轮询到的客户端消费掉**:同一进程里可能有多个 DSH 窗口/标签页
543
604
  // (人手一个、自动化又一个),先问的那个把记录清空后,另一个窗口就再也看不到这次 open,
@@ -550,7 +611,16 @@ export function apply(ctx, config) {
550
611
  }
551
612
  const last = getLastOpen();
552
613
  const fresh = last !== undefined && Date.now() - last.at <= OPEN_REQUEST_TTL_MS ? last : undefined;
553
- replyJson(response, 200, { ok: true, surface: readSurfaceForRoute(), open: isPreferredCarrier(adoptedCarrier) ? null : fresh ?? null });
614
+ const selectedChannel = settings.get().browser.channel;
615
+ const usesExternalBrowser = isPreferredCarrier(adoptedCarrier)
616
+ || adoptedCarrier instanceof SystemBrowserViewHost
617
+ || adoptedCarrier instanceof MissingSystemBrowserHost
618
+ || adoptedCarrier instanceof RemoteElectronViewHost
619
+ || selectedChannel === 'chrome'
620
+ || selectedChannel === 'edge'
621
+ || selectedChannel === 'electron';
622
+ const surface = usesExternalBrowser ? 'builtin' : readSurfaceForRoute();
623
+ replyJson(response, 200, { ok: true, surface, open: usesExternalBrowser ? null : fresh ?? null });
554
624
  }),
555
625
  }, 'dsh-builtin-browser: open request slot'));
556
626
  // guest 代理由根行注册(见 src/web-guest.ts):web 上 Electron 行可能被关闭。
@@ -558,6 +628,7 @@ export function apply(ctx, config) {
558
628
  host.effect(() => host.webServer.register({
559
629
  kind: 'exact',
560
630
  path: PREVIEW_SESSIONS_ROUTE,
631
+ auth: 'required',
561
632
  handler: paired(ctx, (request, response) => handlePreviewSessions(request, response, settings, browser)),
562
633
  }, 'dsh-builtin-browser: live view sessions'));
563
634
  });
@@ -574,8 +645,7 @@ export function apply(ctx, config) {
574
645
  * exactly like the other two.
575
646
  * @param ctx - the plugin context.
576
647
  */
577
- /** Where the panel asks to install or remove the bridge. */
578
- const BRIDGE_ACTION_ROUTE = '/dsh-builtin-browser/bridge-action';
648
+ /** Where the panel asks to install or remove the bridge (the path is declared in browser-policy). */
579
649
  let bridgeActionRunning = false;
580
650
  /**
581
651
  * Prepare external maintenance while Desktop remains open, or execute file maintenance from
@@ -616,8 +686,10 @@ export function apply(ctx, config) {
616
686
  }
617
687
  const root = findDesktopInstall();
618
688
  if (root === undefined) {
619
- // Nothing to patch: say so instead of running an installer against a guess.
620
- replyJson(response, 409, { ok: false, error: 'no DSH Desktop install was found on this machine' });
689
+ // Nothing to patch: say so instead of running an installer against a guess. A third-party
690
+ // shell is named as such so the refusal is not mistaken for a missing install.
691
+ const shell = detectDesktopShell({ preferredBrowser: settings.get().browser.channel });
692
+ replyJson(response, 409, { ok: false, error: shell.kind === 'none' ? 'no DSH Desktop install was found on this machine' : `not patchable: ${shell.reason}`, shell });
621
693
  return;
622
694
  }
623
695
  if (bridgeActionRunning) {
@@ -659,9 +731,10 @@ export function apply(ctx, config) {
659
731
  const hostPatchMaintenance = createHostPatchMaintenance({
660
732
  modules: () => servedClientModules(ctx.get('clientModules')),
661
733
  desktop: () => process.versions.electron !== undefined,
734
+ tauri: () => runningTauriRuntime()?.runtime,
662
735
  });
663
736
  host.effect(() => host.webServer.register({
664
- kind: 'exact', path: HOST_PATCH_ROUTE,
737
+ kind: 'exact', path: HOST_PATCH_ROUTE, auth: 'required',
665
738
  handler: authenticated(ctx, hostPatchMaintenance),
666
739
  }, 'dsh-builtin-browser: Web host patch maintenance'));
667
740
  const automaticMaintenance = createAutomaticMaintenanceHandler({
@@ -674,24 +747,26 @@ export function apply(ctx, config) {
674
747
  start: async (action, options) => {
675
748
  const root = findDesktopInstall();
676
749
  if (root === undefined)
677
- throw new Error('no verified DSH Desktop installation was found');
750
+ throw new Error(`no verified DSH Desktop installation was found: ${detectDesktopShell().reason}`);
678
751
  return await runWithManualBridgePreference('install', patch => settings.update(patch), async () => await startAutomaticMaintenance(action, root, options));
679
752
  },
680
753
  });
681
754
  host.effect(() => host.webServer.register({
682
- kind: 'exact', path: AUTOMATIC_MAINTENANCE_ROUTE,
755
+ kind: 'exact', path: AUTOMATIC_MAINTENANCE_ROUTE, auth: 'required',
683
756
  handler: authenticated(ctx, automaticMaintenance),
684
757
  }, 'dsh-builtin-browser: explicit automatic bridge maintenance'));
685
758
  host.effect(() => host.webServer.register({
686
759
  kind: 'exact',
687
760
  path: BRIDGE_STATUS_ROUTE,
688
- handler: authenticated(ctx, async (request, response) => handleBridgeStatus(request, response, undefined, await readHostExtensionStatus(dshHome()))),
761
+ auth: 'required',
762
+ handler: authenticated(ctx, async (request, response) => handleBridgeStatus(request, response, undefined, await readHostExtensionStatus(dshHome()), undefined, undefined, settings.get().browser.channel)),
689
763
  }, 'dsh-builtin-browser: bridge status'));
690
764
  // The panel prepares a launcher without changing the running Desktop. Direct local
691
765
  // maintenance remains available once Desktop has exited.
692
766
  host.effect(() => host.webServer.register({
693
767
  kind: 'exact',
694
768
  path: BRIDGE_ACTION_ROUTE,
769
+ auth: 'required',
695
770
  handler: authenticated(ctx, (request, response) => handleBridgeAction(request, response)),
696
771
  }, 'dsh-builtin-browser: bridge action'));
697
772
  });
@@ -731,14 +806,19 @@ export function apply(ctx, config) {
731
806
  extensionConnection: () => isPreferredCarrier(adoptedCarrier) ? {
732
807
  ...adoptedCarrier.connectionStatus(), install: extensionInstallHelp(adoptedCarrier.browser), registration: registrationStatus.get(adoptedCarrier.browser),
733
808
  } : undefined,
809
+ carrierHistory: () => carrierHistory.map(entry => entry.reason),
734
810
  selectedCarrier: () => adoptedCarrier instanceof DesktopBridgeViewHost || adoptedCarrier instanceof SidebarOnlyHost ? 'sidebar'
735
811
  : adoptedCarrier instanceof PreferredBrowserViewHost ? adoptedCarrier.activeCarrier()
736
- : adoptedCarrier instanceof ExtensionBrowserViewHost ? 'extension' : adoptedCarrier instanceof SystemBrowserViewHost ? 'system' : 'bundled',
812
+ : adoptedCarrier instanceof ExtensionBrowserViewHost ? 'extension'
813
+ : adoptedCarrier instanceof SystemBrowserViewHost ? 'system'
814
+ : adoptedCarrier instanceof RemoteElectronViewHost ? 'bundled'
815
+ : 'bundled',
737
816
  fallbackReason: () => adoptedCarrier instanceof PreferredBrowserViewHost ? adoptedCarrier.fallbackReason : undefined,
738
817
  systemConnection: () => adoptedCarrier instanceof PreferredBrowserViewHost ? adoptedCarrier.fallback.connectionStatus?.() : adoptedCarrier instanceof SystemBrowserViewHost ? adoptedCarrier.connectionStatus() : undefined,
739
818
  hasBinary: hasElectronRuntime,
740
819
  provision: provisionSnapshot,
741
820
  bridgeError: () => DesktopBridgeViewHost.compatibilityError(),
821
+ shell: () => detectDesktopShell({ preferredBrowser: settings.get().browser.channel }),
742
822
  bridge: () => {
743
823
  const root = findDesktopInstall();
744
824
  return root === undefined ? undefined : readBridgeStatus(root, mainExtension);
@@ -751,13 +831,16 @@ export function apply(ctx, config) {
751
831
  // `force` is what makes the panel's retry button mean anything: without it the answer would be
752
832
  // the settled failure the user is trying to replace. An attempt still running is joined.
753
833
  provision: () => {
754
- void provisionElectronInBackground(message => ctx.logger?.info?.(`dsh-builtin-browser: ${message}`), undefined, { force: true });
834
+ void provisionElectronInBackground(message => ctx.logger?.info?.(`dsh-builtin-browser: ${message}`), undefined, { force: true }).then(() => {
835
+ if (adoptedCarrier instanceof RemoteElectronViewHost)
836
+ adoptedCarrier.refreshAvailability();
837
+ });
755
838
  return provisionSnapshot();
756
839
  },
757
840
  };
758
841
  try {
759
842
  injectRuntime(['webServer'], (host) => {
760
- host.effect(() => host.webServer.register({ kind: 'exact', path: EXTENSION_INSTALL_ROUTE, handler: authenticated(ctx, async (request, response) => {
843
+ host.effect(() => host.webServer.register({ kind: 'exact', path: EXTENSION_INSTALL_ROUTE, auth: 'required', handler: authenticated(ctx, async (request, response) => {
761
844
  if (request.method !== 'POST') {
762
845
  response.writeHead(405);
763
846
  response.end();
@@ -785,6 +868,7 @@ export function apply(ctx, config) {
785
868
  host.effect(() => host.webServer.register({
786
869
  kind: 'exact',
787
870
  path: RUNTIME_STATUS_ROUTE,
871
+ auth: 'required',
788
872
  handler: authenticated(ctx, async (request, response) => {
789
873
  if (request.method === 'GET' && isPreferredCarrier(adoptedCarrier))
790
874
  await adoptedCarrier.refreshStatus();
@@ -794,6 +878,7 @@ export function apply(ctx, config) {
794
878
  host.effect(() => host.webServer.register({
795
879
  kind: 'exact',
796
880
  path: RUNTIME_PROVISION_ROUTE,
881
+ auth: 'required',
797
882
  handler: authenticated(ctx, (request, response) => handleRuntimeProvision(request, response, deps)),
798
883
  }, 'dsh-builtin-browser: runtime provision'));
799
884
  });
@@ -827,6 +912,7 @@ export function apply(ctx, config) {
827
912
  scope.effect(() => scope.webServer.register({
828
913
  kind: 'exact',
829
914
  path,
915
+ auth: 'required',
830
916
  handler: authenticated(host, handler),
831
917
  }, label));
832
918
  }
@@ -848,23 +934,29 @@ export function apply(ctx, config) {
848
934
  * @param carrier - the carrier recorded for captures that do not name one.
849
935
  * @param queue - durable capture-to-draft hand-off.
850
936
  */
851
- function installReferenceRoutes(ctx, service, carrier, queue, receipts) {
937
+ function installReferenceRoutes(ctx, service, carrier, queue) {
852
938
  const injectRoutes = ctx.inject;
853
939
  if (typeof injectRoutes !== 'function')
854
940
  return;
855
941
  try {
856
942
  injectRoutes(['webServer'], (host) => {
857
- const handlers = createReferenceRouteHandlers({ service, carrier, queue, receipts });
943
+ const handlers = createReferenceRouteHandlers({ service, carrier, queue });
858
944
  const routes = [
859
945
  [CLIENT_VERSION_ROUTE, (_request, response) => {
860
946
  // 客户端产物的版本指纹:内容变了,浏览器就应换到新 bundle。
861
- const clientPath = fileURLToPath(new URL('../../dist/client.cjs', import.meta.url));
947
+ const candidates = [
948
+ fileURLToPath(new URL('../client.js', import.meta.url)),
949
+ fileURLToPath(new URL('../../lib/client.js', import.meta.url)),
950
+ ];
862
951
  let version = "unknown";
863
- try {
864
- const stat = statSync(clientPath);
865
- version = `${Math.round(stat.mtimeMs)}-${stat.size}`;
952
+ for (const clientPath of candidates) {
953
+ try {
954
+ const stat = statSync(clientPath);
955
+ version = `${Math.round(stat.mtimeMs)}-${stat.size}`;
956
+ break;
957
+ }
958
+ catch { /* 读不到就试下一个候选路径 */ }
866
959
  }
867
- catch { /* 读不到就返回 unknown:客户端不会重载 */ }
868
960
  response.writeHead(200, { "content-type": "application/json", "cache-control": "no-store" });
869
961
  response.end(JSON.stringify({ ok: true, version }));
870
962
  }, 'dsh-builtin-browser: client version'],
@@ -885,12 +977,14 @@ export function apply(ctx, config) {
885
977
  host.effect(() => host.webServer.register({
886
978
  kind: 'exact',
887
979
  path,
980
+ auth: 'required',
888
981
  handler: authenticated(ctx, handler),
889
982
  }, label));
890
983
  }
891
984
  host.effect(() => host.webServer.register({
892
985
  kind: 'exact',
893
986
  path: REFERENCE_STATUS_ROUTE,
987
+ auth: 'required',
894
988
  handler: authenticated(ctx, (request, response) => {
895
989
  if (request.method !== 'GET') {
896
990
  replyJson(response, 405, { ok: false, error: 'method-not-allowed' });
@@ -973,19 +1067,7 @@ export function apply(ctx, config) {
973
1067
  * restarted without asking the browser for anything (§12.2).
974
1068
  */
975
1069
  const deliveryQueue = createDeliveryQueue();
976
- const receipts = createSubmissionReceipts(deliveryQueue, id => {
977
- const sessions = ctx.get('sessions');
978
- return sessions?.get(id);
979
- });
980
- ctx.on?.('session/event', (session, event) => {
981
- try {
982
- receipts.observe(session.id, event);
983
- }
984
- catch (error) {
985
- ctx.logger?.warn?.(`dsh-builtin-browser: reference receipt pending: ${String(error)}`);
986
- }
987
- }, { global: true });
988
- installReferenceRoutes(ctx, referenceService, referenceCarrier, deliveryQueue, receipts);
1070
+ installReferenceRoutes(ctx, referenceService, referenceCarrier, deliveryQueue);
989
1071
  installShortcutRoutes(ctx);
990
1072
  /** Freeze a captured reference for its owning conversation. */
991
1073
  const prepareCaptured = (reference, failures, onFailure) => {
@@ -1197,6 +1279,7 @@ function installSettingsRoute(ctx, settings, onChannelChange) {
1197
1279
  host.effect(() => host.webServer.register({
1198
1280
  kind: 'exact',
1199
1281
  path: SETTINGS_ROUTE,
1282
+ auth: 'required',
1200
1283
  handler: authenticated(ctx, (request, response) => handleSettingsRequest(request, response, settings, onChannelChange)),
1201
1284
  }, 'dsh-builtin-browser: settings'));
1202
1285
  });