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
@@ -0,0 +1,108 @@
1
+ import { DEEP_DOM_SOURCE } from '../browser/deep-dom.js';
2
+ const OVERLAY_ID = '__dsh_annotations__';
3
+ export const MAX_ANNOTATIONS = 80;
4
+ /** Page script: draw the overlay and return the rows. Resolves after the overlay has painted. */
5
+ export const ANNOTATE_SCRIPT = `(async () => {${DEEP_DOM_SOURCE}
6
+ const OVERLAY_ID = ${JSON.stringify(OVERLAY_ID)}
7
+ const old = document.getElementById(OVERLAY_ID)
8
+ if (old) old.remove()
9
+ const SELECTOR = 'a[href], button, input:not([type=hidden]), textarea, select, summary, [role=button], [role=link], [role=checkbox], [role=radio], [role=tab], [role=menuitem], [role=option], [role=switch], [role=combobox], [role=searchbox], [role=textbox], [contenteditable=""], [contenteditable=true], [tabindex]:not([tabindex="-1"])'
10
+ const implicit = (el) => {
11
+ const tag = el.tagName.toLowerCase()
12
+ if (tag === 'a') return 'link'
13
+ if (tag === 'button' || tag === 'summary') return 'button'
14
+ if (tag === 'select') return el.multiple ? 'listbox' : 'combobox'
15
+ if (tag === 'textarea') return 'textbox'
16
+ if (tag === 'input') {
17
+ const type = (el.getAttribute('type') || 'text').toLowerCase()
18
+ if (type === 'checkbox' || type === 'radio') return type
19
+ if (type === 'submit' || type === 'button' || type === 'reset' || type === 'image') return 'button'
20
+ if (type === 'range') return 'slider'
21
+ if (type === 'search') return 'searchbox'
22
+ return 'textbox'
23
+ }
24
+ if (el.isContentEditable) return 'textbox'
25
+ return 'generic'
26
+ }
27
+ const labelOf = (el) => {
28
+ const root = el.getRootNode()
29
+ const byIds = (el.getAttribute('aria-labelledby') || '').split(/\\s+/).filter(Boolean)
30
+ .map(id => { const n = root.getElementById ? root.getElementById(id) : null; return n ? n.textContent : '' }).join(' ')
31
+ let text = el.getAttribute('aria-label') || byIds
32
+ if (!text && el.labels && el.labels.length) text = el.labels[0].textContent
33
+ // A field's value is what the user typed (possibly a password), never its label; only button inputs name themselves by value.
34
+ const buttonValue = el.tagName === 'INPUT' && /^(submit|button|reset)$/i.test(el.getAttribute('type') || '') ? el.value : ''
35
+ if (!text) text = el.innerText || buttonValue || el.getAttribute('placeholder') || el.getAttribute('title') || el.getAttribute('alt') || el.getAttribute('name') || ''
36
+ return String(text).replace(/\\s+/g, ' ').trim().slice(0, 80)
37
+ }
38
+ const vw = window.innerWidth, vh = window.innerHeight
39
+ // The element's box in top-viewport coordinates, clipped by every enclosing iframe's viewport.
40
+ const visibleBox = (el) => {
41
+ const r = el.getBoundingClientRect()
42
+ let box = { left: r.left, top: r.top, right: r.right, bottom: r.bottom }
43
+ let doc = el.ownerDocument
44
+ while (doc && doc.defaultView && doc.defaultView.frameElement) {
45
+ const view = doc.defaultView
46
+ box = { left: Math.max(box.left, 0), top: Math.max(box.top, 0), right: Math.min(box.right, view.innerWidth), bottom: Math.min(box.bottom, view.innerHeight) }
47
+ const f = view.frameElement.getBoundingClientRect()
48
+ box = { left: box.left + f.left, top: box.top + f.top, right: box.right + f.left, bottom: box.bottom + f.top }
49
+ doc = view.frameElement.ownerDocument
50
+ }
51
+ return { left: Math.max(box.left, 0), top: Math.max(box.top, 0), right: Math.min(box.right, vw), bottom: Math.min(box.bottom, vh) }
52
+ }
53
+ const rows = []
54
+ const boxes = []
55
+ for (const root of __dshRoots()) {
56
+ for (const el of root.querySelectorAll(SELECTOR)) {
57
+ if (rows.length >= ${MAX_ANNOTATIONS}) break
58
+ if (el.disabled) continue
59
+ const r = el.getBoundingClientRect()
60
+ if (r.width < 2 || r.height < 2) continue
61
+ const style = el.ownerDocument.defaultView.getComputedStyle(el)
62
+ if (style.visibility === 'hidden' || style.display === 'none' || Number(style.opacity) === 0) continue
63
+ const v = visibleBox(el)
64
+ if (v.right - v.left < 2 || v.bottom - v.top < 2) continue
65
+ const x = Math.round((v.left + v.right) / 2)
66
+ const y = Math.round((v.top + v.bottom) / 2)
67
+ const id = rows.length + 1
68
+ rows.push({ id, x, y, role: el.getAttribute('role') || implicit(el), label: labelOf(el) })
69
+ boxes.push({ id, left: v.left, top: v.top, width: v.right - v.left, height: v.bottom - v.top })
70
+ }
71
+ }
72
+ const host = document.createElement('div')
73
+ host.id = OVERLAY_ID
74
+ host.setAttribute('aria-hidden', 'true')
75
+ host.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:2147483647;'
76
+ const shadow = host.attachShadow ? host.attachShadow({ mode: 'closed' }) : host
77
+ const colors = ['#e6194b', '#3cb44b', '#4363d8', '#f58231', '#911eb4', '#008080', '#9a6324', '#800000']
78
+ for (const b of boxes) {
79
+ const color = colors[(b.id - 1) % colors.length]
80
+ const box = document.createElement('div')
81
+ box.style.cssText = 'position:fixed;box-sizing:border-box;border:2px solid ' + color + ';left:' + b.left + 'px;top:' + b.top + 'px;width:' + b.width + 'px;height:' + b.height + 'px;'
82
+ const tag = document.createElement('span')
83
+ tag.textContent = String(b.id)
84
+ tag.style.cssText = 'position:absolute;left:-2px;top:' + (b.top >= 14 ? '-14px' : '0') + ';background:' + color + ';color:#fff;font:bold 11px/13px monospace;padding:0 3px;'
85
+ box.appendChild(tag)
86
+ shadow.appendChild(box)
87
+ }
88
+ ;(document.body || document.documentElement).appendChild(host)
89
+ await new Promise(done => requestAnimationFrame(() => requestAnimationFrame(done)))
90
+ return rows
91
+ })()`;
92
+ export const CLEAR_ANNOTATIONS_SCRIPT = `(() => { const el = document.getElementById(${JSON.stringify(OVERLAY_ID)}); if (el) el.remove(); return true })()`;
93
+ export async function drawAnnotations(browser, session, signal) {
94
+ const result = await browser.execute(session, { script: ANNOTATE_SCRIPT }, signal);
95
+ if (!result.ok)
96
+ throw new Error(`browser: could not annotate the page (${result.exception})`);
97
+ return Array.isArray(result.value) ? result.value : [];
98
+ }
99
+ export async function clearAnnotations(browser, session) {
100
+ try {
101
+ await browser.execute(session, { script: CLEAR_ANNOTATIONS_SCRIPT });
102
+ }
103
+ catch { /* the page navigated away; nothing to clear */ }
104
+ }
105
+ /** Text lines naming each numbered element. */
106
+ export function annotationLines(rows) {
107
+ return rows.map(row => ` [${row.id}] ${row.role}${row.label !== '' ? ` "${row.label}"` : ''} @ ${row.x},${row.y}`);
108
+ }
@@ -0,0 +1,337 @@
1
+ /**
2
+ * Per-apply browser tool state: task sessions, the allow-list restriction, and surface rules.
3
+ * @module dsh-browser/tool-browser/state
4
+ */
5
+ import { readFileSync } from 'node:fs';
6
+ import { settingsPath } from '../browser-electron/settings-store.js';
7
+ import { assertCapability, CDP_CARRIER_CAPABILITIES, WEB_PANEL_CAPABILITIES } from '../browser/types.js';
8
+ import { MAX_FILL_FIELDS, TOOL_WAIT_MIN_MS, TOOL_WAIT_RESERVE_MS } from '../../assets/browser-policy.mjs';
9
+ /**
10
+ * Register a cleanup that runs once when the process exits.
11
+ *
12
+ * A single hook per process, holding a list of callbacks, rather than one listener per
13
+ * session: sessions come and go, listeners do not, and Node warns when a listener count
14
+ * passes ten.
15
+ */
16
+ export const exitCleanups = new Set();
17
+ let exitHookInstalled = false;
18
+ export function registerExitCleanup(cleanup) {
19
+ exitCleanups.add(cleanup);
20
+ if (exitHookInstalled)
21
+ return;
22
+ exitHookInstalled = true;
23
+ process.on('exit', () => {
24
+ for (const run of exitCleanups) {
25
+ try {
26
+ run();
27
+ }
28
+ catch { /* exiting; nothing useful to do */ }
29
+ }
30
+ });
31
+ }
32
+ /**
33
+ * Which surface an open should use.
34
+ *
35
+ * "panel" - place the page in the DSH sidebar and open nothing else (the normal Web behaviour).
36
+ * "builtin"- drive the plugin's own Electron browser or the explicitly selected installed Chrome/Edge.
37
+ * @returns the configured surface, defaulting to "panel".
38
+ */
39
+ export function readSurface() {
40
+ // A host that already resolved the surface declares it; otherwise the plugin's own settings file under
41
+ // the live DSH_HOME decides. No machine-specific path is consulted.
42
+ const declared = globalThis.__dshBrowserSurface;
43
+ if (declared === 'builtin')
44
+ return 'builtin';
45
+ try {
46
+ const raw = readFileSync(settingsPath(), 'utf8').replace(/^\uFEFF/u, '');
47
+ const parsed = JSON.parse(raw);
48
+ const surface = parsed.browser?.surface;
49
+ if (surface === 'builtin' || surface === 'panel')
50
+ return surface;
51
+ // Issue #106 & Scheme C: an explicit installed browser channel (chrome / edge) or standalone
52
+ // Electron channel (electron) must drive that browser carrier rather than falling into the
53
+ // Web iframe / Desktop sidebar panel by default.
54
+ const channel = parsed.browser?.channel;
55
+ if (channel === 'chrome' || channel === 'edge' || channel === 'electron')
56
+ return 'builtin';
57
+ }
58
+ catch { /* no settings yet */ }
59
+ if (declared === 'panel')
60
+ return 'panel';
61
+ return 'panel';
62
+ }
63
+ /**
64
+ * Keep the built-in browser for DSH itself.
65
+ *
66
+ * "builtin" exists to debug DSH: a client bundle, the settings panel, the sidebar UI. Using it for an
67
+ * ordinary site opens a window the reader did not ask for — measured as "why did you open the built-in
68
+ * browser again". A non-loopback target therefore degrades to "panel" silently; the caller's intent does
69
+ * not override the rule.
70
+ * @param surface - the requested surface.
71
+ * @param url - the page being opened.
72
+ * @returns the surface that will actually be used.
73
+ */
74
+ export function enforceSurface(surface, _url) {
75
+ // The caller decides the surface. An earlier version degraded "builtin" to "panel" for anything but a
76
+ // loopback URL, which also blocked the agent from driving the human's OWN browser — the opposite of what
77
+ // the setting is for. Which window appears is decided by the carrier (bundled Electron vs. the human's
78
+ // Edge), not by the URL. Keeping ordinary tests on the sidebar is a working rule, not a code constraint.
79
+ return surface;
80
+ }
81
+ /**
82
+ * Refuse a request that cannot work BEFORE anything is opened.
83
+ *
84
+ * The sidebar renders pages through a same-origin proxy, so asking it to load this machine answers with a
85
+ * network-level failure that reads like a bug in the page. Reporting that afterwards is useless — the call
86
+ * already happened. The rule is therefore enforced up front: a loopback target on the panel surface is
87
+ * refused, and the message names the surface that does work.
88
+ * @param surface - the surface this call would use.
89
+ * @param url - the page being opened.
90
+ */
91
+ export function assertSurfaceCanHost(surface, url) {
92
+ if (surface !== 'panel')
93
+ return;
94
+ let host;
95
+ try {
96
+ host = new URL(url).hostname.toLowerCase();
97
+ }
98
+ catch {
99
+ return;
100
+ }
101
+ const local = host === 'localhost' || host === '127.0.0.1' || host === '::1' || host === '[::1]' || /^127\./u.test(host);
102
+ if (!local)
103
+ return;
104
+ throw new Error('dsh-builtin-browser: the sidebar cannot host this machine (' + host
105
+ + '). It proxies pages through itself, so loading DSH there is the proxy fetching its own server. '
106
+ + '调试 DSH 请用 surface: "builtin"(内置浏览器),普通网页才走侧栏。');
107
+ }
108
+ export function createState() {
109
+ return {
110
+ sessionsByTask: new Map(), pendingOpens: new Map(), configRestrictedTo: undefined,
111
+ restrictedByTask: new Map(), panelUrlByTask: new Map(), pendingPanelOpens: new Map(),
112
+ };
113
+ }
114
+ /** Every live state, for the test hook (introspection only, never shared). */
115
+ export const liveStates = new Set();
116
+ /**
117
+ * Tools that only observe, plus the ones that undo a restriction.
118
+ *
119
+ * Never subject to an allow-list: restricting what the agent may *do* must not also
120
+ * blind it or trap it, and the tool descriptions promise as much. dsh_browser_restrict
121
+ * is in here so a task that restricted everything can still lift it.
122
+ */
123
+ export const READ_ONLY_TOOLS = new Set([
124
+ // Tools that only observe.
125
+ 'dsh_browser_snapshot', 'dsh_browser_a11y', 'dsh_browser_content', 'dsh_browser_scrape',
126
+ 'dsh_browser_screenshot', 'dsh_browser_get_value', 'dsh_browser_wait', 'dsh_browser_challenge',
127
+ 'dsh_browser_list_tabs', 'dsh_browser_session', 'dsh_browser_history', 'dsh_browser_visited',
128
+ // Observation added in 0.5.7: console lines, network responses, an assertion, a self-check and the
129
+ // help index. All five only read (the probe's buffers belong to the page, not to the task), so an
130
+ // allow-list must not blind a task that restricted itself.
131
+ 'dsh_browser_console', 'dsh_browser_network', 'dsh_browser_wait_for_response',
132
+ 'dsh_browser_assert', 'dsh_browser_doctor', 'dsh_browser_help',
133
+ // Reading the page's own digest and searching its text: observation like the rest.
134
+ 'dsh_browser_find', 'dsh_browser_state',
135
+ // Where the page keeps its data: shapes of what the page already holds, never a request.
136
+ 'dsh_browser_data_sources',
137
+ // References read the page the human already has open and write only this plugin's own store;
138
+ // restricting an agent's actions must not stop it from recording what it was told to read.
139
+ 'dsh_browser_reference_capture', 'dsh_browser_reference_reveal', 'dsh_browser_reference_list',
140
+ // dsh_browser_auth reads cookies out of the browser: an observation, and one the
141
+ // credentials switch gates on its own (see credentials.allowRead in the settings).
142
+ // dsh_browser_auth is deliberately NOT here. It reads cookies on "flush" but WRITES them on
143
+ // "restore", to arbitrary domains, which is an action like any other — exempting the tool
144
+ // would let a task that restricted its own actions rewrite the shared browser's logins.
145
+ //
146
+ // Getting out of a bad state, or lifting the restriction itself. Without these a task
147
+ // that restricted everything could neither recover nor be released.
148
+ 'dsh_browser_restrict', 'dsh_browser_reset_session', 'dsh_browser_reset',
149
+ ]);
150
+ /**
151
+ * Guard one browser tool call against the active restriction. Refuses calls
152
+ * not on the allow-list when a restriction is in effect.
153
+ * @param state - the calling context's tool state.
154
+ * @param toolName - the browser tool about to run.
155
+ */
156
+ export function assertAllowed(state, toolName, task) {
157
+ // dsh_browser_restrict must stay usable, or a task that restricted everything
158
+ // could never lift it again.
159
+ // An allow-list is a statement about ACTIONS, so it must not take away the ability to
160
+ // look, or to get out of a bad state. The tool description and both READMEs promise
161
+ // that read-only tools are never blocked; before this they were, because only
162
+ // dsh_browser_restrict itself was exempt — a narrow list then locked dsh_browser_history,
163
+ // dsh_browser_reset_session and dsh_browser_auth away with no way back.
164
+ if (READ_ONLY_TOOLS.has(toolName) || toolName === 'dsh_browser_restrict')
165
+ return;
166
+ const config = state.configRestrictedTo;
167
+ if (config !== undefined && !config.includes(toolName)) {
168
+ throw new Error(`browser action "${toolName}" is restricted by the plugin configuration (allow-list: ${config.join(', ')})`);
169
+ }
170
+ const allowed = state.restrictedByTask.get(task);
171
+ if (allowed === undefined || allowed.includes(toolName))
172
+ return;
173
+ throw new Error(`browser action "${toolName}" is restricted (allow-list: ${allowed.join(', ')})`);
174
+ }
175
+ /** Extract the agent from a tool-execution context, when one exists. */
176
+ export function agentOf(exec) {
177
+ return exec?.agent;
178
+ }
179
+ /**
180
+ * The task key for a tool call: the calling DSH session id, or the shared
181
+ * default key when the call carries no agent context (CLI probes, tests).
182
+ * @param exec - the tool-execution context; only its optional agent id is read.
183
+ */
184
+ export function taskKey(exec) {
185
+ return exec?.agent?.id ?? 'default';
186
+ }
187
+ /** Whether this task's page was placed in the DSH sidebar panel rather than a plugin-owned window. */
188
+ export function panelBound(state, key) {
189
+ return state.panelUrlByTask.has(key);
190
+ }
191
+ /**
192
+ * What the task's current carrier can do. A panel placement without a live CDP session is the Web
193
+ * iframe panel: it can only be navigated. Everything else is a CDP-backed page.
194
+ */
195
+ export function carrierCapabilities(browser, state, key) {
196
+ const session = state.sessionsByTask.get(key);
197
+ return panelBound(state, key) && (session === undefined || !browser.exists(session)) ? WEB_PANEL_CAPABILITIES : CDP_CARRIER_CAPABILITIES;
198
+ }
199
+ export function rememberSession(browser, state, key, agent, session, panelUrl) {
200
+ const previous = state.sessionsByTask.get(key);
201
+ const previousPanelUrl = state.panelUrlByTask.get(key);
202
+ if (session === undefined)
203
+ state.sessionsByTask.delete(key);
204
+ else
205
+ state.sessionsByTask.set(key, session);
206
+ if (panelUrl === undefined)
207
+ state.panelUrlByTask.delete(key);
208
+ else
209
+ state.panelUrlByTask.set(key, panelUrl);
210
+ if (previous === session && (previousPanelUrl !== undefined) === (panelUrl !== undefined))
211
+ return;
212
+ const cleanup = () => {
213
+ if (state.sessionsByTask.get(key) !== session || state.panelUrlByTask.has(key) !== (panelUrl !== undefined))
214
+ return;
215
+ state.sessionsByTask.delete(key);
216
+ state.panelUrlByTask.delete(key);
217
+ if (session !== undefined)
218
+ void browser.close(session).catch(() => { });
219
+ };
220
+ try {
221
+ if (agent?.ctx !== undefined)
222
+ agent.ctx.effect(() => cleanup);
223
+ else if (key === 'default' && session !== undefined)
224
+ registerExitCleanup(() => browser.close(session).catch(() => { }));
225
+ }
226
+ catch (error) {
227
+ cleanup();
228
+ if (previous !== undefined)
229
+ state.sessionsByTask.set(key, previous);
230
+ if (previousPanelUrl !== undefined)
231
+ state.panelUrlByTask.set(key, previousPanelUrl);
232
+ throw error;
233
+ }
234
+ if (previous !== undefined && previous !== session)
235
+ void browser.close(previous).catch(() => { });
236
+ }
237
+ /**
238
+ * Resolve the calling task's browser session, opening one on first use.
239
+ * Concurrent first calls for the same key share a single open. When the call
240
+ * carries an agent, the session's lifetime is tied to the agent's scoped
241
+ * context: it closes automatically when the agent (DSH session) is disposed,
242
+ * so sessions and their windows never leak after a task ends.
243
+ * @param browser - the seam service.
244
+ * @param state - the calling context's tool state.
245
+ * @param key - the task key (see {@link taskKey}).
246
+ * @param agent - the calling agent, when any (its ctx owns the session).
247
+ * @returns the task's session id.
248
+ */
249
+ export async function ensureSession(browser, state, key, agent, create = false) {
250
+ await state.pendingPanelOpens.get(key);
251
+ const existing = state.sessionsByTask.get(key);
252
+ if (existing !== undefined) {
253
+ // The human closing a browser window ends that session, so a cached id can
254
+ // be stale: never hand a dead session back to a tool call.
255
+ if (browser.exists(existing))
256
+ return existing;
257
+ state.sessionsByTask.delete(key);
258
+ }
259
+ const pending = state.pendingOpens.get(key);
260
+ if (pending !== undefined)
261
+ return pending;
262
+ assertCapability(carrierCapabilities(browser, state, key), 'cdp', 'dsh-builtin-browser: the panel surface has no live CDP session for this operation. '
263
+ + 'Use the CDP-backed DSH desktop sidebar with a connected desktop bridge and call dsh_browser_open again. '
264
+ + 'The Web iframe panel cannot provide live snapshots, a11y, content, scrape, screenshots, interactions, '
265
+ + 'uploads, downloads, or reference capture. Reading tools never start a separate browser.');
266
+ // Starting a browser is `dsh_browser_open`'s job and nobody else's. A read tool asking "what is on
267
+ // screen" used to start one — which, with the human's own Edge already running, handed the command over
268
+ // and opened yet another window, reported as "one look, two Edge windows". A reader with nothing open
269
+ // reports that instead of launching anything.
270
+ if (!create) {
271
+ throw new Error('dsh-builtin-browser: nothing is open in this task yet — call dsh_browser_open first. '
272
+ + 'Reading tools never start a browser.');
273
+ }
274
+ // The task key rides along as the session label so the window title shows
275
+ // which task's page is currently visible to the human.
276
+ const opening = browser.open(key).then(session => {
277
+ state.pendingOpens.delete(key);
278
+ rememberSession(browser, state, key, agent, session);
279
+ return session;
280
+ }, error => { state.pendingOpens.delete(key); throw error; });
281
+ state.pendingOpens.set(key, opening);
282
+ return opening;
283
+ }
284
+ /**
285
+ * Longest wait `dsh_browser_wait` may poll for, leaving room for the tool call itself to
286
+ * finish and report.
287
+ *
288
+ * `dsh_browser_wait` promises a VERDICT — `{ready:false, reason}` — and the enclosing tool
289
+ * call aborts at `timeoutMs`. A caller-supplied budget longer than that aborted the call
290
+ * instead, so the documented verdict never arrived. Clamping to just inside the budget is
291
+ * what keeps the promise: the polling stops, the reason is returned.
292
+ */
293
+ export function maxWaitFor(timeoutMs) {
294
+ return Math.max(TOOL_WAIT_MIN_MS, timeoutMs - TOOL_WAIT_RESERVE_MS);
295
+ }
296
+ /**
297
+ * Most fields `dsh_browser_fill` accepts in one batch.
298
+ *
299
+ * The batch runs as ONE page evaluation, so hundreds of fields do not produce hundreds of
300
+ * per-field verdicts — they produce a single evaluate that exceeds the tool budget and
301
+ * throws, which is the opposite of the documented "per-field failures are reported instead
302
+ * of throwing". Real forms are far smaller than this; anything larger should be split.
303
+ */
304
+ export { MAX_FILL_FIELDS };
305
+ /** Every tool, in the order the entry registers it (and the code tool's catalog lists it). */
306
+ export const REGISTRATION_ORDER = [
307
+ 'dsh_browser_request_takeover', 'dsh_browser_shortcuts', 'dsh_browser_open', 'dsh_browser_snapshot',
308
+ 'dsh_browser_a11y', 'dsh_browser_challenge', 'dsh_browser_wait', 'dsh_browser_execute',
309
+ 'dsh_browser_content', 'dsh_browser_scrape', 'dsh_browser_click', 'dsh_browser_click_sequence',
310
+ 'dsh_browser_type', 'dsh_browser_scroll', 'dsh_browser_back', 'dsh_browser_forward', 'dsh_browser_refresh',
311
+ 'dsh_browser_key', 'dsh_browser_fill', 'dsh_browser_set_value', 'dsh_browser_check', 'dsh_browser_select',
312
+ 'dsh_browser_clear', 'dsh_browser_get_value', 'dsh_browser_screenshot', 'dsh_browser_list_tabs',
313
+ 'dsh_browser_switch_tab', 'dsh_browser_close_tab', 'dsh_browser_reset', 'dsh_browser_history',
314
+ 'dsh_browser_visited', 'dsh_browser_replay', 'dsh_browser_download', 'dsh_browser_session',
315
+ 'dsh_browser_reset_session', 'dsh_browser_restrict', 'dsh_browser_auth', 'dsh_browser_console',
316
+ 'dsh_browser_network', 'dsh_browser_dialog', 'dsh_browser_wait_for_response', 'dsh_browser_assert',
317
+ 'dsh_browser_drag', 'dsh_browser_doctor', 'dsh_browser_help', 'dsh_browser_do', 'dsh_browser_upload',
318
+ 'dsh_browser_hover', 'dsh_browser_find', 'dsh_browser_state', 'dsh_browser_reference_capture',
319
+ 'dsh_browser_reference_reveal', 'dsh_browser_reference_list', 'dsh_browser_data_sources', 'dsh_browser_fetch_json',
320
+ ];
321
+ /** Test hook: inspect and reset session mappings across every live plugin apply. */
322
+ export const internals = {
323
+ /** A copy of every live apply's per-task session map (task key -> provider session id). */
324
+ get sessions() {
325
+ const merged = new Map();
326
+ for (const state of liveStates) {
327
+ for (const [key, session] of state.sessionsByTask)
328
+ merged.set(key, session);
329
+ }
330
+ return merged;
331
+ },
332
+ /** Drop one task's mapping (across live applies) without closing the provider session. */
333
+ clearSession(key = 'default') {
334
+ for (const state of liveStates)
335
+ state.sessionsByTask.delete(key);
336
+ },
337
+ };
@@ -200,6 +200,6 @@ export function installTakeovers(ctx, takeovers) {
200
200
  ctx.effect(() => () => { takeovers.dispose(); });
201
201
  ctx.inject?.(['webServer'], (host) => {
202
202
  const server = host.get('webServer');
203
- host.effect(() => server.register({ kind: 'exact', path: TAKEOVER_ROUTE, handler: pairedRoute(() => ctx.get('connection'), takeovers.handler) }));
203
+ host.effect(() => server.register({ kind: 'exact', path: TAKEOVER_ROUTE, auth: 'required', handler: pairedRoute(() => ctx.get('connection'), takeovers.handler) }));
204
204
  });
205
205
  }