dsh-builtin-browser 1.0.1 → 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 (360) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +1 -1
  3. package/assets/browser-panel-locales.mjs +37 -5
  4. package/assets/browser-policy.d.mts +29 -0
  5. package/assets/browser-policy.mjs +40 -0
  6. package/desktop-bridge/desktop-discovery.d.mts +1 -1
  7. package/desktop-bridge/desktop-discovery.mjs +59 -9
  8. package/desktop-bridge/desktop-identity.json +12 -0
  9. package/desktop-bridge/install.mjs +14 -7
  10. package/desktop-bridge/plugin-browser-bridge.js +19 -7
  11. package/docs/acceptance-2026-11-27.md +67 -0
  12. package/docs/architecture.md +1 -1
  13. package/docs/development.md +33 -4
  14. package/docs/dsh-0.2.3-host-patch-task.md +34 -0
  15. package/docs/hardcoding-audit.md +28 -8
  16. package/docs/known-issues.md +26 -0
  17. package/docs/limitations.md +6 -2
  18. package/docs/tool-reference.md +1 -1
  19. package/docs/v1.1.0-bu-data-batching-task.md +66 -0
  20. package/docs/v1.1.0-compat-hardcoding-task.md +85 -0
  21. package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
  22. package/dsh-builtin-browser-1.0.3.tgz +0 -0
  23. package/dsh-host-patch/README.md +4 -0
  24. package/dsh-host-patch/apply.mjs +61 -13
  25. package/dsh-host-patch/rc3-revision9.json.gz +0 -0
  26. package/dsh-host-patch/rc5-revision9.json.gz +0 -0
  27. package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  28. package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  29. package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  30. package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  31. package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  32. package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  33. package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  34. package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  35. package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  36. package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  37. package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  38. package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  39. package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  40. package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  41. package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  42. package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  43. package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  44. package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  45. package/dsh-host-patch/sources/manifest.json +218 -0
  46. package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  47. package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  48. package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  49. package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  50. package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  51. package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  52. package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  53. package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  54. package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  55. package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  56. package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  57. package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  58. package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  59. package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  60. package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  61. package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  62. package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  63. package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  64. package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
  65. package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
  66. package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
  67. package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
  68. package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
  69. package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
  70. package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
  71. package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
  72. package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
  73. package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
  74. package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
  75. package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
  76. package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
  77. package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
  78. package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
  79. package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
  80. package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
  81. package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
  82. package/dsh-host-patch/sources/series.json +260 -0
  83. package/dsh-host-patch/tauri/desktop-main.cjs +62 -0
  84. package/dsh-host-patch/tauri/sidebar-session.cjs +104 -0
  85. package/dsh-host-patch/tauri-revision1.json +39 -0
  86. package/dsh-host-patch/tauri.json +43 -0
  87. package/dsh-host-patch/v023-alpha2.json +153 -0
  88. package/lib/browser/anti-bot.js +215 -0
  89. package/lib/browser/deep-dom.js +39 -0
  90. package/lib/browser/runtime.js +15 -0
  91. package/lib/browser/takeover-target.js +13 -6
  92. package/lib/browser/types.js +30 -1
  93. package/lib/browser-electron/authenticated-route.js +16 -2
  94. package/lib/browser-electron/automatic-maintenance.js +16 -10
  95. package/lib/browser-electron/bridge-connection.js +3 -8
  96. package/lib/browser-electron/bridge-install.js +2 -1
  97. package/lib/browser-electron/bridge-status.js +55 -26
  98. package/lib/browser-electron/desktop-bridge-host.js +7 -6
  99. package/lib/browser-electron/desktop-identity.js +28 -5
  100. package/lib/browser-electron/desktop-shell.js +64 -0
  101. package/lib/browser-electron/electron-provision.js +105 -18
  102. package/lib/browser-electron/entry.js +129 -44
  103. package/lib/browser-electron/extension-browser.js +4 -4
  104. package/lib/browser-electron/foreground-watch.js +134 -0
  105. package/lib/browser-electron/guest-cookie-jar.js +13 -13
  106. package/lib/browser-electron/guest-route.js +181 -32
  107. package/lib/browser-electron/guest-runtime.js +61 -10
  108. package/lib/browser-electron/guest-storage.js +2 -2
  109. package/lib/browser-electron/history-store.js +1 -5
  110. package/lib/browser-electron/host-main.js +8 -4
  111. package/lib/browser-electron/host-patch-maintenance.js +14 -8
  112. package/lib/browser-electron/maintenance-route.js +2 -1
  113. package/lib/browser-electron/missing-system-browser.js +5 -9
  114. package/lib/browser-electron/preferred-browser.js +7 -3
  115. package/lib/browser-electron/preview-route.js +9 -13
  116. package/lib/browser-electron/process-ownership.js +1 -1
  117. package/lib/browser-electron/profile-command.js +2 -1
  118. package/lib/browser-electron/profile-extension.js +5 -0
  119. package/lib/browser-electron/profile-lease.js +152 -47
  120. package/lib/browser-electron/provider-core.js +527 -0
  121. package/lib/browser-electron/provider-interaction.js +963 -0
  122. package/lib/browser-electron/provider-media.js +518 -0
  123. package/lib/browser-electron/provider-navigation.js +301 -0
  124. package/lib/browser-electron/provider-observation.js +623 -0
  125. package/lib/browser-electron/provider-tabs.js +372 -0
  126. package/lib/browser-electron/provider.js +150 -3301
  127. package/lib/browser-electron/reference-route.js +9 -18
  128. package/lib/browser-electron/remote-host.js +79 -34
  129. package/lib/browser-electron/runtime-status.js +56 -6
  130. package/lib/browser-electron/settings-store.js +3 -6
  131. package/lib/browser-electron/sidebar-only-host.js +1 -1
  132. package/lib/browser-electron/system-browser.js +539 -172
  133. package/lib/browser-electron/tauri-host.js +208 -0
  134. package/lib/browser-electron/virtual-cursor.js +23 -13
  135. package/lib/browser-reference/service.js +22 -4
  136. package/lib/browser-reference/web-sources.js +1 -1
  137. package/lib/client.js +43409 -0
  138. package/lib/compat/host-features.js +75 -0
  139. package/lib/reference-source.js +1 -1
  140. package/lib/reference-text.js +23 -1
  141. package/lib/takeover-protocol.js +1 -1
  142. package/lib/tool-browser/block-recovery.js +69 -0
  143. package/lib/tool-browser/code-tool.js +170 -19
  144. package/lib/tool-browser/code-worker.js +115 -20
  145. package/lib/tool-browser/errors.js +34 -0
  146. package/lib/tool-browser/index.js +66 -3593
  147. package/lib/tool-browser/page-probe.js +227 -28
  148. package/lib/tool-browser/panel-page.js +2 -1
  149. package/lib/tool-browser/probe-client.js +157 -0
  150. package/lib/tool-browser/screenshot-annotations.js +108 -0
  151. package/lib/tool-browser/state.js +337 -0
  152. package/lib/tool-browser/takeover.js +1 -1
  153. package/lib/tool-browser/tools-debug.js +862 -0
  154. package/lib/tool-browser/tools-interaction.js +993 -0
  155. package/lib/tool-browser/tools-navigation.js +807 -0
  156. package/lib/tool-browser/tools-observation.js +461 -0
  157. package/lib/tool-browser/tools-reference.js +293 -0
  158. package/lib/web-guest.js +1 -0
  159. package/package.json +15 -53
  160. package/README.en.md +0 -89
  161. package/browser-extension/constants.mjs +0 -20
  162. package/browser-extension/controller.mjs +0 -293
  163. package/browser-extension/locales.mjs +0 -15
  164. package/browser-extension/manifest.json +0 -12
  165. package/browser-extension/options.html +0 -14
  166. package/browser-extension/options.mjs +0 -9
  167. package/browser-extension/permission-guard.mjs +0 -13
  168. package/browser-extension/worker.mjs +0 -74
  169. package/dist/client.cjs +0 -43167
  170. package/lib/browser-reference/submission-receipts.js +0 -139
  171. package/scripts/build.mjs +0 -66
  172. package/scripts/bundle-host.mjs +0 -28
  173. package/scripts/fix-exports.mjs +0 -50
  174. package/scripts/install-electron.mjs +0 -51
  175. package/scripts/verify-exports.mjs +0 -47
  176. package/scripts/verify-preview-sdk.mjs +0 -93
  177. package/skills/dsh-builtin-browser/SKILL.md +0 -73
  178. package/skills/dsh-builtin-browser/references/batch.md +0 -53
  179. package/skills/dsh-builtin-browser/references/deliver.md +0 -31
  180. package/skills/dsh-builtin-browser/references/locate.md +0 -11
  181. package/skills/dsh-builtin-browser/references/recover.md +0 -11
  182. package/skills/dsh-builtin-browser/references/verify.md +0 -13
  183. package/skills/dsh-debug-host/SKILL.md +0 -56
  184. package/skills/dsh-debug-self/SKILL.md +0 -50
  185. package/src/bridge-compatibility.ts +0 -39
  186. package/src/browser/handles.ts +0 -89
  187. package/src/browser/runtime.ts +0 -560
  188. package/src/browser/takeover-target.ts +0 -36
  189. package/src/browser/types.ts +0 -817
  190. package/src/browser-electron/authenticated-route.ts +0 -84
  191. package/src/browser-electron/automatic-maintenance.ts +0 -726
  192. package/src/browser-electron/bridge-auto.ts +0 -159
  193. package/src/browser-electron/bridge-connection.ts +0 -385
  194. package/src/browser-electron/bridge-endpoint.ts +0 -129
  195. package/src/browser-electron/bridge-install.ts +0 -289
  196. package/src/browser-electron/bridge-maintenance.ts +0 -189
  197. package/src/browser-electron/bridge-status.ts +0 -347
  198. package/src/browser-electron/desktop-bridge-host.ts +0 -251
  199. package/src/browser-electron/desktop-identity.ts +0 -320
  200. package/src/browser-electron/document-readiness.ts +0 -45
  201. package/src/browser-electron/electron-provision.ts +0 -261
  202. package/src/browser-electron/entry.ts +0 -1299
  203. package/src/browser-electron/ephemeral-profile.ts +0 -189
  204. package/src/browser-electron/extension-browser.ts +0 -223
  205. package/src/browser-electron/extension-setup.ts +0 -67
  206. package/src/browser-electron/file-write.ts +0 -31
  207. package/src/browser-electron/guest-cookie-jar.ts +0 -176
  208. package/src/browser-electron/guest-cookie-store.ts +0 -59
  209. package/src/browser-electron/guest-css-runtime.ts +0 -76
  210. package/src/browser-electron/guest-css.ts +0 -68
  211. package/src/browser-electron/guest-route.ts +0 -568
  212. package/src/browser-electron/guest-runtime.ts +0 -357
  213. package/src/browser-electron/guest-storage-runtime.ts +0 -54
  214. package/src/browser-electron/guest-storage.ts +0 -117
  215. package/src/browser-electron/history-store.ts +0 -227
  216. package/src/browser-electron/host-main.ts +0 -1381
  217. package/src/browser-electron/host-patch-maintenance.ts +0 -112
  218. package/src/browser-electron/http-body.ts +0 -65
  219. package/src/browser-electron/json-reply.ts +0 -47
  220. package/src/browser-electron/maintenance-broker.ts +0 -166
  221. package/src/browser-electron/maintenance-lifecycle.ts +0 -91
  222. package/src/browser-electron/maintenance-route.ts +0 -67
  223. package/src/browser-electron/missing-system-browser.ts +0 -113
  224. package/src/browser-electron/open-slot.ts +0 -49
  225. package/src/browser-electron/paths.ts +0 -25
  226. package/src/browser-electron/preferred-browser.ts +0 -120
  227. package/src/browser-electron/preview-route.ts +0 -218
  228. package/src/browser-electron/process-ownership.ts +0 -168
  229. package/src/browser-electron/process.ts +0 -23
  230. package/src/browser-electron/profile-checkpoint.ts +0 -187
  231. package/src/browser-electron/profile-command.ts +0 -46
  232. package/src/browser-electron/profile-extension.ts +0 -124
  233. package/src/browser-electron/profile-lease.ts +0 -115
  234. package/src/browser-electron/profile-residue.ts +0 -49
  235. package/src/browser-electron/provider.ts +0 -4571
  236. package/src/browser-electron/reference-route.ts +0 -608
  237. package/src/browser-electron/remote-host.ts +0 -1462
  238. package/src/browser-electron/rpc-input.ts +0 -13
  239. package/src/browser-electron/rpc-ops.ts +0 -41
  240. package/src/browser-electron/runtime-diagnostics.ts +0 -38
  241. package/src/browser-electron/runtime-route.ts +0 -105
  242. package/src/browser-electron/runtime-status.ts +0 -242
  243. package/src/browser-electron/settings-route.ts +0 -64
  244. package/src/browser-electron/settings-store.ts +0 -589
  245. package/src/browser-electron/shortcuts-route.ts +0 -112
  246. package/src/browser-electron/sidebar-only-host.ts +0 -298
  247. package/src/browser-electron/startpage-shortcuts.ts +0 -213
  248. package/src/browser-electron/system-browser.ts +0 -1497
  249. package/src/browser-electron/timing.ts +0 -16
  250. package/src/browser-electron/virtual-cursor.ts +0 -152
  251. package/src/browser-electron/windows-system.ts +0 -24
  252. package/src/browser-reference/delivery.ts +0 -384
  253. package/src/browser-reference/entry.ts +0 -631
  254. package/src/browser-reference/export.ts +0 -339
  255. package/src/browser-reference/import.ts +0 -303
  256. package/src/browser-reference/page-script.ts +0 -1537
  257. package/src/browser-reference/service.ts +0 -1315
  258. package/src/browser-reference/store.ts +0 -172
  259. package/src/browser-reference/submission-receipts.ts +0 -122
  260. package/src/browser-reference/text-quote.ts +0 -219
  261. package/src/browser-reference/types.ts +0 -195
  262. package/src/browser-reference/visible.ts +0 -367
  263. package/src/browser-reference/web-sources.ts +0 -103
  264. package/src/client/browser/BrowserController.ts +0 -693
  265. package/src/client/browser/BrowserFrame.ts +0 -78
  266. package/src/client/browser/BrowserNavigation.ts +0 -169
  267. package/src/client/browser/BrowserPage.ts +0 -23
  268. package/src/client/browser/BrowserPersistence.ts +0 -44
  269. package/src/client/browser/IframeImpl.ts +0 -176
  270. package/src/client/browser/child-tabs.ts +0 -14
  271. package/src/client/browser/iframe-reference.ts +0 -67
  272. package/src/client/browser/initialization.ts +0 -262
  273. package/src/client/browser/omnibox.ts +0 -243
  274. package/src/client/browser/store.ts +0 -38
  275. package/src/client/browser/takeover-channel.ts +0 -72
  276. package/src/client/browser/url.ts +0 -46
  277. package/src/client/browser/web-reference-source.ts +0 -52
  278. package/src/client/css-modules.d.ts +0 -4
  279. package/src/client/definition.tsx +0 -30
  280. package/src/client/electron/ElectronWebViewImpl.ts +0 -364
  281. package/src/client/electron/ElectronWebviewPresentation.ts +0 -138
  282. package/src/client/electron/NativeChildPresentation.ts +0 -45
  283. package/src/client/electron/NativeViewPage.ts +0 -251
  284. package/src/client/electron/pages.ts +0 -23
  285. package/src/client/electron/reference-overlay.ts +0 -53
  286. package/src/client/electron/workspace.ts +0 -33
  287. package/src/client/index.ts +0 -293
  288. package/src/client/locales.ts +0 -857
  289. package/src/client/pages.ts +0 -28
  290. package/src/client/reference/client/BrowserRefLink.tsx +0 -142
  291. package/src/client/reference/client/draft-reference.ts +0 -167
  292. package/src/client/reference/client/index.ts +0 -7
  293. package/src/client/reference/client/ordered-submission.ts +0 -108
  294. package/src/client/reference/client/pending-delivery.ts +0 -216
  295. package/src/client/reference/client/plugin.ts +0 -189
  296. package/src/client/reference/client/production/ReferenceCapsules.tsx +0 -345
  297. package/src/client/reference/client/production/ReferenceDock.module.css +0 -193
  298. package/src/client/reference/client/production/ReferenceDock.tsx +0 -6
  299. package/src/client/reference/client/production/ReferenceFeedback.tsx +0 -15
  300. package/src/client/reference/client/production/ReferenceMath.tsx +0 -44
  301. package/src/client/reference/client/production/ReferenceText.tsx +0 -36
  302. package/src/client/reference/client/production/assembly.ts +0 -471
  303. package/src/client/reference/client/production/asset-store.ts +0 -144
  304. package/src/client/reference/client/production/availability.ts +0 -74
  305. package/src/client/reference/client/production/bytes.ts +0 -36
  306. package/src/client/reference/client/production/delivery-client.ts +0 -211
  307. package/src/client/reference/client/production/draft-adapter.ts +0 -508
  308. package/src/client/reference/client/production/http-transport.ts +0 -217
  309. package/src/client/reference/client/production/production-submission.ts +0 -310
  310. package/src/client/reference/client/production/protocol.ts +0 -231
  311. package/src/client/reference/client/production/reference-card.ts +0 -240
  312. package/src/client/reference/client/production/reference-labels.ts +0 -29
  313. package/src/client/reference/client/production/reply-link-bridge.ts +0 -222
  314. package/src/client/reference/client/production/reveal.ts +0 -215
  315. package/src/client/reference/client/production/runtime.ts +0 -1101
  316. package/src/client/reference/client/production/snapshot-adapter.ts +0 -154
  317. package/src/client/reference/client/production/source-marker.ts +0 -63
  318. package/src/client/reference/client/production/source-opener.ts +0 -55
  319. package/src/client/reference/client/production/styles.ts +0 -104
  320. package/src/client/reference/client/production/user-text-rule.ts +0 -58
  321. package/src/client/reference/client/reveal.ts +0 -107
  322. package/src/client/reference/client/scheme.ts +0 -114
  323. package/src/client/reference/client/types.ts +0 -168
  324. package/src/client/reference/css-modules.d.ts +0 -4
  325. package/src/client/reference/index.ts +0 -11
  326. package/src/client/reference-capture-owner.ts +0 -162
  327. package/src/client/reference-intents.ts +0 -36
  328. package/src/client/settings/index.ts +0 -34
  329. package/src/client/settings/panel.ts +0 -2657
  330. package/src/client/shortcut-open.ts +0 -30
  331. package/src/client/startpage/binding.ts +0 -99
  332. package/src/client/startpage/controller.ts +0 -303
  333. package/src/client/startpage/model.ts +0 -279
  334. package/src/client/view/Browser.module.css +0 -751
  335. package/src/client/view/BrowserBody.tsx +0 -314
  336. package/src/client/view/BrowserPresentation.ts +0 -9
  337. package/src/client/view/BrowserTitle.tsx +0 -17
  338. package/src/client/view/IframePresentation.ts +0 -344
  339. package/src/client/view/StartPage.tsx +0 -597
  340. package/src/client/view/TakeoverBanner.tsx +0 -21
  341. package/src/index.ts +0 -110
  342. package/src/reference-owner.ts +0 -5
  343. package/src/reference-page.ts +0 -9
  344. package/src/reference-source.ts +0 -3
  345. package/src/reference-text.ts +0 -197
  346. package/src/startpage-settings.ts +0 -103
  347. package/src/startpage.ts +0 -71
  348. package/src/takeover-protocol.ts +0 -19
  349. package/src/tool-browser/code-tool.ts +0 -401
  350. package/src/tool-browser/code-worker.ts +0 -639
  351. package/src/tool-browser/element-fields.ts +0 -167
  352. package/src/tool-browser/index.ts +0 -3733
  353. package/src/tool-browser/page-probe.ts +0 -474
  354. package/src/tool-browser/panel-page.ts +0 -124
  355. package/src/tool-browser/screenshot-image.ts +0 -49
  356. package/src/tool-browser/takeover.ts +0 -198
  357. package/src/types/electron-shim.d.ts +0 -144
  358. package/src/types.ts +0 -85
  359. package/src/web-guest.ts +0 -34
  360. 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,7 +28,8 @@ 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';
