dsh-builtin-browser 0.5.8 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (401) hide show
  1. package/CHANGELOG.md +410 -1
  2. package/README.en.md +16 -64
  3. package/README.md +33 -64
  4. package/assets/browser-carriers.svg +20 -0
  5. package/assets/browser-extension-identity.d.mts +2 -0
  6. package/assets/browser-extension-identity.mjs +2 -0
  7. package/assets/browser-messages.d.mts +5 -0
  8. package/assets/browser-messages.mjs +64 -0
  9. package/assets/browser-panel-locales.d.mts +2 -0
  10. package/assets/browser-panel-locales.mjs +380 -0
  11. package/assets/browser-policy.d.mts +37 -0
  12. package/assets/browser-policy.mjs +37 -0
  13. package/assets/browser-products.d.mts +6 -0
  14. package/assets/browser-products.mjs +76 -0
  15. package/assets/screenshots/1-main.png +0 -0
  16. package/assets/screenshots/2-form-fill.png +0 -0
  17. package/assets/screenshots/3-challenge.png +0 -0
  18. package/browser-extension/constants.mjs +20 -0
  19. package/browser-extension/controller.mjs +293 -0
  20. package/browser-extension/locales.mjs +15 -0
  21. package/browser-extension/manifest.json +12 -0
  22. package/browser-extension/options.html +14 -0
  23. package/browser-extension/options.mjs +9 -0
  24. package/browser-extension/permission-guard.mjs +13 -0
  25. package/browser-extension/worker.mjs +74 -0
  26. package/cordis.patch.yml +23 -48
  27. package/desktop-bridge/desktop-discovery.d.mts +2 -0
  28. package/desktop-bridge/desktop-discovery.mjs +36 -0
  29. package/desktop-bridge/desktop-identity.json +17 -1
  30. package/desktop-bridge/desktop-processes.d.mts +1 -0
  31. package/desktop-bridge/desktop-processes.mjs +15 -0
  32. package/desktop-bridge/guest-proxy.mjs +109 -0
  33. package/desktop-bridge/install.mjs +197 -74
  34. package/desktop-bridge/main.mjs +11 -0
  35. package/desktop-bridge/maintenance-files.d.mts +8 -0
  36. package/desktop-bridge/maintenance-files.mjs +28 -0
  37. package/desktop-bridge/maintenance-progress.ps1 +2 -2
  38. package/desktop-bridge/native-guests.mjs +41 -0
  39. package/desktop-bridge/plugin-browser-bridge.js +618 -370
  40. package/desktop-bridge/profile-loader.mjs +26 -0
  41. package/dist/client.cjs +43167 -0
  42. package/dist/client.d.cts +516 -0
  43. package/dist/client.d.mts +516 -0
  44. package/dist/index.cjs +92 -0
  45. package/dist/index.d.mts +2960 -0
  46. package/dist/index.mjs +24 -0
  47. package/docs/HANDOVER-2026-11-15.md +178 -0
  48. package/docs/README.md +10 -19
  49. package/docs/architecture.md +17 -145
  50. package/docs/child-tabs.md +13 -0
  51. package/docs/desktop-acceptance.md +9 -0
  52. package/docs/development.md +88 -18
  53. package/docs/extension-browser.md +44 -0
  54. package/docs/hardcoding-audit.md +64 -0
  55. package/docs/limitations.md +23 -73
  56. package/docs/pr64-extension-status.md +46 -0
  57. package/docs/pr64-maintenance.md +25 -0
  58. package/docs/pr64-native-children.md +52 -0
  59. package/docs/pr64-native-views.md +60 -0
  60. package/docs/tool-reference.md +87 -11
  61. package/docs/user-guide.md +47 -255
  62. package/docs/why-browser.md +6 -39
  63. package/dsh-host-patch/README.md +60 -0
  64. package/dsh-host-patch/apply.mjs +194 -0
  65. package/dsh-host-patch/legacy-bridge.mjs +53 -0
  66. package/dsh-host-patch/rc3-revision1.json +90 -0
  67. package/dsh-host-patch/rc3-revision2.json +112 -0
  68. package/dsh-host-patch/rc3-revision3.json.gz +0 -0
  69. package/dsh-host-patch/rc3-revision4.json.gz +0 -0
  70. package/dsh-host-patch/rc3-revision5.json.gz +0 -0
  71. package/dsh-host-patch/rc3-revision6.json.gz +0 -0
  72. package/dsh-host-patch/rc3-revision7.json.gz +0 -0
  73. package/dsh-host-patch/rc3-revision8.json.gz +0 -0
  74. package/dsh-host-patch/rc3.json +148 -0
  75. package/dsh-host-patch/rc5-revision1.json +90 -0
  76. package/dsh-host-patch/rc5-revision2.json +112 -0
  77. package/dsh-host-patch/rc5-revision3.json.gz +0 -0
  78. package/dsh-host-patch/rc5-revision4.json.gz +0 -0
  79. package/dsh-host-patch/rc5-revision5.json.gz +0 -0
  80. package/dsh-host-patch/rc5-revision6.json.gz +0 -0
  81. package/dsh-host-patch/rc5-revision7.json.gz +0 -0
  82. package/dsh-host-patch/rc5-revision8.json.gz +0 -0
  83. package/dsh-host-patch/rc5.json +148 -0
  84. package/lib/bridge-compatibility.js +38 -0
  85. package/lib/browser/handles.js +78 -0
  86. package/lib/browser/runtime.js +155 -43
  87. package/lib/browser/takeover-target.js +24 -0
  88. package/lib/browser-electron/authenticated-route.js +23 -0
  89. package/lib/browser-electron/automatic-maintenance.js +394 -51
  90. package/lib/browser-electron/bridge-auto.js +2 -1
  91. package/lib/browser-electron/bridge-connection.js +8 -1
  92. package/lib/browser-electron/bridge-install.js +27 -2
  93. package/lib/browser-electron/bridge-maintenance.js +35 -10
  94. package/lib/browser-electron/bridge-status.js +98 -27
  95. package/lib/browser-electron/desktop-bridge-host.js +193 -560
  96. package/lib/browser-electron/desktop-identity.js +40 -2
  97. package/lib/browser-electron/document-readiness.js +34 -0
  98. package/lib/browser-electron/electron-provision.js +14 -44
  99. package/lib/browser-electron/entry.js +659 -252
  100. package/lib/browser-electron/extension-browser.js +234 -0
  101. package/lib/browser-electron/extension-setup.js +69 -0
  102. package/lib/browser-electron/guest-cookie-jar.LICENSE.txt +32 -0
  103. package/lib/browser-electron/guest-cookie-jar.js +10559 -0
  104. package/lib/browser-electron/guest-cookie-store.js +74 -0
  105. package/lib/browser-electron/guest-css-runtime.js +75 -0
  106. package/lib/browser-electron/guest-css.js +106 -0
  107. package/lib/browser-electron/guest-route.js +603 -0
  108. package/lib/browser-electron/guest-runtime.js +356 -0
  109. package/lib/browser-electron/guest-storage-runtime.js +52 -0
  110. package/lib/browser-electron/guest-storage.js +163 -0
  111. package/lib/browser-electron/history-store.js +2 -1
  112. package/lib/browser-electron/host-main.js +162 -7
  113. package/lib/browser-electron/host-patch-maintenance.js +141 -0
  114. package/lib/browser-electron/http-body.js +22 -0
  115. package/lib/browser-electron/maintenance-broker.js +35 -5
  116. package/lib/browser-electron/maintenance-lifecycle.js +7 -5
  117. package/lib/browser-electron/maintenance-route.js +9 -6
  118. package/lib/browser-electron/open-slot.js +47 -0
  119. package/lib/browser-electron/paths.js +4 -1
  120. package/lib/browser-electron/preferred-browser.js +144 -0
  121. package/lib/browser-electron/preview-route.js +11 -8
  122. package/lib/browser-electron/process-ownership.js +198 -0
  123. package/lib/browser-electron/profile-checkpoint.js +222 -0
  124. package/lib/browser-electron/profile-command.js +60 -0
  125. package/lib/browser-electron/profile-extension.js +126 -0
  126. package/lib/browser-electron/profile-lease.js +157 -0
  127. package/lib/browser-electron/profile-residue.js +61 -0
  128. package/lib/browser-electron/provider.js +719 -262
  129. package/lib/browser-electron/reference-route.js +635 -0
  130. package/lib/browser-electron/remote-host.js +12 -13
  131. package/lib/browser-electron/runtime-route.js +6 -5
  132. package/lib/browser-electron/runtime-status.js +30 -29
  133. package/lib/browser-electron/settings-store.js +10 -5
  134. package/lib/browser-electron/shortcuts-route.js +108 -0
  135. package/lib/browser-electron/sidebar-only-host.js +119 -18
  136. package/lib/browser-electron/startpage-shortcuts.js +172 -0
  137. package/lib/browser-electron/system-browser.js +352 -371
  138. package/lib/browser-electron/windows-system.js +2 -1
  139. package/lib/browser-reference/delivery.js +326 -0
  140. package/lib/browser-reference/entry.js +597 -0
  141. package/lib/browser-reference/export.js +298 -0
  142. package/lib/browser-reference/import.js +295 -0
  143. package/lib/browser-reference/page-script.js +1406 -0
  144. package/lib/browser-reference/service.js +1062 -0
  145. package/lib/browser-reference/store.js +177 -0
  146. package/lib/browser-reference/submission-receipts.js +139 -0
  147. package/lib/browser-reference/text-quote.js +167 -0
  148. package/lib/browser-reference/types.js +11 -0
  149. package/lib/browser-reference/visible.js +311 -0
  150. package/lib/browser-reference/web-sources.js +97 -0
  151. package/lib/index.js +10 -3
  152. package/lib/reference-owner.js +5 -0
  153. package/lib/reference-page.js +12 -0
  154. package/lib/reference-source.js +2 -0
  155. package/lib/reference-text.js +188 -0
  156. package/lib/startpage-settings.js +63 -0
  157. package/lib/startpage.js +44 -0
  158. package/lib/takeover-protocol.js +2 -0
  159. package/lib/tool-browser/code-tool.js +416 -0
  160. package/lib/tool-browser/code-worker.js +872 -0
  161. package/lib/tool-browser/index.js +940 -76
  162. package/lib/tool-browser/page-probe.js +3 -3
  163. package/lib/tool-browser/panel-page.js +95 -0
  164. package/lib/tool-browser/screenshot-image.js +51 -0
  165. package/lib/tool-browser/takeover.js +205 -0
  166. package/lib/types.js +1 -0
  167. package/lib/web-guest.js +26 -0
  168. package/native-host/client.d.mts +17 -0
  169. package/native-host/client.mjs +100 -0
  170. package/native-host/host.mjs +150 -0
  171. package/native-host/identity.d.mts +2 -0
  172. package/native-host/identity.mjs +1 -0
  173. package/native-host/install.mjs +168 -0
  174. package/native-host/protocol.mjs +75 -0
  175. package/package.json +80 -92
  176. package/scripts/build.mjs +66 -0
  177. package/scripts/bundle-host.mjs +28 -0
  178. package/scripts/fix-exports.mjs +50 -0
  179. package/scripts/install-electron.mjs +11 -26
  180. package/scripts/verify-exports.mjs +47 -0
  181. package/scripts/verify-preview-sdk.mjs +93 -0
  182. package/skills/dsh-builtin-browser/SKILL.md +56 -47
  183. package/skills/dsh-builtin-browser/references/batch.md +31 -1
  184. package/skills/dsh-debug-host/SKILL.md +56 -0
  185. package/skills/dsh-debug-self/SKILL.md +50 -0
  186. package/src/bridge-compatibility.ts +39 -0
  187. package/src/browser/handles.ts +89 -0
  188. package/src/browser/runtime.ts +146 -50
  189. package/src/browser/takeover-target.ts +36 -0
  190. package/src/browser/types.ts +19 -7
  191. package/src/browser-electron/authenticated-route.ts +29 -1
  192. package/src/browser-electron/automatic-maintenance.ts +368 -56
  193. package/src/browser-electron/bridge-auto.ts +5 -4
  194. package/src/browser-electron/bridge-connection.ts +20 -2
  195. package/src/browser-electron/bridge-endpoint.ts +3 -3
  196. package/src/browser-electron/bridge-install.ts +40 -4
  197. package/src/browser-electron/bridge-maintenance.ts +42 -14
  198. package/src/browser-electron/bridge-status.ts +94 -23
  199. package/src/browser-electron/desktop-bridge-host.ts +185 -585
  200. package/src/browser-electron/desktop-identity.ts +53 -2
  201. package/src/browser-electron/document-readiness.ts +45 -0
  202. package/src/browser-electron/electron-provision.ts +12 -45
  203. package/src/browser-electron/entry.ts +1299 -882
  204. package/src/browser-electron/ephemeral-profile.ts +1 -1
  205. package/src/browser-electron/extension-browser.ts +223 -0
  206. package/src/browser-electron/extension-setup.ts +67 -0
  207. package/src/browser-electron/guest-cookie-jar.ts +176 -0
  208. package/src/browser-electron/guest-cookie-store.ts +59 -0
  209. package/src/browser-electron/guest-css-runtime.ts +76 -0
  210. package/src/browser-electron/guest-css.ts +68 -0
  211. package/src/browser-electron/guest-route.ts +568 -0
  212. package/src/browser-electron/guest-runtime.ts +357 -0
  213. package/src/browser-electron/guest-storage-runtime.ts +54 -0
  214. package/src/browser-electron/guest-storage.ts +117 -0
  215. package/src/browser-electron/history-store.ts +5 -4
  216. package/src/browser-electron/host-main.ts +156 -11
  217. package/src/browser-electron/host-patch-maintenance.ts +112 -0
  218. package/src/browser-electron/http-body.ts +23 -0
  219. package/src/browser-electron/maintenance-broker.ts +29 -5
  220. package/src/browser-electron/maintenance-lifecycle.ts +14 -9
  221. package/src/browser-electron/maintenance-route.ts +17 -14
  222. package/src/browser-electron/missing-system-browser.ts +2 -2
  223. package/src/browser-electron/open-slot.ts +49 -0
  224. package/src/browser-electron/paths.ts +5 -1
  225. package/src/browser-electron/preferred-browser.ts +120 -0
  226. package/src/browser-electron/preview-route.ts +18 -11
  227. package/src/browser-electron/process-ownership.ts +168 -0
  228. package/src/browser-electron/profile-checkpoint.ts +187 -0
  229. package/src/browser-electron/profile-command.ts +46 -0
  230. package/src/browser-electron/profile-extension.ts +124 -0
  231. package/src/browser-electron/profile-lease.ts +115 -0
  232. package/src/browser-electron/profile-residue.ts +49 -0
  233. package/src/browser-electron/provider.ts +771 -289
  234. package/src/browser-electron/reference-route.ts +608 -0
  235. package/src/browser-electron/remote-host.ts +15 -15
  236. package/src/browser-electron/runtime-route.ts +11 -10
  237. package/src/browser-electron/runtime-status.ts +51 -32
  238. package/src/browser-electron/settings-store.ts +27 -7
  239. package/src/browser-electron/shortcuts-route.ts +112 -0
  240. package/src/browser-electron/sidebar-only-host.ts +118 -19
  241. package/src/browser-electron/startpage-shortcuts.ts +213 -0
  242. package/src/browser-electron/system-browser.ts +309 -338
  243. package/src/browser-electron/windows-system.ts +2 -1
  244. package/src/browser-reference/delivery.ts +384 -0
  245. package/src/browser-reference/entry.ts +631 -0
  246. package/src/browser-reference/export.ts +339 -0
  247. package/src/browser-reference/import.ts +303 -0
  248. package/src/browser-reference/page-script.ts +1537 -0
  249. package/src/browser-reference/service.ts +1315 -0
  250. package/src/browser-reference/store.ts +172 -0
  251. package/src/browser-reference/submission-receipts.ts +122 -0
  252. package/src/browser-reference/text-quote.ts +219 -0
  253. package/src/browser-reference/types.ts +195 -0
  254. package/src/browser-reference/visible.ts +367 -0
  255. package/src/browser-reference/web-sources.ts +103 -0
  256. package/src/client/browser/BrowserController.ts +693 -0
  257. package/src/client/browser/BrowserFrame.ts +78 -0
  258. package/src/client/browser/BrowserNavigation.ts +169 -0
  259. package/src/client/browser/BrowserPage.ts +23 -0
  260. package/src/client/browser/BrowserPersistence.ts +44 -0
  261. package/src/client/browser/IframeImpl.ts +176 -0
  262. package/src/client/browser/child-tabs.ts +14 -0
  263. package/src/client/browser/iframe-reference.ts +67 -0
  264. package/src/client/browser/initialization.ts +262 -0
  265. package/src/client/browser/omnibox.ts +243 -0
  266. package/src/client/browser/store.ts +38 -0
  267. package/src/client/browser/takeover-channel.ts +72 -0
  268. package/src/client/browser/url.ts +46 -0
  269. package/src/client/browser/web-reference-source.ts +52 -0
  270. package/src/client/css-modules.d.ts +4 -0
  271. package/src/client/definition.tsx +30 -0
  272. package/src/client/electron/ElectronWebViewImpl.ts +364 -0
  273. package/src/client/electron/ElectronWebviewPresentation.ts +138 -0
  274. package/src/client/electron/NativeChildPresentation.ts +45 -0
  275. package/src/client/electron/NativeViewPage.ts +251 -0
  276. package/src/client/electron/pages.ts +23 -0
  277. package/src/client/electron/reference-overlay.ts +53 -0
  278. package/src/client/electron/workspace.ts +33 -0
  279. package/src/client/index.ts +293 -0
  280. package/src/client/locales.ts +857 -0
  281. package/src/client/pages.ts +28 -0
  282. package/src/client/reference/client/BrowserRefLink.tsx +142 -0
  283. package/src/client/reference/client/draft-reference.ts +167 -0
  284. package/src/client/reference/client/index.ts +7 -0
  285. package/src/client/reference/client/ordered-submission.ts +108 -0
  286. package/src/client/reference/client/pending-delivery.ts +216 -0
  287. package/src/client/reference/client/plugin.ts +189 -0
  288. package/src/client/reference/client/production/ReferenceCapsules.tsx +345 -0
  289. package/src/client/reference/client/production/ReferenceDock.module.css +193 -0
  290. package/src/client/reference/client/production/ReferenceDock.tsx +6 -0
  291. package/src/client/reference/client/production/ReferenceFeedback.tsx +15 -0
  292. package/src/client/reference/client/production/ReferenceMath.tsx +44 -0
  293. package/src/client/reference/client/production/ReferenceText.tsx +36 -0
  294. package/src/client/reference/client/production/assembly.ts +471 -0
  295. package/src/client/reference/client/production/asset-store.ts +144 -0
  296. package/src/client/reference/client/production/availability.ts +74 -0
  297. package/src/client/reference/client/production/bytes.ts +36 -0
  298. package/src/client/reference/client/production/delivery-client.ts +211 -0
  299. package/src/client/reference/client/production/draft-adapter.ts +508 -0
  300. package/src/client/reference/client/production/http-transport.ts +217 -0
  301. package/src/client/reference/client/production/production-submission.ts +310 -0
  302. package/src/client/reference/client/production/protocol.ts +231 -0
  303. package/src/client/reference/client/production/reference-card.ts +240 -0
  304. package/src/client/reference/client/production/reference-labels.ts +29 -0
  305. package/src/client/reference/client/production/reply-link-bridge.ts +222 -0
  306. package/src/client/reference/client/production/reveal.ts +215 -0
  307. package/src/client/reference/client/production/runtime.ts +1101 -0
  308. package/src/client/reference/client/production/snapshot-adapter.ts +154 -0
  309. package/src/client/reference/client/production/source-marker.ts +63 -0
  310. package/src/client/reference/client/production/source-opener.ts +55 -0
  311. package/src/client/reference/client/production/styles.ts +104 -0
  312. package/src/client/reference/client/production/user-text-rule.ts +58 -0
  313. package/src/client/reference/client/reveal.ts +107 -0
  314. package/src/client/reference/client/scheme.ts +114 -0
  315. package/src/client/reference/client/types.ts +168 -0
  316. package/src/client/reference/css-modules.d.ts +4 -0
  317. package/src/client/reference/index.ts +11 -0
  318. package/src/client/reference-capture-owner.ts +162 -0
  319. package/src/client/reference-intents.ts +36 -0
  320. package/src/client/settings/index.ts +34 -0
  321. package/{client.js → src/client/settings/panel.ts} +2657 -2231
  322. package/src/client/shortcut-open.ts +30 -0
  323. package/src/client/startpage/binding.ts +99 -0
  324. package/src/client/startpage/controller.ts +303 -0
  325. package/src/client/startpage/model.ts +279 -0
  326. package/src/client/view/Browser.module.css +751 -0
  327. package/src/client/view/BrowserBody.tsx +314 -0
  328. package/src/client/view/BrowserPresentation.ts +9 -0
  329. package/src/client/view/BrowserTitle.tsx +17 -0
  330. package/src/client/view/IframePresentation.ts +344 -0
  331. package/src/client/view/StartPage.tsx +597 -0
  332. package/src/client/view/TakeoverBanner.tsx +21 -0
  333. package/src/index.ts +110 -73
  334. package/src/reference-owner.ts +5 -0
  335. package/src/reference-page.ts +9 -0
  336. package/src/reference-source.ts +3 -0
  337. package/src/reference-text.ts +197 -0
  338. package/src/startpage-settings.ts +103 -0
  339. package/src/startpage.ts +71 -0
  340. package/src/takeover-protocol.ts +19 -0
  341. package/src/tool-browser/code-tool.ts +401 -0
  342. package/src/tool-browser/code-worker.ts +639 -0
  343. package/src/tool-browser/index.ts +908 -77
  344. package/src/tool-browser/page-probe.ts +4 -4
  345. package/src/tool-browser/panel-page.ts +124 -0
  346. package/src/tool-browser/screenshot-image.ts +49 -0
  347. package/src/tool-browser/takeover.ts +198 -0
  348. package/src/types/electron-shim.d.ts +20 -0
  349. package/src/types.ts +85 -0
  350. package/src/web-guest.ts +34 -0
  351. package/tools/accept-desktop.mjs +148 -0
  352. package/lib/browser/runtime.d.ts +0 -175
  353. package/lib/browser/types.d.ts +0 -797
  354. package/lib/browser-electron/authenticated-route.d.ts +0 -27
  355. package/lib/browser-electron/automatic-maintenance.d.ts +0 -41
  356. package/lib/browser-electron/bridge-auto.d.ts +0 -93
  357. package/lib/browser-electron/bridge-connection.d.ts +0 -93
  358. package/lib/browser-electron/bridge-endpoint.d.ts +0 -30
  359. package/lib/browser-electron/bridge-install.d.ts +0 -85
  360. package/lib/browser-electron/bridge-maintenance.d.ts +0 -24
  361. package/lib/browser-electron/bridge-status.d.ts +0 -50
  362. package/lib/browser-electron/desktop-bridge-host.d.ts +0 -248
  363. package/lib/browser-electron/desktop-identity.d.ts +0 -58
  364. package/lib/browser-electron/electron-provision.d.ts +0 -92
  365. package/lib/browser-electron/entry.d.ts +0 -64
  366. package/lib/browser-electron/ephemeral-profile.d.ts +0 -37
  367. package/lib/browser-electron/file-write.d.ts +0 -2
  368. package/lib/browser-electron/history-store.d.ts +0 -98
  369. package/lib/browser-electron/host-main.d.ts +0 -26
  370. package/lib/browser-electron/http-body.d.ts +0 -24
  371. package/lib/browser-electron/json-reply.d.ts +0 -33
  372. package/lib/browser-electron/maintenance-broker.d.ts +0 -35
  373. package/lib/browser-electron/maintenance-lifecycle.d.ts +0 -32
  374. package/lib/browser-electron/maintenance-route.d.ts +0 -18
  375. package/lib/browser-electron/missing-system-browser.d.ts +0 -54
  376. package/lib/browser-electron/paths.d.ts +0 -4
  377. package/lib/browser-electron/preview-route.d.ts +0 -89
  378. package/lib/browser-electron/process.d.ts +0 -14
  379. package/lib/browser-electron/provider.d.ts +0 -959
  380. package/lib/browser-electron/remote-host.d.ts +0 -256
  381. package/lib/browser-electron/rpc-input.d.ts +0 -4
  382. package/lib/browser-electron/rpc-ops.d.ts +0 -18
  383. package/lib/browser-electron/runtime-diagnostics.d.ts +0 -12
  384. package/lib/browser-electron/runtime-route.d.ts +0 -55
  385. package/lib/browser-electron/runtime-status.d.ts +0 -116
  386. package/lib/browser-electron/settings-route.d.ts +0 -15
  387. package/lib/browser-electron/settings-store.d.ts +0 -224
  388. package/lib/browser-electron/sidebar-only-host.d.ts +0 -36
  389. package/lib/browser-electron/system-browser.d.ts +0 -367
  390. package/lib/browser-electron/timing.d.ts +0 -8
  391. package/lib/browser-electron/virtual-cursor.d.ts +0 -67
  392. package/lib/browser-electron/windows-system.d.ts +0 -3
  393. package/lib/index.d.ts +0 -30
  394. package/lib/tool-browser/element-fields.d.ts +0 -145
  395. package/lib/tool-browser/index.d.ts +0 -53
  396. package/lib/tool-browser/page-probe.d.ts +0 -86
  397. package/scripts/consumer-install-check.mjs +0 -72
  398. package/scripts/run-tests.mjs +0 -32
  399. package/scripts/verify-host-compat.mjs +0 -195
  400. package/scripts/verify-preview-route.mjs +0 -168
  401. package/scripts/verify-runtime-status.mjs +0 -179
