dsh-builtin-browser 0.5.8 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/CHANGELOG.md +410 -1
  2. package/README.en.md +16 -64
  3. package/README.md +33 -64
  4. package/assets/browser-carriers.svg +20 -0
  5. package/assets/browser-extension-identity.d.mts +2 -0
  6. package/assets/browser-extension-identity.mjs +2 -0
  7. package/assets/browser-messages.d.mts +5 -0
  8. package/assets/browser-messages.mjs +64 -0
  9. package/assets/browser-panel-locales.d.mts +2 -0
  10. package/assets/browser-panel-locales.mjs +380 -0
  11. package/assets/browser-policy.d.mts +37 -0
  12. package/assets/browser-policy.mjs +37 -0
  13. package/assets/browser-products.d.mts +6 -0
  14. package/assets/browser-products.mjs +76 -0
  15. package/assets/screenshots/1-main.png +0 -0
  16. package/assets/screenshots/2-form-fill.png +0 -0
  17. package/assets/screenshots/3-challenge.png +0 -0
  18. package/browser-extension/constants.mjs +20 -0
  19. package/browser-extension/controller.mjs +293 -0
  20. package/browser-extension/locales.mjs +15 -0
  21. package/browser-extension/manifest.json +12 -0
  22. package/browser-extension/options.html +14 -0
  23. package/browser-extension/options.mjs +9 -0
  24. package/browser-extension/permission-guard.mjs +13 -0
  25. package/browser-extension/worker.mjs +74 -0
  26. package/cordis.patch.yml +23 -48
  27. package/desktop-bridge/desktop-discovery.d.mts +2 -0
  28. package/desktop-bridge/desktop-discovery.mjs +36 -0
  29. package/desktop-bridge/desktop-identity.json +17 -1
  30. package/desktop-bridge/desktop-processes.d.mts +1 -0
  31. package/desktop-bridge/desktop-processes.mjs +15 -0
  32. package/desktop-bridge/guest-proxy.mjs +109 -0
  33. package/desktop-bridge/install.mjs +197 -74
  34. package/desktop-bridge/main.mjs +11 -0
  35. package/desktop-bridge/maintenance-files.d.mts +8 -0
  36. package/desktop-bridge/maintenance-files.mjs +28 -0
  37. package/desktop-bridge/maintenance-progress.ps1 +2 -2
  38. package/desktop-bridge/native-guests.mjs +41 -0
  39. package/desktop-bridge/plugin-browser-bridge.js +618 -370
  40. package/desktop-bridge/profile-loader.mjs +26 -0
  41. package/dist/client.cjs +43167 -0
  42. package/dist/client.d.cts +516 -0
  43. package/dist/client.d.mts +516 -0
  44. package/dist/index.cjs +92 -0
  45. package/dist/index.d.mts +2960 -0
  46. package/dist/index.mjs +24 -0
  47. package/docs/HANDOVER-2026-11-15.md +178 -0
  48. package/docs/README.md +10 -19
  49. package/docs/architecture.md +17 -145
  50. package/docs/child-tabs.md +13 -0
  51. package/docs/desktop-acceptance.md +9 -0
  52. package/docs/development.md +88 -18
  53. package/docs/extension-browser.md +44 -0
  54. package/docs/hardcoding-audit.md +64 -0
  55. package/docs/limitations.md +23 -73
  56. package/docs/pr64-extension-status.md +46 -0
  57. package/docs/pr64-maintenance.md +25 -0
  58. package/docs/pr64-native-children.md +52 -0
  59. package/docs/pr64-native-views.md +60 -0
  60. package/docs/tool-reference.md +87 -11
  61. package/docs/user-guide.md +47 -255
  62. package/docs/why-browser.md +6 -39
  63. package/dsh-host-patch/README.md +60 -0
  64. package/dsh-host-patch/apply.mjs +194 -0
  65. package/dsh-host-patch/legacy-bridge.mjs +53 -0
  66. package/dsh-host-patch/rc3-revision1.json +90 -0
  67. package/dsh-host-patch/rc3-revision2.json +112 -0
  68. package/dsh-host-patch/rc3-revision3.json.gz +0 -0
  69. package/dsh-host-patch/rc3-revision4.json.gz +0 -0
  70. package/dsh-host-patch/rc3-revision5.json.gz +0 -0
  71. package/dsh-host-patch/rc3-revision6.json.gz +0 -0
  72. package/dsh-host-patch/rc3-revision7.json.gz +0 -0
  73. package/dsh-host-patch/rc3-revision8.json.gz +0 -0
  74. package/dsh-host-patch/rc3.json +148 -0
  75. package/dsh-host-patch/rc5-revision1.json +90 -0
  76. package/dsh-host-patch/rc5-revision2.json +112 -0
  77. package/dsh-host-patch/rc5-revision3.json.gz +0 -0
  78. package/dsh-host-patch/rc5-revision4.json.gz +0 -0
  79. package/dsh-host-patch/rc5-revision5.json.gz +0 -0
  80. package/dsh-host-patch/rc5-revision6.json.gz +0 -0
  81. package/dsh-host-patch/rc5-revision7.json.gz +0 -0
  82. package/dsh-host-patch/rc5-revision8.json.gz +0 -0
  83. package/dsh-host-patch/rc5.json +148 -0
  84. package/lib/bridge-compatibility.js +38 -0
  85. package/lib/browser/handles.js +78 -0
  86. package/lib/browser/runtime.js +155 -43
  87. package/lib/browser/takeover-target.js +24 -0
  88. package/lib/browser-electron/authenticated-route.js +23 -0
  89. package/lib/browser-electron/automatic-maintenance.js +394 -51
  90. package/lib/browser-electron/bridge-auto.js +2 -1
  91. package/lib/browser-electron/bridge-connection.js +8 -1
  92. package/lib/browser-electron/bridge-install.js +27 -2
  93. package/lib/browser-electron/bridge-maintenance.js +35 -10
  94. package/lib/browser-electron/bridge-status.js +98 -27
  95. package/lib/browser-electron/desktop-bridge-host.js +193 -560
  96. package/lib/browser-electron/desktop-identity.js +40 -2
  97. package/lib/browser-electron/document-readiness.js +34 -0
  98. package/lib/browser-electron/electron-provision.js +14 -44
  99. package/lib/browser-electron/entry.js +659 -252
  100. package/lib/browser-electron/extension-browser.js +234 -0
  101. package/lib/browser-electron/extension-setup.js +69 -0
  102. package/lib/browser-electron/guest-cookie-jar.LICENSE.txt +32 -0
  103. package/lib/browser-electron/guest-cookie-jar.js +10559 -0
  104. package/lib/browser-electron/guest-cookie-store.js +74 -0
  105. package/lib/browser-electron/guest-css-runtime.js +75 -0
  106. package/lib/browser-electron/guest-css.js +106 -0
  107. package/lib/browser-electron/guest-route.js +603 -0
  108. package/lib/browser-electron/guest-runtime.js +356 -0
  109. package/lib/browser-electron/guest-storage-runtime.js +52 -0
  110. package/lib/browser-electron/guest-storage.js +163 -0
  111. package/lib/browser-electron/history-store.js +2 -1
  112. package/lib/browser-electron/host-main.js +162 -7
  113. package/lib/browser-electron/host-patch-maintenance.js +141 -0
  114. package/lib/browser-electron/http-body.js +22 -0
  115. package/lib/browser-electron/maintenance-broker.js +35 -5
  116. package/lib/browser-electron/maintenance-lifecycle.js +7 -5
  117. package/lib/browser-electron/maintenance-route.js +9 -6
  118. package/lib/browser-electron/open-slot.js +47 -0
  119. package/lib/browser-electron/paths.js +4 -1
  120. package/lib/browser-electron/preferred-browser.js +144 -0
  121. package/lib/browser-electron/preview-route.js +11 -8
  122. package/lib/browser-electron/process-ownership.js +198 -0
  123. package/lib/browser-electron/profile-checkpoint.js +222 -0
  124. package/lib/browser-electron/profile-command.js +60 -0
  125. package/lib/browser-electron/profile-extension.js +126 -0
  126. package/lib/browser-electron/profile-lease.js +157 -0
  127. package/lib/browser-electron/profile-residue.js +61 -0
  128. package/lib/browser-electron/provider.js +719 -262
  129. package/lib/browser-electron/reference-route.js +635 -0
  130. package/lib/browser-electron/remote-host.js +12 -13
  131. package/lib/browser-electron/runtime-route.js +6 -5
  132. package/lib/browser-electron/runtime-status.js +30 -29
  133. package/lib/browser-electron/settings-store.js +10 -5
  134. package/lib/browser-electron/shortcuts-route.js +108 -0
  135. package/lib/browser-electron/sidebar-only-host.js +119 -18
  136. package/lib/browser-electron/startpage-shortcuts.js +172 -0
  137. package/lib/browser-electron/system-browser.js +352 -371
  138. package/lib/browser-electron/windows-system.js +2 -1
  139. package/lib/browser-reference/delivery.js +326 -0
  140. package/lib/browser-reference/entry.js +597 -0
  141. package/lib/browser-reference/export.js +298 -0
  142. package/lib/browser-reference/import.js +295 -0
  143. package/lib/browser-reference/page-script.js +1406 -0
  144. package/lib/browser-reference/service.js +1062 -0
  145. package/lib/browser-reference/store.js +177 -0
  146. package/lib/browser-reference/submission-receipts.js +139 -0
  147. package/lib/browser-reference/text-quote.js +167 -0
  148. package/lib/browser-reference/types.js +11 -0
  149. package/lib/browser-reference/visible.js +311 -0
  150. package/lib/browser-reference/web-sources.js +97 -0
  151. package/lib/index.js +10 -3
  152. package/lib/reference-owner.js +5 -0
  153. package/lib/reference-page.js +12 -0
  154. package/lib/reference-source.js +2 -0
  155. package/lib/reference-text.js +188 -0
  156. package/lib/startpage-settings.js +63 -0
  157. package/lib/startpage.js +44 -0
  158. package/lib/takeover-protocol.js +2 -0
  159. package/lib/tool-browser/code-tool.js +416 -0
  160. package/lib/tool-browser/code-worker.js +872 -0
  161. package/lib/tool-browser/index.js +940 -76
  162. package/lib/tool-browser/page-probe.js +3 -3
  163. package/lib/tool-browser/panel-page.js +95 -0
  164. package/lib/tool-browser/screenshot-image.js +51 -0
  165. package/lib/tool-browser/takeover.js +205 -0
  166. package/lib/types.js +1 -0
  167. package/lib/web-guest.js +26 -0
  168. package/native-host/client.d.mts +17 -0
  169. package/native-host/client.mjs +100 -0
  170. package/native-host/host.mjs +150 -0
  171. package/native-host/identity.d.mts +2 -0
  172. package/native-host/identity.mjs +1 -0
  173. package/native-host/install.mjs +168 -0
  174. package/native-host/protocol.mjs +75 -0
  175. package/package.json +80 -92
  176. package/scripts/build.mjs +66 -0
  177. package/scripts/bundle-host.mjs +28 -0
  178. package/scripts/fix-exports.mjs +50 -0
  179. package/scripts/install-electron.mjs +11 -26
  180. package/scripts/verify-exports.mjs +47 -0
  181. package/scripts/verify-preview-sdk.mjs +93 -0
  182. package/skills/dsh-builtin-browser/SKILL.md +56 -47
  183. package/skills/dsh-builtin-browser/references/batch.md +31 -1
  184. package/skills/dsh-debug-host/SKILL.md +56 -0
  185. package/skills/dsh-debug-self/SKILL.md +50 -0
  186. package/src/bridge-compatibility.ts +39 -0
  187. package/src/browser/handles.ts +89 -0
  188. package/src/browser/runtime.ts +146 -50
  189. package/src/browser/takeover-target.ts +36 -0
  190. package/src/browser/types.ts +19 -7
  191. package/src/browser-electron/authenticated-route.ts +29 -1
  192. package/src/browser-electron/automatic-maintenance.ts +368 -56
  193. package/src/browser-electron/bridge-auto.ts +5 -4
  194. package/src/browser-electron/bridge-connection.ts +20 -2
  195. package/src/browser-electron/bridge-endpoint.ts +3 -3
  196. package/src/browser-electron/bridge-install.ts +40 -4
  197. package/src/browser-electron/bridge-maintenance.ts +42 -14
  198. package/src/browser-electron/bridge-status.ts +94 -23
  199. package/src/browser-electron/desktop-bridge-host.ts +185 -585
  200. package/src/browser-electron/desktop-identity.ts +53 -2
  201. package/src/browser-electron/document-readiness.ts +45 -0
  202. package/src/browser-electron/electron-provision.ts +12 -45
  203. package/src/browser-electron/entry.ts +1299 -882
  204. package/src/browser-electron/ephemeral-profile.ts +1 -1
  205. package/src/browser-electron/extension-browser.ts +223 -0
  206. package/src/browser-electron/extension-setup.ts +67 -0
  207. package/src/browser-electron/guest-cookie-jar.ts +176 -0
  208. package/src/browser-electron/guest-cookie-store.ts +59 -0
  209. package/src/browser-electron/guest-css-runtime.ts +76 -0
  210. package/src/browser-electron/guest-css.ts +68 -0
  211. package/src/browser-electron/guest-route.ts +568 -0
  212. package/src/browser-electron/guest-runtime.ts +357 -0
  213. package/src/browser-electron/guest-storage-runtime.ts +54 -0
  214. package/src/browser-electron/guest-storage.ts +117 -0
  215. package/src/browser-electron/history-store.ts +5 -4
  216. package/src/browser-electron/host-main.ts +156 -11
  217. package/src/browser-electron/host-patch-maintenance.ts +112 -0
  218. package/src/browser-electron/http-body.ts +23 -0
  219. package/src/browser-electron/maintenance-broker.ts +29 -5
  220. package/src/browser-electron/maintenance-lifecycle.ts +14 -9
  221. package/src/browser-electron/maintenance-route.ts +17 -14
  222. package/src/browser-electron/missing-system-browser.ts +2 -2
  223. package/src/browser-electron/open-slot.ts +49 -0
  224. package/src/browser-electron/paths.ts +5 -1
  225. package/src/browser-electron/preferred-browser.ts +120 -0
  226. package/src/browser-electron/preview-route.ts +18 -11
  227. package/src/browser-electron/process-ownership.ts +168 -0
  228. package/src/browser-electron/profile-checkpoint.ts +187 -0
  229. package/src/browser-electron/profile-command.ts +46 -0
  230. package/src/browser-electron/profile-extension.ts +124 -0
  231. package/src/browser-electron/profile-lease.ts +115 -0
  232. package/src/browser-electron/profile-residue.ts +49 -0
  233. package/src/browser-electron/provider.ts +771 -289
  234. package/src/browser-electron/reference-route.ts +608 -0
  235. package/src/browser-electron/remote-host.ts +15 -15
  236. package/src/browser-electron/runtime-route.ts +11 -10
  237. package/src/browser-electron/runtime-status.ts +51 -32
  238. package/src/browser-electron/settings-store.ts +27 -7
  239. package/src/browser-electron/shortcuts-route.ts +112 -0
  240. package/src/browser-electron/sidebar-only-host.ts +118 -19
  241. package/src/browser-electron/startpage-shortcuts.ts +213 -0
  242. package/src/browser-electron/system-browser.ts +309 -338
  243. package/src/browser-electron/windows-system.ts +2 -1
  244. package/src/browser-reference/delivery.ts +384 -0
  245. package/src/browser-reference/entry.ts +631 -0
  246. package/src/browser-reference/export.ts +339 -0
  247. package/src/browser-reference/import.ts +303 -0
  248. package/src/browser-reference/page-script.ts +1537 -0
  249. package/src/browser-reference/service.ts +1315 -0
  250. package/src/browser-reference/store.ts +172 -0
  251. package/src/browser-reference/submission-receipts.ts +122 -0
  252. package/src/browser-reference/text-quote.ts +219 -0
  253. package/src/browser-reference/types.ts +195 -0
  254. package/src/browser-reference/visible.ts +367 -0
  255. package/src/browser-reference/web-sources.ts +103 -0
  256. package/src/client/browser/BrowserController.ts +693 -0
  257. package/src/client/browser/BrowserFrame.ts +78 -0
  258. package/src/client/browser/BrowserNavigation.ts +169 -0
  259. package/src/client/browser/BrowserPage.ts +23 -0
  260. package/src/client/browser/BrowserPersistence.ts +44 -0
  261. package/src/client/browser/IframeImpl.ts +176 -0
  262. package/src/client/browser/child-tabs.ts +14 -0
  263. package/src/client/browser/iframe-reference.ts +67 -0
  264. package/src/client/browser/initialization.ts +262 -0
  265. package/src/client/browser/omnibox.ts +243 -0
  266. package/src/client/browser/store.ts +38 -0
  267. package/src/client/browser/takeover-channel.ts +72 -0
  268. package/src/client/browser/url.ts +46 -0
  269. package/src/client/browser/web-reference-source.ts +52 -0
  270. package/src/client/css-modules.d.ts +4 -0
  271. package/src/client/definition.tsx +30 -0
  272. package/src/client/electron/ElectronWebViewImpl.ts +364 -0
  273. package/src/client/electron/ElectronWebviewPresentation.ts +138 -0
  274. package/src/client/electron/NativeChildPresentation.ts +45 -0
  275. package/src/client/electron/NativeViewPage.ts +251 -0
  276. package/src/client/electron/pages.ts +23 -0
  277. package/src/client/electron/reference-overlay.ts +53 -0
  278. package/src/client/electron/workspace.ts +33 -0
  279. package/src/client/index.ts +293 -0
  280. package/src/client/locales.ts +857 -0
  281. package/src/client/pages.ts +28 -0
  282. package/src/client/reference/client/BrowserRefLink.tsx +142 -0
  283. package/src/client/reference/client/draft-reference.ts +167 -0
  284. package/src/client/reference/client/index.ts +7 -0
  285. package/src/client/reference/client/ordered-submission.ts +108 -0
  286. package/src/client/reference/client/pending-delivery.ts +216 -0
  287. package/src/client/reference/client/plugin.ts +189 -0
  288. package/src/client/reference/client/production/ReferenceCapsules.tsx +345 -0
  289. package/src/client/reference/client/production/ReferenceDock.module.css +193 -0
  290. package/src/client/reference/client/production/ReferenceDock.tsx +6 -0
  291. package/src/client/reference/client/production/ReferenceFeedback.tsx +15 -0
  292. package/src/client/reference/client/production/ReferenceMath.tsx +44 -0
  293. package/src/client/reference/client/production/ReferenceText.tsx +36 -0
  294. package/src/client/reference/client/production/assembly.ts +471 -0
  295. package/src/client/reference/client/production/asset-store.ts +144 -0
  296. package/src/client/reference/client/production/availability.ts +74 -0
  297. package/src/client/reference/client/production/bytes.ts +36 -0
  298. package/src/client/reference/client/production/delivery-client.ts +211 -0
  299. package/src/client/reference/client/production/draft-adapter.ts +508 -0
  300. package/src/client/reference/client/production/http-transport.ts +217 -0
  301. package/src/client/reference/client/production/production-submission.ts +310 -0
  302. package/src/client/reference/client/production/protocol.ts +231 -0
  303. package/src/client/reference/client/production/reference-card.ts +240 -0
  304. package/src/client/reference/client/production/reference-labels.ts +29 -0
  305. package/src/client/reference/client/production/reply-link-bridge.ts +222 -0
  306. package/src/client/reference/client/production/reveal.ts +215 -0
  307. package/src/client/reference/client/production/runtime.ts +1101 -0
  308. package/src/client/reference/client/production/snapshot-adapter.ts +154 -0
  309. package/src/client/reference/client/production/source-marker.ts +63 -0
  310. package/src/client/reference/client/production/source-opener.ts +55 -0
  311. package/src/client/reference/client/production/styles.ts +104 -0
  312. package/src/client/reference/client/production/user-text-rule.ts +58 -0
  313. package/src/client/reference/client/reveal.ts +107 -0
  314. package/src/client/reference/client/scheme.ts +114 -0
  315. package/src/client/reference/client/types.ts +168 -0
  316. package/src/client/reference/css-modules.d.ts +4 -0
  317. package/src/client/reference/index.ts +11 -0
  318. package/src/client/reference-capture-owner.ts +162 -0
  319. package/src/client/reference-intents.ts +36 -0
  320. package/src/client/settings/index.ts +34 -0
  321. package/{client.js → src/client/settings/panel.ts} +2657 -2231
  322. package/src/client/shortcut-open.ts +30 -0
  323. package/src/client/startpage/binding.ts +99 -0
  324. package/src/client/startpage/controller.ts +303 -0
  325. package/src/client/startpage/model.ts +279 -0
  326. package/src/client/view/Browser.module.css +751 -0
  327. package/src/client/view/BrowserBody.tsx +314 -0
  328. package/src/client/view/BrowserPresentation.ts +9 -0
  329. package/src/client/view/BrowserTitle.tsx +17 -0
  330. package/src/client/view/IframePresentation.ts +344 -0
  331. package/src/client/view/StartPage.tsx +597 -0
  332. package/src/client/view/TakeoverBanner.tsx +21 -0
  333. package/src/index.ts +110 -73
  334. package/src/reference-owner.ts +5 -0
  335. package/src/reference-page.ts +9 -0
  336. package/src/reference-source.ts +3 -0
  337. package/src/reference-text.ts +197 -0
  338. package/src/startpage-settings.ts +103 -0
  339. package/src/startpage.ts +71 -0
  340. package/src/takeover-protocol.ts +19 -0
  341. package/src/tool-browser/code-tool.ts +401 -0
  342. package/src/tool-browser/code-worker.ts +639 -0
  343. package/src/tool-browser/index.ts +908 -77
  344. package/src/tool-browser/page-probe.ts +4 -4
  345. package/src/tool-browser/panel-page.ts +124 -0
  346. package/src/tool-browser/screenshot-image.ts +49 -0
  347. package/src/tool-browser/takeover.ts +198 -0
  348. package/src/types/electron-shim.d.ts +20 -0
  349. package/src/types.ts +85 -0
  350. package/src/web-guest.ts +34 -0
  351. package/tools/accept-desktop.mjs +148 -0
  352. package/lib/browser/runtime.d.ts +0 -175
  353. package/lib/browser/types.d.ts +0 -797
  354. package/lib/browser-electron/authenticated-route.d.ts +0 -27
  355. package/lib/browser-electron/automatic-maintenance.d.ts +0 -41
  356. package/lib/browser-electron/bridge-auto.d.ts +0 -93
  357. package/lib/browser-electron/bridge-connection.d.ts +0 -93
  358. package/lib/browser-electron/bridge-endpoint.d.ts +0 -30
  359. package/lib/browser-electron/bridge-install.d.ts +0 -85
  360. package/lib/browser-electron/bridge-maintenance.d.ts +0 -24
  361. package/lib/browser-electron/bridge-status.d.ts +0 -50
  362. package/lib/browser-electron/desktop-bridge-host.d.ts +0 -248
  363. package/lib/browser-electron/desktop-identity.d.ts +0 -58
  364. package/lib/browser-electron/electron-provision.d.ts +0 -92
  365. package/lib/browser-electron/entry.d.ts +0 -64
  366. package/lib/browser-electron/ephemeral-profile.d.ts +0 -37
  367. package/lib/browser-electron/file-write.d.ts +0 -2
  368. package/lib/browser-electron/history-store.d.ts +0 -98
  369. package/lib/browser-electron/host-main.d.ts +0 -26
  370. package/lib/browser-electron/http-body.d.ts +0 -24
  371. package/lib/browser-electron/json-reply.d.ts +0 -33
  372. package/lib/browser-electron/maintenance-broker.d.ts +0 -35
  373. package/lib/browser-electron/maintenance-lifecycle.d.ts +0 -32
  374. package/lib/browser-electron/maintenance-route.d.ts +0 -18
  375. package/lib/browser-electron/missing-system-browser.d.ts +0 -54
  376. package/lib/browser-electron/paths.d.ts +0 -4
  377. package/lib/browser-electron/preview-route.d.ts +0 -89
  378. package/lib/browser-electron/process.d.ts +0 -14
  379. package/lib/browser-electron/provider.d.ts +0 -959
  380. package/lib/browser-electron/remote-host.d.ts +0 -256
  381. package/lib/browser-electron/rpc-input.d.ts +0 -4
  382. package/lib/browser-electron/rpc-ops.d.ts +0 -18
  383. package/lib/browser-electron/runtime-diagnostics.d.ts +0 -12
  384. package/lib/browser-electron/runtime-route.d.ts +0 -55
  385. package/lib/browser-electron/runtime-status.d.ts +0 -116
  386. package/lib/browser-electron/settings-route.d.ts +0 -15
  387. package/lib/browser-electron/settings-store.d.ts +0 -224
  388. package/lib/browser-electron/sidebar-only-host.d.ts +0 -36
  389. package/lib/browser-electron/system-browser.d.ts +0 -367
  390. package/lib/browser-electron/timing.d.ts +0 -8
  391. package/lib/browser-electron/virtual-cursor.d.ts +0 -67
  392. package/lib/browser-electron/windows-system.d.ts +0 -3
  393. package/lib/index.d.ts +0 -30
  394. package/lib/tool-browser/element-fields.d.ts +0 -145
  395. package/lib/tool-browser/index.d.ts +0 -53
  396. package/lib/tool-browser/page-probe.d.ts +0 -86
  397. package/scripts/consumer-install-check.mjs +0 -72
  398. package/scripts/run-tests.mjs +0 -32
  399. package/scripts/verify-host-compat.mjs +0 -195
  400. package/scripts/verify-preview-route.mjs +0 -168
  401. package/scripts/verify-runtime-status.mjs +0 -179
