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.
- package/CHANGELOG.md +410 -1
- package/README.en.md +16 -64
- package/README.md +33 -64
- package/assets/browser-carriers.svg +20 -0
- package/assets/browser-extension-identity.d.mts +2 -0
- package/assets/browser-extension-identity.mjs +2 -0
- package/assets/browser-messages.d.mts +5 -0
- package/assets/browser-messages.mjs +64 -0
- package/assets/browser-panel-locales.d.mts +2 -0
- package/assets/browser-panel-locales.mjs +380 -0
- package/assets/browser-policy.d.mts +37 -0
- package/assets/browser-policy.mjs +37 -0
- package/assets/browser-products.d.mts +6 -0
- package/assets/browser-products.mjs +76 -0
- package/assets/screenshots/1-main.png +0 -0
- package/assets/screenshots/2-form-fill.png +0 -0
- package/assets/screenshots/3-challenge.png +0 -0
- package/browser-extension/constants.mjs +20 -0
- package/browser-extension/controller.mjs +293 -0
- package/browser-extension/locales.mjs +15 -0
- package/browser-extension/manifest.json +12 -0
- package/browser-extension/options.html +14 -0
- package/browser-extension/options.mjs +9 -0
- package/browser-extension/permission-guard.mjs +13 -0
- package/browser-extension/worker.mjs +74 -0
- package/cordis.patch.yml +23 -48
- package/desktop-bridge/desktop-discovery.d.mts +2 -0
- package/desktop-bridge/desktop-discovery.mjs +36 -0
- package/desktop-bridge/desktop-identity.json +17 -1
- package/desktop-bridge/desktop-processes.d.mts +1 -0
- package/desktop-bridge/desktop-processes.mjs +15 -0
- package/desktop-bridge/guest-proxy.mjs +109 -0
- package/desktop-bridge/install.mjs +197 -74
- package/desktop-bridge/main.mjs +11 -0
- package/desktop-bridge/maintenance-files.d.mts +8 -0
- package/desktop-bridge/maintenance-files.mjs +28 -0
- package/desktop-bridge/maintenance-progress.ps1 +2 -2
- package/desktop-bridge/native-guests.mjs +41 -0
- package/desktop-bridge/plugin-browser-bridge.js +618 -370
- package/desktop-bridge/profile-loader.mjs +26 -0
- package/dist/client.cjs +43167 -0
- package/dist/client.d.cts +516 -0
- package/dist/client.d.mts +516 -0
- package/dist/index.cjs +92 -0
- package/dist/index.d.mts +2960 -0
- package/dist/index.mjs +24 -0
- package/docs/HANDOVER-2026-11-15.md +178 -0
- package/docs/README.md +10 -19
- package/docs/architecture.md +17 -145
- package/docs/child-tabs.md +13 -0
- package/docs/desktop-acceptance.md +9 -0
- package/docs/development.md +88 -18
- package/docs/extension-browser.md +44 -0
- package/docs/hardcoding-audit.md +64 -0
- package/docs/limitations.md +23 -73
- package/docs/pr64-extension-status.md +46 -0
- package/docs/pr64-maintenance.md +25 -0
- package/docs/pr64-native-children.md +52 -0
- package/docs/pr64-native-views.md +60 -0
- package/docs/tool-reference.md +87 -11
- package/docs/user-guide.md +47 -255
- package/docs/why-browser.md +6 -39
- package/dsh-host-patch/README.md +60 -0
- package/dsh-host-patch/apply.mjs +194 -0
- package/dsh-host-patch/legacy-bridge.mjs +53 -0
- package/dsh-host-patch/rc3-revision1.json +90 -0
- package/dsh-host-patch/rc3-revision2.json +112 -0
- package/dsh-host-patch/rc3-revision3.json.gz +0 -0
- package/dsh-host-patch/rc3-revision4.json.gz +0 -0
- package/dsh-host-patch/rc3-revision5.json.gz +0 -0
- package/dsh-host-patch/rc3-revision6.json.gz +0 -0
- package/dsh-host-patch/rc3-revision7.json.gz +0 -0
- package/dsh-host-patch/rc3-revision8.json.gz +0 -0
- package/dsh-host-patch/rc3.json +148 -0
- package/dsh-host-patch/rc5-revision1.json +90 -0
- package/dsh-host-patch/rc5-revision2.json +112 -0
- package/dsh-host-patch/rc5-revision3.json.gz +0 -0
- package/dsh-host-patch/rc5-revision4.json.gz +0 -0
- package/dsh-host-patch/rc5-revision5.json.gz +0 -0
- package/dsh-host-patch/rc5-revision6.json.gz +0 -0
- package/dsh-host-patch/rc5-revision7.json.gz +0 -0
- package/dsh-host-patch/rc5-revision8.json.gz +0 -0
- package/dsh-host-patch/rc5.json +148 -0
- package/lib/bridge-compatibility.js +38 -0
- package/lib/browser/handles.js +78 -0
- package/lib/browser/runtime.js +155 -43
- package/lib/browser/takeover-target.js +24 -0
- package/lib/browser-electron/authenticated-route.js +23 -0
- package/lib/browser-electron/automatic-maintenance.js +394 -51
- package/lib/browser-electron/bridge-auto.js +2 -1
- package/lib/browser-electron/bridge-connection.js +8 -1
- package/lib/browser-electron/bridge-install.js +27 -2
- package/lib/browser-electron/bridge-maintenance.js +35 -10
- package/lib/browser-electron/bridge-status.js +98 -27
- package/lib/browser-electron/desktop-bridge-host.js +193 -560
- package/lib/browser-electron/desktop-identity.js +40 -2
- package/lib/browser-electron/document-readiness.js +34 -0
- package/lib/browser-electron/electron-provision.js +14 -44
- package/lib/browser-electron/entry.js +659 -252
- package/lib/browser-electron/extension-browser.js +234 -0
- package/lib/browser-electron/extension-setup.js +69 -0
- package/lib/browser-electron/guest-cookie-jar.LICENSE.txt +32 -0
- package/lib/browser-electron/guest-cookie-jar.js +10559 -0
- package/lib/browser-electron/guest-cookie-store.js +74 -0
- package/lib/browser-electron/guest-css-runtime.js +75 -0
- package/lib/browser-electron/guest-css.js +106 -0
- package/lib/browser-electron/guest-route.js +603 -0
- package/lib/browser-electron/guest-runtime.js +356 -0
- package/lib/browser-electron/guest-storage-runtime.js +52 -0
- package/lib/browser-electron/guest-storage.js +163 -0
- package/lib/browser-electron/history-store.js +2 -1
- package/lib/browser-electron/host-main.js +162 -7
- package/lib/browser-electron/host-patch-maintenance.js +141 -0
- package/lib/browser-electron/http-body.js +22 -0
- package/lib/browser-electron/maintenance-broker.js +35 -5
- package/lib/browser-electron/maintenance-lifecycle.js +7 -5
- package/lib/browser-electron/maintenance-route.js +9 -6
- package/lib/browser-electron/open-slot.js +47 -0
- package/lib/browser-electron/paths.js +4 -1
- package/lib/browser-electron/preferred-browser.js +144 -0
- package/lib/browser-electron/preview-route.js +11 -8
- package/lib/browser-electron/process-ownership.js +198 -0
- package/lib/browser-electron/profile-checkpoint.js +222 -0
- package/lib/browser-electron/profile-command.js +60 -0
- package/lib/browser-electron/profile-extension.js +126 -0
- package/lib/browser-electron/profile-lease.js +157 -0
- package/lib/browser-electron/profile-residue.js +61 -0
- package/lib/browser-electron/provider.js +719 -262
- package/lib/browser-electron/reference-route.js +635 -0
- package/lib/browser-electron/remote-host.js +12 -13
- package/lib/browser-electron/runtime-route.js +6 -5
- package/lib/browser-electron/runtime-status.js +30 -29
- package/lib/browser-electron/settings-store.js +10 -5
- package/lib/browser-electron/shortcuts-route.js +108 -0
- package/lib/browser-electron/sidebar-only-host.js +119 -18
- package/lib/browser-electron/startpage-shortcuts.js +172 -0
- package/lib/browser-electron/system-browser.js +352 -371
- package/lib/browser-electron/windows-system.js +2 -1
- package/lib/browser-reference/delivery.js +326 -0
- package/lib/browser-reference/entry.js +597 -0
- package/lib/browser-reference/export.js +298 -0
- package/lib/browser-reference/import.js +295 -0
- package/lib/browser-reference/page-script.js +1406 -0
- package/lib/browser-reference/service.js +1062 -0
- package/lib/browser-reference/store.js +177 -0
- package/lib/browser-reference/submission-receipts.js +139 -0
- package/lib/browser-reference/text-quote.js +167 -0
- package/lib/browser-reference/types.js +11 -0
- package/lib/browser-reference/visible.js +311 -0
- package/lib/browser-reference/web-sources.js +97 -0
- package/lib/index.js +10 -3
- package/lib/reference-owner.js +5 -0
- package/lib/reference-page.js +12 -0
- package/lib/reference-source.js +2 -0
- package/lib/reference-text.js +188 -0
- package/lib/startpage-settings.js +63 -0
- package/lib/startpage.js +44 -0
- package/lib/takeover-protocol.js +2 -0
- package/lib/tool-browser/code-tool.js +416 -0
- package/lib/tool-browser/code-worker.js +872 -0
- package/lib/tool-browser/index.js +940 -76
- package/lib/tool-browser/page-probe.js +3 -3
- package/lib/tool-browser/panel-page.js +95 -0
- package/lib/tool-browser/screenshot-image.js +51 -0
- package/lib/tool-browser/takeover.js +205 -0
- package/lib/types.js +1 -0
- package/lib/web-guest.js +26 -0
- package/native-host/client.d.mts +17 -0
- package/native-host/client.mjs +100 -0
- package/native-host/host.mjs +150 -0
- package/native-host/identity.d.mts +2 -0
- package/native-host/identity.mjs +1 -0
- package/native-host/install.mjs +168 -0
- package/native-host/protocol.mjs +75 -0
- package/package.json +80 -92
- package/scripts/build.mjs +66 -0
- package/scripts/bundle-host.mjs +28 -0
- package/scripts/fix-exports.mjs +50 -0
- package/scripts/install-electron.mjs +11 -26
- package/scripts/verify-exports.mjs +47 -0
- package/scripts/verify-preview-sdk.mjs +93 -0
- package/skills/dsh-builtin-browser/SKILL.md +56 -47
- package/skills/dsh-builtin-browser/references/batch.md +31 -1
- package/skills/dsh-debug-host/SKILL.md +56 -0
- package/skills/dsh-debug-self/SKILL.md +50 -0
- package/src/bridge-compatibility.ts +39 -0
- package/src/browser/handles.ts +89 -0
- package/src/browser/runtime.ts +146 -50
- package/src/browser/takeover-target.ts +36 -0
- package/src/browser/types.ts +19 -7
- package/src/browser-electron/authenticated-route.ts +29 -1
- package/src/browser-electron/automatic-maintenance.ts +368 -56
- package/src/browser-electron/bridge-auto.ts +5 -4
- package/src/browser-electron/bridge-connection.ts +20 -2
- package/src/browser-electron/bridge-endpoint.ts +3 -3
- package/src/browser-electron/bridge-install.ts +40 -4
- package/src/browser-electron/bridge-maintenance.ts +42 -14
- package/src/browser-electron/bridge-status.ts +94 -23
- package/src/browser-electron/desktop-bridge-host.ts +185 -585
- package/src/browser-electron/desktop-identity.ts +53 -2
- package/src/browser-electron/document-readiness.ts +45 -0
- package/src/browser-electron/electron-provision.ts +12 -45
- package/src/browser-electron/entry.ts +1299 -882
- package/src/browser-electron/ephemeral-profile.ts +1 -1
- package/src/browser-electron/extension-browser.ts +223 -0
- package/src/browser-electron/extension-setup.ts +67 -0
- package/src/browser-electron/guest-cookie-jar.ts +176 -0
- package/src/browser-electron/guest-cookie-store.ts +59 -0
- package/src/browser-electron/guest-css-runtime.ts +76 -0
- package/src/browser-electron/guest-css.ts +68 -0
- package/src/browser-electron/guest-route.ts +568 -0
- package/src/browser-electron/guest-runtime.ts +357 -0
- package/src/browser-electron/guest-storage-runtime.ts +54 -0
- package/src/browser-electron/guest-storage.ts +117 -0
- package/src/browser-electron/history-store.ts +5 -4
- package/src/browser-electron/host-main.ts +156 -11
- package/src/browser-electron/host-patch-maintenance.ts +112 -0
- package/src/browser-electron/http-body.ts +23 -0
- package/src/browser-electron/maintenance-broker.ts +29 -5
- package/src/browser-electron/maintenance-lifecycle.ts +14 -9
- package/src/browser-electron/maintenance-route.ts +17 -14
- package/src/browser-electron/missing-system-browser.ts +2 -2
- package/src/browser-electron/open-slot.ts +49 -0
- package/src/browser-electron/paths.ts +5 -1
- package/src/browser-electron/preferred-browser.ts +120 -0
- package/src/browser-electron/preview-route.ts +18 -11
- package/src/browser-electron/process-ownership.ts +168 -0
- package/src/browser-electron/profile-checkpoint.ts +187 -0
- package/src/browser-electron/profile-command.ts +46 -0
- package/src/browser-electron/profile-extension.ts +124 -0
- package/src/browser-electron/profile-lease.ts +115 -0
- package/src/browser-electron/profile-residue.ts +49 -0
- package/src/browser-electron/provider.ts +771 -289
- package/src/browser-electron/reference-route.ts +608 -0
- package/src/browser-electron/remote-host.ts +15 -15
- package/src/browser-electron/runtime-route.ts +11 -10
- package/src/browser-electron/runtime-status.ts +51 -32
- package/src/browser-electron/settings-store.ts +27 -7
- package/src/browser-electron/shortcuts-route.ts +112 -0
- package/src/browser-electron/sidebar-only-host.ts +118 -19
- package/src/browser-electron/startpage-shortcuts.ts +213 -0
- package/src/browser-electron/system-browser.ts +309 -338
- package/src/browser-electron/windows-system.ts +2 -1
- package/src/browser-reference/delivery.ts +384 -0
- package/src/browser-reference/entry.ts +631 -0
- package/src/browser-reference/export.ts +339 -0
- package/src/browser-reference/import.ts +303 -0
- package/src/browser-reference/page-script.ts +1537 -0
- package/src/browser-reference/service.ts +1315 -0
- package/src/browser-reference/store.ts +172 -0
- package/src/browser-reference/submission-receipts.ts +122 -0
- package/src/browser-reference/text-quote.ts +219 -0
- package/src/browser-reference/types.ts +195 -0
- package/src/browser-reference/visible.ts +367 -0
- package/src/browser-reference/web-sources.ts +103 -0
- package/src/client/browser/BrowserController.ts +693 -0
- package/src/client/browser/BrowserFrame.ts +78 -0
- package/src/client/browser/BrowserNavigation.ts +169 -0
- package/src/client/browser/BrowserPage.ts +23 -0
- package/src/client/browser/BrowserPersistence.ts +44 -0
- package/src/client/browser/IframeImpl.ts +176 -0
- package/src/client/browser/child-tabs.ts +14 -0
- package/src/client/browser/iframe-reference.ts +67 -0
- package/src/client/browser/initialization.ts +262 -0
- package/src/client/browser/omnibox.ts +243 -0
- package/src/client/browser/store.ts +38 -0
- package/src/client/browser/takeover-channel.ts +72 -0
- package/src/client/browser/url.ts +46 -0
- package/src/client/browser/web-reference-source.ts +52 -0
- package/src/client/css-modules.d.ts +4 -0
- package/src/client/definition.tsx +30 -0
- package/src/client/electron/ElectronWebViewImpl.ts +364 -0
- package/src/client/electron/ElectronWebviewPresentation.ts +138 -0
- package/src/client/electron/NativeChildPresentation.ts +45 -0
- package/src/client/electron/NativeViewPage.ts +251 -0
- package/src/client/electron/pages.ts +23 -0
- package/src/client/electron/reference-overlay.ts +53 -0
- package/src/client/electron/workspace.ts +33 -0
- package/src/client/index.ts +293 -0
- package/src/client/locales.ts +857 -0
- package/src/client/pages.ts +28 -0
- package/src/client/reference/client/BrowserRefLink.tsx +142 -0
- package/src/client/reference/client/draft-reference.ts +167 -0
- package/src/client/reference/client/index.ts +7 -0
- package/src/client/reference/client/ordered-submission.ts +108 -0
- package/src/client/reference/client/pending-delivery.ts +216 -0
- package/src/client/reference/client/plugin.ts +189 -0
- package/src/client/reference/client/production/ReferenceCapsules.tsx +345 -0
- package/src/client/reference/client/production/ReferenceDock.module.css +193 -0
- package/src/client/reference/client/production/ReferenceDock.tsx +6 -0
- package/src/client/reference/client/production/ReferenceFeedback.tsx +15 -0
- package/src/client/reference/client/production/ReferenceMath.tsx +44 -0
- package/src/client/reference/client/production/ReferenceText.tsx +36 -0
- package/src/client/reference/client/production/assembly.ts +471 -0
- package/src/client/reference/client/production/asset-store.ts +144 -0
- package/src/client/reference/client/production/availability.ts +74 -0
- package/src/client/reference/client/production/bytes.ts +36 -0
- package/src/client/reference/client/production/delivery-client.ts +211 -0
- package/src/client/reference/client/production/draft-adapter.ts +508 -0
- package/src/client/reference/client/production/http-transport.ts +217 -0
- package/src/client/reference/client/production/production-submission.ts +310 -0
- package/src/client/reference/client/production/protocol.ts +231 -0
- package/src/client/reference/client/production/reference-card.ts +240 -0
- package/src/client/reference/client/production/reference-labels.ts +29 -0
- package/src/client/reference/client/production/reply-link-bridge.ts +222 -0
- package/src/client/reference/client/production/reveal.ts +215 -0
- package/src/client/reference/client/production/runtime.ts +1101 -0
- package/src/client/reference/client/production/snapshot-adapter.ts +154 -0
- package/src/client/reference/client/production/source-marker.ts +63 -0
- package/src/client/reference/client/production/source-opener.ts +55 -0
- package/src/client/reference/client/production/styles.ts +104 -0
- package/src/client/reference/client/production/user-text-rule.ts +58 -0
- package/src/client/reference/client/reveal.ts +107 -0
- package/src/client/reference/client/scheme.ts +114 -0
- package/src/client/reference/client/types.ts +168 -0
- package/src/client/reference/css-modules.d.ts +4 -0
- package/src/client/reference/index.ts +11 -0
- package/src/client/reference-capture-owner.ts +162 -0
- package/src/client/reference-intents.ts +36 -0
- package/src/client/settings/index.ts +34 -0
- package/{client.js → src/client/settings/panel.ts} +2657 -2231
- package/src/client/shortcut-open.ts +30 -0
- package/src/client/startpage/binding.ts +99 -0
- package/src/client/startpage/controller.ts +303 -0
- package/src/client/startpage/model.ts +279 -0
- package/src/client/view/Browser.module.css +751 -0
- package/src/client/view/BrowserBody.tsx +314 -0
- package/src/client/view/BrowserPresentation.ts +9 -0
- package/src/client/view/BrowserTitle.tsx +17 -0
- package/src/client/view/IframePresentation.ts +344 -0
- package/src/client/view/StartPage.tsx +597 -0
- package/src/client/view/TakeoverBanner.tsx +21 -0
- package/src/index.ts +110 -73
- package/src/reference-owner.ts +5 -0
- package/src/reference-page.ts +9 -0
- package/src/reference-source.ts +3 -0
- package/src/reference-text.ts +197 -0
- package/src/startpage-settings.ts +103 -0
- package/src/startpage.ts +71 -0
- package/src/takeover-protocol.ts +19 -0
- package/src/tool-browser/code-tool.ts +401 -0
- package/src/tool-browser/code-worker.ts +639 -0
- package/src/tool-browser/index.ts +908 -77
- package/src/tool-browser/page-probe.ts +4 -4
- package/src/tool-browser/panel-page.ts +124 -0
- package/src/tool-browser/screenshot-image.ts +49 -0
- package/src/tool-browser/takeover.ts +198 -0
- package/src/types/electron-shim.d.ts +20 -0
- package/src/types.ts +85 -0
- package/src/web-guest.ts +34 -0
- package/tools/accept-desktop.mjs +148 -0
- package/lib/browser/runtime.d.ts +0 -175
- package/lib/browser/types.d.ts +0 -797
- package/lib/browser-electron/authenticated-route.d.ts +0 -27
- package/lib/browser-electron/automatic-maintenance.d.ts +0 -41
- package/lib/browser-electron/bridge-auto.d.ts +0 -93
- package/lib/browser-electron/bridge-connection.d.ts +0 -93
- package/lib/browser-electron/bridge-endpoint.d.ts +0 -30
- package/lib/browser-electron/bridge-install.d.ts +0 -85
- package/lib/browser-electron/bridge-maintenance.d.ts +0 -24
- package/lib/browser-electron/bridge-status.d.ts +0 -50
- package/lib/browser-electron/desktop-bridge-host.d.ts +0 -248
- package/lib/browser-electron/desktop-identity.d.ts +0 -58
- package/lib/browser-electron/electron-provision.d.ts +0 -92
- package/lib/browser-electron/entry.d.ts +0 -64
- package/lib/browser-electron/ephemeral-profile.d.ts +0 -37
- package/lib/browser-electron/file-write.d.ts +0 -2
- package/lib/browser-electron/history-store.d.ts +0 -98
- package/lib/browser-electron/host-main.d.ts +0 -26
- package/lib/browser-electron/http-body.d.ts +0 -24
- package/lib/browser-electron/json-reply.d.ts +0 -33
- package/lib/browser-electron/maintenance-broker.d.ts +0 -35
- package/lib/browser-electron/maintenance-lifecycle.d.ts +0 -32
- package/lib/browser-electron/maintenance-route.d.ts +0 -18
- package/lib/browser-electron/missing-system-browser.d.ts +0 -54
- package/lib/browser-electron/paths.d.ts +0 -4
- package/lib/browser-electron/preview-route.d.ts +0 -89
- package/lib/browser-electron/process.d.ts +0 -14
- package/lib/browser-electron/provider.d.ts +0 -959
- package/lib/browser-electron/remote-host.d.ts +0 -256
- package/lib/browser-electron/rpc-input.d.ts +0 -4
- package/lib/browser-electron/rpc-ops.d.ts +0 -18
- package/lib/browser-electron/runtime-diagnostics.d.ts +0 -12
- package/lib/browser-electron/runtime-route.d.ts +0 -55
- package/lib/browser-electron/runtime-status.d.ts +0 -116
- package/lib/browser-electron/settings-route.d.ts +0 -15
- package/lib/browser-electron/settings-store.d.ts +0 -224
- package/lib/browser-electron/sidebar-only-host.d.ts +0 -36
- package/lib/browser-electron/system-browser.d.ts +0 -367
- package/lib/browser-electron/timing.d.ts +0 -8
- package/lib/browser-electron/virtual-cursor.d.ts +0 -67
- package/lib/browser-electron/windows-system.d.ts +0 -3
- package/lib/index.d.ts +0 -30
- package/lib/tool-browser/element-fields.d.ts +0 -145
- package/lib/tool-browser/index.d.ts +0 -53
- package/lib/tool-browser/page-probe.d.ts +0 -86
- package/scripts/consumer-install-check.mjs +0 -72
- package/scripts/run-tests.mjs +0 -32
- package/scripts/verify-host-compat.mjs +0 -195
- package/scripts/verify-preview-route.mjs +0 -168
- package/scripts/verify-runtime-status.mjs +0 -179
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin-owned settings document — the switches the browser settings panel
|
|
3
|
-
* exposes, stored next to the browsing history so both follow the same rules:
|
|
4
|
-
* they survive the browser process and DSH restarts.
|
|
5
|
-
*
|
|
6
|
-
* Every field is optional on disk and falls back to a default, so a hand-edited
|
|
7
|
-
* or older file never breaks startup; an unreadable document refuses capability
|
|
8
|
-
* gates while retaining the defaults for presentation and other conveniences.
|
|
9
|
-
* @module dsh-browser/browser-electron/settings-store
|
|
10
|
-
*/
|
|
11
|
-
import type { BrowserChannel } from './system-browser.js';
|
|
12
|
-
/** Vision/operation strategy the provider prefers when the model can see. */
|
|
13
|
-
export type VisionStrategy = 'auto' | 'nonVisual';
|
|
14
|
-
/**
|
|
15
|
-
* Whether a launched browser gets a window.
|
|
16
|
-
*
|
|
17
|
-
* Split from {@link VisionStrategy} because these answer different questions: that one is how the
|
|
18
|
-
* agent examines a page, this one is whether the browser has anywhere to draw.
|
|
19
|
-
*/
|
|
20
|
-
export type HeadlessMode = 'auto' | 'headless' | 'windowed';
|
|
21
|
-
/** Every value {@link HeadlessMode} accepts, for validation and the settings UI. */
|
|
22
|
-
export declare const HEADLESS_MODES: readonly ["auto", "headless", "windowed"];
|
|
23
|
-
/** The full settings document, with every field resolved. */
|
|
24
|
-
export interface BrowserSettings {
|
|
25
|
-
/** Persistent browsing history (visited pages). */
|
|
26
|
-
readonly history: {
|
|
27
|
-
readonly enabled: boolean;
|
|
28
|
-
readonly maxEntries: number;
|
|
29
|
-
readonly maxAgeDays: number;
|
|
30
|
-
};
|
|
31
|
-
/** Login-state retention: cookies and the browser profile. */
|
|
32
|
-
readonly cookies: {
|
|
33
|
-
readonly persist: boolean;
|
|
34
|
-
};
|
|
35
|
-
/** Presentation behaviour. */
|
|
36
|
-
readonly ui: {
|
|
37
|
-
/** Auto-expand the side panel once per task, then leave the user alone. */
|
|
38
|
-
readonly autoExpandOnce: boolean;
|
|
39
|
-
/** Release the browser when its session ends, instead of waiting for a close. */
|
|
40
|
-
readonly closeWithSession: boolean;
|
|
41
|
-
/** Show the synthetic cursor/click feedback while the agent operates. */
|
|
42
|
-
readonly virtualCursor: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Quiet mode: drive the page without taking over the screen.
|
|
45
|
-
*
|
|
46
|
-
* Off (the default) keeps the contract this plugin is built on — human and agent share one
|
|
47
|
-
* window, so an operation raises it and the user can see what is being driven. On, the
|
|
48
|
-
* carrier never activates the application and never steals keyboard focus:
|
|
49
|
-
* - screenshots of a minimized or hidden window go through CDP `Page.captureScreenshot`
|
|
50
|
-
* instead of `capturePage()`, so grabbing an image stops being a reason to show a window;
|
|
51
|
-
* - navigation and tab switching only change which view is visible INSIDE the window; a
|
|
52
|
-
* minimized window stays minimized;
|
|
53
|
-
* - synthesized input still needs a display surface (Chromium drops `Input.*` for a view
|
|
54
|
-
* without one), so that one barrier may restore a minimized window — with
|
|
55
|
-
* `showInactive()`, which shows it without becoming the key window, and without
|
|
56
|
-
* `moveTop()`.
|
|
57
|
-
*
|
|
58
|
-
* Reported as issue #35: a minimized browser window was restored and focused by the next
|
|
59
|
-
* screenshot or click, pulling the user out of whatever they were typing in.
|
|
60
|
-
*/
|
|
61
|
-
readonly quiet: boolean;
|
|
62
|
-
};
|
|
63
|
-
/** Visual vs non-visual operation strategy. */
|
|
64
|
-
readonly vision: {
|
|
65
|
-
readonly strategy: VisionStrategy;
|
|
66
|
-
};
|
|
67
|
-
/** Which browser binary carries the agent's pages. */
|
|
68
|
-
readonly browser: {
|
|
69
|
-
readonly channel: BrowserChannel;
|
|
70
|
-
/**
|
|
71
|
-
* Whether the browser gets a window.
|
|
72
|
-
*
|
|
73
|
-
* `auto` (the default) launches headless when the process has no display — no `DISPLAY` and no
|
|
74
|
-
* `WAYLAND_DISPLAY` — and with a window otherwise. That combination is what makes the plugin
|
|
75
|
-
* work under systemd, in a container, or on an SSH-only server while leaving desktop users
|
|
76
|
-
* with the visible window they expect. `true` forces headless (CI, screenshot-only servers);
|
|
77
|
-
* `false` forces a window, so a misconfigured display fails loudly instead of silently
|
|
78
|
-
* degrading into a browser nobody can see.
|
|
79
|
-
*
|
|
80
|
-
* Reported as issue #32: as a systemd service there is no display, Chromium exits with
|
|
81
|
-
* "could not connect to display", and every `dsh_browser_*` call failed with "exited
|
|
82
|
-
* immediately after launch".
|
|
83
|
-
*/
|
|
84
|
-
readonly headless: HeadlessMode;
|
|
85
|
-
};
|
|
86
|
-
/** Whether the agent may read cookies / export login state. */
|
|
87
|
-
readonly credentials: {
|
|
88
|
-
readonly allowRead: boolean;
|
|
89
|
-
};
|
|
90
|
-
/**
|
|
91
|
-
* Live view of the browser for a remote operator (issue #34).
|
|
92
|
-
*
|
|
93
|
-
* OFF by default, and that default is the feature's main safety property: a live browser frame can
|
|
94
|
-
* contain a CAPTCHA, an account name, or logged-in content, so nobody should be able to watch
|
|
95
|
-
* without the host having said yes first. The remote side also cannot turn it on: this file is
|
|
96
|
-
* written through the plugin's own settings route, which admits only same-origin requests from the
|
|
97
|
-
* host's own UI, and the frame endpoint refuses everything when this is false.
|
|
98
|
-
*/
|
|
99
|
-
readonly remoteView: {
|
|
100
|
-
/** Serve browser frames to a remote viewer. */
|
|
101
|
-
readonly enabled: boolean;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* What the agent is allowed to DO, as opposed to what it may look at.
|
|
105
|
-
*
|
|
106
|
-
* These are OPERATOR switches: the settings panel is not reachable from the model, so a
|
|
107
|
-
* value here refuses whatever the model asks for, and no tool can lift it. That is what
|
|
108
|
-
* separates them from `dsh_browser_restrict`, which is the model's own soft guardrail. All
|
|
109
|
-
* three default to on, which is the documented out-of-the-box behaviour.
|
|
110
|
-
*/
|
|
111
|
-
readonly actions: {
|
|
112
|
-
/** Run arbitrary page scripts in the active tab (`dsh_browser_execute`). */
|
|
113
|
-
readonly allowExecute: boolean;
|
|
114
|
-
/** Download a URL to disk (`dsh_browser_download`). */
|
|
115
|
-
readonly allowDownload: boolean;
|
|
116
|
-
/** Write cookies — importing login state (`dsh_browser_auth` restore). */
|
|
117
|
-
readonly allowCredentialWrite: boolean;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Where a downloaded file goes after it lands on disk.
|
|
121
|
-
*
|
|
122
|
-
* An ATTRIBUTE of a download, not a new concept: an empty `tool` means the behaviour is exactly
|
|
123
|
-
* what it was before this existed. The user owns the field, can point it at any MCP tool that
|
|
124
|
-
* takes a path (Feishu drive, Baidu Netdisk), and can empty it again at any time.
|
|
125
|
-
*/
|
|
126
|
-
/**
|
|
127
|
-
* Desktop bridge handled without asking.
|
|
128
|
-
*
|
|
129
|
-
* Historical automatic-install preference retained when reading existing settings documents.
|
|
130
|
-
* Runtime automatic installation is disabled; bridge maintenance is an explicit action after
|
|
131
|
-
* DSH Desktop is closed, even when an older document contains autoInstall=true.
|
|
132
|
-
*/
|
|
133
|
-
readonly bridge: {
|
|
134
|
-
/** Legacy preference; it does not trigger installation at runtime. Default false. */
|
|
135
|
-
readonly autoInstall: boolean;
|
|
136
|
-
};
|
|
137
|
-
readonly delivery: {
|
|
138
|
-
/** MCP tool that receives the saved file. Empty = save locally and stop there. */
|
|
139
|
-
readonly tool: string;
|
|
140
|
-
/** Flat argument template; {path}, {name} and {size} are substituted into string values. */
|
|
141
|
-
readonly args: Readonly<Record<string, string>>;
|
|
142
|
-
/** `keep-local` reports both outcomes; `stop` reports the handoff failure as the result. */
|
|
143
|
-
readonly onFail: 'keep-local' | 'stop';
|
|
144
|
-
/** Per-site override: page host → tool name. */
|
|
145
|
-
readonly sites: Readonly<Record<string, string>>;
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
/** Defaults for every switch: the documented out-of-the-box behaviour. */
|
|
149
|
-
export declare const DEFAULT_SETTINGS: BrowserSettings;
|
|
150
|
-
/**
|
|
151
|
-
* Absolute path of the settings file, beside the browser profile and the
|
|
152
|
-
* browsing history.
|
|
153
|
-
* @returns the settings file path.
|
|
154
|
-
*/
|
|
155
|
-
export declare function settingsPath(): string;
|
|
156
|
-
/**
|
|
157
|
-
* The channels a settings document may name.
|
|
158
|
-
*
|
|
159
|
-
* Exported so the log line and the error message can quote the same set the parser accepts: a
|
|
160
|
-
* message that lists a value the code rejects (or omits one it takes) is worse than no message.
|
|
161
|
-
*/
|
|
162
|
-
export declare const BROWSER_CHANNELS: readonly ["chrome", "edge", "auto", "bundled", "sidebar"];
|
|
163
|
-
/**
|
|
164
|
-
* Resolve a raw settings document (already parsed, shape unknown) into the full
|
|
165
|
-
* document, field by field. Unknown keys are dropped: the file is not a place to
|
|
166
|
-
* smuggle configuration.
|
|
167
|
-
* @param raw - the parsed file contents.
|
|
168
|
-
* @returns the resolved settings.
|
|
169
|
-
*/
|
|
170
|
-
export declare function resolveSettings(raw: unknown, warn?: (message: string) => void): BrowserSettings;
|
|
171
|
-
/**
|
|
172
|
-
* File-backed settings with an in-memory snapshot. Reads re-stat the file so an
|
|
173
|
-
* edit from another process (or the settings panel writing through a second
|
|
174
|
-
* code path) is picked up without a restart; writes are atomic enough for a
|
|
175
|
-
* single-writer plugin and never throw at the caller.
|
|
176
|
-
*/
|
|
177
|
-
export declare class SettingsStore {
|
|
178
|
-
private readonly file;
|
|
179
|
-
private readonly log?;
|
|
180
|
-
private cached;
|
|
181
|
-
/** Last observed mtime, used to invalidate the cache on external edits. */
|
|
182
|
-
private cachedMtimeMs;
|
|
183
|
-
/**
|
|
184
|
-
* @param file - settings file path (defaults beside the browser profile).
|
|
185
|
-
*/
|
|
186
|
-
constructor(file?: string, log?: ((message: string) => void) | undefined);
|
|
187
|
-
/** Path this store reads and writes. */
|
|
188
|
-
path(): string;
|
|
189
|
-
/**
|
|
190
|
-
* Current settings, re-read when the file changed on disk.
|
|
191
|
-
* @returns the resolved settings document.
|
|
192
|
-
*/
|
|
193
|
-
get(): BrowserSettings;
|
|
194
|
-
/**
|
|
195
|
-
* Merge a partial patch into the stored document and persist it.
|
|
196
|
-
* @param patch - the fields to change (unknown keys are ignored).
|
|
197
|
-
* @returns the settings after the merge.
|
|
198
|
-
*/
|
|
199
|
-
update(patch: unknown): BrowserSettings;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Replace a file's contents atomically: write a sibling temporary file, then rename it over
|
|
203
|
-
* the target.
|
|
204
|
-
*
|
|
205
|
-
* `writeFileSync(target, …)` truncates and rewrites in place, so a crash, a full disk or an
|
|
206
|
-
* antivirus lock in the middle leaves HALF a JSON document. That used to be silent: the reader
|
|
207
|
-
* resolved an unparseable file to the defaults, so a torn write flipped `credentials.allowRead`
|
|
208
|
-
* and the action switches back ON, and the next successful update wrote those defaults to disk
|
|
209
|
-
* for good. The read side no longer does that (see {@link SETTINGS_WHEN_UNREADABLE}) — but the
|
|
210
|
-
* write side still has to stop producing torn files at all, because half a document is not
|
|
211
|
-
* something this plugin should ever leave behind.
|
|
212
|
-
*
|
|
213
|
-
* The rename is the commit point: a reader sees either the old document or the new one,
|
|
214
|
-
* never a partial one. It stays in the same directory so the rename is atomic on Windows
|
|
215
|
-
* as well as POSIX (`renameSync` maps to MoveFileEx there: same-volume replaces are
|
|
216
|
-
* atomic, cross-volume ones are not supported at all).
|
|
217
|
-
*
|
|
218
|
-
* The temporary is written with a unique suffix rather than a fixed `.tmp`, so two writers
|
|
219
|
-
* (the settings panel and a second DSH process) cannot rename each other's half-written
|
|
220
|
-
* file into place. Shared with the history store, which had the same hole.
|
|
221
|
-
* @param file - the target path.
|
|
222
|
-
* @param contents - the complete new document.
|
|
223
|
-
*/
|
|
224
|
-
export declare function writeFileAtomic(file: string, contents: string): void;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { CarrierLossReason, CarrierPage } from '../browser/types.js';
|
|
2
|
-
import type { ElectronBrowserViewHost, ElectronViewHandle, PresentOptions } from './provider.js';
|
|
3
|
-
/**
|
|
4
|
-
* Keep an explicit sidebar selection while its bridge starts or reconnects.
|
|
5
|
-
* Discovery is deferred until a command needs the bridge; it never selects another carrier.
|
|
6
|
-
*/
|
|
7
|
-
export declare class SidebarOnlyHost implements ElectronBrowserViewHost {
|
|
8
|
-
private readonly loader;
|
|
9
|
-
private readonly views;
|
|
10
|
-
private lease;
|
|
11
|
-
private loading;
|
|
12
|
-
private disposed;
|
|
13
|
-
private lostListener;
|
|
14
|
-
constructor(loader: () => Promise<ElectronBrowserViewHost>);
|
|
15
|
-
/** Keep the explicit selection available so discovery failures reach the caller unchanged. */
|
|
16
|
-
available(): boolean;
|
|
17
|
-
/** Return a stable handle without opening a sidebar or discovering a bridge. */
|
|
18
|
-
createView(owner?: string): ElectronViewHandle;
|
|
19
|
-
destroyView(handle: ElectronViewHandle): void;
|
|
20
|
-
/** Presentation must not turn the provider's initial show into a blank-page navigation. */
|
|
21
|
-
showView(handle: ElectronViewHandle, label?: string, options?: PresentOptions): void;
|
|
22
|
-
listPages(owner?: string): Promise<readonly CarrierPage[]>;
|
|
23
|
-
closePage(id: string, owner?: string): Promise<void>;
|
|
24
|
-
/** Retire only this conversation's handles before awaiting an in-flight discovery. */
|
|
25
|
-
releasePage(owner?: string): Promise<void>;
|
|
26
|
-
collapse(): Promise<void>;
|
|
27
|
-
onLost(listener: (reason: CarrierLossReason) => void): void;
|
|
28
|
-
dispose(): void;
|
|
29
|
-
private assertOpen;
|
|
30
|
-
private assertView;
|
|
31
|
-
private assertLease;
|
|
32
|
-
private load;
|
|
33
|
-
private lost;
|
|
34
|
-
private bind;
|
|
35
|
-
private send;
|
|
36
|
-
}
|
|
@@ -1,367 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Drive the browser the user already has (Chrome / Edge / any Chromium) instead of
|
|
3
|
-
* the Electron we ship — the same approach Codex Browser Use takes.
|
|
4
|
-
*
|
|
5
|
-
* WHY
|
|
6
|
-
* The bundled Electron is a private copy with its own profile, so it can never see
|
|
7
|
-
* the logins the user already has in Chrome, and on a managed machine the user may
|
|
8
|
-
* simply prefer their own browser. Launching their browser with a *separate*
|
|
9
|
-
* `--user-data-dir` gives us a real Chromium we can drive over CDP without touching
|
|
10
|
-
* their everyday profile, bookmarks or windows: nothing of theirs is opened, locked
|
|
11
|
-
* or modified, and closing us never closes them.
|
|
12
|
-
*
|
|
13
|
-
* HOW
|
|
14
|
-
* Chromium exposes CDP on `--remote-debugging-port=0`, and writes the port it chose
|
|
15
|
-
* into `<profile>/DevToolsActivePort`. That file is the discovery mechanism — no
|
|
16
|
-
* port guessing, no collisions. From there everything is CDP over one WebSocket:
|
|
17
|
-
* `Target.createTarget` makes a page, `Target.attachToTarget` (flattened) gives a
|
|
18
|
-
* session for it, and the plugin's commands ride that session. Node 22 ships a global
|
|
19
|
-
* `WebSocket`, so this needs no dependency at all.
|
|
20
|
-
*
|
|
21
|
-
* WHAT IT IMPLEMENTS
|
|
22
|
-
* The same `ElectronBrowserViewHost` seam as the self-hosted and sidebar hosts, so
|
|
23
|
-
* the provider, the tools, history, the cursor and teardown rules are unchanged —
|
|
24
|
-
* only the carrier differs.
|
|
25
|
-
* @module dsh-browser/browser-electron/system-browser
|
|
26
|
-
*/
|
|
27
|
-
import type { HeadlessMode } from './settings-store.js';
|
|
28
|
-
/**
|
|
29
|
-
* Starts a browser process and returns a handle to it.
|
|
30
|
-
*
|
|
31
|
-
* Injectable so tests can supply something that speaks CDP — the seam a recovery test needs
|
|
32
|
-
* and could not have while the launch was hardcoded to a stub that rejects Chromium's args.
|
|
33
|
-
* @param path - the executable to run.
|
|
34
|
-
* @param args - its arguments.
|
|
35
|
-
* @returns the child process.
|
|
36
|
-
*/
|
|
37
|
-
export type BrowserLauncher = (path: string, args: readonly string[]) => ReturnType<typeof spawn>;
|
|
38
|
-
import { spawn } from 'node:child_process';
|
|
39
|
-
import type { ElectronBrowserViewHost, ElectronViewHandle } from './provider.js';
|
|
40
|
-
import type { CarrierPage } from '../browser/types.js';
|
|
41
|
-
/** Which browser the user asked for. */
|
|
42
|
-
export type BrowserChannel = 'bundled' | 'chrome' | 'edge' | 'auto' | 'sidebar';
|
|
43
|
-
/** A resolved browser installation. */
|
|
44
|
-
export interface DetectedBrowser {
|
|
45
|
-
/** Which product this is. */
|
|
46
|
-
readonly kind: 'chrome' | 'edge' | 'brave';
|
|
47
|
-
/** Absolute path to the executable. */
|
|
48
|
-
readonly path: string;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Find an installed Chromium browser.
|
|
52
|
-
*
|
|
53
|
-
* `auto` prefers Chrome, then Edge, then Brave — the order reflects how likely each
|
|
54
|
-
* is to be the browser a user actually chose rather than one the system shipped.
|
|
55
|
-
* Each candidate is looked up in three places, most specific first: an explicit
|
|
56
|
-
* environment override, then PATH, then the platform's conventional install
|
|
57
|
-
* locations. PATH comes before the fixed paths because it is what actually reflects
|
|
58
|
-
* how the browser was installed.
|
|
59
|
-
* @param channel - the configured choice; `bundled` never resolves to a system browser.
|
|
60
|
-
* @param env - environment lookup, injected so tests need no real machine.
|
|
61
|
-
* @param platform - the platform to use conventions for; injected for the same reason.
|
|
62
|
-
* @returns the detected browser, or undefined when the choice is unavailable.
|
|
63
|
-
*/
|
|
64
|
-
export declare function detectBrowser(channel: BrowserChannel, env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): DetectedBrowser | undefined;
|
|
65
|
-
/**
|
|
66
|
-
* Everything that was checked for one product, for reporting a miss.
|
|
67
|
-
*
|
|
68
|
-
* Detection returns undefined with no explanation, which left the caller able to say
|
|
69
|
-
* only "not found". This gives the user the actual list so they can see whether the
|
|
70
|
-
* plugin looked somewhere their browser is not.
|
|
71
|
-
* @param kind - the product to describe.
|
|
72
|
-
* @param platform - the platform whose names and locations apply.
|
|
73
|
-
* @returns the launcher names (as PATH lookups) and the fixed locations checked.
|
|
74
|
-
*/
|
|
75
|
-
export declare function searchSummary(kind: DetectedBrowser['kind'], platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): string[];
|
|
76
|
-
/** A system browser driven over CDP, presented as a browser view host. */
|
|
77
|
-
export declare class SystemBrowserViewHost implements ElectronBrowserViewHost {
|
|
78
|
-
private readonly browser;
|
|
79
|
-
private readonly profileDir;
|
|
80
|
-
private readonly extraArgs;
|
|
81
|
-
private readonly ephemeralDir?;
|
|
82
|
-
private readonly launcher;
|
|
83
|
-
/**
|
|
84
|
-
* Whether this launch should get a window. See {@link resolveLaunchMode} for how `auto` decides
|
|
85
|
-
* and why a display-less host needs headless at all (issue #32).
|
|
86
|
-
*/
|
|
87
|
-
private readonly headlessMode;
|
|
88
|
-
private readonly isQuiet;
|
|
89
|
-
/**
|
|
90
|
-
* viewId -> the session that view rides, and the client that issued it.
|
|
91
|
-
*
|
|
92
|
-
* The client is part of the value on purpose. A session id means nothing to a browser other
|
|
93
|
-
* than the one that handed it out, and this host replaces browsers routinely: the process
|
|
94
|
-
* dies, or its debugging socket closes while the process lives on. Keeping only the id meant
|
|
95
|
-
* the host could start a NEW browser successfully and then send every command to it carrying
|
|
96
|
-
* a session the old one had issued — `Session with given id not found`, on every call, with a
|
|
97
|
-
* browser that answers /json/version perfectly well and nothing the user can do short of
|
|
98
|
-
* restarting DSH. Comparing identity catches it with no round trip; validating each cached
|
|
99
|
-
* session against the browser would put one on every page command.
|
|
100
|
-
*/
|
|
101
|
-
private readonly views;
|
|
102
|
-
private disposed;
|
|
103
|
-
/**
|
|
104
|
-
* The browser is started on FIRST USE, never on construction.
|
|
105
|
-
*
|
|
106
|
-
* A plugin that launches Chrome the moment its host loads is a plugin that takes
|
|
107
|
-
* over the machine before anyone asked it to: simply starting DSH would spawn a
|
|
108
|
-
* browser window. Registration must therefore be inert, and the process is only
|
|
109
|
-
* spawned when a view is actually needed.
|
|
110
|
-
*/
|
|
111
|
-
private client;
|
|
112
|
-
/**
|
|
113
|
-
* Set when a command went unanswered rather than being refused.
|
|
114
|
-
*
|
|
115
|
-
* A timeout says nothing about the connection: the page may simply be slow. It marks the
|
|
116
|
-
* client for a cheap check before the next command trusts it, which keeps a slow page
|
|
117
|
-
* from being mistaken for a dead browser while still catching one that has truly stopped
|
|
118
|
-
* answering.
|
|
119
|
-
*/
|
|
120
|
-
private clientSuspect;
|
|
121
|
-
private child;
|
|
122
|
-
/** Whether this connection's surplus blank pages have been collapsed already. */
|
|
123
|
-
private blanksNormalized;
|
|
124
|
-
private starting;
|
|
125
|
-
/**
|
|
126
|
-
* Browsers that ignored a kill.
|
|
127
|
-
*
|
|
128
|
-
* They are no longer this host's child — a replacement has taken that slot — but they
|
|
129
|
-
* are still running, still holding the profile, and still something release must try to
|
|
130
|
-
* stop. Forgetting them is what allowed a launch this host could not undo.
|
|
131
|
-
*/
|
|
132
|
-
private readonly stubborn;
|
|
133
|
-
/**
|
|
134
|
-
* @param browser - the detected installation to launch on first use.
|
|
135
|
-
* @param profileDir - a plugin-owned directory; the user's own profile is never touched.
|
|
136
|
-
* @param extraArgs - additional Chromium switches.
|
|
137
|
-
* @param ephemeralDir - a directory to delete on release, when the user has turned
|
|
138
|
-
* persistence off so no login state outlives the session.
|
|
139
|
-
* @param launcher - how to start the browser, for tests.
|
|
140
|
-
*
|
|
141
|
-
* Recovery after the browser dies was untestable without this: the suite spawns a stub
|
|
142
|
-
* with Chromium's arguments, and a stub that is not a browser rejects them and exits, so
|
|
143
|
-
* no CDP endpoint ever appears and no session is ever created. Verified by mutation —
|
|
144
|
-
* removing every sessions.clear() left the recovery tests green. A launcher lets a test
|
|
145
|
-
* provide something that actually speaks CDP, so the state those tests describe exists.
|
|
146
|
-
*/
|
|
147
|
-
constructor(browser: DetectedBrowser, profileDir: string, extraArgs?: readonly string[], ephemeralDir?: string | undefined, launcher?: BrowserLauncher,
|
|
148
|
-
/**
|
|
149
|
-
* Whether this launch should get a window. See {@link resolveLaunchMode} for how `auto` decides
|
|
150
|
-
* and why a display-less host needs headless at all (issue #32).
|
|
151
|
-
*/
|
|
152
|
-
headlessMode?: HeadlessMode, isQuiet?: () => boolean);
|
|
153
|
-
/** Which product this host would drive (for diagnostics). */
|
|
154
|
-
get kind(): DetectedBrowser['kind'];
|
|
155
|
-
/** Whether the browser has actually been started yet (diagnostics and tests). */
|
|
156
|
-
get started(): boolean;
|
|
157
|
-
/**
|
|
158
|
-
* The CDP client, starting the browser on first use.
|
|
159
|
-
* @returns the connected client.
|
|
160
|
-
*/
|
|
161
|
-
/**
|
|
162
|
-
* Whether a client that reports itself open is actually answering.
|
|
163
|
-
*
|
|
164
|
-
* An open socket proves nothing: a browser can hold the connection and never reply, and
|
|
165
|
-
* that state must not be cached, or every later command waits out its own timeout. Asking
|
|
166
|
-
* the browser something cheap is a fact; reading the failure text is a guess, and the
|
|
167
|
-
* guess was wrong in both directions (it killed healthy browsers on a slow page, and it
|
|
168
|
-
* mistook the browser's own free text for a verdict).
|
|
169
|
-
*
|
|
170
|
-
* This is only reached when the socket is open, so the common path costs nothing.
|
|
171
|
-
* @param client - the client to question.
|
|
172
|
-
* @returns true when it answered.
|
|
173
|
-
*/
|
|
174
|
-
private probeClient;
|
|
175
|
-
/**
|
|
176
|
-
* Forget which browser issued what, after that browser is gone.
|
|
177
|
-
*
|
|
178
|
-
* The two maps must move together: `views` maps a view id to a session id and `sessions`
|
|
179
|
-
* maps a session id to a target id, so clearing one alone leaves a mapping the next command
|
|
180
|
-
* will act on. Every path that abandons a browser calls this rather than spelling the pair
|
|
181
|
-
* out — four separate copies is how the third one came to be missing.
|
|
182
|
-
*/
|
|
183
|
-
private forgetBrowserState;
|
|
184
|
-
private ensureClient;
|
|
185
|
-
/**
|
|
186
|
-
* Take over a browser already serving this profile, instead of racing it.
|
|
187
|
-
*
|
|
188
|
-
* A previous DSH process leaves its browser running: the child handle died with that process, so
|
|
189
|
-
* nothing here knows about it, and `start()`'s cleanup branch is skipped because it keys on
|
|
190
|
-
* `this.child`. Launching then does something worse than fail — on Windows Chrome hands the
|
|
191
|
-
* request to the instance already holding the profile and exits 0, and that exit is read as a
|
|
192
|
-
* launch failure. The user is told to go kill the leftovers by hand, on every restart, which is
|
|
193
|
-
* exactly what was reported.
|
|
194
|
-
*
|
|
195
|
-
* The launch loop deliberately refuses to trust a `<profile>/DevToolsActivePort` left by a
|
|
196
|
-
* previous launch, and it is right to: a stale port number can be reused by something that is
|
|
197
|
-
* not a browser at all. What makes adoption safe HERE is that this runs BEFORE launching, on a
|
|
198
|
-
* file that lives inside this plugin's own profile directory — only a browser started with this
|
|
199
|
-
* `--user-data-dir` writes it — and the endpoint is then asked to identify itself.
|
|
200
|
-
* @param _why - a short phrase for the log, naming which attempt this is.
|
|
201
|
-
* @returns a connected client for the running browser, or undefined when there is none.
|
|
202
|
-
*/
|
|
203
|
-
private adoptRunningBrowser;
|
|
204
|
-
/**
|
|
205
|
-
* Launch the browser with a private profile and connect over CDP.
|
|
206
|
-
*
|
|
207
|
-
* `--remote-debugging-port=0` plus the `DevToolsActivePort` file is the only
|
|
208
|
-
* reliable way to learn the port: a fixed port collides with whatever else the
|
|
209
|
-
* machine is running, and parsing stderr is fragile across versions.
|
|
210
|
-
* @returns the connected client.
|
|
211
|
-
*/
|
|
212
|
-
private start;
|
|
213
|
-
/**
|
|
214
|
-
* Whether this host can back views.
|
|
215
|
-
*
|
|
216
|
-
* True while the host is usable — including before the browser has been started,
|
|
217
|
-
* since the first command is what starts it. Reporting "unavailable" here would
|
|
218
|
-
* make the plugin fall back for no reason.
|
|
219
|
-
*/
|
|
220
|
-
available(): boolean;
|
|
221
|
-
/**
|
|
222
|
-
* Every page the browser currently holds, including ones this plugin did not create.
|
|
223
|
-
*
|
|
224
|
-
* Chrome and Edge own their own page creation. A click on a link that opens a new page — or any
|
|
225
|
-
* `window.open` — produces a page the provider never asked for, and nothing reports it back.
|
|
226
|
-
* Those pages are real: they hold memory and stay until something closes them. Measured on a real
|
|
227
|
-
* window: four pages present while `dsh_browser_list_tabs` reported one.
|
|
228
|
-
*
|
|
229
|
-
* Discovery is already on at connection time (see the blank-page normalisation), so
|
|
230
|
-
* `Target.getTargets` also lists pages that existed before this client connected.
|
|
231
|
-
* @returns the browser's pages, or an empty list when it cannot answer.
|
|
232
|
-
*/
|
|
233
|
-
/**
|
|
234
|
-
* Every page the browser holds that THIS HOST did not open.
|
|
235
|
-
*
|
|
236
|
-
* Chrome and Edge own their own page creation. A click on a link that opens a new page — or any
|
|
237
|
-
* `window.open` — produces a page the provider never asked for, and nothing reports it back.
|
|
238
|
-
* Those pages are real: they hold memory and stay until something closes them. Measured on a real
|
|
239
|
-
* window: four pages present while `dsh_browser_list_tabs` reported one.
|
|
240
|
-
*
|
|
241
|
-
* Pages this host opened are EXCLUDED here rather than deduplicated by the caller, because the
|
|
242
|
-
* caller cannot do it: the provider knows a tab by its own id, the carrier knows a page by its
|
|
243
|
-
* CDP target id, and the two never match. The first version returned everything and relied on the
|
|
244
|
-
* caller to filter, which reported the same page twice.
|
|
245
|
-
*
|
|
246
|
-
* Discovery is already on at connection time (see the blank-page normalisation), so
|
|
247
|
-
* `Target.getTargets` also lists pages that existed before this client connected.
|
|
248
|
-
* @returns the browser's pages that are not ours, or an empty list when it cannot answer.
|
|
249
|
-
*/
|
|
250
|
-
listPages(): Promise<readonly CarrierPage[]>;
|
|
251
|
-
/**
|
|
252
|
-
* Close one page by the target id {@link listPages} reported.
|
|
253
|
-
*
|
|
254
|
-
* `Target.closeTarget` is the browser's own close, so it works for pages this plugin never
|
|
255
|
-
* created. The page may already be gone if the human closed it in the meantime — the caller
|
|
256
|
-
* asked for it to be closed and it is, so that is not an error.
|
|
257
|
-
* @param id - the CDP target id.
|
|
258
|
-
*/
|
|
259
|
-
closePage(id: string): Promise<void>;
|
|
260
|
-
createView(): ElectronViewHandle;
|
|
261
|
-
destroyView(handle: ElectronViewHandle): void;
|
|
262
|
-
/** Nothing to show: the browser owns its own windows. */
|
|
263
|
-
showView(): void;
|
|
264
|
-
/**
|
|
265
|
-
* Bring the target's page to the front, then report success.
|
|
266
|
-
*
|
|
267
|
-
* The comment on `focus` below used to say this was impossible — that raising the page needs
|
|
268
|
-
* `Page.bringToFront` on a target session, which is a view-level concern the host cannot
|
|
269
|
-
* reach. The handle this method is handed IS that view, and it can send commands, so the
|
|
270
|
-
* capability was here all along; it just was not used. Without it `presentView` was an empty
|
|
271
|
-
* async method, so the provider's whole presentation barrier — the one that stops
|
|
272
|
-
* `Input.*` from being silently dropped for a view with no display surface, and reports
|
|
273
|
-
* `BROWSER_VIEW_NOT_PRESENTED` when it cannot present — never ran on this carrier.
|
|
274
|
-
*
|
|
275
|
-
* A failure is swallowed rather than propagated: a real Chrome window that refuses to come
|
|
276
|
-
* forward is not a reason to refuse the click that follows. The barrier exists to order the
|
|
277
|
-
* two, and the order is honoured either way.
|
|
278
|
-
* @param handle - the view to present.
|
|
279
|
-
*/
|
|
280
|
-
presentView(handle: ElectronViewHandle, _label?: string, options?: {
|
|
281
|
-
readonly quiet?: boolean;
|
|
282
|
-
}): Promise<void>;
|
|
283
|
-
/**
|
|
284
|
-
* Best effort at bringing the browser's window forward.
|
|
285
|
-
*
|
|
286
|
-
* The browser is a separate application, so there is no view to raise. What this can
|
|
287
|
-
* actually do is ask its process to continue from a stopped state — which is a no-op on
|
|
288
|
-
* Windows, where `SIGCONT` is not a supported signal and the call throws. It is kept
|
|
289
|
-
* because it costs nothing and does help on POSIX (a process stopped with SIGSTOP
|
|
290
|
-
* resumes), but it must not be read as a promise that the window comes to the front;
|
|
291
|
-
* importantly, it does NOT raise a window that is merely behind another. Raising the
|
|
292
|
-
* page properly would need `Page.bringToFront` on a specific target session, which is a
|
|
293
|
-
* view-level concern and not available to the host.
|
|
294
|
-
*/
|
|
295
|
-
focus(): Promise<void>;
|
|
296
|
-
/**
|
|
297
|
-
* Close the browser we launched, if we ever launched one.
|
|
298
|
-
*
|
|
299
|
-
* The user's own windows belong to a different process and are never touched. A
|
|
300
|
-
* host whose browser was never started (the common case when nobody used the
|
|
301
|
-
* browser) simply tears down its bookkeeping.
|
|
302
|
-
*/
|
|
303
|
-
dispose(): void;
|
|
304
|
-
/**
|
|
305
|
-
* The flattened session for a view, creating its page on first use.
|
|
306
|
-
*
|
|
307
|
-
* No cache check here: the only caller has already established that the cached session does
|
|
308
|
-
* not belong to the client it is about to use. Re-checking would mean either a round trip or
|
|
309
|
-
* a second copy of that rule.
|
|
310
|
-
*/
|
|
311
|
-
private ensureSession;
|
|
312
|
-
/** Create and attach the target for one view. Serialised by {@link ensureSession}. */
|
|
313
|
-
private buildSession;
|
|
314
|
-
/**
|
|
315
|
-
* Take over a page the browser already has, so a person's own tab becomes one this plugin drives.
|
|
316
|
-
*
|
|
317
|
-
* Reported as a defect: opening a window by hand, navigating it, and then asking a tool to read it
|
|
318
|
-
* produced a SECOND page, because the only tab the provider knew about was one it created itself.
|
|
319
|
-
* The page the human was looking at was listed by `dsh_browser_list_tabs` (under `page:`) and
|
|
320
|
-
* could be closed, but not read or driven — the opposite of what "the page you are looking at"
|
|
321
|
-
* means.
|
|
322
|
-
*
|
|
323
|
-
* Attaching is all it takes: a CDP session is not exclusive, so the browser's own tab becomes a
|
|
324
|
-
* target this plugin has a session on. The page is not moved, reloaded or focused, and its
|
|
325
|
-
* existing session (logins, scroll position, form state) is untouched.
|
|
326
|
-
* @param targetId - the carrier's page id, which for this carrier IS the CDP target id.
|
|
327
|
-
* @returns a handle for that page, in the same shape {@link createView} returns.
|
|
328
|
-
*/
|
|
329
|
-
adoptPage(targetId: string): Promise<ElectronViewHandle>;
|
|
330
|
-
/**
|
|
331
|
-
* Take an unclaimed blank page, if the browser has one to spare.
|
|
332
|
-
*
|
|
333
|
-
* "Unclaimed" is what matters: a blank page the plugin is already driving belongs to a view, and
|
|
334
|
-
* handing the same target to a second view would make two views share one page. The page kept by
|
|
335
|
-
* {@link normalizeBlankPages} is exactly the unclaimed one this is looking for.
|
|
336
|
-
* @param client - the connected browser.
|
|
337
|
-
* @returns the target id to reuse, or undefined when a new page has to be created.
|
|
338
|
-
*/
|
|
339
|
-
private adoptBlankTarget;
|
|
340
|
-
/** Create one page, refusing to go on without an id. */
|
|
341
|
-
private createTarget;
|
|
342
|
-
/**
|
|
343
|
-
* Collapse the blank pages a freshly started browser comes with down to one.
|
|
344
|
-
*
|
|
345
|
-
* Chrome opens more than one page when it is given a URL on top of its own start page, and this
|
|
346
|
-
* is the browser's behaviour rather than a session restore: measured on a cleanly exited profile
|
|
347
|
-
* as well as a crashed one, both pages appear within a second of launch. There is nothing to
|
|
348
|
-
* configure away — by the time a client can talk to the browser, both already exist.
|
|
349
|
-
*
|
|
350
|
-
* Left alone the surplus page is invisible to the plugin's tab model and therefore unclosable
|
|
351
|
-
* through the tools, so it survives every navigation and accumulates for as long as the window
|
|
352
|
-
* lives. One is kept deliberately: {@link buildSession} adopts it instead of creating a third.
|
|
353
|
-
*
|
|
354
|
-
* `Target.setDiscoverTargets` has to come first. Without it the browser may omit pages that
|
|
355
|
-
* existed before this client connected — which is precisely the page that needs closing, and the
|
|
356
|
-
* reason the first attempt at this fix failed silently.
|
|
357
|
-
* @param client - the connected browser.
|
|
358
|
-
* @returns how many surplus blank pages were closed.
|
|
359
|
-
*/
|
|
360
|
-
private normalizeBlankPages;
|
|
361
|
-
/** Views whose session is being created right now, so a second caller waits for the first. */
|
|
362
|
-
private readonly sessionBuilding;
|
|
363
|
-
/** Serialises page selection/creation and attachment for each browser connection. */
|
|
364
|
-
private readonly targetBuilds;
|
|
365
|
-
/** sessionId -> targetId, so a destroyed view can close the right page. */
|
|
366
|
-
private readonly sessions;
|
|
367
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bound an await with a timeout, without dictating the caller's error wording.
|
|
3
|
-
*
|
|
4
|
-
* The two hosts phrase their timeout errors differently and those strings reach the panel, so
|
|
5
|
-
* the shared primitive takes a factory instead of a message.
|
|
6
|
-
* @module dsh-browser/browser-electron/timing
|
|
7
|
-
*/
|
|
8
|
-
export declare function withTimeoutShared<T>(promise: Promise<T>, ms: number, timedOut: () => Error): Promise<T>;
|