@@ -39,13 +41,18 @@ import { runWithManualBridgePreference } from './bridge-auto.js';
39
41
  import { replyJson, writeJsonText } from './json-reply.js';
40
42
  import { readJsonBody, readTextBody } from './http-body.js';
41
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 = [];
42
50
  import { handleRuntimeProvision, handleRuntimeStatus, RUNTIME_PROVISION_ROUTE, RUNTIME_STATUS_ROUTE } from './runtime-route.js';
43
51
  import { createShortcutRouteHandlers, SHORTCUT_ADD_ROUTE, SHORTCUT_REMOVE_ROUTE, SHORTCUTS_ROUTE } from './shortcuts-route.js';
44
52
  import { createShortcutStore } from './startpage-shortcuts.js';
45
53
  import { createReferenceService, setReferenceCaptureActionHandler } from '../browser-reference/service.js';
46
54
  import { WEB_SOURCE_ROUTE } from '../reference-source.js';
47
55
  import { createDeliveryQueue, resolveReferenceOwner } from '../browser-reference/delivery.js';
48
- import { createSubmissionReceipts } from '../browser-reference/submission-receipts.js';
49
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';
50
57
  function isPreferredCarrier(host) {
51
58
  return host instanceof ExtensionBrowserViewHost || host instanceof PreferredBrowserViewHost;
@@ -66,8 +73,8 @@ function overlayTag() {
66
73
  /**
67
74
  * The surface this host would use for an open, echoed to the client.
68
75
  *
69
- * The client must not place a tab when the host is in "builtin" mode, or when it is an older build that
70
- * 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.
71
78
  * @returns "panel" or "builtin".
72
79
  */
73
80
  function readSurfaceForRoute() {
@@ -77,24 +84,28 @@ function readSurfaceForRoute() {
77
84
  const fs = process.getBuiltinModule?.('fs');
78
85
  if (fs === undefined)
79
86
  return 'panel';
80
- const parsed = JSON.parse(fs.readFileSync(settingsPath(), 'utf8'));
81
- 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';
82
93
  }
83
94
  catch {
84
95
  return 'panel';
85
96
  }
86
97
  }
87
- export const OPEN_REQUEST_ROUTE = '/dsh-builtin-browser/browser/open-request';
88
98
  /** open 记录的有效期:超过就不再重放。这是一次即时事件,客户端 2 秒轮询一次,10 秒足够送达;
89
99
  * 留得越久,「关掉侧栏后刷新又被拉起来」的窗口越大(实测复现过)。 */
90
100
  const OPEN_REQUEST_TTL_MS = 10_000;
91
101
  /** The client declares which surface it can host, so the host needs no file sniffing. */
92
- export const SURFACE_DECL_ROUTE = '/dsh-builtin-browser/browser/declare-surface';
93
102
  export { ELECTRON_BROWSER_PROVIDER_ID, ElectronBrowserProvider, } from './provider.js';
94
103
  /** Cordis plugin name used by loader diagnostics. */
95
104
  function carrierSettingsKey(settings) {
105
+ const usesPluginProfile = settings.browser.channel === 'electron'
106
+ || ((settings.browser.channel === 'chrome' || settings.browser.channel === 'edge') && settings.browser.systemProfile === 'plugin');
96
107
  return JSON.stringify([settings.browser.channel, settings.browser.systemProfile, settings.browser.headless,
97
- settings.browser.systemProfile === 'plugin' ? settings.cookies.persist : undefined]);
108
+ usesPluginProfile ? settings.cookies.persist : undefined]);
98
109
  }