package/src/index.ts CHANGED
@@ -1,73 +1,110 @@
1
- /**
2
- * dsh-builtin-browser plugin entry: aggregates the shared-browser capability
3
- * pieces. The cordis.patch.yml rows reference subpath exports:
4
- * - `dsh-builtin-browser/browser` -> the ctx.browser seam (Service)
5
- * - `dsh-builtin-browser/browser-electron` -> the Electron CDP provider
6
- * - `dsh-builtin-browser/tool-browser` -> the model-facing dsh_browser_* tools
7
- * The capability itself is composed by those rows; this root entry exists for
8
- * programmatic imports AND because the host's client-module scan identifies a
9
- * package's browser half through a loader row whose specifier resolves to the
10
- * PACKAGE ROOT. A row named after a subpath (`dsh-builtin-browser/browser`) is
11
- * not a package specifier and is skipped by design, which is why the patch also
12
- * registers a row under the bare package name — see cordis.patch.yml.
13
- * @module dsh-builtin-browser
14
- */
15
-
16
- /** Plugin identity for the root row (the composition surface is the subpath rows). */
17
-
18
- export const name = 'dsh-builtin-browser'
19
-
20
- /**
21
- * Inert application for the root row: the browser seam, the Electron provider and
22
- * the tools are mounted by the subpath rows, so this one only exists to give the
23
- * package a loader row named after the package itself. Without it the host's
24
- * client scan finds no row to resolve `dsh.client` from, and the settings panel
25
- * never reaches the browser (the plugin works, its client half is invisible).
26
- */
27
- export function apply(): void {
28
- }
29
-
30
-
31
- export { BrowserError } from './browser/types.js'
32
- export type {
33
- BrowserA11yNode,
34
- BrowserA11yRequest,
35
- BrowserA11yResult,
36
- BrowserChallenge,
37
- BrowserCheckRequest,
38
- BrowserClearRequest,
39
- BrowserClickRequest,
40
- BrowserContentFormat,
41
- BrowserContentRequest,
42
- BrowserContentResult,
43
- BrowserElementTarget,
44
- BrowserExecuteRequest,
45
- BrowserExecuteResult,
46
- BrowserFillField,
47
- BrowserFillRequest,
48
- BrowserFillResult,
49
- BrowserGetValueRequest,
50
- BrowserGetValueResult,
51
- BrowserNavigateRequest,
52
- BrowserOpenRequest,
53
- BrowserProvider,
54
- BrowserScrapeField,
55
- BrowserScrapeRequest,
56
- BrowserScrapeResult,
57
- BrowserScreenshotRequest,
58
- BrowserScreenshotResult,
59
- BrowserSelectRequest,
60
- BrowserSelectResult,
61
- BrowserSessionId,
62
- BrowserSetValueRequest,
63
- BrowserSetValueResult,
64
- BrowserSnapshotElement,
65
- BrowserSnapshotResult,
66
- BrowserTab,
67
- BrowserTypeRequest,
68
- ExportedCookie,
69
- } from './browser/types.js'
70
- export { BrowserRuntime } from './browser/runtime.js'
71
- export { ElectronBrowserProvider } from './browser-electron/provider.js'
72
- export type { ElectronBrowserViewHost, ElectronViewHandle } from './browser-electron/provider.js'
73
- export { RemoteElectronViewHost, defaultHostMainPath } from './browser-electron/remote-host.js'
1
+ /**
2
+ * dsh-builtin-browser plugin entry: aggregates the shared-browser capability
3
+ * pieces. The cordis.patch.yml rows reference subpath exports:
4
+ * - `dsh-builtin-browser/browser` -> the ctx.browser seam (Service)
5
+ * - `dsh-builtin-browser/browser-electron` -> the Electron CDP provider
6
+ * - `dsh-builtin-browser/tool-browser` -> the model-facing dsh_browser_* tools
7
+ * The capability itself is composed by those rows; this root entry exists for
8
+ * programmatic imports AND because the host's client-module scan identifies a
9
+ * package's browser half through a loader row whose specifier resolves to the
10
+ * PACKAGE ROOT. A row named after a subpath (`dsh-builtin-browser/browser`) is
11
+ * not a package specifier and is skipped by design, which is why the patch also
12
+ * registers a row under the bare package name — see cordis.patch.yml.
13
+ * @module dsh-builtin-browser
14
+ */
15
+
16
+ /** Plugin identity for the root row (the composition surface is the subpath rows). */
17
+
18
+ import type { Context } from '@deepseek-ai/cordis'
19
+
20
+ export const name = 'dsh-builtin-browser'
21
+
22
+ /**
23
+ * Inert application for the root row: the browser seam, the Electron provider and
24
+ * the tools are mounted by the subpath rows, so this one only exists to give the
25
+ * package a loader row named after the package itself. Without it the host's
26
+ * client scan finds no row to resolve `dsh.client` from, and the settings panel
27
+ * never reaches the browser (the plugin works, its client half is invisible).
28
+ */
29
+ import { registerWebGuest } from './web-guest.ts'
30
+
31
+ /**
32
+ * 根行只做与载体无关的装配:侧栏 guest 代理必须始终存在,不能依赖 Electron 行。
33
+ * @param ctx - 插件容器。
34
+ */
35
+ export function apply(ctx: Context): void {
36
+ registerWebGuest(ctx)
37
+ }
38
+
39
+
40
+ export { BrowserError } from './browser/types.ts'
41
+ export type {
42
+ BrowserA11yNode,
43
+ BrowserA11yRequest,
44
+ BrowserA11yResult,
45
+ BrowserChallenge,
46
+ BrowserCheckRequest,
47
+ BrowserClearRequest,
48
+ BrowserClickRequest,
49
+ BrowserContentFormat,
50
+ BrowserContentRequest,
51
+ BrowserContentResult,
52
+ BrowserElementTarget,
53
+ BrowserExecuteRequest,
54
+ BrowserExecuteResult,
55
+ BrowserFillField,
56
+ BrowserFillRequest,
57
+ BrowserFillResult,
58
+ BrowserGetValueRequest,
59
+ BrowserGetValueResult,
60
+ BrowserNavigateRequest,
61
+ BrowserOpenRequest,
62
+ BrowserProvider,
63
+ BrowserScrapeField,
64
+ BrowserScrapeRequest,
65
+ BrowserScrapeResult,
66
+ BrowserScreenshotRequest,
67
+ BrowserScreenshotResult,
68
+ BrowserSelectRequest,
69
+ BrowserSelectResult,
70
+ BrowserSessionId,
71
+ BrowserSetValueRequest,
72
+ BrowserSetValueResult,
73
+ BrowserSnapshotElement,
74
+ BrowserSnapshotResult,
75
+ BrowserTab,
76
+ BrowserTypeRequest,
77
+ ExportedCookie,
78
+ } from './browser/types.ts'
79
+ export { BrowserRuntime } from './browser/runtime.ts'
80
+ export { BrowserReferenceService, createReferenceService, summarizeReference } from './browser-reference/service.ts'
81
+ export type {
82
+ BrowserReferenceDraftAdapter,
83
+ CaptureFailure,
84
+ CaptureOutcome,
85
+ CaptureRequest,
86
+ ReferenceHost,
87
+ ReferenceSummary,
88
+ RevealOutcome,
89
+ RevealPartResult,
90
+ } from './browser-reference/service.ts'
91
+ export type {
92
+ BrowserReference,
93
+ BrowserReferenceCarrier,
94
+ BrowserReferenceEntry,
95
+ BrowserReferenceOrigin,
96
+ BrowserReferencePart,
97
+ ImageAnchor,
98
+ ImageReferencePart,
99
+ TableAnchor,
100
+ TableCellRun,
101
+ TableCellSnapshot,
102
+ TableReferencePart,
103
+ TableSnapshot,
104
+ TextQuoteAnchor,
105
+ TextReferencePart,
106
+ } from './browser-reference/types.ts'
107
+ export { manifestHashOf, ReferenceStore, referenceStorePath } from './browser-reference/store.ts'
108
+ export { buildTextAnchor, findTextQuote } from './browser-reference/text-quote.ts'
109
+ export { ElectronBrowserProvider } from './browser-electron/provider.ts'
110
+ export type { ElectronBrowserViewHost, ElectronViewHandle } from './browser-electron/provider.ts'
@@ -0,0 +1,5 @@
1
+ /** Canonical reference owner; browser session / view identities are separate. */
2
+ export function referenceOwnerKey(sessionId: string): string {
3
+ const value = sessionId.trim()
4
+ return value.startsWith('session-') ? value.slice('session-'.length) : value
5
+ }
@@ -0,0 +1,9 @@
1
+ export function sameReferenceDocument(left: string, right: string): boolean {
2
+ try {
3
+ const current = new URL(left)
4
+ const source = new URL(right)
5
+ current.hash = ''
6
+ source.hash = ''
7
+ return current.href === source.href
8
+ } catch { return left === right }
9
+ }
@@ -0,0 +1,3 @@
1
+ export const WEB_SOURCE_ROUTE = '/dsh-builtin-browser/reference/source'
2
+ export const WEB_REVEAL_STATUSES = ['revealed', 'partial', 'ambiguous', 'missing', 'not-found', 'page-mismatch', 'unavailable'] as const
3
+ export type WebRevealStatus = typeof WEB_REVEAL_STATUSES[number]
@@ -0,0 +1,197 @@
1
+ export const MAX_REFERENCE_TEXT = 20_000
2
+
3
+ export type ReferenceTextNode =
4
+ | { readonly type: 'text'; readonly text: string }
5
+ | { readonly type: 'break' }
6
+ | { readonly type: 'rule' }
7
+ | { readonly type: 'math'; readonly latex: string; readonly display: boolean; readonly mathml?: string }
8
+ | { readonly type: 'heading'; readonly level: number; readonly children: readonly ReferenceTextNode[] }
9
+ | { readonly type: 'pre'; readonly language?: string; readonly children: readonly ReferenceTextNode[] }
10
+ | { readonly type: 'list-item'; readonly value?: number; readonly children: readonly ReferenceTextNode[] }
11
+ | { readonly type: 'block' | 'paragraph' | 'strong' | 'emphasis' | 'code' | 'blockquote' | 'definition-list' | 'term' | 'definition' | 'sup' | 'sub' | 'ruby' | 'ruby-text'; readonly children: readonly ReferenceTextNode[] }
12
+ | { readonly type: 'link'; readonly href: string; readonly children: readonly ReferenceTextNode[] }
13
+ | { readonly type: 'list'; readonly ordered: boolean; readonly start: number; readonly children: readonly ReferenceTextNode[] }
14
+
15
+ /** Accept only bounded semantic data, never page HTML or arbitrary attributes. */
16
+ export function isReferenceText(value: unknown, maxLength = MAX_REFERENCE_TEXT): value is readonly ReferenceTextNode[] {
17
+ let count = 0
18
+ let mathmlCharacters = 0
19
+ const visit = (nodes: unknown, depth: number): boolean => Array.isArray(nodes) && depth <= 64 && nodes.every(node => {
20
+ if (++count > 4096 || typeof node !== 'object' || node === null) return false
21
+ if (node.type === 'text') {
22
+ if (typeof node.text !== 'string') return false
23
+ return node.text.length <= maxLength
24
+ }
25
+ if (node.type === 'break' || node.type === 'rule') return true
26
+ if (node.type === 'math') {
27
+ if (typeof node.latex !== 'string' || node.latex.length === 0 || typeof node.display !== 'boolean') return false
28
+ if (node.mathml !== undefined && (typeof node.mathml !== 'string' || node.mathml.length > 64_000)) return false
29
+ mathmlCharacters += node.mathml?.length ?? 0
30
+ return node.latex.length <= maxLength && mathmlCharacters <= 64_000
31
+ }
32
+ if (!['block', 'paragraph', 'strong', 'emphasis', 'code', 'pre', 'list-item', 'blockquote', 'link', 'list', 'heading', 'definition-list', 'term', 'definition', 'sup', 'sub', 'ruby', 'ruby-text'].includes(node.type)) return false
33
+ if (node.type === 'heading' && (!Number.isInteger(node.level) || node.level < 1 || node.level > 6)) return false
34
+ if (node.type === 'pre' && node.language !== undefined && (typeof node.language !== 'string' || !/^[\w+-]{1,64}$/u.test(node.language))) return false
35
+ if (node.type === 'list-item' && node.value !== undefined && (!Number.isSafeInteger(node.value) || Math.abs(node.value) > 1_000_000)) return false
36
+ if (node.type === 'link' && (typeof node.href !== 'string' || node.href.length > 4000 || !/^https?:\/\//iu.test(node.href))) return false
37
+ if (node.type === 'list' && (typeof node.ordered !== 'boolean' || !Number.isSafeInteger(node.start) || Math.abs(node.start) > 1_000_000)) return false
38
+ return visit(node.children, depth + 1)
39
+ })
40
+ return visit(value, 0) && renderReferenceText(value as readonly ReferenceTextNode[]).length <= maxLength
41
+ }
42
+
43
+ /** Optional preview structure must not consume the model-facing quote budget. */
44
+ export function normalizeReferenceText(value: unknown, maxLength = MAX_REFERENCE_TEXT): readonly ReferenceTextNode[] | undefined {
45
+ let count = 0
46
+ let remainingMathML = 64_000
47
+ const visit = (nodes: unknown, depth: number): unknown => {
48
+ if (!Array.isArray(nodes) || depth > 64) return undefined
49
+ return nodes.map(node => {
50
+ if (++count > 4096 || typeof node !== 'object' || node === null) return undefined
51
+ if (node.type === 'math') {
52
+ const { mathml, ...source } = node
53
+ if (typeof mathml !== 'string' || mathml.length > remainingMathML) return source
54
+ remainingMathML -= mathml.length
55
+ return { ...source, mathml }
56
+ }
57
+ return 'children' in node ? { ...node, children: visit(node.children, depth + 1) } : node
58
+ })
59
+ }
60
+ const normalized = visit(value, 0)
61
+ return isReferenceText(normalized, maxLength) ? normalized : undefined
62
+ }
63
+
64
+ function escapeMarkdown(text: string): string {
65
+ return text.replace(/[\\`*_{}[\]<>!|#]/gu, '\\$&')
66
+ }
67
+
68
+ export function referenceTextContent(nodes: readonly ReferenceTextNode[]): string {
69
+ return nodes.map(node => node.type === 'text' ? node.text : node.type === 'math' ? node.latex : node.type === 'rule' ? '\n---\n' : node.type === 'break' ? '\n' : referenceTextContent(node.children)).join('')
70
+ }
71
+
72
+ /** The host accepts text content parts; encode the frozen semantics as Markdown. */
73
+ export function renderReferenceText(nodes: readonly ReferenceTextNode[]): string {
74
+ const render = (items: readonly ReferenceTextNode[]): string => {
75
+ let result = ''
76
+ for (const node of items) {
77
+ const text = renderNode(node)
78
+ if (['block', 'paragraph', 'pre', 'blockquote', 'list', 'heading', 'definition-list', 'term', 'definition', 'rule'].includes(node.type) || (node.type === 'math' && node.display)) {
79
+ if (result && !result.endsWith('\n\n')) result += result.endsWith('\n') ? '\n' : '\n\n'
80
+ result += `${text}\n\n`
81
+ } else result += text
82
+ }
83
+ return result
84
+ }
85
+ const renderNode = (node: ReferenceTextNode): string => {
86
+ if (node.type === 'text') return escapeMarkdown(node.text)
87
+ if (node.type === 'break') return ' \n'
88
+ if (node.type === 'rule') return '---'
89
+ if (node.type === 'math') return node.display ? `$$\n${node.latex}\n$$` : `$${node.latex}$`
90
+ if (node.type === 'code' || node.type === 'pre') {
91
+ const text = referenceTextContent(node.children)
92
+ const size = Math.max(node.type === 'pre' ? 3 : 1, ...[...text.matchAll(/`+/gu)].map(match => match[0].length + 1))
93
+ const fence = '`'.repeat(size)
94
+ return node.type === 'pre' ? `${fence}${node.language ?? ''}\n${text}\n${fence}` : `${fence} ${text} ${fence}`
95
+ }
96
+ const text = render(node.children)
97
+ switch (node.type) {
98
+ case 'block':
99
+ case 'paragraph': return text.trim()
100
+ case 'heading': return `${'#'.repeat(node.level)} ${text.trim()}`
101
+ case 'definition-list': return text.trim()
102
+ case 'term': return text.trim()
103
+ case 'definition': return `: ${text.trim()}`
104
+ case 'sup': return `<sup>${text}</sup>`
105
+ case 'sub': return `<sub>${text}</sub>`
106
+ case 'ruby': return `<ruby>${text}</ruby>`
107
+ case 'ruby-text': return `<rt>${text}</rt>`
108
+ case 'strong': return `**${text}**`
109
+ case 'emphasis': return `*${text}*`
110
+ case 'link': return `[${text}](${node.href.replace(/[\s()<>\\]/gu, char => encodeURIComponent(char).replace(/[()]/gu, token => `%${token.charCodeAt(0).toString(16).toUpperCase()}`))})`
111
+ case 'blockquote': return text.trim().split('\n').map(line => `> ${line}`).join('\n')
112
+ case 'list-item': return text
113
+ case 'list': {
114
+ let next = node.start
115
+ return node.children.map(child => {
116
+ if (child.type === 'list-item' && child.value !== undefined) next = child.value
117
+ const prefix = node.ordered ? `${next++}. ` : '- '
118
+ const lines = render([child]).trim().split('\n')
119
+ return prefix + lines.join(`\n${' '.repeat(prefix.length)}`)
120
+ }).join('\n')
121
+ }
122
+ }
123
+ }
124
+ return render(nodes).trim()
125
+ }
126
+
127
+ export interface ReferenceTable {
128
+ readonly columnCount?: number
129
+ readonly cells: readonly {
130
+ readonly row: number
131
+ readonly column: number
132
+ readonly rowSpan: number
133
+ readonly columnSpan: number
134
+ readonly role: 'header' | 'data'
135
+ readonly text: string
136
+ readonly content?: readonly ReferenceTextNode[]
137
+ }[]
138
+ readonly caption?: string
139
+ }
140
+
141
+ export function isReferenceTable(value: unknown): value is ReferenceTable {
142
+ if (typeof value !== 'object' || value === null) return false
143
+ const table = value as ReferenceTable
144
+ return (table.caption === undefined || (typeof table.caption === 'string' && table.caption.length <= MAX_REFERENCE_TEXT))
145
+ && (table.columnCount === undefined || (Number.isSafeInteger(table.columnCount) && table.columnCount >= 0))
146
+ && Array.isArray(table.cells) && table.cells.length <= 20_000
147
+ && table.cells.every(cell => cell && typeof cell.text === 'string' && cell.text.length <= MAX_REFERENCE_TEXT
148
+ && (cell.content === undefined || isReferenceText(cell.content))
149
+ && (cell.role === 'header' || cell.role === 'data')
150
+ && [cell.row, cell.column].every(n => Number.isSafeInteger(n) && n >= 0)
151
+ && [cell.rowSpan, cell.columnSpan].every(n => Number.isSafeInteger(n) && n > 0))
152
+ }
153
+
154
+ export function renderReferenceTable(table: ReferenceTable): string {
155
+ const escape = (text: string): string => text.replace(/&/gu, '&amp;').replace(/</gu, '&lt;').replace(/>/gu, '&gt;').replace(/\r?\n/gu, '<br>')
156
+ const caption = table.caption === undefined ? '' : `<caption>${escape(table.caption)}</caption>\n`
157
+ return `<table>\n${caption}${referenceTableRows(table).map(({ cells }) => `<tr>${cells.map(({ value: cell, columnSpan, rowSpan }) => {
158
+ if (cell === undefined) return `<td colspan="${columnSpan}"></td>`
159
+ const tag = cell.role === 'header' ? 'th' : 'td'
160
+ return `<${tag} rowspan="${rowSpan}" colspan="${columnSpan}">${escape(cell.text)}</${tag}>`
161
+ }).join('')}</tr>`).join('\n')}\n</table>`
162
+ }
163
+
164
+ export function renderReferenceMarkdownTable(table: ReferenceTable): string {
165
+ if (table.cells.length === 0) return ''
166
+ const rows = [...new Set(table.cells.map(cell => cell.row))].sort((a, b) => a - b)
167
+ const width = Math.min(200, table.cells.reduce((max, cell) => Math.max(max, cell.column + cell.columnSpan), table.columnCount ?? 0))
168
+ const escape = (text: string): string => text.replace(/\\/gu, '\\\\').replace(/\|/gu, '\\|').replace(/</gu, '&lt;').replace(/>/gu, '&gt;').replace(/\r?\n/gu, '<br>')
169
+ const line = (values: readonly string[]): string => `| ${values.join(' | ')} |`
170
+ const values = rows.map(row => Array.from({ length: width }, (_, column) => {
171
+ const cell = table.cells.find(cell => cell.row <= row && cell.row + cell.rowSpan > row && cell.column <= column && cell.column + cell.columnSpan > column)
172
+ return cell?.content === undefined ? escape(cell?.text ?? '') : renderReferenceText(cell.content).replace(/\\?\|/gu, '\\|').replace(/\r?\n/gu, '<br>')
173
+ }))
174
+ const header = table.cells.some(cell => cell.row === rows[0] && cell.role === 'header') ? values.shift()! : Array.from({ length: width }, () => '')
175
+ return [table.caption, line(header), line(Array.from({ length: width }, () => '---')), ...values.map(line)].filter(value => value !== undefined && value !== '').join('\n')
176
+ }
177
+
178
+ export function referenceTableRows<T extends ReferenceTable['cells'][number]>(table: { readonly cells: readonly T[]; readonly columnCount?: number }): {
179
+ row: number; cells: { column: number; columnSpan: number; rowSpan: number; value?: T }[]
180
+ }[] {
181
+ const rows = [...new Set(table.cells.map(cell => cell.row))].sort((a, b) => a - b)
182
+ const width = table.cells.reduce((max, cell) => Math.max(max, cell.column + cell.columnSpan), table.columnCount ?? 0)
183
+ return rows.map(row => {
184
+ const slots = table.cells.filter(cell => cell.row <= row && cell.row + cell.rowSpan > row)
185
+ .sort((a, b) => a.column - b.column)
186
+ const cells: { column: number; columnSpan: number; rowSpan: number; value?: T }[] = []
187
+ let column = 0
188
+ for (const cell of slots) {
189
+ if (cell.column > column) cells.push({ column, columnSpan: cell.column - column, rowSpan: 1 })
190
+ if (cell.row === row) cells.push({ column: cell.column, columnSpan: cell.columnSpan,
191
+ rowSpan: rows.filter(index => index >= row && index < row + cell.rowSpan).length, value: cell })
192
+ column = Math.max(column, cell.column + cell.columnSpan)
193
+ }
194
+ if (column < width) cells.push({ column, columnSpan: width - column, rowSpan: 1 })
195
+ return { row, cells }
196
+ })
197
+ }
@@ -0,0 +1,103 @@
1
+ /** Shared, schema-independent Sidebar Browser start-page preference model. */
2
+
3
+ /** Settings namespace owned by the start-page Host companion. */
4
+ export const BROWSER_STARTPAGE_NAMESPACE = 'browser-startpage'
5
+
6
+ /** Persisted preference layout version. */
7
+ export const BROWSER_STARTPAGE_VERSION = 1
8
+
9
+ /** Maximum stored shortcut entries. */
10
+ export const MAX_STARTPAGE_SHORTCUTS = 48
11
+
12
+ /** Maximum stored search engines. */
13
+ export const MAX_STARTPAGE_ENGINES = 12
14
+
15
+ /** Maximum stored URL length; shorter than the address-bar bound to keep patches readable. */
16
+ export const MAX_STARTPAGE_URL_LENGTH = 2048
17
+
18
+ /** Maximum shortcut display title length. */
19
+ export const MAX_SHORTCUT_TITLE_LENGTH = 80
20
+
21
+ /** Maximum search-engine display label length. */
22
+ export const MAX_ENGINE_LABEL_LENGTH = 48
23
+
24
+ /** Maximum shortcut icon key length; keys select local glyphs only. */
25
+ export const MAX_SHORTCUT_ICON_KEY_LENGTH = 32
26
+
27
+ /** One user-visible website entry. */
28
+ export interface BrowserShortcut {
29
+ readonly id: string
30
+ readonly title: string
31
+ readonly url: string
32
+ readonly iconKey?: string
33
+ }
34
+
35
+ /** One fixed search endpoint; no template syntax is interpreted. */
36
+ export interface BrowserSearchEngine {
37
+ readonly id: string
38
+ readonly label: string
39
+ readonly homeUrl: string
40
+ readonly searchUrl: string
41
+ readonly queryParameter: string
42
+ readonly extraParameters?: Readonly<Record<string, string>>
43
+ }
44
+
45
+ /** The complete shared start-page section. Array order is display order. */
46
+ export interface BrowserStartPagePreferences {
47
+ readonly version: number
48
+ readonly defaultSearchEngineId: string
49
+ readonly searchEngines: readonly BrowserSearchEngine[]
50
+ readonly shortcuts: readonly BrowserShortcut[]
51
+ }
52
+
53
+ /** Initial default engine. */
54
+ export const DEFAULT_SEARCH_ENGINE_ID = 'bing'
55
+
56
+ /** Initial search endpoints; replaceable by the user. */
57
+ export const DEFAULT_SEARCH_ENGINES: readonly BrowserSearchEngine[] = Object.freeze([
58
+ {
59
+ id: 'bing', label: 'Bing', homeUrl: 'https://www.bing.com/',
60
+ searchUrl: 'https://www.bing.com/search', queryParameter: 'q', extraParameters: {},
61
+ },
62
+ {
63
+ id: 'baidu', label: '百度', homeUrl: 'https://www.baidu.com/',
64
+ searchUrl: 'https://www.baidu.com/s', queryParameter: 'wd', extraParameters: {},
65
+ },
66
+ ])
67
+
68
+ /** Initial website entries; editable, deletable, and never re-added after removal. */
69
+ export const DEFAULT_SHORTCUTS: readonly BrowserShortcut[] = Object.freeze([
70
+ ...DEFAULT_SEARCH_ENGINES.map(({ id, label, homeUrl }) => ({ id, title: label, url: homeUrl, iconKey: id })),
71
+ { id: 'deepseek', title: 'DeepSeek', url: 'https://chat.deepseek.com/', iconKey: 'deepseek' },
72
+ ])
73
+
74
+ /**
75
+ * Build a detached initial preference section.
76
+ * @returns defaults safe for schema defaults and first-run display.
77
+ */
78
+ export function defaultStartPagePreferences(): BrowserStartPagePreferences {
79
+ return {
80
+ version: BROWSER_STARTPAGE_VERSION,
81
+ defaultSearchEngineId: DEFAULT_SEARCH_ENGINE_ID,
82
+ searchEngines: DEFAULT_SEARCH_ENGINES.map(engine => ({ ...engine })),
83
+ shortcuts: DEFAULT_SHORTCUTS.map(shortcut => ({ ...shortcut })),
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Whether a value can be a stable preference identifier.
89
+ * @param value - candidate id.
90
+ * @returns true for lowercase alphanumeric ids with inner dashes.
91
+ */
92
+ export function isPreferenceId(value: string): boolean {
93
+ return /^[a-z0-9][a-z0-9-]{0,47}$/u.test(value)
94
+ }
95
+
96
+ /**
97
+ * Whether a value can name a URL query parameter.
98
+ * @param value - candidate parameter name.
99
+ * @returns true for a bounded plain name.
100
+ */
101
+ export function isQueryParameterName(value: string): boolean {
102
+ return /^[A-Za-z][A-Za-z0-9_.-]{0,31}$/u.test(value)
103
+ }
@@ -0,0 +1,71 @@
1
+ /** Host registration for shared Sidebar Browser start-page preferences. */
2
+ import type { Context, Volatile } from '@deepseek-ai/cordis'
3
+ import type {} from '@deepseek-ai/dsh-settings'
4
+ import z from '@deepseek-ai/schemastery'
5
+ import {
6
+ BROWSER_STARTPAGE_VERSION, DEFAULT_SEARCH_ENGINE_ID, DEFAULT_SEARCH_ENGINES, DEFAULT_SHORTCUTS,
7
+ MAX_ENGINE_LABEL_LENGTH, MAX_SHORTCUT_ICON_KEY_LENGTH,
8
+ MAX_SHORTCUT_TITLE_LENGTH, MAX_STARTPAGE_ENGINES, MAX_STARTPAGE_SHORTCUTS,
9
+ MAX_STARTPAGE_URL_LENGTH,
10
+ } from './startpage-settings.ts'
11
+ import type { BrowserSearchEngine, BrowserShortcut } from './startpage-settings.ts'
12
+
13
+ const identifier = z.string().pattern(/^[a-z0-9][a-z0-9-]{0,47}$/u).required()
14
+ const httpUrl = z.string().max(MAX_STARTPAGE_URL_LENGTH).pattern(/^https?:\/\/\S+$/u).required()
15
+
16
+ const shortcutSchema = z.object({
17
+ id: identifier,
18
+ title: z.string().max(MAX_SHORTCUT_TITLE_LENGTH).required(),
19
+ url: httpUrl,
20
+ iconKey: z.string().max(MAX_SHORTCUT_ICON_KEY_LENGTH).default(''),
21
+ })
22
+
23
+ const searchEngineSchema = z.object({
24
+ id: identifier,
25
+ label: z.string().max(MAX_ENGINE_LABEL_LENGTH).required(),
26
+ homeUrl: httpUrl,
27
+ searchUrl: httpUrl,
28
+ queryParameter: z.string().pattern(/^[A-Za-z][A-Za-z0-9_.-]{0,31}$/u).required(),
29
+ extraParameters: z.dict(z.string().max(200)).default({}),
30
+ })
31
+
32
+ /** Live start-page preferences projected to every client of this Host. */
33
+ export interface Config {
34
+ /** Persisted layout version. */
35
+ version: Volatile<number>
36
+ /** Selected search engine id. */
37
+ defaultSearchEngineId: Volatile<string>
38
+ /** Search endpoints in display order. */
39
+ searchEngines: Volatile<BrowserSearchEngine[]>
40
+ /** Website entries in display order. */
41
+ shortcuts: Volatile<BrowserShortcut[]>
42
+ }
43
+
44
+ const DEFAULT_ENGINE_OBJECTS = DEFAULT_SEARCH_ENGINES.map(engine => ({ ...engine, extraParameters: { ...engine.extraParameters } }))
45
+ const DEFAULT_SHORTCUT_OBJECTS = DEFAULT_SHORTCUTS.map(shortcut => ({ ...shortcut }))
46
+
47
+ /**
48
+ * Volatile-only config: preference writes update values without remounting the browser.
49
+ *
50
+ * 显式标注类型:schemastery 的 `z.object(...)` 推导类型在本仓库的声明生成里会引入无法命名的
51
+ * `Dict` 引用(`TS2883`),导致 `target/dts` 里缺少本文件的 `.d.ts`,进而被发布前检查判为
52
+ * 「声明缺失」。标注 `z<Config>` 只影响类型,运行期对象一字未改。
53
+ */
54
+ export const Config: z<Config> = z.object({
55
+ version: z.number().default(BROWSER_STARTPAGE_VERSION).volatile(),
56
+ defaultSearchEngineId: z.string().default(DEFAULT_SEARCH_ENGINE_ID).volatile(),
57
+ searchEngines: z.array(searchEngineSchema).max(MAX_STARTPAGE_ENGINES)
58
+ .default(DEFAULT_ENGINE_OBJECTS).volatile(),
59
+ shortcuts: z.array(shortcutSchema).max(MAX_STARTPAGE_SHORTCUTS)
60
+ .default(DEFAULT_SHORTCUT_OBJECTS).volatile(),
61
+ }) as z<Config>
62
+
63
+ /**
64
+ * Keep preference writes live instead of reloading the owning entry.
65
+ * @param ctx - the start-page Host companion's context.
66
+ */
67
+ export function apply(ctx: Context): void {
68
+ ctx.inject(['settings'], (child) => {
69
+ child.effect(() => child.settings.configure({ auto: false }, ctx.fiber), 'browser-startpage: live preferences')
70
+ })
71
+ }
@@ -0,0 +1,19 @@
1
+ export const TAKEOVER_ROUTE = '/dsh-builtin-browser/browser/takeover'
2
+ export const TAKEOVER_TOOL = 'dsh_browser_request_takeover'
3
+
4
+ export type TakeoverOutcome = 'done' | 'skipped' | 'cancelled'
5
+ export type TakeoverDecision = 'allowed-once' | 'rejected' | 'cancelled' | 'unavailable'
6
+
7
+ export interface TakeoverSummary {
8
+ readonly url: string
9
+ readonly title: string
10
+ readonly snapshotHint: string
11
+ readonly fresh: boolean
12
+ }
13
+
14
+ export interface TakeoverNotice {
15
+ readonly id: string
16
+ readonly reason: string
17
+ readonly instructions?: string
18
+ readonly phase: 'waiting' | 'summary'
19
+ }