@@ -0,0 +1,293 @@
1
+ import { EXTENSION_LIMITS, DEBUGGER_IDLE_TIMEOUT_MS, DEBUGGER_IDLE_ALARM, DEBUGGER_SESSION_KEY } from './constants.mjs'
2
+ import { permissionGuard } from './permission-guard.mjs'
3
+
4
+ const DOMAINS = new Set(['Accessibility', 'DOM', 'DOMSnapshot', 'CSS', 'Emulation', 'Input', 'Log', 'Network', 'Page', 'Runtime', 'Target'])
5
+ const DENIED = new Set(['Page.close', 'Page.bringToFront', 'Page.setDownloadBehavior', 'Page.setInterceptFileChooserDialog',
6
+ 'Target.activateTarget', 'Target.createTarget', 'Target.closeTarget', 'Target.attachToTarget', 'Target.attachToBrowserTarget',
7
+ 'Target.detachFromTarget', 'Target.sendMessageToTarget', 'Target.exposeDevToolsProtocol', 'DOM.setFileInputFiles', 'Page.printToPDF'])
8
+ const validScope = value => typeof value === 'string' && value.length > 0 && value.length <= EXTENSION_LIMITS.scopeLength
9
+ const allowedUrl = url => typeof url === 'string' && (url === 'about:blank' || /^https?:\/\//i.test(url))
10
+
11
+ export class ExtensionController {
12
+ constructor(api, emit) {
13
+ this.api = api; this.emit = emit; this.leases = new Map(); this.created = new Map(); this.tabLeases = new Map(); this.attaching = new Set(); this.generation = 0
14
+ this.related = new Map(); this.containing = new Set()
15
+ this.active = undefined; this.expectedDetach = new Set(); this.tail = Promise.resolve()
16
+ this.ready = this.restore()
17
+ this.ready.catch(() => {})
18
+ api.alarms?.onAlarm.addListener(alarm => {
19
+ if (alarm.name === DEBUGGER_IDLE_ALARM) return this.enqueue(async () => {
20
+ if (Date.now() >= this.idleAt) await this.suspend()
21
+ }).catch(() => {})
22
+ })
23
+ api.debugger.onEvent.addListener((source, method, params) => { void this.event(source, method, params) })
24
+ api.debugger.onDetach.addListener((source, reason) => {
25
+ if (reason !== 'canceled_by_user' && this.expectedDetach.delete(source.tabId)) return
26
+ if (this.active === source.tabId) this.active = undefined
27
+ const lease = this.tabLeases.get(source.tabId)
28
+ if (lease) { this.leases.delete(lease.id); this.tabLeases.delete(source.tabId); this.emit({ type: 'event', lease: lease.id, method: 'target.detached', params: { reason } }) }
29
+ void this.enqueue(() => this.persist()).catch(() => {})
30
+ })
31
+ api.tabs.onRemoved.addListener(tabId => { this.created.delete(tabId); this.related.delete(tabId) })
32
+ api.tabs.onCreated.addListener(tab => { void this.containPopup(tab) })
33
+ api.windows.onCreated.addListener(window => {
34
+ void api.tabs.query({ windowId: window.id }).then(tabs => Promise.all(tabs.map(tab => this.containPopup(tab)))).catch(() => {})
35
+ })
36
+ }
37
+ enqueue(work) {
38
+ const result = this.tail.then(() => this.ready).then(work)
39
+ this.tail = result.catch(() => {})
40
+ return result
41
+ }
42
+ async persist() {
43
+ await this.api.storage?.session?.set({ [DEBUGGER_SESSION_KEY]: {
44
+ leases: [...this.leases.values()], created: [...this.created], active: this.active, activeReady: this.activeReady, idleAt: this.idleAt,
45
+ } })
46
+ }
47
+ async restore() {
48
+ if (!this.api.storage?.session) return
49
+ const stored = (await this.api.storage.session.get(DEBUGGER_SESSION_KEY))[DEBUGGER_SESSION_KEY]
50
+ for (const lease of stored?.leases ?? []) {
51
+ if (validScope(lease.id) && validScope(lease.scope) && validScope(lease.view) && Number.isInteger(lease.tabId)) {
52
+ lease.notices = Array.isArray(lease.notices) ? lease.notices : []
53
+ lease.blockingNotices = Array.isArray(lease.blockingNotices) ? lease.blockingNotices : []
54
+ this.leases.set(lease.id, lease); this.tabLeases.set(lease.tabId, lease)
55
+ }
56
+ }
57
+ this.created = new Map(stored?.created ?? [])
58
+ const targets = await this.api.debugger.getTargets()
59
+ let retained
60
+ for (const target of targets.filter(target => target.attached && Number.isInteger(target.tabId))) {
61
+ // getTargets also includes other debuggers. Only our own sessions accept commands.
62
+ try { await this.api.debugger.sendCommand({ tabId: target.tabId }, 'Runtime.getIsolateId', {}) }
63
+ catch { continue }
64
+ if (target.tabId === stored?.active && stored.activeReady && this.tabLeases.has(target.tabId) && stored.idleAt > Date.now()) {
65
+ retained = target.tabId
66
+ } else { this.active = target.tabId; await this.suspend() }
67
+ }
68
+ this.active = retained
69
+ this.activeReady = retained !== undefined
70
+ this.idleAt = stored?.idleAt
71
+ if (this.active !== undefined) await this.api.alarms.create(DEBUGGER_IDLE_ALARM, { when: this.idleAt })
72
+ await this.persist()
73
+ }
74
+ suspend() {
75
+ return this.suspending ??= this.detachActive().finally(() => { this.suspending = undefined })
76
+ }
77
+ async detachActive() {
78
+ if (this.active === undefined) return
79
+ const tabId = this.active
80
+ this.expectedDetach.add(tabId)
81
+ try { await this.api.debugger.detach({ tabId }) }
82
+ finally { this.expectedDetach.delete(tabId) }
83
+ this.active = undefined
84
+ this.activeReady = false
85
+ await this.api.alarms?.clear(DEBUGGER_IDLE_ALARM)
86
+ await this.persist()
87
+ }
88
+ async activate(lease) {
89
+ if (this.active === lease.tabId) return
90
+ const generation = this.generation
91
+ await this.suspend()
92
+ const tab = await this.api.tabs.get(lease.tabId)
93
+ if (tab.incognito || !allowedUrl(tab.url || tab.pendingUrl) || !allowedUrl(tab.pendingUrl || tab.url)) throw Error('restricted/internal, extension and incognito pages are unavailable')
94
+ this.active = lease.tabId
95
+ this.activeReady = false
96
+ await this.persist()
97
+ if (generation !== this.generation) { this.active = undefined; throw Error('connection released') }
98
+ try { await this.api.debugger.attach({ tabId: lease.tabId }, '1.3') }
99
+ catch (error) { this.active = undefined; await this.persist(); throw error }
100
+ if (generation !== this.generation) { this.active = lease.tabId; await this.suspend(); throw Error('connection released') }
101
+ try {
102
+ for (const [method, params] of [
103
+ ['Page.enable', {}], ['Page.setInterceptFileChooserDialog', { enabled: true }],
104
+ ['Emulation.setFocusEmulationEnabled', { enabled: true }], ['Page.setWebLifecycleState', { state: 'active' }],
105
+ ]) await this.api.debugger.sendCommand({ tabId: lease.tabId }, method, params)
106
+ if (this.created.get(lease.tabId) === lease.scope) {
107
+ await this.api.debugger.sendCommand({ tabId: lease.tabId }, 'Page.addScriptToEvaluateOnNewDocument', { source: permissionGuard })
108
+ await this.api.debugger.sendCommand({ tabId: lease.tabId }, 'Runtime.evaluate', { expression: permissionGuard })
109
+ }
110
+ if (generation !== this.generation || !this.leases.has(lease.id)) throw Error('connection released')
111
+ this.activeReady = true
112
+ } catch (error) {
113
+ await this.suspend()
114
+ throw error
115
+ }
116
+ }
117
+ async containPopup(tab) {
118
+ const root = this.created.has(tab.openerTabId) ? tab.openerTabId : this.related.get(tab.openerTabId)?.root
119
+ const scope = this.tabLeases.has(root) ? this.created.get(root) : undefined
120
+ if (!scope || !Number.isInteger(tab.id) || this.containing.has(tab.id) || this.related.has(tab.id)) return
121
+ this.containing.add(tab.id)
122
+ const generation = this.generation
123
+ try {
124
+ const opener = await this.api.tabs.get(tab.openerTabId)
125
+ if (generation !== this.generation) return
126
+ this.related.set(tab.id, { scope, opener: tab.openerTabId, root })
127
+ const window = await this.api.windows.get(tab.windowId)
128
+ if (generation !== this.generation || !this.tabLeases.has(root)) return
129
+ if (window.type === 'popup' && opener.windowId !== tab.windowId) {
130
+ await this.api.tabs.move(tab.id, { windowId: opener.windowId, index: -1 })
131
+ }
132
+ const lease = this.tabLeases.get(root)
133
+ if (lease) {
134
+ lease.notices.push(`Site-created tab ${tab.id} detected${window.type === 'popup' ? '; moved to opener window without activation' : ''}. Site activation may precede browser events.`)
135
+ lease.notices = lease.notices.slice(-EXTENSION_LIMITS.notices)
136
+ }
137
+ this.emit({ type: 'event', method: 'target.popup', lease: lease?.id, params: { tabId: tab.id, openerTabId: tab.openerTabId, containment: window.type === 'popup' ? 'moved' : 'observed', siteActivated: tab.active === true } })
138
+ } catch {
139
+ this.emit({ type: 'event', method: 'target.popup', params: { tabId: tab.id, containment: 'unavailable' } })
140
+ } finally { this.containing.delete(tab.id) }
141
+ }
142
+ async event(source, method, params = {}) {
143
+ const lease = this.tabLeases.get(source.tabId)
144
+ if (!lease) return
145
+ if (method === 'Page.javascriptDialogOpening') {
146
+ try {
147
+ await this.api.debugger.sendCommand(source, 'Page.handleJavaScriptDialog', { accept: false })
148
+ lease.notices.push(`Quiet mode dismissed JavaScript ${params.type ?? 'dialog'}: ${String(params.message ?? '').slice(0, EXTENSION_LIMITS.dialogPreview)}`)
149
+ } catch {
150
+ const msg = 'Quiet mode could not dismiss a JavaScript dialog; human action may be required.'
151
+ lease.notices.push(msg)
152
+ lease.blockingNotices.push(msg)
153
+ lease.blockingNotices = lease.blockingNotices.slice(-EXTENSION_LIMITS.notices)
154
+ }
155
+ lease.notices = lease.notices.slice(-EXTENSION_LIMITS.notices)
156
+ }
157
+ if (method === 'Page.fileChooserOpened') {
158
+ const msg = 'Quiet mode blocked a file chooser; file uploads are unavailable.'
159
+ lease.notices.push(msg)
160
+ lease.blockingNotices.push(msg)
161
+ lease.notices = lease.notices.slice(-EXTENSION_LIMITS.notices)
162
+ lease.blockingNotices = lease.blockingNotices.slice(-EXTENSION_LIMITS.notices)
163
+ }
164
+ if (method.startsWith('Network.')) {
165
+ params = JSON.parse(JSON.stringify(params))
166
+ for (const headers of [params.headers, params.request?.headers, params.response?.headers]) {
167
+ if (headers) for (const key of Object.keys(headers)) if (/^(authorization|proxy-authorization|cookie|set-cookie)$/i.test(key)) headers[key] = '[redacted]'
168
+ }
169
+ }
170
+ const event = { type: 'event', lease: lease.id, method, params, ...(source.sessionId ? { sessionId: source.sessionId } : {}) }
171
+ if (new TextEncoder().encode(JSON.stringify(event)).length <= EXTENSION_LIMITS.eventBytes) this.emit(event)
172
+ }
173
+ async attach(tabId, scope, view) {
174
+ if (!Number.isInteger(tabId) || tabId < 0 || !validScope(scope) || !validScope(view)) throw Error('invalid tab lease')
175
+ if (this.tabLeases.has(tabId) || this.attaching.has(tabId)) throw Error('tab is already leased; release it before adoption')
176
+ if (this.created.has(tabId) && this.created.get(tabId) !== scope) throw Error('tab belongs to another session')
177
+ this.attaching.add(tabId)
178
+ const generation = this.generation
179
+ try {
180
+ const tab = await this.api.tabs.get(tabId)
181
+ const url = tab.url || tab.pendingUrl || (this.created.get(tabId) === scope ? 'about:blank' : undefined)
182
+ if (tab.incognito || !allowedUrl(url) || !allowedUrl(tab.pendingUrl || url)) throw Error('restricted/internal, extension and incognito pages are unavailable')
183
+ const lease = { id: crypto.randomUUID(), tabId, scope, view, notices: [], blockingNotices: [] }
184
+ this.leases.set(lease.id, lease); this.tabLeases.set(tabId, lease)
185
+ try {
186
+ await this.activate(lease)
187
+ if (generation !== this.generation || !this.leases.has(lease.id)) throw Error('connection released')
188
+ return { lease: lease.id, tabId, url, title: tab.title ?? '', created: this.created.get(tabId) === scope }
189
+ } catch {
190
+ this.leases.delete(lease.id); this.tabLeases.delete(tabId)
191
+ if (this.active === tabId) await this.suspend()
192
+ throw Error('quiet-mode interception is unavailable on this browser/tab; no control lease was granted')
193
+ }
194
+ } finally { this.attaching.delete(tabId) }
195
+ }
196
+ request(operation) {
197
+ const generation = this.generation
198
+ return this.enqueue(async () => {
199
+ if (generation !== this.generation) throw Error('connection released')
200
+ try { return await this.perform(operation) }
201
+ finally {
202
+ if (this.active !== undefined) {
203
+ this.idleAt = Date.now() + DEBUGGER_IDLE_TIMEOUT_MS
204
+ await this.api.alarms?.create(DEBUGGER_IDLE_ALARM, { when: this.idleAt })
205
+ }
206
+ await this.persist()
207
+ }
208
+ })
209
+ }
210
+ async perform(operation) {
211
+ if (!operation || typeof operation !== 'object' || !validScope(operation.scope)) throw Error('a scoped operation is required')
212
+ const { kind, scope } = operation
213
+ if (kind === 'create') {
214
+ if (!validScope(operation.view)) throw Error('view identity is required')
215
+ const generation = this.generation
216
+ const windows = await this.api.windows.getAll({ windowTypes: ['normal'] })
217
+ const window = windows.find(value => !value.incognito && Number.isInteger(value.id))
218
+ if (!window) throw Error('open a normal browser window first; quiet mode never creates a window')
219
+ const tab = await this.api.tabs.create({ windowId: window.id, active: false, url: 'about:blank' })
220
+ this.created.set(tab.id, scope)
221
+ if (generation !== this.generation) throw Error('connection released during creation; inactive tab was left open')
222
+ try { return await this.attach(tab.id, scope, operation.view) }
223
+ catch (error) { throw Error(`${error.message}; the inactive agent tab was left open (id ${tab.id})`) }
224
+ }
225
+ if (kind === 'list') {
226
+ const tabs = await this.api.tabs.query({})
227
+ return tabs.filter(tab => !tab.incognito && allowedUrl(tab.url) && !this.tabLeases.has(tab.id) && (!this.created.has(tab.id) || this.created.get(tab.id) === scope))
228
+ .slice(0, 256).map(tab => ({ tabId: tab.id, title: tab.title ?? '', url: tab.url, created: this.created.get(tab.id) === scope }))
229
+ }
230
+ if (kind === 'attach') return this.attach(operation.tabId, scope, operation.view)
231
+ if (kind === 'close') {
232
+ if (!Number.isInteger(operation.tabId) || this.created.get(operation.tabId) !== scope) throw Error('personal, adopted or other-session tabs are detach-only')
233
+ if (this.active === operation.tabId) await this.suspend()
234
+ await this.api.tabs.remove(operation.tabId)
235
+ const lease = this.tabLeases.get(operation.tabId)
236
+ if (lease) this.leases.delete(lease.id)
237
+ this.tabLeases.delete(operation.tabId)
238
+ this.created.delete(operation.tabId)
239
+ return {}
240
+ }
241
+ const lease = this.leases.get(operation.lease)
242
+ if (kind === 'detach' && !lease) return {}
243
+ if (!lease || lease.scope !== scope || lease.view !== operation.view) throw Error('stale or foreign tab lease; explicitly reacquire the tab')
244
+ if (kind === 'detach') {
245
+ this.leases.delete(lease.id); this.tabLeases.delete(lease.tabId)
246
+ if (this.active === lease.tabId) await this.suspend()
247
+ return {}
248
+ }
249
+ if (kind === 'events') return lease.notices.splice(0)
250
+ if (kind !== 'cdp') throw Error('unsupported extension operation')
251
+ if (lease.blockingNotices?.length) throw Error(lease.blockingNotices.shift())
252
+ let { method, params = {}, sessionId } = operation
253
+ if (typeof method !== 'string' || !DOMAINS.has(method.split('.')[0]) || DENIED.has(method)
254
+ || /Cookies|Cookie/.test(method) || method.startsWith('Input.') && !method.startsWith('Input.dispatch') && method !== 'Input.insertText'
255
+ || sessionId !== undefined && (typeof sessionId !== 'string' || sessionId.length > 128)
256
+ || !params || typeof params !== 'object' || Array.isArray(params)) throw Error('CDP capability is unavailable in personal-browser quiet mode')
257
+ if (method === 'Page.navigate' && !allowedUrl(params.url)) throw Error('navigation requires an http(s) URL')
258
+ await this.activate(lease)
259
+ if (!this.leases.has(lease.id)) throw Error('tab detached during request')
260
+ if (method === 'Input.insertText') {
261
+ for (const text of String(params.text ?? '')) {
262
+ await this.api.debugger.sendCommand({ tabId: lease.tabId, ...(sessionId ? { sessionId } : {}) }, 'Input.dispatchKeyEvent', { type: 'char', text })
263
+ }
264
+ return {}
265
+ }
266
+ if (method === 'Page.captureScreenshot') {
267
+ if (!params.clip) {
268
+ const metrics = await this.api.debugger.sendCommand({ tabId: lease.tabId, ...(sessionId ? { sessionId } : {}) }, 'Page.getLayoutMetrics', {})
269
+ const viewport = metrics.cssVisualViewport ?? metrics.visualViewport
270
+ const width = viewport?.clientWidth ?? EXTENSION_LIMITS.screenshotWidth, height = viewport?.clientHeight ?? EXTENSION_LIMITS.screenshotHeight
271
+ params = { ...params, clip: { x: viewport?.pageX ?? 0, y: viewport?.pageY ?? 0, width, height, scale: Math.min(1, EXTENSION_LIMITS.screenshotWidth / width, EXTENSION_LIMITS.screenshotHeight / height) } }
272
+ }
273
+ if (params.captureBeyondViewport === true || params.fromSurface === false || params.clip && (
274
+ !Number.isFinite(params.clip.width) || !Number.isFinite(params.clip.height) || !Number.isFinite(params.clip.scale)
275
+ || params.clip.width <= 0 || params.clip.height <= 0 || !Number.isFinite(params.clip.x) || !Number.isFinite(params.clip.y)
276
+ || params.clip.width * params.clip.scale > EXTENSION_LIMITS.screenshotWidth || params.clip.height * params.clip.scale > EXTENSION_LIMITS.screenshotHeight || params.clip.scale <= 0)) throw Error('screenshot exceeds quiet-mode dimensions')
277
+ params = { ...params, fromSurface: true, captureBeyondViewport: false }
278
+ }
279
+ return this.api.debugger.sendCommand({ tabId: lease.tabId, ...(sessionId ? { sessionId } : {}) }, method, params)
280
+ }
281
+ release() {
282
+ this.generation++
283
+ const interrupt = this.ready.then(() => this.suspend())
284
+ interrupt.catch(() => {})
285
+ return this.enqueue(async () => {
286
+ await interrupt.catch(() => {})
287
+ await this.suspend()
288
+ this.related.clear()
289
+ this.leases.clear(); this.tabLeases.clear()
290
+ await this.persist()
291
+ })
292
+ }
293
+ }
@@ -0,0 +1,15 @@
1
+ export const en = {
2
+ title: 'DSH Browser Bridge status',
3
+ heading: 'DSH Browser Bridge',
4
+ consent: 'This explicitly grants DSH control of tabs in this browser profile. Browser debugging warnings remain visible. No extension popup or automatic window activation is used.',
5
+ automatic: 'DSH registers the native host automatically. This extension connects automatically; no token or configuration is needed.',
6
+ disconnect: 'Disconnect',
7
+ pause: 'Disconnect leaves all tabs open and pauses reconnects. Remove and add the extension again to resume. The native-host --revoke command disables access persistently, including across plugin restarts.',
8
+ quiet: 'Quiet-mode limits: the normal debugger infobar cannot be hidden; browser/OS permission prompts, website-initiated downloads and page-created windows cannot be guaranteed invisible. File choosers are intercepted on attached tabs. Never use this mode when absolutely no browser-owned UI is acceptable.',
9
+ identity: 'Extension ID: {id}',
10
+ accepted: 'Request accepted. Refreshing connection status…',
11
+ unavailable: 'Extension worker unavailable.',
12
+ disconnected: 'Native host is disconnected.',
13
+ reconnect: 'Native host disconnected or is not installed. Reconnect after installing.',
14
+ debuggerCanceled: 'Debugging was canceled. The detached tab requires an explicit new request to reacquire it.',
15
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "manifest_version": 3,
3
+ "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1hDzFuWdQi+Tu5v9275Mqd8Ql6F/Kgl72RyLiX6hTh1/TU89i/0pX5DK9L6NFZAuTTrAXWaP86gKJO/XUvDr+cTI0fJ4lpKn6EGTK75/r1g2m23LGPgNQZRwVM6xnx4t5qaKvgrW7F+E7xUwtO6NkzDNsh3Lw6piDzVuN8MhWxAkwCKxQ3S4PFQA4U/yD+knEq6rQk/7MILe+rrZ1SgMOMuxm01I0Dgbkowvu/LHRkQnrNTMAhQW0VRjb8c1947HTwc5t4inN4fIFY3Vl8RMZSH4FbaSir7CwZZrpC8yjSlnRuGHDBXXnVSWe6Qw/ZhNGQqdgXH+vuiqrMYTyQFUEwIDAQAB",
4
+ "name": "DSH Browser Bridge",
5
+ "version": "0.1.0",
6
+ "description": "Explicitly pair DSH with this Edge or Chrome profile. Browser debugging warnings remain visible.",
7
+ "minimum_chrome_version": "125",
8
+ "permissions": ["debugger", "tabs", "storage", "nativeMessaging", "alarms"],
9
+ "background": { "service_worker": "worker.mjs", "type": "module" },
10
+ "options_page": "options.html",
11
+ "incognito": "not_allowed"
12
+ }
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title data-message="title"></title></head>
4
+ <body>
5
+ <h1 data-message="heading"></h1>
6
+ <p data-message="consent"></p>
7
+ <p data-message="automatic"></p>
8
+ <p id="identity"></p><pre id="status" role="status"></pre>
9
+ <p><button id="disconnect" type="button" data-message="disconnect"></button></p>
10
+ <p data-message="pause"></p>
11
+ <p data-message="quiet"></p>
12
+ <script type="module" src="options.mjs"></script>
13
+ </body>
14
+ </html>
@@ -0,0 +1,9 @@
1
+ import { en } from './locales.mjs'
2
+
3
+ for (const element of document.querySelectorAll('[data-message]')) element.textContent = en[element.dataset.message]
4
+ const status = document.getElementById('status')
5
+ document.getElementById('identity').textContent = en.identity.replace('{id}', chrome.runtime.id)
6
+ const show = value => { status.textContent = value.error ?? value.detail ?? (value.ok ? en.accepted : JSON.stringify(value)) }
7
+ async function request(message) { try { show(await chrome.runtime.sendMessage(message)) } catch { show({ error: en.unavailable }) } }
8
+ document.getElementById('disconnect').addEventListener('click', () => { void request({ type: 'disconnect' }) })
9
+ void request({ type: 'status' })
@@ -0,0 +1,13 @@
1
+ export const permissionGuard = `(()=>{
2
+ const denied=()=>Promise.reject(new DOMException('Permission request denied in DSH agent tab','NotAllowedError'));
3
+ const replace=(object,key,value)=>{try{if(object&&typeof object[key]==='function')Object.defineProperty(object,key,{value,configurable:true,writable:true})}catch{}};
4
+ replace(globalThis.Notification,'requestPermission',callback=>{if(typeof callback==='function')queueMicrotask(()=>callback('denied'));return Promise.resolve('denied')});
5
+ for(const [object,keys] of [
6
+ [navigator.mediaDevices,['getUserMedia','getDisplayMedia']],
7
+ [navigator.clipboard,['read','readText','write','writeText']],
8
+ [navigator.bluetooth,['requestDevice']], [navigator.usb,['requestDevice']],
9
+ [navigator.hid,['requestDevice']], [navigator.serial,['requestPort']],
10
+ [globalThis,['showOpenFilePicker','showSaveFilePicker','showDirectoryPicker']]
11
+ ])for(const key of keys)replace(object,key,denied);
12
+ for(const key of ['getCurrentPosition','watchPosition'])replace(navigator.geolocation,key,(_success,error)=>{if(typeof error==='function')queueMicrotask(()=>error({code:1,message:'Permission denied in DSH agent tab',PERMISSION_DENIED:1}));return -1});
13
+ })()`
@@ -0,0 +1,74 @@
1
+ import { nativeHostName, MAX_MESSAGE, CHUNK_BYTES, MAX_IN_FLIGHT, MAX_ERROR_LENGTH, RECONNECT_ALARM, RECONNECT_DELAY_MINUTES } from './constants.mjs'
2
+ import { ExtensionController } from './controller.mjs'
3
+ import { en } from './locales.mjs'
4
+
5
+ const browser = /Edg\//.test(navigator.userAgent) ? 'edge' : 'chrome'
6
+ let port, connecting, inFlight = 0, reconnectAllowed = true
7
+ let status = { state: 'extension-missing', detail: en.disconnected }
8
+ const controller = new ExtensionController(chrome, event => { try { port?.postMessage(event) } catch {} })
9
+
10
+ async function connect() {
11
+ if (port) return
12
+ connecting ??= (async () => {
13
+ await controller.ready
14
+ const stored = await chrome.storage.local.get('installId')
15
+ const installId = stored.installId ?? crypto.randomUUID()
16
+ if (!stored.installId) await chrome.storage.local.set({ installId })
17
+ const native = chrome.runtime.connectNative(nativeHostName(browser))
18
+ port = native
19
+ native.onMessage.addListener(message => {
20
+ if (native !== port) return
21
+ if (message.type === 'status') status = { state: message.state, detail: message.detail }
22
+ else if (message.type === 'release') void controller.release().catch(() => {})
23
+ else if (message.type === 'request') {
24
+ if (inFlight >= MAX_IN_FLIGHT) { native.postMessage({ type: 'result', id: message.id, error: 'extension concurrency limit' }); return }
25
+ inFlight++
26
+ void controller.request(message.operation).then(
27
+ value => respond(native, { type: 'result', id: message.id, value }),
28
+ error => respond(native, { type: 'result', id: message.id, error: String(error.message ?? error).slice(0, MAX_ERROR_LENGTH) }),
29
+ ).catch(() => native.disconnect()).finally(() => { inFlight-- })
30
+ }
31
+ })
32
+ native.onDisconnect.addListener(() => {
33
+ void chrome.runtime.lastError
34
+ if (native !== port) return
35
+ port = undefined
36
+ status = { state: 'extension-missing', detail: en.reconnect }
37
+ void controller.release().catch(() => {})
38
+ if (reconnectAllowed) void chrome.alarms.create(RECONNECT_ALARM, { delayInMinutes: RECONNECT_DELAY_MINUTES })
39
+ })
40
+ native.postMessage({ type: 'hello', installId, browser })
41
+ })().finally(() => { connecting = undefined })
42
+ return connecting
43
+ }
44
+
45
+ function respond(native, value) {
46
+ if (native !== port) return
47
+ let text = JSON.stringify(value)
48
+ if (new TextEncoder().encode(text).length > MAX_MESSAGE) text = JSON.stringify({ type: 'result', id: value.id, error: 'extension response exceeds 8 MiB limit' })
49
+ const total = Math.ceil(text.length / CHUNK_BYTES)
50
+ for (let index = 0; index < total; index++) native.postMessage({ type: 'chunk', id: value.id, index, total, data: text.slice(index * CHUNK_BYTES, (index + 1) * CHUNK_BYTES) })
51
+ }
52
+
53
+ chrome.runtime.onMessage.addListener((message, sender, reply) => {
54
+ if (sender.id !== chrome.runtime.id || sender.url !== chrome.runtime.getURL('options.html')) return false
55
+ void (async () => {
56
+ if (message.type === 'status') return { ...status, browser, extensionId: chrome.runtime.id }
57
+ if (message.type === 'disconnect') {
58
+ reconnectAllowed = false; await chrome.storage.local.set({ paused: true }); await chrome.alarms.clear(RECONNECT_ALARM)
59
+ port?.disconnect(); return { ok: true }
60
+ }
61
+ throw Error('unsupported options request')
62
+ })().then(reply, error => reply({ ok: false, error: String(error.message ?? error) }))
63
+ return true
64
+ })
65
+ chrome.debugger.onDetach.addListener((_source, reason) => {
66
+ if (reason === 'canceled_by_user') {
67
+ status = { ...status, detail: en.debuggerCanceled }
68
+ }
69
+ })
70
+ chrome.alarms.onAlarm.addListener(alarm => { if (alarm.name === RECONNECT_ALARM && reconnectAllowed) void connect().catch(() => {}) })
71
+ const autoConnect = () => chrome.storage.local.get('paused').then(({ paused }) => { reconnectAllowed = !paused; if (reconnectAllowed) return connect() }).catch(() => {})
72
+ chrome.runtime.onInstalled.addListener(() => { void autoConnect() })
73
+ chrome.runtime.onStartup.addListener(() => { void autoConnect() })
74
+ void autoConnect()
package/cordis.patch.yml CHANGED
@@ -1,32 +1,22 @@
1
- # dsh-builtin-browser bundle patch: mounts the shared-browser capability into a
2
- # profile composition.
1
+ # dsh-builtin-browser —— 一份包、一次安装装齐全部能力,不改 DSH 本体。
3
2
  #
4
- # Row names matter beyond loading: the host's client-module scan resolves a row's
5
- # specifier to a PACKAGE ROOT and reads `dsh.client` from there. A row named after
6
- # a subpath (`dsh-builtin-browser/browser`) is not a package specifier and is
7
- # skipped by design, which would leave the settings panel permanently absent even
8
- # though every tool works — hence the inert root row under the bare package name.
3
+ # 这份文件由包清单的 `dsh.bundle.patch` 声明:DSH 的插件管理器在安装时读它并把行挂进用户
4
+ # 的 profile,所以用户装完即可用,不需要手工改任何设置。
9
5
  #
10
- # The browser seam (ctx.browser) is always mounted, and the Electron provider plus
11
- # the dsh_browser_* tools are always registered. The CARRIER is chosen at run time:
6
+ # 行名必须与包的真实子路径一致;客户端半由**根行**承载——宿主把行的 specifier 解析到包根后
7
+ # 读 `dsh.client`,因此 `dsh-builtin-browser` 这条根行(惰性)同时是客户端半的入口。
12
8
  #
13
- # 1. a browser the user selected in settings (their installed Chrome / Edge),
14
- # launched with a plugin-owned profile;
15
- # 2. the desktop shell's sidebar, driven over its loopback bridge — the agent
16
- # then works on the same page the human is looking at;
17
- # 3. a self-hosted Electron window, which is what every surface without either
18
- # of the above gets; installing the plugin is enough for the browser to work.
19
- #
20
- # DSH 0.2 no longer provides `electronViewHost` (the desktop shell's embedded view),
21
- # so the row below resolves to undefined on current hosts. It keeps reading the
22
- # seam on purpose: a host that reintroduces one is then picked up without a code
23
- # change, and an explicit `viewHost` always outranks the automatic choice.
9
+ # 这里刻意不写 `!!js` 之类自定义标签:bundle patch 由装配器按固定 schema 解析,
10
+ # 只保留 patch 操作本身,取值走各行自己的配置默认值。
11
+
12
+ # 1) 让位:DSH 自带(`dsh-web-app` bundle)的侧栏浏览器行 `ui-sidebar-browser` 与本包的同名能力
13
+ # 争同一个标签类型,而 builtin 优先级更高——桌面端实测显示的是**上游那套面板**(没有起始页、
14
+ # 没有本包的设置分节),表现为「快捷访问没了」。关掉它,由本包的客户端半提供面板。
15
+ - id: ui-sidebar-browser
16
+ disabled: true
17
+
18
+ # 2) 本包的行。
24
19
  - insert:
25
- # Root row. The host's client-module scan resolves a loader row's specifier
26
- # to a PACKAGE ROOT; a row named after a subpath is skipped, and this package
27
- # would then have no row to read its `dsh.client` declaration from — the
28
- # browser would work while its settings panel never appeared. This row is
29
- # inert (see src/index.ts) and exists only to name the package.
30
20
  - id: dsh-builtin-browser
31
21
  name: dsh-builtin-browser
32
22
 
@@ -35,29 +25,14 @@
35
25
 
36
26
  - id: browser-electron
37
27
  name: dsh-builtin-browser/browser-electron
38
- config:
39
- viewHost: !!js ctx.get('electronViewHost')
40
28
 
41
29
  - id: tool-browser
42
30
  name: dsh-builtin-browser/tool-browser
43
- # The tool layer's own switches. The `config` key is what makes them reachable at all:
44
- # without it nothing at the plugin level could set them, so the operator allow-list the
45
- # READMEs describe was unreachable in every factory deployment.
46
- #
47
- # Every field is optional, so an empty mapping uses the defaults:
48
- #
49
- # allowedActions: operator-level allow-list of browser tool names, applied to every
50
- # task in the deployment (a task can still narrow it further with dsh_browser_restrict).
51
- # READ_ONLY_TOOLS and dsh_browser_restrict are never blocked, whatever the list says.
52
- # timeoutMs: cooperative per-call budget in ms (default 60000).
53
- # tabTools: whether the tab-management tools are registered (default true).
54
- #
55
- # To restrict a deployment, replace this with, for example:
56
- # config:
57
- # allowedActions: [dsh_browser_snapshot, dsh_browser_a11y, dsh_browser_content, dsh_browser_click]
58
- #
59
- # The settings panel's "What the agent may do" switches are a SEPARATE layer with the
60
- # same property — the model cannot lift them either — and they need no patch file at
61
- # all. The list above restricts every task in a deployment; those three switches
62
- # restrict what any task may do on this installation, and need no YAML.
63
- config: {}
31
+
32
+ # 起始页的宿主伴生条目:注册 `browser-startpage` 设置分节(快捷方式与搜索引擎)。
33
+ # 没有它,起始页读不到快捷方式列表(`startpage-shortcuts.ts` 会抛
34
+ # `the "browser-startpage" settings entry is not loaded in this profile`),
35
+ # 面板就退化成「输入 HTTP(S) 地址开始浏览」的空态——桌面端实测过这个现象。
36
+ # 由本包提供(`./startpage` 出口):不依赖上游导出,装到哪都能用。
37
+ - id: browser-startpage
38
+ name: dsh-builtin-browser/startpage
@@ -0,0 +1,2 @@
1
+ export function registeredInstallLocations(platform?: string, query?: typeof import('node:child_process').execFileSync): readonly string[]
2
+ export function conventionalInstallRoots(platform?: string, home?: string): readonly string[]
@@ -0,0 +1,36 @@
1
+ import { execFileSync } from 'node:child_process'
2
+ import { homedir } from 'node:os'
3
+ import { join } from 'node:path'
4
+
5
+ export function registeredInstallLocations(platform = process.platform, query = execFileSync) {
6
+ if (platform !== 'win32') return []
7
+ const roots = [
8
+ 'HKCU\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
9
+ 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
10
+ 'HKLM\\SOFTWARE\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
11
+ ]
12
+ const locations = []
13
+ for (const root of roots) {
14
+ try {
15
+ const output = query('reg', ['query', root, '/s', '/f', 'DeepSeek Harness', '/t', 'REG_SZ'],
16
+ { encoding: 'utf8', stdio: 'pipe', timeout: 15_000, windowsHide: true })
17
+ for (const line of output.split(/\r?\n/)) {
18
+ const match = /^\s+InstallLocation\s+REG_SZ\s+(.+?)\s*$/.exec(line)
19
+ if (match !== null && match[1] !== '') locations.push(match[1])
20
+ }
21
+ } catch {}
22
+ }
23
+ return locations
24
+ }
25
+
26
+ export function conventionalInstallRoots(platform = process.platform, home = homedir()) {
27
+ if (platform === 'darwin') {
28
+ return ['/Applications', ...home === '' ? [] : [join(home, 'Applications')]]
29
+ .flatMap(base => ['DeepSeek Harness.app', 'DSH Desktop.app'].map(name => join(base, name)))
30
+ }
31
+ if (platform === 'linux') {
32
+ return ['/opt', '/usr/lib', ...home === '' ? [] : [join(home, '.local', 'share')]]
33
+ .flatMap(base => ['DeepSeek Harness', 'DSH Desktop'].map(name => join(base, name)))
34
+ }
35
+ return []
36
+ }
@@ -5,5 +5,21 @@
5
5
  "dsh-desktop"
6
6
  ],