99
110
  export const name = 'browser-electron';
100
111
  /** The browser seam this provider registers into. */
@@ -138,9 +149,17 @@ function readSessionId(ctx) {
138
149
  }
139
150
  /** Register the Electron browser provider with `ctx.browser`. */
140
151
  export function apply(ctx, config) {
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
+ }
141
160
  // Which session is this process serving?
142
161
  //
143
- // 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
144
163
  // containers sat in the DOM at once, each carrying its own session id on the React fiber, and
145
164
  // the invisible one's webview was unloaded. So the bridge CAN tell which sidebar belongs to
146
165
  // whom; what it lacked was the other half, this process's own identity. Without it, the bridge
@@ -344,6 +363,9 @@ export function apply(ctx, config) {
344
363
  // is right against two carriers racing in, and exactly wrong for a user changing the setting:
345
364
  // `chooseCarrier` runs again on purpose, and a refusal here is indistinguishable from the
346
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();
347
369
  const previous = adoptedCarrier;
348
370
  try {
349
371
  unregister();
@@ -357,6 +379,30 @@ export function apply(ctx, config) {
357
379
  })));
358
380
  void host.refreshStatus();
359
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
+ }
360
406
  ctx.logger?.info?.(`dsh-builtin-browser: ${note}`);
361
407
  // A borrowed carrier can lose the process behind it, and this is the only notification that
