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,248 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Desktop-sidebar browser host: drive the page the desktop shell shows in its
|
|
3
|
-
* sidebar, instead of spawning a second, parallel Electron window.
|
|
4
|
-
*
|
|
5
|
-
* WHY
|
|
6
|
-
* The plugin runs inside the desktop's Node-mode host, where there is no Electron
|
|
7
|
-
* API — which is why it self-hosts a whole browser today. The shell, however, can
|
|
8
|
-
* own views, and its sidebar already displays real web pages. This host borrows
|
|
9
|
-
* that page over the shell's bridge (see apps/desktop/bridge/plugin-browser-bridge.js),
|
|
10
|
-
* so the agent and the human end up on ONE page instead of two.
|
|
11
|
-
*
|
|
12
|
-
* CONTRACT
|
|
13
|
-
* It implements the same `ElectronBrowserViewHost` seam the self-hosted host does,
|
|
14
|
-
* so the provider, the tools, browsing history, the synthetic cursor and the
|
|
15
|
-
* teardown rules are all unchanged: only the carrier differs. Everything is
|
|
16
|
-
* lazily materialized — a fresh shell has no sidebar guest until something asks
|
|
17
|
-
* for a page, and the bridge creates one on demand.
|
|
18
|
-
*
|
|
19
|
-
* FALLBACK
|
|
20
|
-
* `discover()` returns undefined whenever the shell offers no usable bridge
|
|
21
|
-
* (older desktop build, plain `dsh web`, bridge not started), and the entry point
|
|
22
|
-
* then keeps the self-hosted Electron it has always used.
|
|
23
|
-
* @module dsh-browser/browser-electron/desktop-bridge-host
|
|
24
|
-
*/
|
|
25
|
-
import { bridgeEndpointPath } from './paths.js';
|
|
26
|
-
import type { ElectronBrowserViewHost, ElectronViewHandle } from './provider.js';
|
|
27
|
-
import type { BrowserUserAction } from './provider.js';
|
|
28
|
-
import type { CarrierPage, CarrierLossReason } from '../browser/types.js';
|
|
29
|
-
/** Absolute path of the endpoint file the shell writes. */
|
|
30
|
-
export { bridgeEndpointPath };
|
|
31
|
-
/**
|
|
32
|
-
* A failure worth showing as-is: the carrier is alive and this is a condition the shell can change.
|
|
33
|
-
*
|
|
34
|
-
* Thrown instead of a plain Error so callers can distinguish "the panel did not render" from "the
|
|
35
|
-
* browser broke", which is exactly the distinction issue #37 says was missing. The plugin no longer
|
|
36
|
-
* waits for a human to show the conversation — the client half asks the shell to (`openSession`) and
|
|
37
|
-
* this host retries while it renders — so reaching here means the shell did not render it at all.
|
|
38
|
-
*/
|
|
39
|
-
export declare class BrowserPanelNotDisplayedError extends Error {
|
|
40
|
-
readonly code: string;
|
|
41
|
-
/**
|
|
42
|
-
* @param detail - the bridge's own explanation, appended so the message says why.
|
|
43
|
-
*/
|
|
44
|
-
constructor(detail: string, code?: string);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* The desktop sidebar, presented as a browser view host.
|
|
48
|
-
*
|
|
49
|
-
* One sidebar exists per shell window, so every view this host hands out refers
|
|
50
|
-
* to the same guest: the provider keeps its tab bookkeeping, and the tabs simply
|
|
51
|
-
* share the visible page. That is the intended behaviour for this carrier — the
|
|
52
|
-
* point is a single page both parties can see.
|
|
53
|
-
*/
|
|
54
|
-
export declare class DesktopBridgeViewHost implements ElectronBrowserViewHost {
|
|
55
|
-
private readonly _isQuiet;
|
|
56
|
-
private readonly protocol;
|
|
57
|
-
private readonly connection;
|
|
58
|
-
/**
|
|
59
|
-
* One entry per view this host handed out: the conversation it serves, and the guest backing it.
|
|
60
|
-
*
|
|
61
|
-
* The conversation belongs to the ENTRY, not to this host. A single plugin process serves every
|
|
62
|
-
* conversation — DSH runs them all through one host instance — so an owner held on the host
|
|
63
|
-
* would be one conversation's id applied to all of them, and a page could still land in
|
|
64
|
-
* another's sidebar however carefully the bridge checked it.
|
|
65
|
-
*/
|
|
66
|
-
private readonly views;
|
|
67
|
-
/**
|
|
68
|
-
* This process's identity with the bridge, for tab ownership.
|
|
69
|
-
*
|
|
70
|
-
* Every DSH session is its own plugin process, and the sidebar is one surface they all share.
|
|
71
|
-
* A session can only see its own `views` map, so before the bridge kept a ledger it adopted
|
|
72
|
-
* whichever tab it found — including one another session had opened, which is how a URL from
|
|
73
|
-
* one session appeared in another's sidebar. The id is per process, so two sessions never
|
|
74
|
-
* collide and one session's tabs are never handed to another; it is deliberately not the DSH
|
|
75
|
-
* session id, which this layer has no access to and does not need.
|
|
76
|
-
*
|
|
77
|
-
* The whole ledger rests on that premise, so it was measured rather than assumed: with two
|
|
78
|
-
* sessions running, the desktop had TWO host processes (plus one main, two renderers and a
|
|
79
|
-
* gpu/utility pair). If sessions ever shared a process, every owner check in the bridge would
|
|
80
|
-
* compare equal and the bleed would return in a new shape — so a change to how DSH spawns
|
|
81
|
-
* sessions invalidates this file, not just this comment.
|
|
82
|
-
*
|
|
83
|
-
* It is now the CONVERSATION id rather than an invented uuid, read from the plugin's ctx by the
|
|
84
|
-
* same path DSH's own desktop host uses. That matters because the shell keeps one sidebar per
|
|
85
|
-
* conversation and writes its session id onto each sidebar container (on the React fiber,
|
|
86
|
-
* measured on the running app) — so the bridge can only answer "is this sidebar mine" if it has
|
|
87
|
-
* a comparable id. With an invented uuid it never could, which is how a command came to be typed
|
|
88
|
-
* into another conversation's address bar.
|
|
89
|
-
*
|
|
90
|
-
* Falls back to a random uuid when the host cannot supply one — an older DSH, or a non-desktop
|
|
91
|
-
* composition. That is no worse than before: the bridge then knows only "this process", and it
|
|
92
|
-
* refuses to operate on a sidebar it cannot prove is its own.
|
|
93
|
-
*/
|
|
94
|
-
private readonly owner;
|
|
95
|
-
/**
|
|
96
|
-
* Guests whose view is gone but whose page may still be open in the sidebar, with the
|
|
97
|
-
* conversation each belongs to.
|
|
98
|
-
*
|
|
99
|
-
* The provider destroys its view handles before it asks for a release, so the mapping is dropped
|
|
100
|
-
* by then — keeping the guest ids here is what lets us close only our own tabs when several
|
|
101
|
-
* conversations are running (requirements 搂4: each session gets its own page). The owner rides
|
|
102
|
-
* along for the same reason it does in {@link views}: a release names one conversation.
|
|
103
|
-
*/
|
|
104
|
-
private readonly orphaned;
|
|
105
|
-
/**
|
|
106
|
-
* Registered by the provider, and deliberately never invoked on this carrier.
|
|
107
|
-
*
|
|
108
|
-
* The sidebar is the shell's own interface: a human clicking inside that page is an
|
|
109
|
-
* event the shell owns, and the bridge exposes no operation that reports it. The
|
|
110
|
-
* handler is stored anyway so the interface contract holds (a caller may register
|
|
111
|
-
* one and must not be surprised) and so a future bridge operation can deliver it
|
|
112
|
-
* without changing the provider. Consequently no user-action event is emitted while
|
|
113
|
-
* the desktop sidebar is the carrier — by design, not by omission.
|
|
114
|
-
*/
|
|
115
|
-
private userActionHandler;
|
|
116
|
-
/** Told when the shell behind this bridge exits; see `onLost`. */
|
|
117
|
-
private lostListener;
|
|
118
|
-
/**
|
|
119
|
-
* @param endpoint - the shell's published bridge endpoint.
|
|
120
|
-
*/
|
|
121
|
-
private constructor();
|
|
122
|
-
/**
|
|
123
|
-
* Called when this carrier concludes it cannot serve anything more.
|
|
124
|
-
*
|
|
125
|
-
* Forwarded rather than acted on here: only the entry point owns the swap back to the self-hosted
|
|
126
|
-
* browser, and a host that tried to replace itself would be reaching outside its own contract.
|
|
127
|
-
* @param reason - which failure this was, so the fallback can say so accurately.
|
|
128
|
-
*/
|
|
129
|
-
private reportLost;
|
|
130
|
-
/** Register the "this carrier is gone" listener (see the interface's `onLost`). */
|
|
131
|
-
onLost(listener: (reason: CarrierLossReason) => void): void;
|
|
132
|
-
/**
|
|
133
|
-
* Find a usable desktop bridge, if this surface has one.
|
|
134
|
-
*
|
|
135
|
-
* A stale endpoint (a shell that already exited, leaving its file behind) is
|
|
136
|
-
* rejected here rather than surfacing later as a mysterious ECONNREFUSED: the
|
|
137
|
-
* caller falls back to self-hosting, which always works.
|
|
138
|
-
* @returns the host, or undefined when no bridge is available.
|
|
139
|
-
*/
|
|
140
|
-
static discover(sessionId?: string, isQuiet?: () => boolean): Promise<DesktopBridgeViewHost | undefined>;
|
|
141
|
-
/**
|
|
142
|
-
* Whether the last discovery refused a bridge because its sidebar panel is an iframe.
|
|
143
|
-
*
|
|
144
|
-
* Recorded so the entry point can say WHY the plugin is self-hosting on a shell that does have a
|
|
145
|
-
* bridge. Otherwise the user sees a second browser window and no explanation, on a machine where
|
|
146
|
-
* they just followed instructions to install the bridge.
|
|
147
|
-
*/
|
|
148
|
-
private static refuseIframe;
|
|
149
|
-
/** Whether discovery refused a bridge for an undrivable sidebar panel (see {@link discover}). */
|
|
150
|
-
static refusedIframePanel(): boolean;
|
|
151
|
-
/** Whether this host can back views: the bridge already answered `list`. */
|
|
152
|
-
available(): boolean;
|
|
153
|
-
/**
|
|
154
|
-
* Every page this conversation's sidebar panel currently holds.
|
|
155
|
-
*
|
|
156
|
-
* The shell owns page creation inside the panel: a link the user or the agent clicks may open a
|
|
157
|
-
* new page, and nothing tells the provider. Those pages are real — they are what the human sees
|
|
158
|
-
* — but without this the tab model reports only the ones the provider created, so the rest are
|
|
159
|
-
* invisible to `dsh_browser_list_tabs` and unclosable through `dsh_browser_close_tab`.
|
|
160
|
-
*
|
|
161
|
-
* The bridge's `list` already answers with the sidebar guests, which is the same information, so
|
|
162
|
-
* this asks for it rather than reaching into the shell again.
|
|
163
|
-
* @returns the panel's pages, or an empty list when the bridge cannot answer.
|
|
164
|
-
*/
|
|
165
|
-
/**
|
|
166
|
-
* Every sidebar page this conversation holds that THIS HOST did not open.
|
|
167
|
-
*
|
|
168
|
-
* The shell owns page creation inside the panel: a link the user or the agent clicks may open a
|
|
169
|
-
* new page, and nothing tells the provider. Those pages are real — they are what the human sees
|
|
170
|
-
* — but without this the tab model reports only the ones the provider created, so the rest are
|
|
171
|
-
* invisible to `dsh_browser_list_tabs` and unclosable through `dsh_browser_close_tab`.
|
|
172
|
-
*
|
|
173
|
-
* Pages this host opened are EXCLUDED here rather than deduplicated by the caller, because the
|
|
174
|
-
* caller cannot do it: the provider knows a tab by its own id and the carrier knows a page by the
|
|
175
|
-
* guest id, and the two never match. The first version returned everything and relied on the
|
|
176
|
-
* caller to filter, which reported the same page twice — the mapping that makes the match
|
|
177
|
-
* possible exists only here.
|
|
178
|
-
* @returns the panel's pages that are not ours, or an empty list when the bridge cannot answer.
|
|
179
|
-
*/
|
|
180
|
-
listPages(owner?: string): Promise<readonly CarrierPage[]>;
|
|
181
|
-
/**
|
|
182
|
-
* Close one sidebar page by the id {@link listPages} reported.
|
|
183
|
-
*
|
|
184
|
-
* The bridge closes sidebar pages by TITLE, and only the ones the caller owns — that is what
|
|
185
|
-
* stopped one conversation's teardown from destroying another's page. So the title is looked up
|
|
186
|
-
* through the same listing, and a page that no longer appears is treated as already gone rather
|
|
187
|
-
* than as an error: the caller asked for it to be closed, and it is.
|
|
188
|
-
* @param id - the sidebar guest id, as a string.
|
|
189
|
-
*/
|
|
190
|
-
closePage(id: string, owner?: string): Promise<void>;
|
|
191
|
-
/**
|
|
192
|
-
* The guest backing a view, materialized on first use.
|
|
193
|
-
*
|
|
194
|
-
* The conversation that called owns exactly one sidebar page on this carrier — a human and the
|
|
195
|
-
* agent look at the same page — so every view resolves to that conversation's own guest, and the
|
|
196
|
-
* page does not multiply behind the provider's own tab bookkeeping.
|
|
197
|
-
*
|
|
198
|
-
* A cached guest is used as-is: probing it first cost a round-trip on every command, so liveness
|
|
199
|
-
* is established by the command failing instead.
|
|
200
|
-
* @param viewId - the view whose guest is wanted.
|
|
201
|
-
* @param url - address to use when this conversation has no page yet.
|
|
202
|
-
*/
|
|
203
|
-
private guestFor;
|
|
204
|
-
/**
|
|
205
|
-
* @param owner - the conversation this view serves. Recorded WITH the view: one host instance
|
|
206
|
-
* serves every conversation, so the owner cannot live on the host.
|
|
207
|
-
*/
|
|
208
|
-
createView(owner?: string): ElectronViewHandle;
|
|
209
|
-
destroyView(handle: ElectronViewHandle): void;
|
|
210
|
-
/**
|
|
211
|
-
* Bring this view's tab to the front in the sidebar.
|
|
212
|
-
*
|
|
213
|
-
* This used to be empty, on the reasoning that the sidebar is already on screen so there is
|
|
214
|
-
* nothing to show. That confused "the sidebar is visible" with "this page is the one being
|
|
215
|
-
* looked at": opening a page left it behind whatever the human had in front, which is issue
|
|
216
|
-
* #23. The other two carriers both do this — the self-hosted window re-adds the view and the
|
|
217
|
-
* system browser calls `Page.bringToFront` — so this carrier was the odd one out.
|
|
218
|
-
*
|
|
219
|
-
* Best-effort by design: the tab strip belongs to the shell's renderer, and failing to raise
|
|
220
|
-
* it must not fail the navigation that has already happened.
|
|
221
|
-
* @param handle - the view to bring forward.
|
|
222
|
-
*/
|
|
223
|
-
showView(handle: ElectronViewHandle, _label?: string, options?: {
|
|
224
|
-
readonly quiet?: boolean;
|
|
225
|
-
readonly select?: boolean;
|
|
226
|
-
}): void;
|
|
227
|
-
onUserAction(handler: (action: BrowserUserAction) => void): void;
|
|
228
|
-
/**
|
|
229
|
-
* Release the sidebar's browser pages (requirements 搂3, `ui.closeWithSession`).
|
|
230
|
-
*
|
|
231
|
-
* Destroying our own view handles is not enough on this carrier: the sidebar
|
|
232
|
-
* belongs to the shell and would happily keep the page (and its renderer) alive.
|
|
233
|
-
* Closing the tabs is what actually ends the page — and only the page: cookies
|
|
234
|
-
* live in the partition, history on disk, so both survive.
|
|
235
|
-
* @param owner - the conversation whose pages to close. Omit to close every conversation's,
|
|
236
|
-
* which is only correct from a teardown that is itself global.
|
|
237
|
-
* @returns a promise that settles once the shell has been asked.
|
|
238
|
-
*/
|
|
239
|
-
releasePage(owner?: string): Promise<void>;
|
|
240
|
-
/**
|
|
241
|
-
* Fold the sidebar away without ending the page (`ui.autoExpandOnce` is off, or
|
|
242
|
-
* the caller wants the screen back while work continues).
|
|
243
|
-
* @returns a promise that settles once the shell has been asked.
|
|
244
|
-
*/
|
|
245
|
-
collapse(): Promise<void>;
|
|
246
|
-
/** No child process of our own to stop; close the shared connection instead. */
|
|
247
|
-
dispose(): void;
|
|
248
|
-
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/** The identity rule, as data. */
|
|
2
|
-
interface IdentityRule {
|
|
3
|
-
readonly packageNames: readonly string[];
|
|
4
|
-
readonly mainEntry: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* The rule shipped in `desktop-bridge/desktop-identity.json`, used when the file cannot be read.
|
|
8
|
-
*
|
|
9
|
-
* A copy exists here only as a fallback for a broken package layout; the test suite asserts that it
|
|
10
|
-
* equals the JSON, so the two can never drift apart silently.
|
|
11
|
-
*/
|
|
12
|
-
export declare const FALLBACK_RULE: IdentityRule;
|
|
13
|
-
/** A verified install. */
|
|
14
|
-
export interface DesktopIdentity {
|
|
15
|
-
readonly ok: true;
|
|
16
|
-
/** The install root that was verified. */
|
|
17
|
-
readonly root: string;
|
|
18
|
-
/** Which shape was verified — the archive when it exists, the extraction only without one. */
|
|
19
|
-
readonly layout: 'packed' | 'unpacked';
|
|
20
|
-
/** `name` from the package the caller will actually run. */
|
|
21
|
-
readonly packageName: string;
|
|
22
|
-
/** `version`, when the package declares one. */
|
|
23
|
-
readonly version?: string;
|
|
24
|
-
}
|
|
25
|
-
/** A refusal, with a reason a human can act on. */
|
|
26
|
-
export interface IdentityRefusal {
|
|
27
|
-
readonly ok: false;
|
|
28
|
-
readonly reason: string;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Read the identity rule.
|
|
32
|
-
*
|
|
33
|
-
* Resolved relative to this module, which in both the repository and the published tarball puts
|
|
34
|
-
* `desktop-bridge/` beside `lib/`. A missing file is not fatal — the fallback is the same rule —
|
|
35
|
-
* but a *malformed* one is an error the caller should not ignore, so it is reported through the
|
|
36
|
-
* refusal path rather than silently swapped for the fallback.
|
|
37
|
-
* @returns the rule, or an error string.
|
|
38
|
-
*/
|
|
39
|
-
export declare function readIdentityRule(): IdentityRule | {
|
|
40
|
-
readonly error: string;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Read one file out of an asar archive without extracting the tree.
|
|
44
|
-
* @param archive - the archive path.
|
|
45
|
-
* @param path - a slash-separated path inside the archive.
|
|
46
|
-
* @returns the bytes, or undefined when the entry is absent or unreadable.
|
|
47
|
-
*/
|
|
48
|
-
export declare function readAsarFile(archive: string, path: string): Buffer | undefined;
|
|
49
|
-
/**
|
|
50
|
-
* Whether an install directory is DSH Desktop.
|
|
51
|
-
*
|
|
52
|
-
* Everything the caller does next (stop the app, delete a tree, extract, rename, write) depends on
|
|
53
|
-
* this being right, so every uncertainty resolves to a refusal that names what was found.
|
|
54
|
-
* @param installRoot - the directory a user or the discovery probe named.
|
|
55
|
-
* @returns the verified identity, or a refusal with a reason.
|
|
56
|
-
*/
|
|
57
|
-
export declare function readDesktopIdentity(installRoot: string): DesktopIdentity | IdentityRefusal;
|
|
58
|
-
export {};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/** How long a background provision may run before it is abandoned. */
|
|
2
|
-
export declare const PROVISION_TIMEOUT_MS = 180000;
|
|
3
|
-
/** What happened, in terms a log line can carry. */
|
|
4
|
-
export interface ProvisionResult {
|
|
5
|
-
/** `present` — nothing to do; `ready` — provisioned now; `skipped` — opted out; `failed`. */
|
|
6
|
-
readonly status: 'present' | 'ready' | 'skipped' | 'failed';
|
|
7
|
-
/** One line for the log; never contains a stack trace a user has to decode. */
|
|
8
|
-
readonly detail: string;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* The state a settings panel shows, which is one state wider than {@link ProvisionResult}.
|
|
12
|
-
*
|
|
13
|
-
* `idle` and `preparing` are the two a log line never needs and a user always does: "nothing has
|
|
14
|
-
* been asked for yet" and "a ~100 MB download is running right now" are the states in which a first
|
|
15
|
-
* browser call is slow, and until this existed neither was visible anywhere in the product — the
|
|
16
|
-
* only trace was a log line the panel cannot read.
|
|
17
|
-
*/
|
|
18
|
-
export interface ProvisionSnapshot {
|
|
19
|
-
/** `idle` and `preparing` are provisional; the rest are terminal for this attempt. */
|
|
20
|
-
readonly state: 'idle' | 'preparing' | 'present' | 'ready' | 'skipped' | 'failed';
|
|
21
|
-
/** One line, already user-facing: never a stack trace. */
|
|
22
|
-
readonly detail: string;
|
|
23
|
-
/** When the state last changed, ISO. */
|
|
24
|
-
readonly at: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* The current provisioning state, for a readiness report.
|
|
28
|
-
*
|
|
29
|
-
* Deliberately a snapshot rather than a promise: a panel polling this must be able to answer in one
|
|
30
|
-
* synchronous read, without awaiting (and thereby echoing) the download it is reporting on.
|
|
31
|
-
* @returns the last state written, or the idle state before anything ran.
|
|
32
|
-
*/
|
|
33
|
-
export declare function provisionSnapshot(): ProvisionSnapshot;
|
|
34
|
-
/** Everything this module touches from the outside, so a test can drive it without Electron. */
|
|
35
|
-
export interface ProvisionDeps {
|
|
36
|
-
/** Whether a spawnable binary already exists. */
|
|
37
|
-
readonly hasBinary: () => boolean;
|
|
38
|
-
/** The installed electron package's own installer script, or undefined when it is not there. */
|
|
39
|
-
readonly installerScript: () => string | undefined;
|
|
40
|
-
/** Runs the installer; resolves to an exit code, or rejects/returns null on failure. */
|
|
41
|
-
readonly run: (script: string, signal?: AbortSignal) => Promise<{
|
|
42
|
-
code: number | null;
|
|
43
|
-
detail?: string;
|
|
44
|
-
}>;
|
|
45
|
-
/** Where the outcome goes. */
|
|
46
|
-
readonly log: (message: string) => void;
|
|
47
|
-
/** Opt-out honoured exactly like the install script honours it. */
|
|
48
|
-
readonly skip: () => boolean;
|
|
49
|
-
/** Budget for one provision. */
|
|
50
|
-
readonly timeoutMs: number;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Whether a spawnable Electron binary is already available.
|
|
54
|
-
*
|
|
55
|
-
* Resolved through the same probe the host uses, so this can never disagree with what a launch
|
|
56
|
-
* would find: a second, cheaper-looking check would be the classic way to report "ready" and then
|
|
57
|
-
* fail at spawn time.
|
|
58
|
-
* @returns true when a launch would find a binary.
|
|
59
|
-
*/
|
|
60
|
-
export declare function hasElectronRuntime(): boolean;
|
|
61
|
-
/** The real dependencies: this process's spawn, fs and logger. */
|
|
62
|
-
export declare function defaultDeps(log?: (message: string) => void): ProvisionDeps;
|
|
63
|
-
/**
|
|
64
|
-
* Provision the runtime once per process, when it is missing.
|
|
65
|
-
*
|
|
66
|
-
* Concurrent callers share the first attempt: two tool calls arriving together must not start two
|
|
67
|
-
* downloads into the same directory.
|
|
68
|
-
* @param deps - the effects, defaulted to this process's.
|
|
69
|
-
* @returns what happened. Never throws.
|
|
70
|
-
*/
|
|
71
|
-
export declare function ensureElectronRuntime(deps?: ProvisionDeps): Promise<ProvisionResult>;
|
|
72
|
-
/**
|
|
73
|
-
* Start (or join) the single background attempt.
|
|
74
|
-
*
|
|
75
|
-
* Returns immediately with the shared promise, so a caller that does not care can ignore it and one
|
|
76
|
-
* that does can await it — the returned promise never rejects.
|
|
77
|
-
*
|
|
78
|
-
* `force` is the second half of the settings panel's retry button. Without it the memoised attempt
|
|
79
|
-
* made a failed download permanent for the life of the process: the panel could offer a button, the
|
|
80
|
-
* button could call this, and the answer would be the failure it was trying to replace. An attempt
|
|
81
|
-
* still IN FLIGHT is always joined, never restarted — two downloads into one directory is the one
|
|
82
|
-
* outcome worth refusing.
|
|
83
|
-
* @param log - where the outcome goes.
|
|
84
|
-
* @param deps - the effects; defaulted to this process's, overridable so a test can drive it.
|
|
85
|
-
* @param options - `force` discards a settled attempt so a new one may start.
|
|
86
|
-
* @returns the shared attempt.
|
|
87
|
-
*/
|
|
88
|
-
export declare function provisionElectronInBackground(log: (message: string) => void, deps?: ProvisionDeps, options?: {
|
|
89
|
-
readonly force?: boolean;
|
|
90
|
-
}): Promise<ProvisionResult>;
|
|
91
|
-
/** Forget the attempt. Tests only: a real process provisions at most once. */
|
|
92
|
-
export declare function resetProvisionStateForTest(): void;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Electron browser provider plugin entry: registers the Electron-backed
|
|
3
|
-
* `BrowserProvider` with `ctx.browser`. The provider needs a view host (real
|
|
4
|
-
* Electron `WebContentsView` objects). When a desktop shell supplies
|
|
5
|
-
* `ctx.electronViewHost`, that host is used (embedded, human-machine shared
|
|
6
|
-
* view). Otherwise the plugin self-hosts: it spawns its own Electron child
|
|
7
|
-
* (`host-main.js`) and drives it over a local TCP JSON-RPC socket, so
|
|
8
|
-
* installing the plugin is enough for `dsh_browser_*` tools to work on any
|
|
9
|
-
* surface.
|
|
10
|
-
* @module dsh-browser/browser-electron
|
|
11
|
-
*/
|
|
12
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
13
|
-
import z from '@deepseek-ai/schemastery';
|
|
14
|
-
import type { BrowserRuntime } from '../browser/runtime.js';
|
|
15
|
-
import type { ElectronBrowserViewHost } from './provider.js';
|
|
16
|
-
export { ELECTRON_BROWSER_PROVIDER_ID, ElectronBrowserProvider, } from './provider.js';
|
|
17
|
-
export type { ElectronBrowserViewHost, ElectronViewHandle } from './provider.js';
|
|
18
|
-
export { RemoteElectronViewHost, defaultHostMainPath } from './remote-host.js';
|
|
19
|
-
/** Cordis plugin name used by loader diagnostics. */
|
|
20
|
-
export declare const name = "browser-electron";
|
|
21
|
-
/** The browser seam this provider registers into. */
|
|
22
|
-
export declare const inject: string[];
|
|
23
|
-
/** Plugin config: an optional externally-supplied view host. */
|
|
24
|
-
export interface Config {
|
|
25
|
-
/** View host supplied by a desktop shell; absent -> self-host. */
|
|
26
|
-
readonly viewHost?: ElectronBrowserViewHost;
|
|
27
|
-
/** Allow navigation only to HTTP(S) URLs. Default true. */
|
|
28
|
-
readonly httpOnly?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Directory `dsh_browser_download` save paths must resolve inside (prevents a
|
|
31
|
-
* prompt-injected agent from writing arbitrary machine paths). Default:
|
|
32
|
-
* the user's Downloads folder; override to confine downloads elsewhere.
|
|
33
|
-
*/
|
|
34
|
-
readonly downloadDir?: string;
|
|
35
|
-
/** Maximum snapshot elements before truncation. Default 60. */
|
|
36
|
-
readonly snapshotMaxElements?: number;
|
|
37
|
-
/** Maximum content characters before truncation when no maxChars is given. No longer read: the cap is per format (html and json 50 000, otherwise 20 000). */
|
|
38
|
-
readonly contentMaxChars?: number;
|
|
39
|
-
}
|
|
40
|
-
export declare const Config: z<Config>;
|
|
41
|
-
/** Register the Electron browser provider with `ctx.browser`. */
|
|
42
|
-
export declare function apply(ctx: Context & {
|
|
43
|
-
browser: BrowserRuntime;
|
|
44
|
-
}, config: Config): void;
|
|
45
|
-
/**
|
|
46
|
-
* Move a browser profile left behind by the old layout into the directory the plugin uses now.
|
|
47
|
-
*
|
|
48
|
-
* Before the `?.dsh` component was added here, a desktop launched from a shortcut (no `DSH_HOME`
|
|
49
|
-
* in the environment) put its browser profile in `<homedir>/dsh-builtin-browser-host/` while its
|
|
50
|
-
* settings and history lived in `<homedir>/.dsh/dsh-builtin-browser-host/`. Login state lives
|
|
51
|
-
* INSIDE the browser profile, so leaving the old directory behind silently signs the user out of
|
|
52
|
-
* everything they had signed into — reported after the fix shipped, as a one-time cost of it.
|
|
53
|
-
*
|
|
54
|
-
* That cost does not have to be paid. The move happens only when the new location is absent, so a
|
|
55
|
-
* profile in use is never overwritten, and every failure — a cross-device rename, a permission
|
|
56
|
-
* problem, a profile another process holds — falls through to an empty profile, which is exactly
|
|
57
|
-
* what would have happened without this function. The old directory is then left untouched rather
|
|
58
|
-
* than deleted, because a half-moved profile is worse than a stale one.
|
|
59
|
-
*
|
|
60
|
-
* @param profileRoot - the root the plugin resolves today (`<DSH_HOME>/dsh-builtin-browser-host`).
|
|
61
|
-
* @param legacyRoot - the pre-`DSH_HOME` layout's root. Injected so the move can be exercised
|
|
62
|
-
* without touching the real home directory.
|
|
63
|
-
*/
|
|
64
|
-
export declare function adoptLegacyProfileRoot(profileRoot: string, legacyRoot?: string): void;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/** Test seams; production passes neither. */
|
|
2
|
-
export interface SweepOptions {
|
|
3
|
-
/** The clock, for the age check. */
|
|
4
|
-
readonly now?: number;
|
|
5
|
-
/** Liveness test for an owner pid. */
|
|
6
|
-
readonly alive?: (pid: number) => boolean;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* The directory name an ephemeral profile for `kind` gets, before it is claimed.
|
|
10
|
-
*
|
|
11
|
-
* The sweep matches on the same shape, so the two must agree: a name built anywhere else
|
|
12
|
-
* is a directory the sweep will never find.
|
|
13
|
-
* @param kind - the detected browser product (`chrome`, `edge`, ...).
|
|
14
|
-
* @param id - a per-run unique suffix.
|
|
15
|
-
* @returns the directory NAME, not a path.
|
|
16
|
-
*/
|
|
17
|
-
export declare function ephemeralProfileName(kind: string, id: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Mark an ephemeral profile directory as this process's, so a later run can tell whether
|
|
20
|
-
* the process that created it is still there.
|
|
21
|
-
* @param dir - the profile directory (created if it does not exist yet).
|
|
22
|
-
* @param pid - the claiming process, defaulting to this one.
|
|
23
|
-
* @param now - the claim time, defaulting to the current clock.
|
|
24
|
-
* @returns true when the marker was written.
|
|
25
|
-
*/
|
|
26
|
-
export declare function claimEphemeralProfile(dir: string, pid?: number, now?: number): boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Delete the ephemeral profiles under `root` that belong to processes which are gone.
|
|
29
|
-
*
|
|
30
|
-
* Called before a new one is claimed, because that is the only moment that can still act
|
|
31
|
-
* on a profile whose owner was killed: nothing runs when the signal lands.
|
|
32
|
-
* @param root - the plugin's profile root (`<DSH_HOME>/dsh-builtin-browser-host`).
|
|
33
|
-
* @param kind - the browser product, which selects the directory-name prefix.
|
|
34
|
-
* @param options - test seams for the clock and the liveness test.
|
|
35
|
-
* @returns the names of the directories that were removed.
|
|
36
|
-
*/
|
|
37
|
-
export declare function sweepAbandonedEphemeralProfiles(root: string, kind: string, options?: SweepOptions): string[];
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persistent browsing history: which pages the shared browser actually visited,
|
|
3
|
-
* kept independently from any session's operation log (`dsh_browser_history`) and
|
|
4
|
-
* from the browser process's lifetime.
|
|
5
|
-
*
|
|
6
|
-
* It lives beside the browser profile (`$DSH_HOME/dsh-builtin-browser-host/
|
|
7
|
-
* history.jsonl`), so it follows the same persistence rules as the login state:
|
|
8
|
-
* closing the interface releases the process, never the record.
|
|
9
|
-
*
|
|
10
|
-
* Format: one JSON object per line, append-only. Appending stays cheap for a
|
|
11
|
-
* long session, and a half-written tail (crash, power loss) is dropped on read
|
|
12
|
-
* instead of poisoning the whole file.
|
|
13
|
-
* @module dsh-browser/browser-electron/history-store
|
|
14
|
-
*/
|
|
15
|
-
import type { VisitedPage } from '../browser/types.js';
|
|
16
|
-
export type { VisitedPage };
|
|
17
|
-
/** Retention limits; whichever is hit first starts trimming. */
|
|
18
|
-
export interface HistoryLimits {
|
|
19
|
-
/** Maximum retained entries. Default 5000. */
|
|
20
|
-
readonly maxEntries?: number;
|
|
21
|
-
/** Maximum age in days. Default 90. */
|
|
22
|
-
readonly maxAgeDays?: number;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Absolute path of the browsing-history file, beside the browser profile so the
|
|
26
|
-
* record shares the login state's persistence rules.
|
|
27
|
-
* @returns the history file path.
|
|
28
|
-
*/
|
|
29
|
-
export declare function visitedHistoryPath(): string;
|
|
30
|
-
/**
|
|
31
|
-
* Append-only browsing history with bounded retention. Every method tolerates a
|
|
32
|
-
* missing or damaged file: recording a visit must never fail a navigation, and
|
|
33
|
-
* a corrupted line must never hide the rest of the history.
|
|
34
|
-
*/
|
|
35
|
-
export declare class HistoryStore {
|
|
36
|
-
private readonly file;
|
|
37
|
-
/** Entry count at which another batched rewrite is due. */
|
|
38
|
-
private pruneThreshold;
|
|
39
|
-
/** Number of entries at the last full read, unknown until the first prune. */
|
|
40
|
-
private knownEntries;
|
|
41
|
-
/** Successful appends since the last full read. */
|
|
42
|
-
private appendedSincePrune;
|
|
43
|
-
/** Earliest retained visit's expiry; time can require a prune without any new visit. */
|
|
44
|
-
private nextExpiryAt;
|
|
45
|
-
/** Changing retention invalidates both the count and the age calculation. */
|
|
46
|
-
private limitsChanged;
|
|
47
|
-
private maxEntries;
|
|
48
|
-
private maxAgeMs;
|
|
49
|
-
/**
|
|
50
|
-
* @param file - absolute path of the JSONL history file.
|
|
51
|
-
* @param limits - retention overrides (entry count and age).
|
|
52
|
-
*/
|
|
53
|
-
constructor(file?: string, limits?: HistoryLimits);
|
|
54
|
-
/**
|
|
55
|
-
* Re-read the retention limits.
|
|
56
|
-
*
|
|
57
|
-
* They are settings, and settings change while the plugin runs — a panel that let the
|
|
58
|
-
* operator edit them while nothing read the new values made the control a lie. Entry count
|
|
59
|
-
* and age are the pair the interface presents, so they are updated together.
|
|
60
|
-
* @param limits - the current retention overrides.
|
|
61
|
-
*/
|
|
62
|
-
updateLimits(limits: HistoryLimits): void;
|
|
63
|
-
/** Whether the history file exists yet (diagnostics and tests). */
|
|
64
|
-
exists(): boolean;
|
|
65
|
-
/**
|
|
66
|
-
* Record one visit. Failures are swallowed by design: history is a
|
|
67
|
-
* convenience, and losing an entry must never break the tool call that
|
|
68
|
-
* produced it.
|
|
69
|
-
* @param page - the visited page.
|
|
70
|
-
*/
|
|
71
|
-
append(page: VisitedPage): void;
|
|
72
|
-
/**
|
|
73
|
-
* Read visits, newest first. Unparseable lines are skipped; entries older
|
|
74
|
-
* than the age limit are filtered out but left on disk until the next prune.
|
|
75
|
-
* @param options - optional result cap plus three filters: `domain` (hostname),
|
|
76
|
-
* `query` (substring of the URL or title) and `session` (the task that visited
|
|
77
|
-
* it). Filters compose, so "the pages THIS task opened on that host" is one call.
|
|
78
|
-
* @returns the matching visits, newest first.
|
|
79
|
-
*/
|
|
80
|
-
list(options?: {
|
|
81
|
-
readonly limit?: number;
|
|
82
|
-
readonly domain?: string;
|
|
83
|
-
readonly query?: string;
|
|
84
|
-
readonly session?: string;
|
|
85
|
-
}): VisitedPage[];
|
|
86
|
-
/**
|
|
87
|
-
* How far past the cap the file may grow before it is rewritten.
|
|
88
|
-
*
|
|
89
|
-
* Scaled to the cap rather than fixed: a fixed 500 was meaningless when the cap is
|
|
90
|
-
* small (a caller asking for three entries would never reach 503), and the slack is
|
|
91
|
-
* there to batch rewrites, not to overrule the caller's bound.
|
|
92
|
-
* @returns the number of extra entries tolerated before a rewrite.
|
|
93
|
-
*/
|
|
94
|
-
private slack;
|
|
95
|
-
prune(): void;
|
|
96
|
-
/** Parse the whole file, skipping blank and damaged lines. */
|
|
97
|
-
private readAll;
|
|
98
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Self-hosted Electron browser host (child side): the Electron main process
|
|
3
|
-
* spawned by {@link RemoteElectronViewHost}. Owns one `BrowserWindow` PER
|
|
4
|
-
* SESSION (each session's views live in their own window) plus a browser
|
|
5
|
-
* toolbar (address bar, back/forward/reload, tab strip) that makes the
|
|
6
|
-
* built-in browser usable as a real browser by the human — every window has
|
|
7
|
-
* its own toolbar. Views are `WebContentsView`s driven over
|
|
8
|
-
* `webContents.debugger` (CDP); user toolbar actions are routed back to the
|
|
9
|
-
* parent so the agent and the human always share one tab/navigation model.
|
|
10
|
-
*
|
|
11
|
-
* Protocol (one JSON object per line, both directions):
|
|
12
|
-
* <- { id, op: 'ping' } | { id, op: 'createView', viewId } |
|
|
13
|
-
* { id, op: 'destroyView', viewId } | { id, op: 'showView', viewId } |
|
|
14
|
-
* { id, op: 'groupView', viewId, windowId, label? } |
|
|
15
|
-
* { id, op: 'command', viewId, method, params } |
|
|
16
|
-
* { id, op: 'focus', viewId } |
|
|
17
|
-
* { id, op: 'userActionError', windowId, message }
|
|
18
|
-
* -> { id: 0, op: 'hello', token } (our FIRST message — proves we know the
|
|
19
|
-
* parent's stdin token; the parent refuses the connection otherwise)
|
|
20
|
-
* -> { id, ok: true, result? } | { id, ok: false, err }
|
|
21
|
-
* -> { id: 0, op: 'userAction', action } (fire-and-forget; no reply)
|
|
22
|
-
*
|
|
23
|
-
* The parent never parses stderr, so diagnostics may go there freely.
|
|
24
|
-
* @module dsh-browser/browser-electron/host-main
|
|
25
|
-
*/
|
|
26
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bounded request bodies shared by every plugin HTTP route. Keeping one implementation means the
|
|
3
|
-
* byte limit, UTF-8 decoding and oversize behaviour cannot drift between the settings and the
|
|
4
|
-
* maintenance endpoints.
|
|
5
|
-
* @module dsh-browser/browser-electron/http-body
|
|
6
|
-
*/
|
|
7
|
-
import type { IncomingMessage } from 'node:http';
|
|
8
|
-
/**
|
|
9
|
-
* Read a body as UTF-8 text. Chunks are collected as Buffers and decoded once: setting an
|
|
10
|
-
* encoding on the stream and concatenating `String(chunk)` corrupts a multi-byte character that
|
|
11
|
-
* happens to be split across two TCP chunks.
|
|
12
|
-
* @param request - the incoming request.
|
|
13
|
-
* @param limit - maximum accepted bytes.
|
|
14
|
-
* @returns the body text.
|
|
15
|
-
*/
|
|
16
|
-
export declare function readTextBody(request: IncomingMessage, limit?: number): Promise<string>;
|
|
17
|
-
/**
|
|
18
|
-
* Read and parse a JSON body. An empty body is an empty object, matching the settings route's
|
|
19
|
-
* long-standing behaviour.
|
|
20
|
-
* @param request - the incoming request.
|
|
21
|
-
* @param limit - maximum accepted bytes.
|
|
22
|
-
* @returns the parsed value.
|
|
23
|
-
*/
|
|
24
|
-
export declare function readJsonBody<T>(request: IncomingMessage, limit?: number): Promise<T>;
|