7
7
  "mainEntry": "lib/main.js",
8
- "_layoutNote": "resources/app.asar wins over resources/app whenever it exists, so identity is read from the archive in that case and never from the sibling extraction, which the updater leaves behind and which may be a different build."
8
+ "_layoutNote": "resources/app.asar wins over resources/app whenever it exists, so identity is read from the archive in that case and never from the sibling extraction, which the updater leaves behind and which may be a different build.",
9
+ "layouts": [
10
+ {
11
+ "name": "macos-bundle",
12
+ "marker": "Contents/Info.plist",
13
+ "resources": "Contents/Resources",
14
+ "executable": "Contents/MacOS/DeepSeek Harness",
15
+ "cliLauncher": "runtime/cli/bin/dsh"
16
+ },
17
+ {
18
+ "name": "directory",
19
+ "resources": "resources",
20
+ "executable": "DeepSeek Harness.exe",
21
+ "cliLauncher": "runtime/cli/bin/dsh.cmd"
22
+ }
23
+ ],
24
+ "_layoutsNote": "Where an install keeps its resources and executable. The first layout whose marker exists under the install root applies; the last one has no marker and is the default. A macOS .app bundle keeps resources in Contents/Resources; Windows keeps them in resources/ beside the .exe."
9
25
  }
@@ -0,0 +1 @@
1
+ export function isDesktopExecutable(path: unknown, executable: string, bundleRoot?: string, platform?: string): boolean
@@ -0,0 +1,15 @@
1
+ import { realpathSync } from 'node:fs'
2
+ import { isAbsolute, relative, resolve, sep } from 'node:path'
3
+
4
+ export function isDesktopExecutable(path, executable, bundleRoot, platform = process.platform) {
5
+ if (typeof path !== 'string' || !isAbsolute(path)) return false
6
+ const canonical = value => {
7
+ if (platform === 'win32') return resolve(value).toLowerCase()
8
+ try { return realpathSync.native(value) } catch { return resolve(value) }
9
+ }
10
+ const candidate = canonical(path)
11
+ if (candidate === canonical(executable)) return true
12
+ if (bundleRoot === undefined) return false
13
+ const part = relative(canonical(bundleRoot), candidate)
14
+ return part !== '' && !isAbsolute(part) && part !== '..' && !part.startsWith('..' + sep)
15
+ }