362
408
  // will ever arrive. Registering AFTER the swap succeeded means a listener can never fire
@@ -433,6 +479,20 @@ export function apply(ctx, config) {
433
479
  // spawns a browser window. (An earlier version launched it here, which meant a
434
480
  // browser appeared the moment the plugin loaded — reported and fixed.)
435
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
+ }
436
496
  // Naming a browser is a decision about which one to use, so it also decides whether the
437
497
  // desktop sidebar may take over. Skipping discovery for an explicit choice is what makes
438
498
  // that choice real — otherwise a user who picked Chrome would silently get the sidebar,
@@ -456,7 +516,7 @@ export function apply(ctx, config) {
456
516
  // Same profile root as settings-store, history-store and desktop-bridge-host: the
457
517
  // `?.dsh` component used to be missing HERE only, so a desktop launched from a
458
518
  // shortcut (no DSH_HOME in the environment) put its browser profile in
459
- // `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
460
520
  // `~/.dsh/dsh-builtin-browser-host/` — two half-profiles that never met, and a
461
521
  // settings panel whose switches appeared not to apply.
462
522
  const home = dshHome();
@@ -512,6 +572,7 @@ export function apply(ctx, config) {
512
572
  host.effect(() => host.webServer.register({
513
573
  kind: 'exact',
514
574
  path: PREVIEW_ROUTE,
575
+ auth: 'required',
515
576
  handler: paired(ctx, (request, response) => handlePreviewFrame(request, response, settings, browser)),
516
577
  }, 'dsh-builtin-browser: live view frame'));
517
578
  // The Web sidebar's iframe has no handle into a cross-origin guest, so the guest is served
@@ -522,6 +583,7 @@ export function apply(ctx, config) {
522
583
  host.effect(() => host.webServer.register({
523
584
  kind: 'exact',
524
585
  path: SURFACE_DECL_ROUTE,
586
+ auth: 'required',
525
587
  handler: authenticated(ctx, (request, response) => {
526
588
  readJsonBody(request).then((body) => {
527
589
  const surface = body !== null && typeof body === 'object' && body.surface;
@@ -536,6 +598,7 @@ export function apply(ctx, config) {
536
598
  host.effect(() => host.webServer.register({
537
599
  kind: 'exact',
538
600
  path: OPEN_REQUEST_ROUTE,
601
+ auth: 'required',
539
602
  handler: authenticated(ctx, (request, response) => {
540
603
  // 这条记录**不能被第一个轮询到的客户端消费掉**:同一进程里可能有多个 DSH 窗口/标签页
541
604
  // (人手一个、自动化又一个),先问的那个把记录清空后,另一个窗口就再也看不到这次 open,
@@ -548,7 +611,16 @@ export function apply(ctx, config) {
548
611
  }
549
612
  const last = getLastOpen();
550
613
  const fresh = last !== undefined && Date.now() - last.at <= OPEN_REQUEST_TTL_MS ? last : undefined;
551
- 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 });
552
624
  }),
553
625
  }, 'dsh-builtin-browser: open request slot'));
554
626
  // guest 代理由根行注册(见 src/web-guest.ts):web 上 Electron 行可能被关闭。
@@ -556,6 +628,7 @@ export function apply(ctx, config) {
556
628
  host.effect(() => host.webServer.register({
557
629
  kind: 'exact',
558
630
  path: PREVIEW_SESSIONS_ROUTE,
631
+ auth: 'required',
559
632
  handler: paired(ctx, (request, response) => handlePreviewSessions(request, response, settings, browser)),
560
633
  }, 'dsh-builtin-browser: live view sessions'));
561
634
  });
@@ -572,8 +645,7 @@ export function apply(ctx, config) {
572
645
  * exactly like the other two.
573
646
  * @param ctx - the plugin context.
574
647
  */
575
- /** Where the panel asks to install or remove the bridge. */
576
- 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). */
577
649
  let bridgeActionRunning = false;
578
650
  /**
579
651
  * Prepare external maintenance while Desktop remains open, or execute file maintenance from
@@ -614,8 +686,10 @@ export function apply(ctx, config) {
614
686
  }
615
687
  const root = findDesktopInstall();
616
688
  if (root === undefined) {
617
- // Nothing to patch: say so instead of running an installer against a guess.
618
- 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 });
619
693
  return;
620
694
  }
621
695
  if (bridgeActionRunning) {
@@ -657,9 +731,10 @@ export function apply(ctx, config) {
657
731
  const hostPatchMaintenance = createHostPatchMaintenance({
658
732
  modules: () => servedClientModules(ctx.get('clientModules')),
659
733
  desktop: () => process.versions.electron !== undefined,
734
+ tauri: () => runningTauriRuntime()?.runtime,
660
735
  });
661
736
  host.effect(() => host.webServer.register({
662
- kind: 'exact', path: HOST_PATCH_ROUTE,
737
+ kind: 'exact', path: HOST_PATCH_ROUTE, auth: 'required',
663
738
  handler: authenticated(ctx, hostPatchMaintenance),
664
739
  }, 'dsh-builtin-browser: Web host patch maintenance'));
665
740
  const automaticMaintenance = createAutomaticMaintenanceHandler({
@@ -672,24 +747,26 @@ export function apply(ctx, config) {
672
747
  start: async (action, options) => {
673
748
  const root = findDesktopInstall();
674
749
  if (root === undefined)
675
- throw new Error('no verified DSH Desktop installation was found');
750
+ throw new Error(`no verified DSH Desktop installation was found: ${detectDesktopShell().reason}`);
676
751
  return await runWithManualBridgePreference('install', patch => settings.update(patch), async () => await startAutomaticMaintenance(action, root, options));
677
752
  },
678
753
  });
679
754
  host.effect(() => host.webServer.register({
680
- kind: 'exact', path: AUTOMATIC_MAINTENANCE_ROUTE,
755
+ kind: 'exact', path: AUTOMATIC_MAINTENANCE_ROUTE, auth: 'required',
681
756
  handler: authenticated(ctx, automaticMaintenance),
682
757
  }, 'dsh-builtin-browser: explicit automatic bridge maintenance'));
683
758
  host.effect(() => host.webServer.register({
684
759
  kind: 'exact',
685
760
  path: BRIDGE_STATUS_ROUTE,
686
- 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)),
687
763
  }, 'dsh-builtin-browser: bridge status'));
688
764
  // The panel prepares a launcher without changing the running Desktop. Direct local
689
765
  // maintenance remains available once Desktop has exited.
690
766
  host.effect(() => host.webServer.register({
691
767
  kind: 'exact',
692
768
  path: BRIDGE_ACTION_ROUTE,
769
+ auth: 'required',
693
770
  handler: authenticated(ctx, (request, response) => handleBridgeAction(request, response)),
694
771
  }, 'dsh-builtin-browser: bridge action'));
695
772
  });
@@ -729,14 +806,19 @@ export function apply(ctx, config) {
729
806
  extensionConnection: () => isPreferredCarrier(adoptedCarrier) ? {
730
807
  ...adoptedCarrier.connectionStatus(), install: extensionInstallHelp(adoptedCarrier.browser), registration: registrationStatus.get(adoptedCarrier.browser),
731
808
  } : undefined,
809
+ carrierHistory: () => carrierHistory.map(entry => entry.reason),
732
810
  selectedCarrier: () => adoptedCarrier instanceof DesktopBridgeViewHost || adoptedCarrier instanceof SidebarOnlyHost ? 'sidebar'
733
811
  : adoptedCarrier instanceof PreferredBrowserViewHost ? adoptedCarrier.activeCarrier()
734
- : 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',
735
816
  fallbackReason: () => adoptedCarrier instanceof PreferredBrowserViewHost ? adoptedCarrier.fallbackReason : undefined,
736
817
  systemConnection: () => adoptedCarrier instanceof PreferredBrowserViewHost ? adoptedCarrier.fallback.connectionStatus?.() : adoptedCarrier instanceof SystemBrowserViewHost ? adoptedCarrier.connectionStatus() : undefined,
737
818
  hasBinary: hasElectronRuntime,
738
819
  provision: provisionSnapshot,
739
820
  bridgeError: () => DesktopBridgeViewHost.compatibilityError(),
821
+ shell: () => detectDesktopShell({ preferredBrowser: settings.get().browser.channel }),
740
822
  bridge: () => {
741
823
  const root = findDesktopInstall();
742
824
  return root === undefined ? undefined : readBridgeStatus(root, mainExtension);
@@ -749,13 +831,16 @@ export function apply(ctx, config) {
749
831
  // `force` is what makes the panel's retry button mean anything: without it the answer would be
750
832
  // the settled failure the user is trying to replace. An attempt still running is joined.
751
833
  provision: () => {
752
- 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
+ });
753
838
  return provisionSnapshot();
754
839
  },
755
840
  };
756
841
  try {
757
842
  injectRuntime(['webServer'], (host) => {
758
- 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) => {
759
844
  if (request.method !== 'POST') {
760
845
  response.writeHead(405);
761
846
  response.end();
@@ -783,6 +868,7 @@ export function apply(ctx, config) {
783
868
  host.effect(() => host.webServer.register({
784
869
  kind: 'exact',
785
870
  path: RUNTIME_STATUS_ROUTE,
871
+ auth: 'required',
786
872
  handler: authenticated(ctx, async (request, response) => {
787
873
  if (request.method === 'GET' && isPreferredCarrier(adoptedCarrier))
788
874
  await adoptedCarrier.refreshStatus();
@@ -792,6 +878,7 @@ export function apply(ctx, config) {
792
878
  host.effect(() => host.webServer.register({
793
879
  kind: 'exact',
794
880
  path: RUNTIME_PROVISION_ROUTE,
881
+ auth: 'required',
795
882
  handler: authenticated(ctx, (request, response) => handleRuntimeProvision(request, response, deps)),
796
883
  }, 'dsh-builtin-browser: runtime provision'));
797
884
  });
@@ -825,6 +912,7 @@ export function apply(ctx, config) {
825
912
  scope.effect(() => scope.webServer.register({
826
913
  kind: 'exact',
827
914
  path,
915
+ auth: 'required',
828
916
  handler: authenticated(host, handler),
829
917
  }, label));
830
918
  }
@@ -846,23 +934,29 @@ export function apply(ctx, config) {
846
934
  * @param carrier - the carrier recorded for captures that do not name one.
847
935
  * @param queue - durable capture-to-draft hand-off.
848
936
  */
849
- function installReferenceRoutes(ctx, service, carrier, queue, receipts) {
937
+ function installReferenceRoutes(ctx, service, carrier, queue) {
850
938
  const injectRoutes = ctx.inject;
851
939
  if (typeof injectRoutes !== 'function')
852
940
  return;
853
941
  try {
854
942
  injectRoutes(['webServer'], (host) => {
855
- const handlers = createReferenceRouteHandlers({ service, carrier, queue, receipts });
943
+ const handlers = createReferenceRouteHandlers({ service, carrier, queue });
856
944
  const routes = [
857
945
  [CLIENT_VERSION_ROUTE, (_request, response) => {
858
946
  // 客户端产物的版本指纹:内容变了,浏览器就应换到新 bundle。
859
- 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
+ ];
860
951
  let version = "unknown";
861
- try {
862
- const stat = statSync(clientPath);
863
- 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 { /* 读不到就试下一个候选路径 */ }
864
959
  }
865
- catch { /* 读不到就返回 unknown:客户端不会重载 */ }
866
960
  response.writeHead(200, { "content-type": "application/json", "cache-control": "no-store" });
867
961
  response.end(JSON.stringify({ ok: true, version }));
868
962
  }, 'dsh-builtin-browser: client version'],
@@ -883,12 +977,14 @@ export function apply(ctx, config) {
883
977
  host.effect(() => host.webServer.register({
884
978
  kind: 'exact',
885
979
  path,
980
+ auth: 'required',
886
981
  handler: authenticated(ctx, handler),
887
982
  }, label));
888
983
  }
889
984
  host.effect(() => host.webServer.register({
890
985
  kind: 'exact',
891
986
  path: REFERENCE_STATUS_ROUTE,
987
+ auth: 'required',
892
988
  handler: authenticated(ctx, (request, response) => {
893
989
  if (request.method !== 'GET') {
894
990
  replyJson(response, 405, { ok: false, error: 'method-not-allowed' });
@@ -971,19 +1067,7 @@ export function apply(ctx, config) {
971
1067
  * restarted without asking the browser for anything (§12.2).
972
1068
  */
973
1069
  const deliveryQueue = createDeliveryQueue();
974
- const receipts = createSubmissionReceipts(deliveryQueue, id => {
975
- const sessions = ctx.get('sessions');
976
- return sessions?.get(id);
977
- });
978
- ctx.on?.('session/event', (session, event) => {
979
- try {
980
- receipts.observe(session.id, event);
981
- }
982
- catch (error) {
983
- ctx.logger?.warn?.(`dsh-builtin-browser: reference receipt pending: ${String(error)}`);
984
- }
985
- }, { global: true });
986
- installReferenceRoutes(ctx, referenceService, referenceCarrier, deliveryQueue, receipts);
1070
+ installReferenceRoutes(ctx, referenceService, referenceCarrier, deliveryQueue);
987
1071
  installShortcutRoutes(ctx);
988
1072
  /** Freeze a captured reference for its owning conversation. */
989
1073
  const prepareCaptured = (reference, failures, onFailure) => {
@@ -1195,6 +1279,7 @@ function installSettingsRoute(ctx, settings, onChannelChange) {
1195
1279
  host.effect(() => host.webServer.register({
1196
1280
  kind: 'exact',
1197
1281
  path: SETTINGS_ROUTE,
1282
+ auth: 'required',
1198
1283
  handler: authenticated(ctx, (request, response) => handleSettingsRequest(request, response, settings, onChannelChange)),
1199
1284
  }, 'dsh-builtin-browser: settings'));
1200
1285
  });
@@ -5,13 +5,13 @@ import { access } from 'node:fs/promises';
5
5
  import { readTabHandle, resolveSessionHandle, resolveTabHandle, sessionWireId, tabWireId } from '../browser/handles.js';
6
6
  import { dshHome } from './paths.js';
7
7
  class LazyNativeBrowserClient {
8
- directory;
9
- browser;
10
8
  client;
11
9
  loading;
12
10
  disposed = false;
13
11
  detail = 'Optional browser extension is not connected; managed CDP fallback is available.';
14
12
  listeners = new Set();
13
+ directory;
14
+ browser;
15
15
  constructor(directory, browser) {
16
16
  this.directory = directory;
17
17
  this.browser = browser;
@@ -68,13 +68,13 @@ export function extensionInstallHelp(browser) {
68
68
  };
69
69
  }
70
70
  export class ExtensionBrowserViewHost {
71
- browser;
72
- client;
73
71
  get referenceOverlayOwner() { return 'client'; }
74
72
  views = new Map();
75
73
  detaching = new Map();
76
74
  unsubscribe;
77
75
  disposed = false;
76
+ browser;
77
+ client;
78
78
  constructor(browser, client = new LazyNativeBrowserClient(extensionDirectory(browser), browser)) {
79
79
  this.browser = browser;
80
80
  this.client = client;