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,959 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Electron-backed browser provider: `WebContentsView` sessions driven over
|
|
3
|
-
* `webContents.debugger` (CDP). The provider itself does not import Electron — it operates through the {@link ElectronBrowserViewHost} seam, which the
|
|
4
|
-
* desktop shell implements with real Electron objects. That keeps this
|
|
5
|
-
* package testable under plain Node and leaves the Electron dependency to the
|
|
6
|
-
* shell that owns the `BrowserWindow`.
|
|
7
|
-
* @module dsh-browser/browser-electron
|
|
8
|
-
*/
|
|
9
|
-
import { type VisitedPage } from './history-store.js';
|
|
10
|
-
import type { BrowserSettings } from './settings-store.js';
|
|
11
|
-
import type { BrowserA11yRequest, BrowserA11yResult, BrowserChallenge, BrowserCheckRequest, BrowserClearRequest, BrowserClickRequest, BrowserClickSequenceRequest, BrowserClickSequenceResult, BrowserContentRequest, BrowserContentResult, BrowserElementTarget, BrowserExecuteRequest, BrowserPageOperationRequest, BrowserExecuteResult, BrowserFillRequest, BrowserFillResult, BrowserGetValueRequest, BrowserGetValueResult, BrowserHistoryEntry, BrowserOpenRequest, BrowserProvider, BrowserScrapeRequest, BrowserScrapeResult, BrowserScreenshotRequest, BrowserSelectRequest, BrowserSelectResult, BrowserSessionId, BrowserSetValueRequest, BrowserSetValueResult, BrowserSnapshotResult, BrowserTab, BrowserTypeRequest, BrowserWaitRequest, BrowserWaitResult, BrowserScrollRequest, BrowserKeyRequest, ExportedCookie } from '../browser/types.js';
|
|
12
|
-
import type { CarrierPage, CarrierLossReason } from '../browser/types.js';
|
|
13
|
-
/** Stable provider id registered with `ctx.browser`. */
|
|
14
|
-
export declare const ELECTRON_BROWSER_PROVIDER_ID = "electron";
|
|
15
|
-
/**
|
|
16
|
-
* The minimal Electron surface this provider needs. Implemented by the
|
|
17
|
-
* desktop shell with a real `WebContentsView`; a fake implements it in tests.
|
|
18
|
-
*/
|
|
19
|
-
export interface ElectronBrowserViewHost {
|
|
20
|
-
/**
|
|
21
|
-
* Create a new browser view and return a handle to its webContents-like
|
|
22
|
-
* surface. The host owns windowing (adding the view to the window, sizing,
|
|
23
|
-
* removal); the provider owns CDP-driven behavior.
|
|
24
|
-
* @param owner - the conversation this view serves. A host shared by several conversations
|
|
25
|
-
* needs it to keep one conversation's page out of another's; a host with one conversation per
|
|
26
|
-
* process may ignore it. It is per VIEW and not per host on purpose: the desktop's host is a
|
|
27
|
-
* single instance that every conversation runs through, so an owner held there would be one
|
|
28
|
-
* conversation's id applied to all of them.
|
|
29
|
-
*/
|
|
30
|
-
createView(owner?: string): ElectronViewHandle;
|
|
31
|
-
/**
|
|
32
|
-
* Destroy a view created by this host. Called on session close; idempotent
|
|
33
|
-
* for an already-destroyed view.
|
|
34
|
-
* @param handle - the handle returned by {@link createView}.
|
|
35
|
-
*/
|
|
36
|
-
destroyView(handle: ElectronViewHandle): void;
|
|
37
|
-
/**
|
|
38
|
-
* Show one view as the session's visible surface. The host keeps exactly
|
|
39
|
-
* one visible; switching tabs reorders visibility without losing state.
|
|
40
|
-
* Optional: a host without visible-tab switching treats every view as
|
|
41
|
-
* always present (acceptable for headless/probe hosts).
|
|
42
|
-
* @param handle - the handle to make visible.
|
|
43
|
-
* @param label - human-readable session/task label, when the provider knows
|
|
44
|
-
* one; the host may surface it (e.g. in the window title) so a human can
|
|
45
|
-
* tell which task's page is currently visible.
|
|
46
|
-
* @param options - presentation policy; `quiet` asks for a surface without taking
|
|
47
|
-
* over the screen (see {@link PresentOptions}).
|
|
48
|
-
*/
|
|
49
|
-
showView?(handle: ElectronViewHandle, label?: string, options?: PresentOptions): void;
|
|
50
|
-
/**
|
|
51
|
-
* Optional: (re)present a view and WAIT until the host confirms it. Chromium
|
|
52
|
-
* silently drops CDP-synthesized input (`Input.*`) for a view that has no
|
|
53
|
-
* display surface, which made clicks/typing report success while the page
|
|
54
|
-
* received nothing (and made the first input after a navigation vanish,
|
|
55
|
-
* because the replaced renderer has no surface yet). Unlike
|
|
56
|
-
* {@link showView}, this round-trips an RPC barrier that is ordered AFTER
|
|
57
|
-
* the show on the same socket, so its reply means the view is on screen.
|
|
58
|
-
* Rejects when the view cannot be presented; a host without this method is
|
|
59
|
-
* assumed to present every view (headless/probe hosts).
|
|
60
|
-
* @param handle - the handle to present.
|
|
61
|
-
* @param label - human-readable session/task label, as in {@link showView}.
|
|
62
|
-
* @param options - presentation policy, as in {@link showView}.
|
|
63
|
-
*/
|
|
64
|
-
presentView?(handle: ElectronViewHandle, label?: string, options?: PresentOptions): Promise<void>;
|
|
65
|
-
/**
|
|
66
|
-
* Optional: pages this carrier holds that the provider never created.
|
|
67
|
-
*
|
|
68
|
-
* A sidebar panel and an installed browser both own their own page creation. Clicking a link
|
|
69
|
-
* that opens a new page — or any `window.open` the page performs — produces a page the provider
|
|
70
|
-
* did not ask for and therefore never recorded. Those pages are real: they are what the human
|
|
71
|
-
* sees, they hold memory, and they persist until something closes them. Without this the tab
|
|
72
|
-
* model reports only what the provider itself made, so the extras are invisible to
|
|
73
|
-
* `dsh_browser_list_tabs` and unclosable through `dsh_browser_close_tab`, accumulating for the
|
|
74
|
-
* life of the browser.
|
|
75
|
-
*
|
|
76
|
-
* Views the host itself opened are NOT included. That exclusion belongs to the host, which is the
|
|
77
|
-
* only side that can make it: a provider tab is identified by the provider's own id and a carrier
|
|
78
|
-
* page by the carrier's, so a caller comparing the two matches nothing and reports every page
|
|
79
|
-
* twice. Measured on the sidebar carrier: three clicks produced three webview guests while
|
|
80
|
-
* `dsh_browser_list_tabs` reported one tab; on the installed-browser carrier the window held four
|
|
81
|
-
* pages and the tool reported one.
|
|
82
|
-
* @param owner - the calling task/conversation; shared sidebar hosts must scope to it.
|
|
83
|
-
* @returns every page this conversation's carrier holds that this host did not open.
|
|
84
|
-
*/
|
|
85
|
-
listPages?(owner?: string): Promise<readonly CarrierPage[]>;
|
|
86
|
-
/**
|
|
87
|
-
* Optional: take over one page reported by {@link listPages}, so it becomes a page this provider
|
|
88
|
-
* drives rather than one it can only see.
|
|
89
|
-
*
|
|
90
|
-
* Reported as a defect: opening a window by hand, navigating it, and then asking a tool to read it
|
|
91
|
-
* produced a SECOND page — the human's own tab was listed (under `page:`) and closable, but not
|
|
92
|
-
* readable, which is the opposite of "the page you are looking at". A carrier that cannot do this
|
|
93
|
-
* must leave it undefined rather than pretend: a switch that reported success and then read
|
|
94
|
-
* nothing is the failure this removes.
|
|
95
|
-
* @param viewId - the view to bind the page to.
|
|
96
|
-
* @param id - the carrier's own page id, as {@link listPages} reported it.
|
|
97
|
-
* @returns a handle for that page, usable for commands like any other view's.
|
|
98
|
-
*/
|
|
99
|
-
adoptPage?(id: string): Promise<ElectronViewHandle>;
|
|
100
|
-
/**
|
|
101
|
-
* Optional: close one page reported by {@link listPages}.
|
|
102
|
-
*
|
|
103
|
-
* The pair exists because listing a page the caller cannot close is worse than not listing it:
|
|
104
|
-
* `dsh_browser_list_tabs` would report pages that `dsh_browser_close_tab` answers "not open in
|
|
105
|
-
* this session" about, which reads as a contradiction rather than a boundary.
|
|
106
|
-
* @param id - the carrier's own page id, as {@link listPages} reported it.
|
|
107
|
-
* @param owner - the same task/conversation used for listing; never a global fallback.
|
|
108
|
-
*/
|
|
109
|
-
closePage?(id: string, owner?: string): Promise<void>;
|
|
110
|
-
/**
|
|
111
|
-
* Optional cheap usability probe (no network): whether the host can back
|
|
112
|
-
* views at all right now. The self-hosted host checks for a usable Electron
|
|
113
|
-
* binary; a host without the probe is assumed usable. Lets the seam's
|
|
114
|
-
* provider selection (BROWSER_PROVIDER_UNAVAILABLE etc.) be real instead
|
|
115
|
-
* of failing only at first use.
|
|
116
|
-
*/
|
|
117
|
-
available?(): boolean;
|
|
118
|
-
/**
|
|
119
|
-
* Tell the human that a toolbar action the agent could not complete has failed.
|
|
120
|
-
*
|
|
121
|
-
* Optional. Declared rather than reached through a cast because this is what issue #16 was:
|
|
122
|
-
* the call used to be unbound, so `this` inside the host's implementation was undefined and
|
|
123
|
-
* its first statement threw — inside an async catch, which turned it into an unhandled
|
|
124
|
-
* rejection that took the whole DSH process down. A declared member is checkable; a cast is
|
|
125
|
-
* not.
|
|
126
|
-
* @param windowId - the window the action came from.
|
|
127
|
-
* @param message - what to show the human.
|
|
128
|
-
*/
|
|
129
|
-
notifyUserActionError?(windowId: string, message: string): void;
|
|
130
|
-
/**
|
|
131
|
-
* Optional: associate a view with a window group. Views grouped under the
|
|
132
|
-
* same `windowId` share one window (one window per browser session); a host
|
|
133
|
-
* without this keeps a single shared window. Called right after
|
|
134
|
-
* `createView`, so the host may route the view to its own window even
|
|
135
|
-
* before the first command materializes it.
|
|
136
|
-
* @param handle - the view to group.
|
|
137
|
-
* @param windowId - the group (session) key.
|
|
138
|
-
* @param label - human-readable label for the window title.
|
|
139
|
-
*/
|
|
140
|
-
groupView?(handle: ElectronViewHandle, windowId: string, label?: string): void;
|
|
141
|
-
/**
|
|
142
|
-
* Optional: receive user-initiated browser actions from the host's own UI
|
|
143
|
-
* (e.g. a toolbar address bar, back/forward buttons, tab strip). The
|
|
144
|
-
* provider routes them into the session model so the agent and the human
|
|
145
|
-
* always see the same tabs and navigation state.
|
|
146
|
-
* @param handler - called for every user action; must not throw.
|
|
147
|
-
*/
|
|
148
|
-
onUserAction?(handler: (action: BrowserUserAction) => void): void;
|
|
149
|
-
/**
|
|
150
|
-
* Optional: receive notice that the human closed a browser window. Closing the
|
|
151
|
-
* interface ends the session it showed — the next call opens a clean one —
|
|
152
|
-
* while browsing history and login state survive on disk.
|
|
153
|
-
* @param handler - called with the group (session) key; must not throw.
|
|
154
|
-
*/
|
|
155
|
-
onViewClosed?(handler: (windowId: string) => void): void;
|
|
156
|
-
/**
|
|
157
|
-
* Release the service's page(s) without ending the plugin's own lifetime.
|
|
158
|
-
*
|
|
159
|
-
* Only carriers that outlive a browser session need this. A self-hosted window
|
|
160
|
-
* dies with its view, but the desktop shell's sidebar keeps running no matter
|
|
161
|
-
* what the plugin does — so "release the browser when the session ends"
|
|
162
|
-
* (settings: ui.closeWithSession) has to be asked for explicitly there.
|
|
163
|
-
* @returns a promise that settles once the release was attempted.
|
|
164
|
-
*/
|
|
165
|
-
/**
|
|
166
|
-
* Release this carrier's browser pages for one conversation.
|
|
167
|
-
* @param owner - the conversation whose pages to close. Omit to close every conversation's,
|
|
168
|
-
* which is only correct from a teardown that is itself global.
|
|
169
|
-
*/
|
|
170
|
-
releasePage?(owner?: string): Promise<void>;
|
|
171
|
-
/**
|
|
172
|
-
* Report that this carrier can no longer serve anything, so its owner may replace it.
|
|
173
|
-
*
|
|
174
|
-
* A carrier that borrows an outside process can lose it: the desktop shell exits, and every call
|
|
175
|
-
* after that would dial a port nobody owns. Without this signal the swap happens only at
|
|
176
|
-
* startup, so the choice made then is final for the process's life — which is what a user
|
|
177
|
-
* experiences as "the browser stopped working until I restart DSH". Optional: a carrier that
|
|
178
|
-
* owns its own lifetime has nothing to report.
|
|
179
|
-
*
|
|
180
|
-
* The listener receives WHY, because the fallback's message has to match what happened: a shell
|
|
181
|
-
* that exited and a shell whose panel cannot provide a page both reach the same fallback, and
|
|
182
|
-
* announcing "the shell has exited" for the second tells the user their desktop crashed when it
|
|
183
|
-
* did not.
|
|
184
|
-
* @param listener - called once, when the carrier concludes it is gone.
|
|
185
|
-
*/
|
|
186
|
-
onLost?(listener: (reason: CarrierLossReason) => void): void;
|
|
187
|
-
/**
|
|
188
|
-
* Fold the carrier's presentation away while keeping the page alive.
|
|
189
|
-
*
|
|
190
|
-
* The desktop sidebar keeps running regardless of the plugin, so "do not take
|
|
191
|
-
* over the screen" (settings: ui.autoExpandOnce = false) can only be honoured by
|
|
192
|
-
* asking the shell to fold it. A self-hosted window has no such state and simply
|
|
193
|
-
* does not implement this.
|
|
194
|
-
* @returns a promise that settles once the fold was attempted.
|
|
195
|
-
*/
|
|
196
|
-
collapse?(): Promise<void>;
|
|
197
|
-
/**
|
|
198
|
-
* Release everything the carrier owns (a spawned browser, a socket, a child).
|
|
199
|
-
* Called when the plugin stops using it, never while it is still in service.
|
|
200
|
-
*/
|
|
201
|
-
dispose?(): void;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* A user-initiated browser action from the host's own UI (toolbar). The
|
|
205
|
-
* `windowId` is the session id the view was grouped under, so the provider
|
|
206
|
-
* can route the action to the right session.
|
|
207
|
-
*/
|
|
208
|
-
export type BrowserUserAction = {
|
|
209
|
-
readonly type: 'navigate';
|
|
210
|
-
readonly windowId: string;
|
|
211
|
-
readonly url: string;
|
|
212
|
-
} | {
|
|
213
|
-
readonly type: 'newTab';
|
|
214
|
-
readonly windowId: string;
|
|
215
|
-
readonly url?: string;
|
|
216
|
-
} | {
|
|
217
|
-
readonly type: 'activateTab';
|
|
218
|
-
readonly windowId: string;
|
|
219
|
-
readonly viewId: string;
|
|
220
|
-
} | {
|
|
221
|
-
readonly type: 'closeTab';
|
|
222
|
-
readonly windowId: string;
|
|
223
|
-
readonly viewId: string;
|
|
224
|
-
} | {
|
|
225
|
-
readonly type: 'back';
|
|
226
|
-
readonly windowId: string;
|
|
227
|
-
} | {
|
|
228
|
-
readonly type: 'forward';
|
|
229
|
-
readonly windowId: string;
|
|
230
|
-
} | {
|
|
231
|
-
readonly type: 'reload';
|
|
232
|
-
readonly windowId: string;
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* A CDP-capable view handle. This is the subset of Electron's
|
|
236
|
-
* `WebContents`/`WebContentsView` the provider drives; the shell's real
|
|
237
|
-
* implementation adapts `webContents.debugger` to it.
|
|
238
|
-
*/
|
|
239
|
-
export interface ElectronViewHandle {
|
|
240
|
-
/** Unique id of the backing view, used for diagnostics. */
|
|
241
|
-
readonly id: string;
|
|
242
|
-
/**
|
|
243
|
-
* Send one CDP command and resolve with its result. Rejects when the
|
|
244
|
-
* debugger is not attached or the command fails.
|
|
245
|
-
* @param method - CDP method, e.g. `Page.navigate`.
|
|
246
|
-
* @param params - CDP command parameters.
|
|
247
|
-
* @returns the CDP `result` object.
|
|
248
|
-
*/
|
|
249
|
-
sendCommand(method: string, params?: Record<string, unknown>, options?: CommandOptions): Promise<Record<string, unknown>>;
|
|
250
|
-
/**
|
|
251
|
-
* Whether this view's CDP can encode JPEG and honour a quality setting.
|
|
252
|
-
*
|
|
253
|
-
* Electron 43's CDP hangs on `Page.captureScreenshot` with `format: 'jpeg'`, so a view
|
|
254
|
-
* backed by Electron must leave this unset and the provider keeps to PNG. A view backed
|
|
255
|
-
* by an installed Chrome or Edge is the real browser, where JPEG works, and sets it so
|
|
256
|
-
* the requested format is not silently downgraded.
|
|
257
|
-
*/
|
|
258
|
-
readonly supportsCdpJpeg?: boolean;
|
|
259
|
-
/**
|
|
260
|
-
* Give the backing view web focus so keyboard input reaches its page.
|
|
261
|
-
* Optional: an adapter that cannot focus a view omits it, and the provider
|
|
262
|
-
* then behaves exactly as before.
|
|
263
|
-
*/
|
|
264
|
-
focus?(options?: PresentOptions): Promise<void>;
|
|
265
|
-
/**
|
|
266
|
-
* Save a URL straight to disk, when the backing view can do that itself.
|
|
267
|
-
*
|
|
268
|
-
* Optional. Declared here rather than reached through a structural cast at the call site:
|
|
269
|
-
* a cast tells the compiler nothing, so a host that implements the interface without this
|
|
270
|
-
* method compiles and then silently does nothing.
|
|
271
|
-
* @param url - the URL to fetch.
|
|
272
|
-
* @param savePath - where to write it.
|
|
273
|
-
*/
|
|
274
|
-
download?(url: string, savePath: string): Promise<void>;
|
|
275
|
-
/**
|
|
276
|
-
* Export this view's cookies. Optional; see {@link download} for why it is declared.
|
|
277
|
-
* @returns the cookies, scoped to the view's own page.
|
|
278
|
-
*/
|
|
279
|
-
flushAuth?(): Promise<readonly ExportedCookie[]>;
|
|
280
|
-
/**
|
|
281
|
-
* Import cookies into this view. Optional.
|
|
282
|
-
* @param cookies - the cookies to write.
|
|
283
|
-
* @returns how many were accepted.
|
|
284
|
-
*/
|
|
285
|
-
restoreAuth?(cookies: readonly ExportedCookie[]): Promise<number>;
|
|
286
|
-
/**
|
|
287
|
-
* Capture this view natively, returning the image and its measured size.
|
|
288
|
-
*
|
|
289
|
-
* Optional. The size is part of the contract because the caller's own tool schema declares
|
|
290
|
-
* `width`/`height`; a host that can measure the image should say so here rather than leaving
|
|
291
|
-
* the provider to guess.
|
|
292
|
-
* @param opts - format, quality and downscale bounds.
|
|
293
|
-
* @returns the encoded image and the pixel size the caller will receive.
|
|
294
|
-
*/
|
|
295
|
-
capture?(opts?: ScreenshotOptions): Promise<{
|
|
296
|
-
base64: string;
|
|
297
|
-
mime: string;
|
|
298
|
-
width?: number;
|
|
299
|
-
height?: number;
|
|
300
|
-
}>;
|
|
301
|
-
}
|
|
302
|
-
/** Provider config: navigation admission defaults and snapshot caps. */
|
|
303
|
-
export interface ElectronBrowserProviderConfig {
|
|
304
|
-
/** Allow navigation only to HTTP(S) URLs; reject anything else. Default true. */
|
|
305
|
-
readonly httpOnly?: boolean;
|
|
306
|
-
/**
|
|
307
|
-
* Persistent browsing history (visited pages), independent of session
|
|
308
|
-
* lifetime. `enabled: false` keeps the browser working but records nothing;
|
|
309
|
-
* the retained limits ride along so a user's choice from the settings panel
|
|
310
|
-
* reaches the store without a second configuration path.
|
|
311
|
-
*/
|
|
312
|
-
readonly history?: {
|
|
313
|
-
readonly enabled?: boolean;
|
|
314
|
-
readonly maxEntries?: number;
|
|
315
|
-
readonly maxAgeDays?: number;
|
|
316
|
-
/**
|
|
317
|
-
* Explicit history file path. Default: beside the browser profile
|
|
318
|
-
* (`$DSH_HOME/dsh-builtin-browser-host/history.jsonl`).
|
|
319
|
-
*/
|
|
320
|
-
readonly file?: string;
|
|
321
|
-
};
|
|
322
|
-
/**
|
|
323
|
-
* Live settings source (the settings panel's document). When present it wins
|
|
324
|
-
* over the static `history` config, so a switch flipped in the UI takes effect
|
|
325
|
-
* without restarting DSH.
|
|
326
|
-
*/
|
|
327
|
-
readonly settings?: () => BrowserSettings;
|
|
328
|
-
/** Maximum snapshot elements before truncation. Default 60. */
|
|
329
|
-
readonly snapshotMaxElements?: number;
|
|
330
|
-
/**
|
|
331
|
-
* Explicit content cap, overriding the per-format default when set.
|
|
332
|
-
*
|
|
333
|
-
* Honoured again, and it is worth saying why that is a fix rather than a feature: this was
|
|
334
|
-
* `config.contentMaxChars ?? 100_000`, one number for every format, and when the caps became
|
|
335
|
-
* per-format (html and json 50 000, otherwise 20 000) the field was left assigned and never
|
|
336
|
-
* read. A configuration knob that silently does nothing is worse than no knob — it is an
|
|
337
|
-
* operator's decision that quietly went nowhere. Leaving it unset means the per-format
|
|
338
|
-
* default; setting it means the operator meant it.
|
|
339
|
-
*/
|
|
340
|
-
readonly contentMaxChars?: number;
|
|
341
|
-
/**
|
|
342
|
-
* Directory `dsh_browser_download` save paths must resolve inside (prevents a
|
|
343
|
-
* prompt-injected agent from writing arbitrary machine paths). Default:
|
|
344
|
-
* `~/Downloads`. NOTE: this default is a convenience, not a security
|
|
345
|
-
* boundary — on Windows it may resolve to OneDrive/redirected paths;
|
|
346
|
-
* a production deployment should set an explicit, verified path.
|
|
347
|
-
*/
|
|
348
|
-
readonly downloadDir?: string;
|
|
349
|
-
}
|
|
350
|
-
/**
|
|
351
|
-
* CDP method/params for `Page.navigate`, as sent to {@link ElectronViewHandle.sendCommand}.
|
|
352
|
-
*/
|
|
353
|
-
export interface CdpNavigateParams {
|
|
354
|
-
readonly url: string;
|
|
355
|
-
}
|
|
356
|
-
/**
|
|
357
|
-
* CDP method/params for `Input.dispatchMouseEvent`: a pointer move, or one half
|
|
358
|
-
* of a click's press+release pair. `button`/`clickCount` belong to the press and
|
|
359
|
-
* release halves; a move carries only the position.
|
|
360
|
-
*
|
|
361
|
-
* `buttons` is a BITMASK of what is held down at the moment of the event, and it is not the same
|
|
362
|
-
* field as `button` — `button` says which one this event is about, `buttons` says which ones are
|
|
363
|
-
* down. Chromium needs both to recognise a synthesized press as a real button press: with
|
|
364
|
-
* `buttons` omitted (0), the event still reaches the page and a `click` listener still fires, but
|
|
365
|
-
* the element's DEFAULT ACTION does not run. Measured on the sidebar carrier: a click on an
|
|
366
|
-
* anchor sent `mousedown`/`mouseup`/`click` to the page with `isTrusted: true` and
|
|
367
|
-
* `defaultPrevented: false`, and the browser did not follow the link — including for an anchor
|
|
368
|
-
* injected by the test itself, so the page was not responsible.
|
|
369
|
-
*/
|
|
370
|
-
export interface CdpMouseParams {
|
|
371
|
-
readonly type: 'mouseMoved' | 'mousePressed' | 'mouseReleased';
|
|
372
|
-
readonly x: number;
|
|
373
|
-
readonly y: number;
|
|
374
|
-
readonly button?: 'left';
|
|
375
|
-
readonly clickCount?: number;
|
|
376
|
-
/** Buttons held during the event: 1 = primary down. A move carries 0. */
|
|
377
|
-
readonly buttons?: number;
|
|
378
|
-
}
|
|
379
|
-
/** CDP method/params for `Input.insertText`. */
|
|
380
|
-
export interface CdpInsertTextParams {
|
|
381
|
-
readonly text: string;
|
|
382
|
-
}
|
|
383
|
-
/** CDP method/params for `Runtime.evaluate`. */
|
|
384
|
-
export interface CdpEvaluateParams {
|
|
385
|
-
readonly expression: string;
|
|
386
|
-
readonly returnByValue: boolean;
|
|
387
|
-
readonly awaitPromise?: boolean;
|
|
388
|
-
}
|
|
389
|
-
/** CDP method for a full-page screenshot capture. */
|
|
390
|
-
export declare const CDP_PAGE_CAPTURE_SCREENSHOT = "Page.captureScreenshot";
|
|
391
|
-
/**
|
|
392
|
-
* The document size out of a `Page.getLayoutMetrics` response.
|
|
393
|
-
*
|
|
394
|
-
* CDP returns `cssContentSize` (the whole document) and `cssLayoutViewport` (what is
|
|
395
|
-
* visible); the newer spellings `contentSize` / `layoutViewport` appear on some
|
|
396
|
-
* versions, so both are accepted. Returns undefined when neither is usable, leaving the
|
|
397
|
-
* caller to capture unscaled rather than guess.
|
|
398
|
-
* @param metrics - the raw CDP response.
|
|
399
|
-
* @returns the document and viewport size in CSS pixels.
|
|
400
|
-
*/
|
|
401
|
-
export declare function layoutSize(metrics: Record<string, unknown>): {
|
|
402
|
-
width: number;
|
|
403
|
-
height: number;
|
|
404
|
-
viewportHeight: number;
|
|
405
|
-
} | undefined;
|
|
406
|
-
/**
|
|
407
|
-
* Map CDP cookies onto the shape `dsh_browser_auth` exports.
|
|
408
|
-
*
|
|
409
|
-
* CDP reports a cookie as domain + path rather than a URL, and in seconds rather than
|
|
410
|
-
* milliseconds, so both are converted. Entries missing a name, value or domain are
|
|
411
|
-
* dropped rather than exported as broken cookies the caller cannot restore.
|
|
412
|
-
* @param raw - the `cookies` array from a CDP response, of unknown shape.
|
|
413
|
-
* @returns the mappable cookies.
|
|
414
|
-
*/
|
|
415
|
-
export declare function toExportedCookies(raw: unknown): ExportedCookie[];
|
|
416
|
-
/**
|
|
417
|
-
* Map an exported cookie onto the fields `Storage.setCookies` expects.
|
|
418
|
-
*
|
|
419
|
-
* An exported cookie may carry only a URL, so the domain and path are recovered from it
|
|
420
|
-
* when they are absent; without either, CDP cannot place the cookie and it is skipped.
|
|
421
|
-
* @param cookie - the cookie to convert.
|
|
422
|
-
* @returns the CDP cookie, or undefined when it lacks a usable domain.
|
|
423
|
-
*/
|
|
424
|
-
export declare function toCdpCookie(cookie: ExportedCookie): Record<string, unknown> | undefined;
|
|
425
|
-
/**
|
|
426
|
-
* How the carrier should present a view before it is used.
|
|
427
|
-
*
|
|
428
|
-
* `quiet` is the resolved `ui.quiet` switch. It does not mean "invisible": Chromium drops
|
|
429
|
-
* synthesized `Input.*` for a view without a display surface, so input still needs one. It means
|
|
430
|
-
* the carrier must get that surface without taking the screen over — no application activation
|
|
431
|
-
* and no operating-system keyboard focus. New windows open inactive; a minimized window and the
|
|
432
|
-
* foreground window's selected page remain under the operator's control. DOM focus and CDP input
|
|
433
|
-
* still target the task's page. Explicit sidebar navigation can select the task's pane.
|
|
434
|
-
*/
|
|
435
|
-
export interface PresentOptions {
|
|
436
|
-
readonly quiet?: boolean;
|
|
437
|
-
/** Explicit navigation or tab selection may change the task's sidebar tab without OS activation. */
|
|
438
|
-
readonly select?: boolean;
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* How a command should reach its page.
|
|
442
|
-
*
|
|
443
|
-
* Reported as issue #46: opening the live preview pushed the conversation's sidebar browser panel
|
|
444
|
-
* to the front — a read-only "look at it" action changing the reader's layout. The chain was
|
|
445
|
-
* `capturePassive` → `sendCommand('Page.captureScreenshot')` → the host's guest lookup → the bridge's
|
|
446
|
-
* `ensureSidebar` → a retry that asked the client half to `openSession`, which is exactly what a tool
|
|
447
|
-
* call is allowed to do and a preview is not.
|
|
448
|
-
*
|
|
449
|
-
* `present: false` says "this command must not make anything visible": use the page this
|
|
450
|
-
* conversation already has, and treat "not displayed" as a state to report rather than a condition
|
|
451
|
-
* to fix.
|
|
452
|
-
*/
|
|
453
|
-
export interface CommandOptions {
|
|
454
|
-
/** Present the view first (default), or only use a page that is already there. */
|
|
455
|
-
readonly present?: boolean;
|
|
456
|
-
/** Only use a guest already attached to this handle, without sidebar initialization. */
|
|
457
|
-
readonly initialize?: boolean;
|
|
458
|
-
}
|
|
459
|
-
/** Native capture options the self-hosted view handle understands. */
|
|
460
|
-
export interface ScreenshotOptions {
|
|
461
|
-
readonly format?: 'png' | 'jpeg';
|
|
462
|
-
readonly quality?: number;
|
|
463
|
-
readonly maxWidth?: number;
|
|
464
|
-
readonly maxHeight?: number;
|
|
465
|
-
/**
|
|
466
|
-
* Capture without presenting the window first (`ui.quiet`).
|
|
467
|
-
*
|
|
468
|
-
* The self-hosted host answers this by skipping its restore/show/focus step: a visible window
|
|
469
|
-
* still captures through `capturePage()`, and a minimized or hidden one falls through to the
|
|
470
|
-
* CDP path, which needs no display surface.
|
|
471
|
-
*/
|
|
472
|
-
readonly quiet?: boolean;
|
|
473
|
-
}
|
|
474
|
-
/** CDP method for runtime evaluation (the execute path). */
|
|
475
|
-
export declare const CDP_RUNTIME_EVALUATE = "Runtime.evaluate";
|
|
476
|
-
/** CDP method for navigation. */
|
|
477
|
-
export declare const CDP_PAGE_NAVIGATE = "Page.navigate";
|
|
478
|
-
/** Supported key names, exported for the tool's enum and error messages. */
|
|
479
|
-
export declare const BROWSER_KEY_NAMES: readonly string[];
|
|
480
|
-
/**
|
|
481
|
-
* Browser provider over Electron views. Sessions hold an ordered list of
|
|
482
|
-
* tabs; each tab is one view created by the host. The active tab receives
|
|
483
|
-
* every operation; switching tabs calls the host's optional `showView` and
|
|
484
|
-
* never loses state. Navigation is admitted only for HTTP(S) targets unless
|
|
485
|
-
* {@link ElectronBrowserProviderConfig.httpOnly} is disabled.
|
|
486
|
-
*/
|
|
487
|
-
export declare class ElectronBrowserProvider implements BrowserProvider {
|
|
488
|
-
private readonly host;
|
|
489
|
-
readonly id = "electron";
|
|
490
|
-
private readonly sessions;
|
|
491
|
-
private readonly httpOnly;
|
|
492
|
-
private readonly snapshotMaxElements;
|
|
493
|
-
private readonly contentMaxChars;
|
|
494
|
-
private readonly downloadDir;
|
|
495
|
-
/**
|
|
496
|
-
* Persistent browsing history, or `undefined` when the user turned it off.
|
|
497
|
-
* Sessions come and go; this record outlives all of them.
|
|
498
|
-
*/
|
|
499
|
-
private readonly historyStore;
|
|
500
|
-
/** Live settings source; absent when nothing owns a settings document. */
|
|
501
|
-
private readonly settingsSource;
|
|
502
|
-
constructor(host: ElectronBrowserViewHost, config?: ElectronBrowserProviderConfig);
|
|
503
|
-
/**
|
|
504
|
-
* Usable when the host says it can back views (the self-hosted host probes
|
|
505
|
-
* for a usable Electron binary; the desktop shell is assumed usable).
|
|
506
|
-
*/
|
|
507
|
-
available(): boolean;
|
|
508
|
-
/**
|
|
509
|
-
* Open a NEW browser session with its own view. Every call mints a fresh
|
|
510
|
-
* session id and backing view; per-task reuse is owned by the caller (the
|
|
511
|
-
* tool layer caches one session per DSH task). Sessions are isolated from
|
|
512
|
-
* each other: each keeps its own tabs, active tab, and history, and only
|
|
513
|
-
* the active tab of a session is made visible.
|
|
514
|
-
* @param label - optional human-readable label (e.g. the DSH task id) shown
|
|
515
|
-
* in the window title so a human can tell which task's page is visible.
|
|
516
|
-
*/
|
|
517
|
-
open(label?: string): Promise<BrowserSessionId>;
|
|
518
|
-
/** Open a URL in the active tab (default) or a new tab. */
|
|
519
|
-
openUrl(session: BrowserSessionId, request: BrowserOpenRequest, signal?: AbortSignal): Promise<void>;
|
|
520
|
-
/**
|
|
521
|
-
* Bind the carrier page that already shows this URL, if there is one.
|
|
522
|
-
*
|
|
523
|
-
* Compare the part of a URL that says WHICH page it is: scheme, host, path and query. A hash is a
|
|
524
|
-
* position inside a document, and a trailing slash is spelling, so neither makes a different page.
|
|
525
|
-
* @param s - the session to bind the page into.
|
|
526
|
-
* @param url - the URL being opened.
|
|
527
|
-
* @returns whether an existing page was taken over.
|
|
528
|
-
*/
|
|
529
|
-
private adoptMatchingPage;
|
|
530
|
-
/** The parts of a URL that decide identity, or undefined when it cannot be parsed. */
|
|
531
|
-
private comparableUrl;
|
|
532
|
-
/** List the session's tabs with their titles. */
|
|
533
|
-
listTabs(session: BrowserSessionId): Promise<readonly BrowserTab[]>;
|
|
534
|
-
/** Switch to a tab by id, making its view visible. */
|
|
535
|
-
switchTab(session: BrowserSessionId, tabId: string): Promise<void>;
|
|
536
|
-
/** Close one tab; closing the active tab activates the next. */
|
|
537
|
-
closeTab(session: BrowserSessionId, tabId: string): Promise<void>;
|
|
538
|
-
/**
|
|
539
|
-
* Find a tab by id, preferring the calling session. Tab ids are globally
|
|
540
|
-
* unique UUIDs, so when the calling session does not hold the tab (the tool
|
|
541
|
-
* layer's session resolution can drift from the session that opened it),
|
|
542
|
-
* fall back to locating it in any other session instead of failing — the
|
|
543
|
-
* caller explicitly named a tab, so acting on it is what they want. Throws
|
|
544
|
-
* BROWSER_TAB_UNKNOWN with the session's actual tabs when the id exists
|
|
545
|
-
* nowhere.
|
|
546
|
-
*/
|
|
547
|
-
private locateTab;
|
|
548
|
-
/** Close every tab and reset to one blank tab. */
|
|
549
|
-
reset(session: BrowserSessionId): Promise<void>;
|
|
550
|
-
/** Navigate the active tab's view to a URL, honoring HTTP(S)-only admission. */
|
|
551
|
-
navigate(session: BrowserSessionId, request: {
|
|
552
|
-
readonly url: string;
|
|
553
|
-
}, signal?: AbortSignal): Promise<void>;
|
|
554
|
-
/**
|
|
555
|
-
* A per-document stamp: `performance.timeOrigin` is unique per document load,
|
|
556
|
-
* so it tells a same-URL reload and an A→B→A redirect apart from the document
|
|
557
|
-
* that was current before the navigation. Empty string when unreadable.
|
|
558
|
-
*/
|
|
559
|
-
private documentStamp;
|
|
560
|
-
/**
|
|
561
|
-
* One cheap in-page reading of the document's identity and parse state.
|
|
562
|
-
*
|
|
563
|
-
* Returns null when the page did NOT answer (mid-commit, execution context
|
|
564
|
-
* destroyed) — the caller keeps waiting. A page that answered with an
|
|
565
|
-
* unexpected shape (an override or a non-conforming host; the production
|
|
566
|
-
* expression always yields a string) is reported as `unknown` rather than as
|
|
567
|
-
* "no answer": blocking the navigation for the whole budget on a page that
|
|
568
|
-
* demonstrably responded has no upside.
|
|
569
|
-
*/
|
|
570
|
-
private documentProbe;
|
|
571
|
-
/**
|
|
572
|
-
* Page.navigate resolves at navigation COMMIT, not at load: the new document
|
|
573
|
-
* is already current (so location.href and document.title are the new page's)
|
|
574
|
-
* while its DOM is still being parsed. dsh_browser_open snapshots immediately
|
|
575
|
-
* after navigating, which is why it could report the right title with zero
|
|
576
|
-
* interactive elements — and why a separate dsh_browser_snapshot right after
|
|
577
|
-
* always found them.
|
|
578
|
-
*
|
|
579
|
-
* Wait — bounded, best-effort — for the new document to settle: readyState
|
|
580
|
-
* must reach interactive/complete AND the document identity must have
|
|
581
|
-
* changed. A page that never settles must not fail a navigation that already
|
|
582
|
-
* succeeded, so a timeout here is swallowed.
|
|
583
|
-
*/
|
|
584
|
-
private settleDocument;
|
|
585
|
-
/**
|
|
586
|
-
* Make sure the active tab's view can actually receive synthesized input.
|
|
587
|
-
* Chromium drops `Input.*` events for a view with no display surface, so this
|
|
588
|
-
* runs before click/type/key and fails loudly (BROWSER_VIEW_NOT_PRESENTED)
|
|
589
|
-
* rather than reporting a success the page never saw.
|
|
590
|
-
* @param s - the session whose active view must be presented.
|
|
591
|
-
* @param signal - optional cancellation.
|
|
592
|
-
* @returns the view the session's active tab has AFTER the presentation barrier.
|
|
593
|
-
*/
|
|
594
|
-
private present;
|
|
595
|
-
/**
|
|
596
|
-
* Refuse to send synthesized input to a view that is no longer the one it was located
|
|
597
|
-
* against.
|
|
598
|
-
*
|
|
599
|
-
* `locateHandle` was captured before a page-side locate that can consume its whole
|
|
600
|
-
* 10s budget; the session's active tab is re-read afterwards. If they differ, the human
|
|
601
|
-
* switched tabs mid-flight (the product's whole point is that they can take over), and
|
|
602
|
-
* the coordinates belong to one page while the dispatch would go to another. Comparing
|
|
603
|
-
* the handles turns that into a loud, retryable error instead of input the caller
|
|
604
|
-
* believes landed.
|
|
605
|
-
* @param session - the session id, for the message.
|
|
606
|
-
* @param locateHandle - the view the locate ran in.
|
|
607
|
-
* @param liveHandle - the view that is active now.
|
|
608
|
-
*/
|
|
609
|
-
private assertSameView;
|
|
610
|
-
/**
|
|
611
|
-
* Give the view web focus before synthesizing keyboard input.
|
|
612
|
-
*
|
|
613
|
-
* A renderer only delivers key events to the view that holds web focus. A
|
|
614
|
-
* view that was created but never clicked holds none — and `Input` events
|
|
615
|
-
* injected over CDP do not grant it — so the FIRST `dsh_browser_key` of a fresh
|
|
616
|
-
* session vanished inside the renderer while the command still answered
|
|
617
|
-
* success. Hosts that cannot focus a view (a test double, a different shell
|
|
618
|
-
* adapter) simply have no `focus`, and nothing changes for them.
|
|
619
|
-
*/
|
|
620
|
-
private focusView;
|
|
621
|
-
/** Execute JS in the active tab's page context. */
|
|
622
|
-
execute(session: BrowserSessionId, request: BrowserExecuteRequest, signal?: AbortSignal): Promise<BrowserExecuteResult>;
|
|
623
|
-
/** Run a fixed browser operation; the request cannot contain a script. */
|
|
624
|
-
pageOperation(session: BrowserSessionId, request: BrowserPageOperationRequest, signal?: AbortSignal): Promise<BrowserExecuteResult>;
|
|
625
|
-
/** Send page pointer input through CDP while preserving presentation and cancellation policy. */
|
|
626
|
-
private dispatchPointer;
|
|
627
|
-
private evaluatePage;
|
|
628
|
-
/**
|
|
629
|
-
* Poll until the active tab's page is ready (and optional URL/selector
|
|
630
|
-
* match), or the budget runs out. Returns a verdict instead of throwing on
|
|
631
|
-
* timeout — the caller (model) decides what a miss means. Polling evaluates
|
|
632
|
-
* in the CURRENT document, so after a navigation the old document may
|
|
633
|
-
* briefly answer; pass the expected `url` to disambiguate.
|
|
634
|
-
*/
|
|
635
|
-
waitFor(session: BrowserSessionId, request: BrowserWaitRequest, signal?: AbortSignal): Promise<BrowserWaitResult>;
|
|
636
|
-
/** Produce an AI-friendly snapshot of the active tab. */
|
|
637
|
-
snapshot(session: BrowserSessionId, signal?: AbortSignal): Promise<BrowserSnapshotResult>;
|
|
638
|
-
/**
|
|
639
|
-
* Read the active tab's accessibility tree: semantic roles/names/states for
|
|
640
|
-
* every interactive node (Chrome's `computedRole`/`computedName` when
|
|
641
|
-
* available, tag/attribute inference otherwise). Pierces same-origin
|
|
642
|
-
* iframes and shadow roots like the snapshot; cross-origin frames stay
|
|
643
|
-
* opaque. Coordinates are top-document viewport-relative, so a node can
|
|
644
|
-
* also be driven by click/type.
|
|
645
|
-
*/
|
|
646
|
-
a11y(session: BrowserSessionId, request: BrowserA11yRequest, signal?: AbortSignal): Promise<BrowserA11yResult>;
|
|
647
|
-
/** Check whether a human-verification challenge is blocking the active tab. */
|
|
648
|
-
detectChallenge(session: BrowserSessionId, signal?: AbortSignal): Promise<BrowserChallenge>;
|
|
649
|
-
/** Fetch page content in a requested format. */
|
|
650
|
-
content(session: BrowserSessionId, request: BrowserContentRequest, signal?: AbortSignal): Promise<BrowserContentResult>;
|
|
651
|
-
/**
|
|
652
|
-
* Click at viewport coordinates, or at a located element's center when a
|
|
653
|
-
* `target` (css/text/xpath) is given. CDP mousePressed + mouseReleased.
|
|
654
|
-
*/
|
|
655
|
-
click(session: BrowserSessionId, request: BrowserClickRequest | {
|
|
656
|
-
readonly target: BrowserElementTarget;
|
|
657
|
-
}, signal?: AbortSignal): Promise<void>;
|
|
658
|
-
/**
|
|
659
|
-
* Click many points in order, once.
|
|
660
|
-
*
|
|
661
|
-
* The same wire sequence as {@link click}, looped — only the round-trip count changes. Presenting
|
|
662
|
-
* happens ONCE: the display-surface barrier is per view, not per press, and paying it for every
|
|
663
|
-
* point is what made an 86-cell board expensive.
|
|
664
|
-
*
|
|
665
|
-
* Stops at the first point that fails and reports where: a run that pressed through a page which
|
|
666
|
-
* had navigated or lost its surface would fill the wrong cells and still answer success.
|
|
667
|
-
* @param session - the session to click in.
|
|
668
|
-
* @param request - the points and the interval between them.
|
|
669
|
-
* @param signal - cancellation between points.
|
|
670
|
-
* @returns how many points landed, and where it stopped if it did not finish.
|
|
671
|
-
*/
|
|
672
|
-
clickSequence(session: BrowserSessionId, request: BrowserClickSequenceRequest, signal?: AbortSignal): Promise<BrowserClickSequenceResult>;
|
|
673
|
-
/**
|
|
674
|
-
* Type into the focused element, or focus a located element (css/text/xpath)
|
|
675
|
-
* first and then insert the text.
|
|
676
|
-
*/
|
|
677
|
-
type(session: BrowserSessionId, request: BrowserTypeRequest | {
|
|
678
|
-
readonly target: BrowserElementTarget;
|
|
679
|
-
}, signal?: AbortSignal): Promise<void>;
|
|
680
|
-
/** Scroll the page: by deltas, to a selector, or to top/bottom. */
|
|
681
|
-
scroll(session: BrowserSessionId, request: BrowserScrollRequest, signal?: AbortSignal): Promise<void>;
|
|
682
|
-
/** Go back (-1) or forward (+1) in the active tab's navigation history. */
|
|
683
|
-
private historyStep;
|
|
684
|
-
/** Go back in the active tab's history. */
|
|
685
|
-
back(session: BrowserSessionId, signal?: AbortSignal): Promise<void>;
|
|
686
|
-
/** Go forward in the active tab's history. */
|
|
687
|
-
forward(session: BrowserSessionId, signal?: AbortSignal): Promise<void>;
|
|
688
|
-
/** Reload the active tab. */
|
|
689
|
-
reload(session: BrowserSessionId, signal?: AbortSignal): Promise<void>;
|
|
690
|
-
/** Press one named key (Enter/Tab/arrows/…) via CDP key events. */
|
|
691
|
-
key(session: BrowserSessionId, request: BrowserKeyRequest, signal?: AbortSignal): Promise<void>;
|
|
692
|
-
/**
|
|
693
|
-
* Fill a form's fields in one batch. Runs one page-context script that
|
|
694
|
-
* resolves each field (selector, or name/label/placeholder among visible
|
|
695
|
-
* controls), sets its value with the native prototype setter (React/Vue
|
|
696
|
-
* controlled inputs included) plus input/change events, handles
|
|
697
|
-
* select/checkbox/radio/contenteditable, and optionally submits the form.
|
|
698
|
-
*/
|
|
699
|
-
fillForm(session: BrowserSessionId, request: BrowserFillRequest, signal?: AbortSignal): Promise<BrowserFillResult>;
|
|
700
|
-
/**
|
|
701
|
-
* Build an in-page async IIFE that locates ONE element by css/text/xpath
|
|
702
|
-
* (polling until it appears or the budget runs out) and then runs `body`
|
|
703
|
-
* with `el` in scope. Shared by the target-based tools: click/type (②),
|
|
704
|
-
* setValue/check/select/clear/getValue (③), and the scrape item wait.
|
|
705
|
-
* A selector that fails to PARSE is reported immediately instead of being
|
|
706
|
-
* polled until the budget expires — see the comment in `match`.
|
|
707
|
-
*/
|
|
708
|
-
private buildTargetScript;
|
|
709
|
-
/**
|
|
710
|
-
* Shared evaluate wrapper for the target-based tools. Runs the in-page
|
|
711
|
-
* script and returns its result object; throws a typed BrowserError on
|
|
712
|
-
* evaluation failure or an in-page `{ ok: false, error }` verdict.
|
|
713
|
-
*/
|
|
714
|
-
private runTargetScript;
|
|
715
|
-
/** Set one element's value (native setter + input/change, React-friendly). */
|
|
716
|
-
setValue(session: BrowserSessionId, request: BrowserSetValueRequest, signal?: AbortSignal): Promise<BrowserSetValueResult>;
|
|
717
|
-
/** Check or uncheck one checkbox/radio. */
|
|
718
|
-
check(session: BrowserSessionId, request: BrowserCheckRequest, signal?: AbortSignal): Promise<{
|
|
719
|
-
readonly checked: boolean;
|
|
720
|
-
}>;
|
|
721
|
-
/** Select one option of a <select>, by value, visible text, or index. */
|
|
722
|
-
selectOption(session: BrowserSessionId, request: BrowserSelectRequest, signal?: AbortSignal): Promise<BrowserSelectResult>;
|
|
723
|
-
/** Clear one input/textarea/contenteditable (or uncheck a checkbox/radio). */
|
|
724
|
-
clearField(session: BrowserSessionId, request: BrowserClearRequest, signal?: AbortSignal): Promise<{
|
|
725
|
-
readonly cleared: boolean;
|
|
726
|
-
}>;
|
|
727
|
-
/** Read one element's current value (for verification). */
|
|
728
|
-
getValue(session: BrowserSessionId, request: BrowserGetValueRequest, signal?: AbortSignal): Promise<BrowserGetValueResult>;
|
|
729
|
-
/**
|
|
730
|
-
* Extract structured data from repeated DOM items (static CSS, CSP-safe —
|
|
731
|
-
* no arbitrary code runs). Waits for the item selector, then maps each item
|
|
732
|
-
* through the field selectors; `selector@attr` reads an attribute instead
|
|
733
|
-
* of text (`a@href` yields an absolute URL).
|
|
734
|
-
*/
|
|
735
|
-
scrape(session: BrowserSessionId, request: BrowserScrapeRequest, signal?: AbortSignal): Promise<BrowserScrapeResult>;
|
|
736
|
-
/**
|
|
737
|
-
* Refuse an action the settings have switched off.
|
|
738
|
-
*
|
|
739
|
-
* These switches belong to the OPERATOR. The settings document is written through the
|
|
740
|
-
* plugin's own panel and no tool can reach it, so — unlike `dsh_browser_restrict`, which the
|
|
741
|
-
* model owns and can lift at will — a refusal here stands for as long as the setting does.
|
|
742
|
-
* That is the point of them: a deployment can take page-script execution, downloads, or
|
|
743
|
-
* login-state writes off the table without relying on the model's cooperation.
|
|
744
|
-
*
|
|
745
|
-
* Read through `settingsSource` on every call rather than captured at construction, so
|
|
746
|
-
* flipping a switch applies to the next command instead of the next restart — the same
|
|
747
|
-
* rule the credentials gate follows.
|
|
748
|
-
* @param action - which switch to consult.
|
|
749
|
-
* @throws BrowserError when that switch is off.
|
|
750
|
-
*/
|
|
751
|
-
private assertActionAllowed;
|
|
752
|
-
/**
|
|
753
|
-
* Admit a caller-supplied save path for a file the browser writes to disk.
|
|
754
|
-
* ONE gate for both `dsh_browser_download` and `dsh_browser_screenshot`: the path
|
|
755
|
-
* must be absolute, must resolve inside `downloadDir`, and must not already
|
|
756
|
-
* exist. Without it a prompt-injected agent could write — or silently
|
|
757
|
-
* replace — any file the DSH process can reach, which also escapes the file
|
|
758
|
-
* sandbox every other tool in the set runs under.
|
|
759
|
-
* @param savePath - the caller's target path.
|
|
760
|
-
* @param kind - the operation, used in the error code and message.
|
|
761
|
-
* @returns the resolved absolute target path.
|
|
762
|
-
* @throws BrowserError when the path is relative, outside the directory, or occupied.
|
|
763
|
-
*/
|
|
764
|
-
private admitSavePath;
|
|
765
|
-
/**
|
|
766
|
-
* Download an HTTP(S) URL with the session's cookies to a local file.
|
|
767
|
-
* Admission is the shared {@link admitSavePath} gate. The carrier downloads
|
|
768
|
-
* with its own authenticated browser session. Both admitted paths and screenshots are confined
|
|
769
|
-
* to `downloadDir`, so a prompt-injected agent cannot write arbitrary
|
|
770
|
-
* machine paths.
|
|
771
|
-
* @param session - the session whose cookies are used.
|
|
772
|
-
* @param request - the URL plus the absolute target path.
|
|
773
|
-
* @param signal - optional cancellation.
|
|
774
|
-
* @returns the path the file was written to.
|
|
775
|
-
*/
|
|
776
|
-
download(session: BrowserSessionId, request: {
|
|
777
|
-
readonly url: string;
|
|
778
|
-
readonly savePath: string;
|
|
779
|
-
}, signal?: AbortSignal): Promise<{
|
|
780
|
-
readonly path: string;
|
|
781
|
-
}>;
|
|
782
|
-
/**
|
|
783
|
-
* Export the session's cookies (login state) as serializable objects.
|
|
784
|
-
* Self-hosted only; the desktop shell's embedded views use the real profile.
|
|
785
|
-
*/
|
|
786
|
-
flushAuth(session: BrowserSessionId): Promise<readonly ExportedCookie[]>;
|
|
787
|
-
/** Import cookies into the session (restore login state). Self-hosted only. */
|
|
788
|
-
restoreAuth(session: BrowserSessionId, cookies: readonly ExportedCookie[]): Promise<number>;
|
|
789
|
-
/**
|
|
790
|
-
* Capture the active page WITHOUT presenting it.
|
|
791
|
-
*
|
|
792
|
-
* `screenshot` calls `showActive()` before capturing, and that is right for a tool whose point is
|
|
793
|
-
* that the human sees what the model just captured. It is also what makes that path unusable for a
|
|
794
|
-
* live preview: presenting on every frame would move focus, switch tabs and expand windows on the
|
|
795
|
-
* host's screen — exactly the side effects a viewer must not cause (issue #34).
|
|
796
|
-
*
|
|
797
|
-
* So this does the capture and nothing else. Deliberately narrow: viewport only, JPEG at the
|
|
798
|
-
* preview defaults, a short timeout, no save path, no history entry, no carrier recovery. A
|
|
799
|
-
* preview that rebuilt a vanished carrier would make watching a way to start a browser, which the
|
|
800
|
-
* design forbids: no page means "nothing to watch", not "open one".
|
|
801
|
-
* @param session - the session whose active page to capture.
|
|
802
|
-
* @returns the encoded image and its dimensions; throws BROWSER_PREVIEW_UNAVAILABLE when the page
|
|
803
|
-
* is not painted, which the caller turns into a "paused" state rather than an error.
|
|
804
|
-
*/
|
|
805
|
-
capturePassive(session: BrowserSessionId): Promise<{
|
|
806
|
-
readonly dataUrl: string;
|
|
807
|
-
readonly width?: number;
|
|
808
|
-
readonly height?: number;
|
|
809
|
-
}>;
|
|
810
|
-
/** Capture the current page, optionally full-page, PNG or JPEG, scalable. */
|
|
811
|
-
screenshot(session: BrowserSessionId, request?: BrowserScreenshotRequest, signal?: AbortSignal): Promise<{
|
|
812
|
-
readonly dataUrl: string;
|
|
813
|
-
readonly path?: string;
|
|
814
|
-
readonly width?: number;
|
|
815
|
-
readonly height?: number;
|
|
816
|
-
}>;
|
|
817
|
-
/**
|
|
818
|
-
* Build the data URL and optionally write the image to disk. The caller's
|
|
819
|
-
* path goes through the SAME {@link admitSavePath} gate as a download — it
|
|
820
|
-
* must be absolute, resolve inside `downloadDir`, and not be an existing
|
|
821
|
-
* file — so a screenshot cannot be used to write to, or silently replace,
|
|
822
|
-
* files anywhere the DSH process happens to have permission (issue #13).
|
|
823
|
-
*/
|
|
824
|
-
private saveScreenshot;
|
|
825
|
-
/** Append one operation to the session's history. */
|
|
826
|
-
private record;
|
|
827
|
-
/** Return the session's chronological operation log (newest last). */
|
|
828
|
-
history(session: BrowserSessionId): Promise<readonly BrowserHistoryEntry[]>;
|
|
829
|
-
/**
|
|
830
|
-
* Record one page visit in the persistent browsing history. Fire-and-forget by
|
|
831
|
-
* design: a visit must never delay or fail the navigation that produced it,
|
|
832
|
-
* and the title is only worth reading once the document has settled.
|
|
833
|
-
* @param s - the session that drove the visit.
|
|
834
|
-
* @param handle - the view whose document just loaded.
|
|
835
|
-
*/
|
|
836
|
-
private recordVisit;
|
|
837
|
-
/**
|
|
838
|
-
* List persisted visits, newest first — what `dsh_browser_visited` reads back.
|
|
839
|
-
* @param options - result cap and an optional hostname filter.
|
|
840
|
-
* @returns the matching visits, or an empty list when history is disabled.
|
|
841
|
-
*/
|
|
842
|
-
visited(options?: {
|
|
843
|
-
readonly limit?: number;
|
|
844
|
-
readonly domain?: string;
|
|
845
|
-
readonly query?: string;
|
|
846
|
-
readonly session?: string;
|
|
847
|
-
}): readonly VisitedPage[];
|
|
848
|
-
/**
|
|
849
|
-
* Show the synthetic pointer on a view, unless the user switched it off. The
|
|
850
|
-
* cursor is the "the agent has taken over this tab" signal, so it is painted
|
|
851
|
-
* for every operation that has a landing point — including DOM-level ones that
|
|
852
|
-
* move no real pointer.
|
|
853
|
-
* @param handle - the view to paint into.
|
|
854
|
-
* @param x - viewport x in CSS pixels.
|
|
855
|
-
* @param y - viewport y in CSS pixels.
|
|
856
|
-
* @param action - click pulses a ripple; move only relocates.
|
|
857
|
-
* @param label - short description of the operation, shown beside the pointer.
|
|
858
|
-
* @param force - paint even when the pointer is already there (a click ripple must
|
|
859
|
-
* always play; a bare move need not repeat).
|
|
860
|
-
*/
|
|
861
|
-
private showCursor;
|
|
862
|
-
/**
|
|
863
|
-
* Replay one recorded operation by sequence number. Navigate/click/type are
|
|
864
|
-
* re-issued against the current page; execute re-runs its script. The
|
|
865
|
-
* replayed step is appended to history as a new entry.
|
|
866
|
-
* @param session - the session id.
|
|
867
|
-
* @param seq - the recorded entry's sequence number to replay.
|
|
868
|
-
*/
|
|
869
|
-
replay(session: BrowserSessionId, seq: number): Promise<void>;
|
|
870
|
-
/** Close the session and destroy all its views. Idempotent. */
|
|
871
|
-
close(session: BrowserSessionId): Promise<void>;
|
|
872
|
-
/** Look up a session or throw the unknown-session error. */
|
|
873
|
-
private session;
|
|
874
|
-
/** The active tab of a session. */
|
|
875
|
-
private activeTab;
|
|
876
|
-
/** Append a fresh tab and make it active. */
|
|
877
|
-
private newTab;
|
|
878
|
-
/**
|
|
879
|
-
* Swap a wedged view for a fresh blank one, keeping the tab's public id.
|
|
880
|
-
*
|
|
881
|
-
* A view whose renderer never commits cannot be read again: every evaluate into it runs out its
|
|
882
|
-
* whole budget. Replacing it is what turns that from permanent into one bad call — the tab id
|
|
883
|
-
* callers hold stays valid, and the next `dsh_browser_open` with the real URL re-populates it.
|
|
884
|
-
*
|
|
885
|
-
* The old view is destroyed AFTER the new one is in place, so a failure here cannot leave the
|
|
886
|
-
* session holding a handle that is already gone.
|
|
887
|
-
* @param s - the session owning the tab.
|
|
888
|
-
* @param tab - the tab to reset.
|
|
889
|
-
*/
|
|
890
|
-
private replaceTabWithBlank;
|
|
891
|
-
/** Find a session's tab by its backing view id (toolbar actions carry view ids). */
|
|
892
|
-
private tabByViewId;
|
|
893
|
-
/**
|
|
894
|
-
* Whether a session is still live. The human closing a window ends its session
|
|
895
|
-
* (see {@link handleViewClosed}), so callers that cache ids must ask first.
|
|
896
|
-
* @param session - the session id to test.
|
|
897
|
-
*/
|
|
898
|
-
exists(session: BrowserSessionId): boolean;
|
|
899
|
-
/**
|
|
900
|
-
* The sessions a viewer may watch, which is exactly the sessions that exist.
|
|
901
|
-
*
|
|
902
|
-
* Served so the browser page can build a frame URL without guessing: the provider names its
|
|
903
|
-
* sessions, and an id invented by a client is refused at the route. Ids only — no URL, no title,
|
|
904
|
-
* no target handle — because the point is to let the panel address a session, not to describe
|
|
905
|
-
* what is in it.
|
|
906
|
-
* @returns the live session ids.
|
|
907
|
-
*/
|
|
908
|
-
watchableSessions(): readonly BrowserSessionId[];
|
|
909
|
-
/**
|
|
910
|
-
* The human closed a browser window: the session that window showed is over.
|
|
911
|
-
* Ending it here is what makes the next call a clean start rather than a
|
|
912
|
-
* resurrection of an invisible window. Browsing history and login state live
|
|
913
|
-
* on disk, so nothing the human cares about is lost with it.
|
|
914
|
-
* @param windowId - the group key the host reported, which is the session id.
|
|
915
|
-
*/
|
|
916
|
-
private handleViewClosed;
|
|
917
|
-
/**
|
|
918
|
-
* Route a user-initiated action from the host's UI into the session model.
|
|
919
|
-
* Fire-and-forget by design: a user action failing (e.g. an unreachable
|
|
920
|
-
* URL typed into the address bar) must never crash the host UI loop — it
|
|
921
|
-
* is reported to the host (toolbar) when the host supports it, else logged.
|
|
922
|
-
*/
|
|
923
|
-
private handleUserAction;
|
|
924
|
-
/**
|
|
925
|
-
* Report a failed user action to the host UI (toolbar), when supported.
|
|
926
|
-
*
|
|
927
|
-
* Two properties matter here, because this runs inside the catch of an async
|
|
928
|
-
* handler (issue #16):
|
|
929
|
-
* - the receiver must be preserved. Reading the method off the host and calling
|
|
930
|
-
* it unbound runs the host's implementation with `this === undefined`, so its
|
|
931
|
-
* very first statement (`void this.ready()`) throws, the throw escapes the
|
|
932
|
-
* async catch as an unhandled rejection, and the whole DSH host exits;
|
|
933
|
-
* - this method must be incapable of throwing. Reporting a failed action is
|
|
934
|
-
* diagnostics: it can never be allowed to become the failure.
|
|
935
|
-
*/
|
|
936
|
-
private notifyUserActionError;
|
|
937
|
-
/**
|
|
938
|
-
* Whether the operator asked for quiet mode (`ui.quiet`).
|
|
939
|
-
*
|
|
940
|
-
* Read live on every call rather than captured at construction: the panel writes the document
|
|
941
|
-
* and the next operation is expected to honour it, without a restart.
|
|
942
|
-
* @returns true when the carrier must present views without taking the screen over.
|
|
943
|
-
*/
|
|
944
|
-
private isQuiet;
|
|
945
|
-
/**
|
|
946
|
-
* Ask the host to show the active tab's view, carrying the session label.
|
|
947
|
-
*
|
|
948
|
-
* The two halves are sequential, not alternatives. `showView` makes the view the
|
|
949
|
-
* visible one — which is what keeps what the human sees in step with what the agent
|
|
950
|
-
* drives, and what lets `capturePage` return an image at all (a hidden view captures
|
|
951
|
-
* empty) — while `collapse` folds the carrier's own chrome away when the user asked
|
|
952
|
-
* for no auto-expand. Making them exclusive meant that with auto-expand off this
|
|
953
|
-
* method did nothing at all on carriers without `collapse` (the self-hosted one),
|
|
954
|
-
* silently desynchronising the two and failing every screenshot.
|
|
955
|
-
*/
|
|
956
|
-
private showActive;
|
|
957
|
-
/** Read the current URL of a view through CDP. */
|
|
958
|
-
private currentUrl;
|
|
959
|
-
}
|