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,262 +0,0 @@
1
- /**
2
- * Explicit lifecycle protocol for one Sidebar Browser initialization.
3
- *
4
- * Issue #55 reported a single symptom — "produced no page" — for several very
5
- * different failures: no tab, no Controller, a Controller that never consumed
6
- * the URL, and a guest that never attached. Collapsing them into one message
7
- * made the failure unrecoverable and undiagnosable.
8
- *
9
- * This journal keeps the exact `(session, tab, occurrence, navigation revision)`
10
- * a request was aimed at, the stage it reached, and — on failure — the stage
11
- * plus the raw reason. It is deliberately carrier-neutral: the Controller and
12
- * the Electron/iframe frame both advance it, and tests drive it directly.
13
- *
14
- * Stages:
15
- * - `accepted`: the navigation record was written for THIS occurrence/revision.
16
- * - `mounted`: the Controller for that occurrence exists.
17
- * - `navigating`: the Controller handed the URL to its frame (URL consumed).
18
- * - `attached`: the guest/iframe document is ready.
19
- * - `failed`: carries the stage transition that failed and why.
20
- *
21
- * @module dsh-client-ui-sidebar-browser/browser/initialization
22
- */
23
- import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit'
24
-
25
- /** How far one initialization got. */
26
- export type BrowserInitStage = 'accepted' | 'mounted' | 'navigating' | 'attached' | 'failed'
27
-
28
- /** Machine reason carried by a failed receipt; the UI localizes it. */
29
- export type BrowserInitFailure =
30
- | 'occurrence-aborted'
31
- | 'controller-missing'
32
- | 'workspace-unavailable'
33
- | 'acquire-failed'
34
- | 'guest-bootstrap-failed'
35
- | 'navigation-failed'
36
- | 'navigation-rejected'
37
- | 'timeout'
38
-
39
- /** One immutable observation of an initialization attempt. */
40
- export interface BrowserInitReceipt {
41
- readonly generation?: string
42
- readonly frameId?: string
43
- readonly loaderId?: string
44
- readonly requestId: string
45
- readonly sessionId: string
46
- readonly tabId: TabId
47
- /** Distinguishes a reopened tab from its previous lifetime. */
48
- readonly occurrenceId: string
49
- /** The navigation record this request was aimed at. */
50
- readonly navigationRevision: number
51
- readonly url: string
52
- readonly stage: BrowserInitStage
53
- /** Present once the carrier reports an attached guest/document. */
54
- readonly guestId?: string
55
- /** Present only when `stage === 'failed'`. */
56
- readonly reason?: BrowserInitFailure
57
- /** Original carrier failure text, when the failed stage supplied it. */
58
- readonly detail?: string
59
- /** Epoch milliseconds; diagnostic only, never used for ordering. */
60
- readonly at: number
61
- }
62
-
63
- /** Identity half of a receipt, supplied when a request starts. */
64
- export interface BrowserInitRequest {
65
- readonly requestId?: string
66
- readonly sessionId: string
67
- readonly tabId: TabId
68
- readonly occurrenceId: string
69
- readonly navigationRevision: number
70
- readonly url: string
71
- }
72
-
73
- /** A stage transition may carry the guest id observed by the carrier. */
74
- export interface BrowserInitPatch {
75
- readonly generation?: string
76
- readonly frameId?: string
77
- readonly loaderId?: string
78
- readonly detail?: string
79
- readonly guestId?: string
80
- readonly navigationRevision?: number
81
- readonly url?: string
82
- }
83
-
84
- export interface BrowserInitializationJournal {
85
- /** Start (or restart) the request for one tab; a dead occurrence fails immediately. */
86
- begin(request: BrowserInitRequest, options?: { readonly aborted?: boolean }): BrowserInitReceipt
87
- /** Advance a live request; a request that already failed is not revived. */
88
- advance(tabId: TabId, stage: Exclude<BrowserInitStage, 'failed'>, patch?: BrowserInitPatch): BrowserInitReceipt | undefined
89
- /** Fail a live request with a machine reason, preserving its last reached stage. */
90
- fail(tabId: TabId, reason: BrowserInitFailure, patch?: BrowserInitPatch): BrowserInitReceipt | undefined
91
- get(tabId: TabId): BrowserInitReceipt | undefined
92
- /** Newest first, bounded: this is a diagnostic ring, not a durable log. */
93
- all(): readonly BrowserInitReceipt[]
94
- forget(tabId: TabId): void
95
- dispose(): void
96
- }
97
-
98
- /** Ready document observed in the live frame, independent of its last requested URL. */
99
- export interface BrowserObservedPage {
100
- readonly generation?: string
101
- readonly frameId?: string
102
- readonly loaderId?: string
103
- readonly url: string
104
- readonly guestId?: string
105
- }
106
-
107
- export interface BrowserInitializationReader {
108
- readonly protocolVersion: 1
109
- navigate?(query: { readonly sessionId: string; readonly tabId: TabId; readonly url: string }): boolean
110
- current(query: { readonly sessionId: string; readonly tabId: TabId }): BrowserObservedPage | undefined
111
- read(query: { readonly sessionId: string; readonly tabId: TabId; readonly url: string; readonly requestId?: string; readonly afterRequestId?: string }): BrowserInitReceipt | undefined
112
- wait(query: { readonly sessionId: string; readonly tabId: TabId; readonly url: string; readonly requestId?: string; readonly afterRequestId?: string }, signal: AbortSignal): Promise<BrowserInitReceipt>
113
- }
114
-
115
- /** Scope reads to a Session/tab and the requested document before exposing a receipt. */
116
- export function createBrowserInitializationReader(
117
- lookup: (sessionId: string, tabId: TabId) => BrowserInitReceipt | undefined,
118
- subscribe?: (listener: () => void) => () => void,
119
- observe?: (sessionId: string, tabId: TabId) => BrowserObservedPage | undefined,
120
- navigate?: (sessionId: string, tabId: TabId, url: string) => boolean,
121
- ): BrowserInitializationReader {
122
- const canonical = (value: string): string => {
123
- try { return new URL(value).href } catch { return value }
124
- }
125
- const reader: BrowserInitializationReader = {
126
- protocolVersion: 1,
127
- ...(navigate === undefined ? {} : { navigate: (query: { readonly sessionId: string; readonly tabId: TabId; readonly url: string }) => navigate(query.sessionId, query.tabId, query.url) }),
128
- current: query => observe?.(query.sessionId, query.tabId),
129
- read(query) {
130
- const receipt = lookup(query.sessionId, query.tabId)
131
- if (receipt?.sessionId !== query.sessionId || receipt.tabId !== query.tabId
132
- || canonical(receipt.url) !== canonical(query.url)
133
- || (query.requestId !== undefined && receipt.requestId !== query.requestId)
134
- || receipt.requestId === query.afterRequestId) return undefined
135
- return receipt
136
- },
137
- wait(query, signal) {
138
- if (subscribe === undefined) return Promise.reject(new Error('initialization subscriptions unavailable'))
139
- return new Promise((resolve, reject) => {
140
- let done = false
141
- let requestId = query.requestId
142
- let unsubscribe = (): void => {}
143
- const finish = (error?: Error, receipt?: BrowserInitReceipt): void => {
144
- if (done) return
145
- done = true
146
- unsubscribe()
147
- signal.removeEventListener('abort', abort)
148
- if (error !== undefined) reject(error)
149
- else resolve(receipt!)
150
- }
151
- const abort = (): void => finish(signal.reason ?? new Error('source initialization aborted'))
152
- const check = (): void => {
153
- if (signal.aborted) { abort(); return }
154
- const latest = lookup(query.sessionId, query.tabId)
155
- if (requestId !== undefined && latest !== undefined && latest.requestId !== requestId) {
156
- finish(Object.assign(new Error('source initialization superseded'), { code: 'panel-navigation-superseded' }))
157
- return
158
- }
159
- const receipt = reader.read(query)
160
- if (receipt !== undefined) requestId ??= receipt.requestId
161
- if (receipt?.stage === 'failed') {
162
- const code = receipt.reason === 'timeout' ? 'BROWSER_DOCUMENT_TIMEOUT'
163
- : receipt.reason === 'occurrence-aborted' ? 'BROWSER_NAVIGATION_CANCELLED'
164
- : receipt.reason === 'navigation-failed' || receipt.reason === 'navigation-rejected' ? 'BROWSER_NAVIGATION_FAILED'
165
- : 'panel-initialization-failed'
166
- finish(Object.assign(new Error(receipt.detail ?? receipt.reason ?? 'source initialization failed'), { code }))
167
- }
168
- else if (receipt?.stage === 'attached') finish(undefined, receipt)
169
- }
170
- unsubscribe = subscribe(check)
171
- if (done) { unsubscribe(); return }
172
- signal.addEventListener('abort', abort, { once: true })
173
- check()
174
- })
175
- },
176
- }
177
- return reader
178
- }
179
-
180
- const HISTORY_LIMIT = 200
181
-
182
- /**
183
- * Build a journal. `now` is injectable so tests get stable receipts.
184
- * @param options - clock and history bound.
185
- * @returns the journal.
186
- */
187
- export function createBrowserInitializationJournal(
188
- options: { readonly now?: () => number; readonly historyLimit?: number; readonly onChange?: () => void } = {},
189
- ): BrowserInitializationJournal {
190
- const now = options.now ?? (() => Date.now())
191
- const limit = options.historyLimit ?? HISTORY_LIMIT
192
- const latest = new Map<TabId, BrowserInitReceipt>()
193
- let history: BrowserInitReceipt[] = []
194
- let serial = 0
195
- let disposed = false
196
-
197
- const publish = (receipt: BrowserInitReceipt): BrowserInitReceipt => {
198
- latest.set(receipt.tabId, receipt)
199
- history.push(receipt)
200
- if (history.length > limit) history = history.slice(history.length - limit)
201
- options.onChange?.()
202
- return receipt
203
- }
204
-
205
- return {
206
- begin(request, beginOptions = {}) {
207
- const receipt: BrowserInitReceipt = {
208
- requestId: request.requestId ?? `browser-init-${++serial}`,
209
- sessionId: request.sessionId,
210
- tabId: request.tabId,
211
- occurrenceId: request.occurrenceId,
212
- navigationRevision: request.navigationRevision,
213
- url: request.url,
214
- stage: beginOptions.aborted === true ? 'failed' : 'accepted',
215
- ...beginOptions.aborted === true ? { reason: 'occurrence-aborted' as const } : {},
216
- at: now(),
217
- }
218
- return publish(receipt)
219
- },
220
- advance(tabId, stage, patch = {}) {
221
- if (disposed) return undefined
222
- const current = latest.get(tabId)
223
- if (current === undefined || current.stage === 'failed') return undefined
224
- return publish({
225
- ...current,
226
- ...patch.navigationRevision === undefined ? {} : { navigationRevision: patch.navigationRevision },
227
- ...patch.url === undefined ? {} : { url: patch.url },
228
- ...patch.guestId === undefined ? {} : { guestId: patch.guestId },
229
- ...patch.generation === undefined ? {} : { generation: patch.generation, frameId: patch.frameId, loaderId: patch.loaderId },
230
- stage,
231
- at: now(),
232
- })
233
- },
234
- fail(tabId, reason, patch = {}) {
235
- if (disposed) return undefined
236
- const current = latest.get(tabId)
237
- if (current === undefined) return undefined
238
- if (current.stage === 'failed') return current
239
- return publish({
240
- ...current,
241
- ...patch.navigationRevision === undefined ? {} : { navigationRevision: patch.navigationRevision },
242
- ...patch.url === undefined ? {} : { url: patch.url },
243
- ...patch.guestId === undefined ? {} : { guestId: patch.guestId },
244
- ...patch.generation === undefined ? {} : { generation: patch.generation, frameId: patch.frameId, loaderId: patch.loaderId },
245
- stage: 'failed',
246
- reason,
247
- ...patch.detail === undefined ? {} : { detail: patch.detail },
248
- at: now(),
249
- })
250
- },
251
- get: tabId => latest.get(tabId),
252
- all: () => [...history].reverse(),
253
- forget(tabId) {
254
- latest.delete(tabId)
255
- },
256
- dispose() {
257
- disposed = true
258
- latest.clear()
259
- history = []
260
- },
261
- }
262
- }
@@ -1,243 +0,0 @@
1
- /** Manual address-bar intent resolution; strict navigation stays in url.ts. */
2
- import { MAX_BROWSER_URL_LENGTH, parseBrowserAddress } from './url.ts'
3
- import type { BrowserAddressFailure, BrowserTarget } from './url.ts'
4
-
5
- /** One search endpoint whose address is stored without template syntax. */
6
- export interface SearchEngine {
7
- readonly id: string
8
- readonly label: string
9
- readonly homeUrl: string
10
- readonly searchUrl: string
11
- readonly queryParameter: string
12
- readonly extraParameters?: Readonly<Record<string, string>>
13
- }
14
-
15
- /** Locally shared search selection used to resolve keyword input. */
16
- export interface OmniboxPreferences {
17
- readonly defaultSearchEngineId: string
18
- readonly searchEngines: readonly SearchEngine[]
19
- }
20
-
21
- /** Why manual input produced no navigation; address failures keep their strict meaning. */
22
- export type OmniboxRefusal = BrowserAddressFailure | 'path' | 'engine-unavailable'
23
-
24
- /** A validated HTTP(S) navigation resolved from manual input. */
25
- export interface OmniboxNavigation {
26
- readonly kind: 'navigate'
27
- readonly target: BrowserTarget
28
- /** Whether the typed input already named its scheme or was completed as a host. */
29
- readonly source: 'explicit' | 'host'
30
- }
31
-
32
- /** A validated search-result address built from the selected engine. */
33
- export interface OmniboxSearch {
34
- readonly kind: 'search'
35
- readonly engineId: string
36
- readonly query: string
37
- readonly target: BrowserTarget
38
- }
39
-
40
- /** One action a manual submission can take. */
41
- export type OmniboxAction = OmniboxNavigation | OmniboxSearch
42
-
43
- /** Primary action plus the explicit alternative offered for ambiguous input. */
44
- export type OmniboxResolution =
45
- | { readonly kind: 'resolved'; readonly primary: OmniboxAction; readonly alternative?: OmniboxAction }
46
- | { readonly kind: 'refused'; readonly reason: OmniboxRefusal }
47
-
48
- /** Inputs needed to resolve one address-bar submission. */
49
- export interface OmniboxOptions extends OmniboxPreferences {
50
- readonly applicationOrigin?: string
51
- }
52
-
53
- const CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/u
54
- const SCHEME_PREFIX = /^([A-Za-z][A-Za-z\d+.-]*):/u
55
- const HOST_AUTHORITY = /^(\[[0-9A-Fa-f:.]+\]|[^:@/?#\[\]\s]+)(?::(\d{1,5}))?$/u
56
- const CREDENTIALS = /^[^\s/?#]*:[^\s/?#]*@/u
57
- const IPV4_OR_VERSION = /^\d+(?:\.\d+)*$/u
58
- const DISABLED_SCHEMES = new Set([
59
- 'about', 'blob', 'chrome', 'data', 'file', 'ftp', 'ftps', 'javascript', 'mailto',
60
- 'tel', 'vbscript', 'view-source', 'ws', 'wss',
61
- ])
62
-
63
- /**
64
- * Resolve text typed into the manual address bar into navigation or search.
65
- * Explicit URLs still pass the strict HTTP(S) admission; no failure falls back
66
- * to a search engine.
67
- * @param input - raw address-bar value.
68
- * @param options - shared search selection and the current application origin.
69
- * @returns the action to take or the refusal to display.
70
- */
71
- export function resolveOmniboxInput(input: string, options: OmniboxOptions): OmniboxResolution {
72
- const classified = classifyInput(input)
73
- switch (classified.kind) {
74
- case 'refused':
75
- return { kind: 'refused', reason: classified.reason }
76
- case 'keyword':
77
- return resolveSearch(classified.query, options)
78
- case 'credentials':
79
- return strictNavigation(`https://${classified.value}`, 'host', options)
80
- case 'explicit':
81
- return strictNavigation(classified.value, 'explicit', options)
82
- case 'host': {
83
- const primary = strictNavigation(classified.url, 'host', options)
84
- if (primary.kind === 'refused') return primary
85
- const alternative = resolveSearch(classified.query, options)
86
- return alternative.kind === 'resolved'
87
- ? { kind: 'resolved', primary: primary.primary, alternative: alternative.primary }
88
- : primary
89
- }
90
- }
91
- }
92
-
93
- /**
94
- * Resolve only the address branch of manual input, for shortcut forms that must
95
- * not turn ordinary keywords into an implicit search.
96
- * @param input - user-supplied website address.
97
- * @param applicationOrigin - current DSH origin, refused by strict admission.
98
- * @returns a validated target or the refusal to display.
99
- */
100
- export function resolveAddressInput(input: string, applicationOrigin?: string):
101
- | { readonly ok: true; readonly target: BrowserTarget }
102
- | { readonly ok: false; readonly reason: OmniboxRefusal } {
103
- const classified = classifyInput(input)
104
- switch (classified.kind) {
105
- case 'refused': return { ok: false, reason: classified.reason }
106
- case 'keyword': return { ok: false, reason: 'invalid' }
107
- case 'credentials': return addressTarget(`https://${classified.value}`, applicationOrigin)
108
- case 'explicit': return addressTarget(classified.value, applicationOrigin)
109
- case 'host': return addressTarget(classified.url, applicationOrigin)
110
- }
111
- }
112
-
113
- type ClassifiedInput =
114
- | { readonly kind: 'refused'; readonly reason: OmniboxRefusal }
115
- | { readonly kind: 'keyword'; readonly query: string }
116
- | { readonly kind: 'credentials'; readonly value: string }
117
- | { readonly kind: 'explicit'; readonly value: string }
118
- | { readonly kind: 'host'; readonly url: string; readonly query: string }
119
-
120
- function classifyInput(input: string): ClassifiedInput {
121
- const trimmed = input.trim()
122
- if (trimmed === '') return { kind: 'refused', reason: 'empty' }
123
- if (trimmed.length > MAX_BROWSER_URL_LENGTH) return { kind: 'refused', reason: 'invalid' }
124
- if (CONTROL_CHARACTER.test(trimmed)) return { kind: 'refused', reason: 'invalid' }
125
- // Local paths belong to document and resource providers, never to an address or a search.
126
- if (/^[A-Za-z]:[\\/]/u.test(trimmed) || trimmed.startsWith('\\\\')) {
127
- return { kind: 'refused', reason: 'path' }
128
- }
129
- // A single leading slash without a host is a POSIX absolute path; a lone
130
- // slash-prefixed word such as "/help" can still be an ordinary search.
131
- if (/^\/(?!\/)(?:[^/\s]+\/)+[^/\s]*$/u.test(trimmed)) {
132
- return { kind: 'refused', reason: 'path' }
133
- }
134
- const scheme = SCHEME_PREFIX.exec(trimmed)?.[1]?.toLowerCase()
135
- if (scheme === 'http' || scheme === 'https') return { kind: 'explicit', value: trimmed }
136
- if (scheme !== undefined && (DISABLED_SCHEMES.has(scheme) || trimmed.includes('://'))) {
137
- return { kind: 'refused', reason: 'protocol' }
138
- }
139
- // Scheme-less userinfo still names a URL; strict admission reports the credential refusal.
140
- if (CREDENTIALS.test(trimmed)) return { kind: 'credentials', value: trimmed }
141
- const normalized = normalizeHostInput(trimmed)
142
- return normalized === undefined
143
- ? { kind: 'keyword', query: trimmed }
144
- : { kind: 'host', url: normalized, query: trimmed }
145
- }
146
-
147
- function addressTarget(value: string, applicationOrigin?: string):
148
- | { readonly ok: true; readonly target: BrowserTarget }
149
- | { readonly ok: false; readonly reason: OmniboxRefusal } {
150
- const parsed = parseBrowserAddress(value, applicationOrigin)
151
- return parsed.ok ? { ok: true, target: parsed.target } : { ok: false, reason: parsed.reason }
152
- }
153
-
154
- /**
155
- * Build one engine's result address.
156
- * @param engine - validated search endpoint.
157
- * @param query - keyword text encoded once through URLSearchParams.
158
- * @param applicationOrigin - current DSH origin, refused by strict admission.
159
- * @returns the target, or undefined when the engine cannot be used safely.
160
- */
161
- export function buildSearchTarget(engine: SearchEngine, query: string,
162
- applicationOrigin?: string): BrowserTarget | undefined {
163
- if (engine.queryParameter === '') return undefined
164
- let url: URL
165
- try { url = new URL(engine.searchUrl) } catch { return undefined }
166
- if (url.protocol !== 'http:' && url.protocol !== 'https:') return undefined
167
- try {
168
- for (const [name, value] of Object.entries(engine.extraParameters ?? {})) url.searchParams.set(name, value)
169
- url.searchParams.set(engine.queryParameter, query)
170
- } catch { return undefined }
171
- const parsed = parseBrowserAddress(url.href, applicationOrigin)
172
- if (!parsed.ok) return undefined
173
- return { ...parsed.target, title: query }
174
- }
175
-
176
- function strictNavigation(value: string, source: 'explicit' | 'host',
177
- options: OmniboxOptions): OmniboxResolution {
178
- const parsed = parseBrowserAddress(value, options.applicationOrigin)
179
- if (!parsed.ok) return { kind: 'refused', reason: parsed.reason }
180
- return { kind: 'resolved', primary: { kind: 'navigate', target: parsed.target, source } }
181
- }
182
-
183
- function resolveSearch(query: string, options: OmniboxOptions): OmniboxResolution {
184
- const engine = options.searchEngines.find(candidate => candidate.id === options.defaultSearchEngineId)
185
- if (engine === undefined) return { kind: 'refused', reason: 'engine-unavailable' }
186
- const target = buildSearchTarget(engine, query, options.applicationOrigin)
187
- if (target === undefined) return { kind: 'refused', reason: 'engine-unavailable' }
188
- return { kind: 'resolved', primary: { kind: 'search', engineId: engine.id, query, target } }
189
- }
190
-
191
- /**
192
- * Complete host-like input into an address; keyword-like input returns undefined.
193
- * Local loopback services use HTTP, public hosts HTTPS, and a single intranet
194
- * label needs an explicit scheme unless it names a port.
195
- */
196
- function normalizeHostInput(input: string): string | undefined {
197
- if (/\s/u.test(input)) return undefined
198
- const protocolRelative = input.startsWith('//')
199
- const value = protocolRelative ? input.slice(2) : input
200
- if (value === '') return undefined
201
- const boundary = value.search(/[/?#]/u)
202
- const authority = boundary === -1 ? value : value.slice(0, boundary)
203
- const suffix = boundary === -1 ? '' : value.slice(boundary)
204
- if (authority === '') return undefined
205
- const match = HOST_AUTHORITY.exec(authority)
206
- if (match === null) return undefined
207
- const host = match[1]
208
- if (host === undefined) return undefined
209
- const port = match[2]
210
- const ipv6 = host.startsWith('[')
211
- const bare = ipv6 ? host.slice(1, -1) : host
212
- const local = isLoopbackHost(bare)
213
- if (!local && !ipv6) {
214
- if (IPV4_OR_VERSION.test(bare)) {
215
- const octets = bare.split('.')
216
- // A dotted number without exactly four in-range octets is a version, not a host.
217
- if (octets.length !== 4 || octets.some(octet => Number(octet) > 255)) return undefined
218
- } else if (!bare.includes('.')) {
219
- if (port === undefined) return undefined
220
- // A single intranet label with an explicit port is an HTTP service.
221
- return validHttpUrl(`http://${authority}${suffix}`) ? `http://${authority}${suffix}` : undefined
222
- }
223
- }
224
- const completed = `${local ? 'http' : 'https'}://${authority}${suffix}`
225
- return validHttpUrl(completed) ? completed : undefined
226
- }
227
-
228
- function isLoopbackHost(host: string): boolean {
229
- const normalized = host.toLowerCase()
230
- if (normalized === 'localhost' || normalized.endsWith('.localhost')) return true
231
- if (IPV4_OR_VERSION.test(normalized) && normalized.includes('.')) {
232
- const octets = normalized.split('.')
233
- if (octets.length === 4 && octets.every(octet => Number(octet) <= 255)) return octets[0] === '127'
234
- }
235
- return normalized === '::1' || normalized === '0:0:0:0:0:0:0:1'
236
- }
237
-
238
- function validHttpUrl(value: string): boolean {
239
- try {
240
- const url = new URL(value)
241
- return (url.protocol === 'http:' || url.protocol === 'https:') && url.username === '' && url.password === ''
242
- } catch { return false }
243
- }
@@ -1,38 +0,0 @@
1
- /** Persisted Browser tab snapshots shared by the body and title slots. */
2
- import { defineStore, type EngineStoreHandle } from '@deepseek-ai/dsh-client-store'
3
- import type { TabId } from '@deepseek-ai/dsh-client-ui-dockkit'
4
- import type { BrowserTabState } from './BrowserPersistence.ts'
5
-
6
- /** All Browser tabs in one Session-scoped store. */
7
- export interface BrowserState {
8
- byTab: Record<TabId, BrowserTabState>
9
- }
10
-
11
- type BrowserActions = {
12
- replace: (draft: BrowserState, tabId: TabId, state: BrowserTabState) => void
13
- forget: (draft: BrowserState, tabId: TabId) => void
14
- }
15
-
16
- /**
17
- * Declare the Session-scoped Browser persistence store.
18
- * @returns a fresh store handle for Slot registration.
19
- */
20
- export function createBrowserStore(): EngineStoreHandle<BrowserState, BrowserActions> {
21
- return defineStore({
22
- init: (): BrowserState => ({ byTab: {} }),
23
- persist: 'dsh.sidebar-browser.v1',
24
- actions: {
25
- replace: (draft, tabId: TabId, state: BrowserTabState) => { draft.byTab[tabId] = state },
26
- forget: (draft, tabId: TabId) => {
27
- const byTab: BrowserState['byTab'] = {}
28
- for (const [id, state] of Object.entries(draft.byTab) as [TabId, BrowserTabState][]) {
29
- if (id !== tabId) byTab[id] = state
30
- }
31
- draft.byTab = byTab
32
- },
33
- },
34
- })
35
- }
36
-
37
- /** Browser store handle shared by body and title registrations. */
38
- export type BrowserStore = ReturnType<typeof createBrowserStore>
@@ -1,72 +0,0 @@
1
- import { referenceOwnerKey } from '../../reference-owner.ts'
2
- import { TAKEOVER_ROUTE, type TakeoverNotice, type TakeoverSummary } from '../../takeover-protocol.ts'
3
-
4
- const readers = new Map<string, { owner: string; read: (signal: AbortSignal) => Promise<TakeoverSummary> }>()
5
-
6
- export function registerTakeoverSummary(pageId: string, owner: string, read: (signal: AbortSignal) => Promise<TakeoverSummary>): () => void {
7
- const reader = { owner: referenceOwnerKey(owner), read }
8
- readers.set(pageId, reader)
9
- return () => { if (readers.get(pageId) === reader) readers.delete(pageId) }
10
- }
11
-
12
- export async function readTakeoverSummary(pageId: string, owner: string, signal: AbortSignal): Promise<TakeoverSummary> {
13
- const reader = readers.get(pageId)
14
- if (!reader || reader.owner !== referenceOwnerKey(owner)) throw new Error('takeover source is unavailable')
15
- return reader.read(signal)
16
- }
17
-
18
- export function connectBrowserTakeover(options: {
19
- readonly owner: string
20
- readonly tabId: string
21
- readonly pageId: string
22
- readonly current: () => { url: string; active: boolean; navigationUrl?: string }
23
- readonly changed: (notice?: TakeoverNotice, error?: boolean) => void
24
- }, signal: AbortSignal): { answer(outcome: 'done' | 'skipped'): Promise<void> } {
25
- let lease: string | undefined, notice: TakeoverNotice | undefined, timer: ReturnType<typeof setTimeout> | undefined
26
- let answering = false
27
- const post = async (body: object): Promise<{ lease?: string; notice?: TakeoverNotice }> => {
28
- const response = await fetch(TAKEOVER_ROUTE, { method: 'POST', credentials: 'include',
29
- headers: { 'content-type': 'application/json' }, body: JSON.stringify(body), signal })
30
- if (!response.ok) {
31
- if (response.status === 400) lease = undefined
32
- throw new Error('browser takeover channel unavailable')
33
- }
34
- return response.json()
35
- }
36
- const poll = async (): Promise<void> => {
37
- try {
38
- if (!lease) {
39
- const registered = await post({ operation: 'register', owner: options.owner, tabId: options.tabId, pageId: options.pageId, ...options.current() })
40
- lease = registered.lease
41
- if (!lease) throw new Error('browser takeover lease missing')
42
- }
43
- const result = await post({ operation: 'poll', lease, ...options.current() })
44
- notice = result.notice
45
- if (!signal.aborted) options.changed(notice?.phase === 'waiting' && !answering ? notice : undefined)
46
- if (notice?.phase === 'summary' && options.pageId.startsWith('iframe:')) {
47
- const summary = await readTakeoverSummary(options.pageId, options.owner, AbortSignal.any([signal, AbortSignal.timeout(5000)]))
48
- await post({ operation: 'summary', lease, id: notice.id, summary })
49
- }
50
- } catch {
51
- if (!signal.aborted) options.changed(undefined)
52
- }
53
- if (!signal.aborted) timer = setTimeout(() => { void poll() }, 400)
54
- }
55
- const stop = (): void => {
56
- clearTimeout(timer)
57
- options.changed(undefined)
58
- if (lease) void fetch(TAKEOVER_ROUTE, { method: 'POST', credentials: 'include', keepalive: true,
59
- headers: { 'content-type': 'application/json' }, body: JSON.stringify({ operation: 'remove', lease }) }).catch(() => {})
60
- }
61
- signal.addEventListener('abort', stop, { once: true })
62
- if (!signal.aborted) void poll()
63
- return { async answer(outcome) {
64
- if (!notice || notice.phase !== 'waiting' || answering || signal.aborted) return
65
- answering = true
66
- const current = notice
67
- options.changed(undefined)
68
- try { await post({ operation: 'answer', lease, id: current.id, outcome }) }
69
- catch { if (!signal.aborted) options.changed(current, true) }
70
- finally { answering = false }
71
- } }
72
- }
@@ -1,46 +0,0 @@
1
- /** Address parsing for the Sidebar browser's HTTP(S) allowlist. */
2
-
3
- /** Maximum accepted address length; this bounds persisted navigation state. */
4
- export const MAX_BROWSER_URL_LENGTH = 16 * 1024
5
-
6
- /** A normalized Browser navigation target. */
7
- export type BrowserTarget =
8
- | { readonly kind: 'blank'; readonly url: 'about:blank'; readonly title: string }
9
- | { readonly kind: 'https'; readonly url: string; readonly title: string }
10
- | { readonly kind: 'http'; readonly url: string; readonly title: string }
11
-
12
- /** Why an address was refused before navigation. */
13
- export type BrowserAddressFailure = 'empty' | 'invalid' | 'protocol' | 'credentials' | 'application-origin'
14
-
15
- /** Result of parsing an address-bar value. */
16
- export type BrowserAddressResult =
17
- | { readonly ok: true; readonly target: BrowserTarget }
18
- | { readonly ok: false; readonly reason: BrowserAddressFailure }
19
-
20
- /**
21
- * Parse one address-bar value into the fixed protocol allowlist.
22
- * @param input - user or typed-open input.
23
- * @param applicationOrigin - current DSH document origin, blocked for HTTPS.
24
- * @returns a canonical target or the refusal reason.
25
- */
26
- export function parseBrowserAddress(input: string, applicationOrigin?: string): BrowserAddressResult {
27
- const trimmed = input.trim()
28
- if (trimmed === '') return { ok: false, reason: 'empty' }
29
- if (trimmed.length > MAX_BROWSER_URL_LENGTH) return { ok: false, reason: 'invalid' }
30
- const explicitScheme = /^[A-Za-z][A-Za-z\d+.-]*:(?!\d+(?:[/?#]|$))/u.test(trimmed)
31
- const candidate = explicitScheme ? trimmed : `https://${trimmed}`
32
- let url: URL
33
- try { url = new URL(candidate) } catch { return { ok: false, reason: 'invalid' } }
34
- if (url.username !== '' || url.password !== '') return { ok: false, reason: 'credentials' }
35
- if (url.protocol === 'https:' || url.protocol === 'http:') {
36
- if (applicationOrigin !== undefined && applicationOrigin !== 'null') {
37
- try {
38
- if (url.origin === new URL(applicationOrigin).origin) return { ok: false, reason: 'application-origin' }
39
- } catch {
40
- // An unavailable application origin cannot grant access to a target.
41
- }
42
- }
43
- return { ok: true, target: { kind: url.protocol === 'https:' ? 'https' : 'http', url: url.href, title: url.hostname } }
44
- }
45
- return { ok: false, reason: 'protocol' }
46
- }