dsh-builtin-browser 1.0.3 → 1.0.4
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/README.en.md +89 -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/package.json +20 -2
- package/scripts/build-client.mjs +305 -0
- package/scripts/build.mjs +69 -0
- package/scripts/bundle-host.mjs +28 -0
- package/scripts/fix-exports.mjs +40 -0
- package/scripts/install-electron.mjs +101 -0
- package/scripts/pack.mjs +99 -0
- package/scripts/publish-manifest.mjs +56 -0
- package/scripts/verify-exports.mjs +58 -0
- package/scripts/verify-preview-sdk.mjs +93 -0
- package/skills/dsh-builtin-browser/SKILL.md +98 -0
- package/skills/dsh-builtin-browser/references/batch.md +68 -0
- package/skills/dsh-builtin-browser/references/deliver.md +31 -0
- package/skills/dsh-builtin-browser/references/locate.md +11 -0
- package/skills/dsh-builtin-browser/references/recover.md +11 -0
- package/skills/dsh-builtin-browser/references/verify.md +13 -0
- 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/anti-bot.ts +251 -0
- package/src/browser/deep-dom.ts +40 -0
- package/src/browser/handles.ts +89 -0
- package/src/browser/runtime.ts +578 -0
- package/src/browser/takeover-target.ts +45 -0
- package/src/browser/types.ts +870 -0
- package/src/browser-electron/authenticated-route.ts +109 -0
- package/src/browser-electron/automatic-maintenance.ts +736 -0
- package/src/browser-electron/bridge-auto.ts +159 -0
- package/src/browser-electron/bridge-connection.ts +386 -0
- package/src/browser-electron/bridge-endpoint.ts +129 -0
- package/src/browser-electron/bridge-install.ts +290 -0
- package/src/browser-electron/bridge-maintenance.ts +189 -0
- package/src/browser-electron/bridge-status.ts +386 -0
- package/src/browser-electron/desktop-bridge-host.ts +253 -0
- package/src/browser-electron/desktop-identity.ts +353 -0
- package/src/browser-electron/desktop-shell.ts +100 -0
- package/src/browser-electron/document-readiness.ts +45 -0
- package/src/browser-electron/electron-provision.ts +347 -0
- package/src/browser-electron/entry.ts +1378 -0
- package/src/browser-electron/ephemeral-profile.ts +189 -0
- package/src/browser-electron/extension-browser.ts +230 -0
- package/src/browser-electron/extension-setup.ts +67 -0
- package/src/browser-electron/file-write.ts +31 -0
- package/src/browser-electron/foreground-watch.ts +142 -0
- package/src/browser-electron/guest-cookie-jar.ts +177 -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 +716 -0
- package/src/browser-electron/guest-runtime.ts +408 -0
- package/src/browser-electron/guest-storage-runtime.ts +54 -0
- package/src/browser-electron/guest-storage.ts +120 -0
- package/src/browser-electron/history-store.ts +224 -0
- package/src/browser-electron/host-main.ts +1385 -0
- package/src/browser-electron/host-patch-maintenance.ts +121 -0
- package/src/browser-electron/http-body.ts +65 -0
- package/src/browser-electron/json-reply.ts +47 -0
- package/src/browser-electron/maintenance-broker.ts +166 -0
- package/src/browser-electron/maintenance-lifecycle.ts +91 -0
- package/src/browser-electron/maintenance-route.ts +68 -0
- package/src/browser-electron/missing-system-browser.ts +114 -0
- package/src/browser-electron/open-slot.ts +49 -0
- package/src/browser-electron/paths.ts +25 -0
- package/src/browser-electron/preferred-browser.ts +130 -0
- package/src/browser-electron/preview-route.ts +215 -0
- package/src/browser-electron/process-ownership.ts +174 -0
- package/src/browser-electron/process.ts +23 -0
- package/src/browser-electron/profile-checkpoint.ts +187 -0
- package/src/browser-electron/profile-command.ts +47 -0
- package/src/browser-electron/profile-extension.ts +129 -0
- package/src/browser-electron/profile-lease.ts +211 -0
- package/src/browser-electron/profile-residue.ts +49 -0
- package/src/browser-electron/provider-core.ts +1107 -0
- package/src/browser-electron/provider-interaction.ts +1034 -0
- package/src/browser-electron/provider-media.ts +589 -0
- package/src/browser-electron/provider-navigation.ts +323 -0
- package/src/browser-electron/provider-observation.ts +664 -0
- package/src/browser-electron/provider-tabs.ts +372 -0
- package/src/browser-electron/provider.ts +666 -0
- package/src/browser-electron/reference-route.ts +598 -0
- package/src/browser-electron/remote-host.ts +1538 -0
- package/src/browser-electron/rpc-input.ts +13 -0
- package/src/browser-electron/rpc-ops.ts +41 -0
- package/src/browser-electron/runtime-diagnostics.ts +38 -0
- package/src/browser-electron/runtime-route.ts +105 -0
- package/src/browser-electron/runtime-status.ts +309 -0
- package/src/browser-electron/settings-route.ts +64 -0
- package/src/browser-electron/settings-store.ts +593 -0
- package/src/browser-electron/shortcuts-route.ts +112 -0
- package/src/browser-electron/sidebar-only-host.ts +300 -0
- package/src/browser-electron/startpage-shortcuts.ts +213 -0
- package/src/browser-electron/system-browser.ts +1850 -0
- package/src/browser-electron/tauri-host.ts +194 -0
- package/src/browser-electron/timing.ts +16 -0
- package/src/browser-electron/virtual-cursor.ts +162 -0
- package/src/browser-electron/windows-system.ts +24 -0
- 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 +1346 -0
- package/src/browser-reference/store.ts +172 -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 +106 -0
- package/src/client/apply-guard.ts +22 -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 +182 -0
- package/src/client/browser/child-tabs.ts +14 -0
- package/src/client/browser/frame-history.ts +125 -0
- package/src/client/browser/frame-state.ts +27 -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 +56 -0
- package/src/client/css-modules.d.ts +4 -0
- package/src/client/definition.tsx +36 -0
- package/src/client/electron/ElectronWebViewImpl.ts +371 -0
- package/src/client/electron/ElectronWebviewPresentation.ts +140 -0
- package/src/client/electron/NativeChildPresentation.ts +53 -0
- package/src/client/electron/NativeViewPage.ts +265 -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 +333 -0
- package/src/client/locales.ts +860 -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 +208 -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 +447 -0
- package/src/client/reference/client/production/asset-store.ts +144 -0
- package/src/client/reference/client/production/availability.ts +72 -0
- package/src/client/reference/client/production/bytes.ts +36 -0
- package/src/client/reference/client/production/composer-attachments.ts +44 -0
- package/src/client/reference/client/production/delivery-client.ts +211 -0
- package/src/client/reference/client/production/draft-adapter.ts +512 -0
- package/src/client/reference/client/production/http-transport.ts +212 -0
- package/src/client/reference/client/production/production-submission.ts +70 -0
- package/src/client/reference/client/production/protocol.ts +234 -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 +1056 -0
- package/src/client/reference/client/production/snapshot-adapter.ts +154 -0
- package/src/client/reference/client/production/source-marker.ts +99 -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 +67 -0
- package/src/client/reference/client/reveal.ts +109 -0
- package/src/client/reference/client/scheme.ts +114 -0
- package/src/client/reference/client/session-schedule.ts +36 -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 +42 -0
- package/src/client/settings/mount-guard.ts +31 -0
- package/src/client/settings/panel.ts +2768 -0
- package/src/client/shortcut-open.ts +30 -0
- package/src/client/startpage/binding.ts +99 -0
- package/src/client/startpage/controller.ts +300 -0
- package/src/client/startpage/model.ts +279 -0
- package/src/client/view/Browser.module.css +751 -0
- package/src/client/view/BrowserBody.tsx +315 -0
- package/src/client/view/BrowserPresentation.ts +9 -0
- package/src/client/view/BrowserTitle.tsx +17 -0
- package/src/client/view/IframePresentation.ts +365 -0
- package/src/client/view/StartPage.tsx +598 -0
- package/src/client/view/TakeoverBanner.tsx +21 -0
- package/src/compat/host-features.ts +92 -0
- package/src/index.ts +110 -0
- 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 +219 -0
- package/src/startpage-settings.ts +103 -0
- package/src/startpage.ts +71 -0
- package/src/takeover-protocol.ts +28 -0
- package/src/tool-browser/block-recovery.ts +85 -0
- package/src/tool-browser/code-tool.ts +555 -0
- package/src/tool-browser/code-worker.ts +725 -0
- package/src/tool-browser/element-fields.ts +167 -0
- package/src/tool-browser/errors.ts +40 -0
- package/src/tool-browser/index.ts +265 -0
- package/src/tool-browser/page-probe.ts +675 -0
- package/src/tool-browser/panel-page.ts +126 -0
- package/src/tool-browser/probe-client.ts +183 -0
- package/src/tool-browser/screenshot-annotations.ts +131 -0
- package/src/tool-browser/screenshot-image.ts +49 -0
- package/src/tool-browser/state.ts +375 -0
- package/src/tool-browser/takeover.ts +199 -0
- package/src/tool-browser/tools-debug.ts +806 -0
- package/src/tool-browser/tools-interaction.ts +956 -0
- package/src/tool-browser/tools-navigation.ts +786 -0
- package/src/tool-browser/tools-observation.ts +474 -0
- package/src/tool-browser/tools-reference.ts +294 -0
- package/src/types/electron-shim.d.ts +144 -0
- package/src/types.ts +85 -0
- package/src/web-guest.ts +35 -0
- package/tools/accept-desktop.mjs +148 -0
- package/dist/client.d.cts +0 -516
- package/dist/client.d.mts +0 -516
- package/dist/index.cjs +0 -92
- package/dist/index.d.mts +0 -2960
- package/dist/index.mjs +0 -24
- package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
- package/dsh-builtin-browser-1.0.3.tgz +0 -0
- package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/manifest.json +0 -218
- package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/series.json +0 -260
package/README.en.md
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://img.shields.io/github/stars/wqty123/dsh-browser?style=flat&label=%E2%98%85&color=08C" alt="GitHub stars">
|
|
3
|
+
<img src="https://img.shields.io/npm/v/dsh-builtin-browser?style=flat&label=npm&color=CB3837" alt="npm version">
|
|
4
|
+
<img src="https://img.shields.io/badge/license-MIT-2EA44F?style=flat" alt="MIT License">
|
|
5
|
+
<img src="https://img.shields.io/badge/DSH-Plugin-47848F?style=flat" alt="DeepSeek Harness plugin">
|
|
6
|
+
</p>
|
|
7
|
+
|
|
8
|
+
<p align="center"><sub><a href="README.md">中文</a> · English</sub></p>
|
|
9
|
+
|
|
10
|
+
# Browser plugin for DeepSeek Harness
|
|
11
|
+
|
|
12
|
+
Browse in the DSH sidebar, send rich page selections into a conversation, and let the agent operate the same page on supported Desktop hosts. Tabs and action history belong to the task. [1.0.0 release changes](CHANGELOG.md#未发布)
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
## Quick start
|
|
17
|
+
|
|
18
|
+
Desktop and Web use separate DSH profiles. These commands install the version currently published on npm:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
dsh plugin --profile desktop add dsh-builtin-browser
|
|
22
|
+
dsh plugin --profile web add dsh-builtin-browser
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If already installed, run `dsh plugin --profile desktop remove dsh-builtin-browser` before adding the target version; replace `desktop` with `web` for Web. See the [update steps](docs/user-guide.md#先移除再安装).
|
|
26
|
+
|
|
27
|
+
**Desktop (Windows and macOS).** Keep **DSH Sidebar** selected. If the bridge needs repair, save active work and use **Settings → Browser → Uninstall and reinstall** when available. On supported builds this can apply the bundled host patch; it changes local DSH files and is not required to use Chrome or Edge. DSH asks before quitting an active task. After a host update, check bridge status again.
|
|
28
|
+
|
|
29
|
+
**Web (`dsh web`).** Open the browser from the DSH sidebar. You can navigate and send selections from the isolated guest. Desktop-native tooling and opener-dependent child tabs are not available in this guest. Use a supported Desktop sidebar or explicitly select a local browser when a task requires CDP.
|
|
30
|
+
|
|
31
|
+
## Choose a browser
|
|
32
|
+
|
|
33
|
+
| Option | How it works |
|
|
34
|
+
| --- | --- |
|
|
35
|
+
| DSH Sidebar (default) | Uses the selected host's sidebar. If the needed capability is missing, it reports why instead of opening another window. |
|
|
36
|
+
| Chrome / Edge | Uses a DSH-managed profile by default. If you prefer your own browser, the optional extension can use its sign-in state; when the extension is unavailable, a new session uses the managed profile. |
|
|
37
|
+
| Bundled / Auto (legacy values) | Both now mean sidebar only. Neither downloads Electron or picks an external browser. |
|
|
38
|
+
|
|
39
|
+
## Quote a page in chat
|
|
40
|
+
|
|
41
|
+
Select text in the sidebar, then use the floating bar to add it to the conversation. Supported selections retain paragraph, link, table and formula formatting. Sent references stay as capsules, without duplicated quote text. Hover for a preview or choose **Return to source** to reopen the page and locate the selection. If the source has changed, the saved preview is still available.
|
|
42
|
+
|
|
43
|
+
## Browser settings
|
|
44
|
+
|
|
45
|
+
- **Environment check** shows the selected carrier, the bridge status, and the detected Chrome and Edge executables.
|
|
46
|
+
- **Quiet mode** avoids raising the host window. With DSH sidebar selected, opening a URL reveals the target conversation's sidebar page; explicit tab switching selects the corresponding sidebar tab. Window behavior applies only to explicitly selected external browsers.
|
|
47
|
+
- **Presentation** controls sidebar expansion, closing the browser with the session, the agent cursor, and remote viewing.
|
|
48
|
+
- **Agent permissions** controls page scripts, downloads, and reading or writing sign-in state.
|
|
49
|
+
- **Advanced settings** covers browsing history, permission for coordinate clicks and drags, and sign-in persistence and window mode for explicitly selected Chrome or Edge. The delivery form validates and saves the tool name, argument template, failure policy, and per-site rules together.
|
|
50
|
+
|
|
51
|
+
On the local machine or in an isolated test environment, turn on **Allow remote viewing** and open the DSH viewer for a read-only view of the browser session. The viewer refreshes JPEG frames up to twice per second.
|
|
52
|
+
|
|
53
|
+
## Download delivery
|
|
54
|
+
|
|
55
|
+
In **Advanced settings → Delivery**, enter an upload tool registered in DSH and configure its destination arguments. Automatic delivery uses the DSH native tool executor and retains the current task's tool permissions. The result includes the local download path and the upload tool's complete return value.
|
|
56
|
+
|
|
57
|
+
DSH sidebar downloads use the target page's authenticated browser session, stream to a temporary file, and commit the completed file while preserving existing destinations.
|
|
58
|
+
|
|
59
|
+
The official Baidu Netdisk stdio MCP upload tool accepts this argument template:
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"local_file_path": "{path}",
|
|
64
|
+
"remote_path": "/来自:mcp_server/DSH下载"
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`{path}` becomes the downloaded file's absolute path. `remote_path` names the destination folder. Use the tool name actually registered in DSH, following `mcp__<serverName>__upload_file`. [Baidu Netdisk MCP parameters](https://github.com/baidu-netdisk/mcp)
|
|
69
|
+
|
|
70
|
+
For Feishu, configure an MCP tool that provides file uploads and use the argument fields it declares.
|
|
71
|
+
|
|
72
|
+
## Browser tools
|
|
73
|
+
|
|
74
|
+
Common `dsh_browser_*` tools are loaded by default. Use `dsh_browser_load_tools` for less common groups and `dsh_browser_do` for a fixed action list. For loops, branches, or independent reads in parallel, use `dsh_browser_code` in standard DSH mode or DSH's `run_code` in PTC mode.
|
|
75
|
+
|
|
76
|
+
When a site needs a login, CAPTCHA or other human verification, ask the agent to request takeover. The plugin does not solve challenges automatically.
|
|
77
|
+
|
|
78
|
+
## Documentation
|
|
79
|
+
|
|
80
|
+
- [User guide](docs/user-guide.md)
|
|
81
|
+
- [Tool parameters and examples](docs/tool-reference.md)
|
|
82
|
+
- [Choosing tools, locating elements, and running steps](skills/dsh-builtin-browser/SKILL.md)
|
|
83
|
+
- [Architecture](docs/architecture.md)
|
|
84
|
+
- [Compatibility and operating conditions](docs/limitations.md)
|
|
85
|
+
- [Build and test](docs/development.md)
|
|
86
|
+
|
|
87
|
+
A community plugin built on [DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) and [Cordis](https://github.com/cordiverse/cordis). Thanks to everyone who contributed issue reports, reproduction steps, and patches.
|
|
88
|
+
|
|
89
|
+
Author on WeChat **hui13866591135** · [MIT License](LICENSE)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const nativeHostName = browser => `com.dsh.browser.${browser}`
|
|
2
|
+
export const MAX_FRAME = 256 * 1024
|
|
3
|
+
export const MAX_MESSAGE = 8 * 1024 * 1024
|
|
4
|
+
export const CHUNK_BYTES = 48 * 1024
|
|
5
|
+
export const MAX_IN_FLIGHT = 32
|
|
6
|
+
export const MAX_ID_LENGTH = 128
|
|
7
|
+
export const MAX_CHUNKS = 256
|
|
8
|
+
export const MAX_PEERS = 8
|
|
9
|
+
export const AUTH_TIMEOUT_MS = 5000
|
|
10
|
+
export const HOST_OPERATION_TIMEOUT_MS = 15000
|
|
11
|
+
export const CLIENT_OPERATION_TIMEOUT_MS = 20000
|
|
12
|
+
export const LEGACY_PAIR_TTL_MS = 5 * 60 * 1000
|
|
13
|
+
export const RECONNECT_ALARM = 'native-reconnect'
|
|
14
|
+
export const RECONNECT_DELAY_MINUTES = 1
|
|
15
|
+
export const MAX_ERROR_LENGTH = 1024
|
|
16
|
+
export const DEBUGGER_IDLE_TIMEOUT_MS = 30_000
|
|
17
|
+
export const DEBUGGER_IDLE_ALARM = 'debugger-idle'
|
|
18
|
+
export const DEBUGGER_SESSION_KEY = 'debugger-owner'
|
|
19
|
+
export const NATIVE_FILES = Object.freeze({ config: 'config.json', relay: 'relay.json' })
|
|
20
|
+
export const EXTENSION_LIMITS = Object.freeze({ scopeLength: 4096, eventBytes: 32 * 1024, notices: 16, dialogPreview: 256, screenshotWidth: 1280, screenshotHeight: 960 })
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { EXTENSION_LIMITS, DEBUGGER_IDLE_TIMEOUT_MS, DEBUGGER_IDLE_ALARM, DEBUGGER_SESSION_KEY } from './constants.mjs'
|
|
2
|
+
import { permissionGuard } from './permission-guard.mjs'
|
|
3
|
+
|
|
4
|
+
const DOMAINS = new Set(['Accessibility', 'DOM', 'DOMSnapshot', 'CSS', 'Emulation', 'Input', 'Log', 'Network', 'Page', 'Runtime', 'Target'])
|
|
5
|
+
const DENIED = new Set(['Page.close', 'Page.bringToFront', 'Page.setDownloadBehavior', 'Page.setInterceptFileChooserDialog',
|
|
6
|
+
'Target.activateTarget', 'Target.createTarget', 'Target.closeTarget', 'Target.attachToTarget', 'Target.attachToBrowserTarget',
|
|
7
|
+
'Target.detachFromTarget', 'Target.sendMessageToTarget', 'Target.exposeDevToolsProtocol', 'DOM.setFileInputFiles', 'Page.printToPDF'])
|
|
8
|
+
const validScope = value => typeof value === 'string' && value.length > 0 && value.length <= EXTENSION_LIMITS.scopeLength
|
|
9
|
+
const allowedUrl = url => typeof url === 'string' && (url === 'about:blank' || /^https?:\/\//i.test(url))
|
|
10
|
+
|
|
11
|
+
export class ExtensionController {
|
|
12
|
+
constructor(api, emit) {
|
|
13
|
+
this.api = api; this.emit = emit; this.leases = new Map(); this.created = new Map(); this.tabLeases = new Map(); this.attaching = new Set(); this.generation = 0
|
|
14
|
+
this.related = new Map(); this.containing = new Set()
|
|
15
|
+
this.active = undefined; this.expectedDetach = new Set(); this.tail = Promise.resolve()
|
|
16
|
+
this.ready = this.restore()
|
|
17
|
+
this.ready.catch(() => {})
|
|
18
|
+
api.alarms?.onAlarm.addListener(alarm => {
|
|
19
|
+
if (alarm.name === DEBUGGER_IDLE_ALARM) return this.enqueue(async () => {
|
|
20
|
+
if (Date.now() >= this.idleAt) await this.suspend()
|
|
21
|
+
}).catch(() => {})
|
|
22
|
+
})
|
|
23
|
+
api.debugger.onEvent.addListener((source, method, params) => { void this.event(source, method, params) })
|
|
24
|
+
api.debugger.onDetach.addListener((source, reason) => {
|
|
25
|
+
if (reason !== 'canceled_by_user' && this.expectedDetach.delete(source.tabId)) return
|
|
26
|
+
if (this.active === source.tabId) this.active = undefined
|
|
27
|
+
const lease = this.tabLeases.get(source.tabId)
|
|
28
|
+
if (lease) { this.leases.delete(lease.id); this.tabLeases.delete(source.tabId); this.emit({ type: 'event', lease: lease.id, method: 'target.detached', params: { reason } }) }
|
|
29
|
+
void this.enqueue(() => this.persist()).catch(() => {})
|
|
30
|
+
})
|
|
31
|
+
api.tabs.onRemoved.addListener(tabId => { this.created.delete(tabId); this.related.delete(tabId) })
|
|
32
|
+
api.tabs.onCreated.addListener(tab => { void this.containPopup(tab) })
|
|
33
|
+
api.windows.onCreated.addListener(window => {
|
|
34
|
+
void api.tabs.query({ windowId: window.id }).then(tabs => Promise.all(tabs.map(tab => this.containPopup(tab)))).catch(() => {})
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
enqueue(work) {
|
|
38
|
+
const result = this.tail.then(() => this.ready).then(work)
|
|
39
|
+
this.tail = result.catch(() => {})
|
|
40
|
+
return result
|
|
41
|
+
}
|
|
42
|
+
async persist() {
|
|
43
|
+
await this.api.storage?.session?.set({ [DEBUGGER_SESSION_KEY]: {
|
|
44
|
+
leases: [...this.leases.values()], created: [...this.created], active: this.active, activeReady: this.activeReady, idleAt: this.idleAt,
|
|
45
|
+
} })
|
|
46
|
+
}
|
|
47
|
+
async restore() {
|
|
48
|
+
if (!this.api.storage?.session) return
|
|
49
|
+
const stored = (await this.api.storage.session.get(DEBUGGER_SESSION_KEY))[DEBUGGER_SESSION_KEY]
|
|
50
|
+
for (const lease of stored?.leases ?? []) {
|
|
51
|
+
if (validScope(lease.id) && validScope(lease.scope) && validScope(lease.view) && Number.isInteger(lease.tabId)) {
|
|
52
|
+
lease.notices = Array.isArray(lease.notices) ? lease.notices : []
|
|
53
|
+
lease.blockingNotices = Array.isArray(lease.blockingNotices) ? lease.blockingNotices : []
|
|
54
|
+
this.leases.set(lease.id, lease); this.tabLeases.set(lease.tabId, lease)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
this.created = new Map(stored?.created ?? [])
|
|
58
|
+
const targets = await this.api.debugger.getTargets()
|
|
59
|
+
let retained
|
|
60
|
+
for (const target of targets.filter(target => target.attached && Number.isInteger(target.tabId))) {
|
|
61
|
+
// getTargets also includes other debuggers. Only our own sessions accept commands.
|
|
62
|
+
try { await this.api.debugger.sendCommand({ tabId: target.tabId }, 'Runtime.getIsolateId', {}) }
|
|
63
|
+
catch { continue }
|
|
64
|
+
if (target.tabId === stored?.active && stored.activeReady && this.tabLeases.has(target.tabId) && stored.idleAt > Date.now()) {
|
|
65
|
+
retained = target.tabId
|
|
66
|
+
} else { this.active = target.tabId; await this.suspend() }
|
|
67
|
+
}
|
|
68
|
+
this.active = retained
|
|
69
|
+
this.activeReady = retained !== undefined
|
|
70
|
+
this.idleAt = stored?.idleAt
|
|
71
|
+
if (this.active !== undefined) await this.api.alarms.create(DEBUGGER_IDLE_ALARM, { when: this.idleAt })
|
|
72
|
+
await this.persist()
|
|
73
|
+
}
|
|
74
|
+
suspend() {
|
|
75
|
+
return this.suspending ??= this.detachActive().finally(() => { this.suspending = undefined })
|
|
76
|
+
}
|
|
77
|
+
async detachActive() {
|
|
78
|
+
if (this.active === undefined) return
|
|
79
|
+
const tabId = this.active
|
|
80
|
+
this.expectedDetach.add(tabId)
|
|
81
|
+
try { await this.api.debugger.detach({ tabId }) }
|
|
82
|
+
finally { this.expectedDetach.delete(tabId) }
|
|
83
|
+
this.active = undefined
|
|
84
|
+
this.activeReady = false
|
|
85
|
+
await this.api.alarms?.clear(DEBUGGER_IDLE_ALARM)
|
|
86
|
+
await this.persist()
|
|
87
|
+
}
|
|
88
|
+
async activate(lease) {
|
|
89
|
+
if (this.active === lease.tabId) return
|
|
90
|
+
const generation = this.generation
|
|
91
|
+
await this.suspend()
|
|
92
|
+
const tab = await this.api.tabs.get(lease.tabId)
|
|
93
|
+
if (tab.incognito || !allowedUrl(tab.url || tab.pendingUrl) || !allowedUrl(tab.pendingUrl || tab.url)) throw Error('restricted/internal, extension and incognito pages are unavailable')
|
|
94
|
+
this.active = lease.tabId
|
|
95
|
+
this.activeReady = false
|
|
96
|
+
await this.persist()
|
|
97
|
+
if (generation !== this.generation) { this.active = undefined; throw Error('connection released') }
|
|
98
|
+
try { await this.api.debugger.attach({ tabId: lease.tabId }, '1.3') }
|
|
99
|
+
catch (error) { this.active = undefined; await this.persist(); throw error }
|
|
100
|
+
if (generation !== this.generation) { this.active = lease.tabId; await this.suspend(); throw Error('connection released') }
|
|
101
|
+
try {
|
|
102
|
+
for (const [method, params] of [
|
|
103
|
+
['Page.enable', {}], ['Page.setInterceptFileChooserDialog', { enabled: true }],
|
|
104
|
+
['Emulation.setFocusEmulationEnabled', { enabled: true }], ['Page.setWebLifecycleState', { state: 'active' }],
|
|
105
|
+
]) await this.api.debugger.sendCommand({ tabId: lease.tabId }, method, params)
|
|
106
|
+
if (this.created.get(lease.tabId) === lease.scope) {
|
|
107
|
+
await this.api.debugger.sendCommand({ tabId: lease.tabId }, 'Page.addScriptToEvaluateOnNewDocument', { source: permissionGuard })
|
|
108
|
+
await this.api.debugger.sendCommand({ tabId: lease.tabId }, 'Runtime.evaluate', { expression: permissionGuard })
|
|
109
|
+
}
|
|
110
|
+
if (generation !== this.generation || !this.leases.has(lease.id)) throw Error('connection released')
|
|
111
|
+
this.activeReady = true
|
|
112
|
+
} catch (error) {
|
|
113
|
+
await this.suspend()
|
|
114
|
+
throw error
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async containPopup(tab) {
|
|
118
|
+
const root = this.created.has(tab.openerTabId) ? tab.openerTabId : this.related.get(tab.openerTabId)?.root
|
|
119
|
+
const scope = this.tabLeases.has(root) ? this.created.get(root) : undefined
|
|
120
|
+
if (!scope || !Number.isInteger(tab.id) || this.containing.has(tab.id) || this.related.has(tab.id)) return
|
|
121
|
+
this.containing.add(tab.id)
|
|
122
|
+
const generation = this.generation
|
|
123
|
+
try {
|
|
124
|
+
const opener = await this.api.tabs.get(tab.openerTabId)
|
|
125
|
+
if (generation !== this.generation) return
|
|
126
|
+
this.related.set(tab.id, { scope, opener: tab.openerTabId, root })
|
|
127
|
+
const window = await this.api.windows.get(tab.windowId)
|
|
128
|
+
if (generation !== this.generation || !this.tabLeases.has(root)) return
|
|
129
|
+
if (window.type === 'popup' && opener.windowId !== tab.windowId) {
|
|
130
|
+
await this.api.tabs.move(tab.id, { windowId: opener.windowId, index: -1 })
|
|
131
|
+
}
|
|
132
|
+
const lease = this.tabLeases.get(root)
|
|
133
|
+
if (lease) {
|
|
134
|
+
lease.notices.push(`Site-created tab ${tab.id} detected${window.type === 'popup' ? '; moved to opener window without activation' : ''}. Site activation may precede browser events.`)
|
|
135
|
+
lease.notices = lease.notices.slice(-EXTENSION_LIMITS.notices)
|
|
136
|
+
}
|
|
137
|
+
this.emit({ type: 'event', method: 'target.popup', lease: lease?.id, params: { tabId: tab.id, openerTabId: tab.openerTabId, containment: window.type === 'popup' ? 'moved' : 'observed', siteActivated: tab.active === true } })
|
|
138
|
+
} catch {
|
|
139
|
+
this.emit({ type: 'event', method: 'target.popup', params: { tabId: tab.id, containment: 'unavailable' } })
|
|
140
|
+
} finally { this.containing.delete(tab.id) }
|
|
141
|
+
}
|
|
142
|
+
async event(source, method, params = {}) {
|
|
143
|
+
const lease = this.tabLeases.get(source.tabId)
|
|
144
|
+
if (!lease) return
|
|
145
|
+
if (method === 'Page.javascriptDialogOpening') {
|
|
146
|
+
try {
|
|
147
|
+
await this.api.debugger.sendCommand(source, 'Page.handleJavaScriptDialog', { accept: false })
|
|
148
|
+
lease.notices.push(`Quiet mode dismissed JavaScript ${params.type ?? 'dialog'}: ${String(params.message ?? '').slice(0, EXTENSION_LIMITS.dialogPreview)}`)
|
|
149
|
+
} catch {
|
|
150
|
+
const msg = 'Quiet mode could not dismiss a JavaScript dialog; human action may be required.'
|
|
151
|
+
lease.notices.push(msg)
|
|
152
|
+
lease.blockingNotices.push(msg)
|
|
153
|
+
lease.blockingNotices = lease.blockingNotices.slice(-EXTENSION_LIMITS.notices)
|
|
154
|
+
}
|
|
155
|
+
lease.notices = lease.notices.slice(-EXTENSION_LIMITS.notices)
|
|
156
|
+
}
|
|
157
|
+
if (method === 'Page.fileChooserOpened') {
|
|
158
|
+
const msg = 'Quiet mode blocked a file chooser; file uploads are unavailable.'
|
|
159
|
+
lease.notices.push(msg)
|
|
160
|
+
lease.blockingNotices.push(msg)
|
|
161
|
+
lease.notices = lease.notices.slice(-EXTENSION_LIMITS.notices)
|
|
162
|
+
lease.blockingNotices = lease.blockingNotices.slice(-EXTENSION_LIMITS.notices)
|
|
163
|
+
}
|
|
164
|
+
if (method.startsWith('Network.')) {
|
|
165
|
+
params = JSON.parse(JSON.stringify(params))
|
|
166
|
+
for (const headers of [params.headers, params.request?.headers, params.response?.headers]) {
|
|
167
|
+
if (headers) for (const key of Object.keys(headers)) if (/^(authorization|proxy-authorization|cookie|set-cookie)$/i.test(key)) headers[key] = '[redacted]'
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
const event = { type: 'event', lease: lease.id, method, params, ...(source.sessionId ? { sessionId: source.sessionId } : {}) }
|
|
171
|
+
if (new TextEncoder().encode(JSON.stringify(event)).length <= EXTENSION_LIMITS.eventBytes) this.emit(event)
|
|
172
|
+
}
|
|
173
|
+
async attach(tabId, scope, view) {
|
|
174
|
+
if (!Number.isInteger(tabId) || tabId < 0 || !validScope(scope) || !validScope(view)) throw Error('invalid tab lease')
|
|
175
|
+
if (this.tabLeases.has(tabId) || this.attaching.has(tabId)) throw Error('tab is already leased; release it before adoption')
|
|
176
|
+
if (this.created.has(tabId) && this.created.get(tabId) !== scope) throw Error('tab belongs to another session')
|
|
177
|
+
this.attaching.add(tabId)
|
|
178
|
+
const generation = this.generation
|
|
179
|
+
try {
|
|
180
|
+
const tab = await this.api.tabs.get(tabId)
|
|
181
|
+
const url = tab.url || tab.pendingUrl || (this.created.get(tabId) === scope ? 'about:blank' : undefined)
|
|
182
|
+
if (tab.incognito || !allowedUrl(url) || !allowedUrl(tab.pendingUrl || url)) throw Error('restricted/internal, extension and incognito pages are unavailable')
|
|
183
|
+
const lease = { id: crypto.randomUUID(), tabId, scope, view, notices: [], blockingNotices: [] }
|
|
184
|
+
this.leases.set(lease.id, lease); this.tabLeases.set(tabId, lease)
|
|
185
|
+
try {
|
|
186
|
+
await this.activate(lease)
|
|
187
|
+
if (generation !== this.generation || !this.leases.has(lease.id)) throw Error('connection released')
|
|
188
|
+
return { lease: lease.id, tabId, url, title: tab.title ?? '', created: this.created.get(tabId) === scope }
|
|
189
|
+
} catch {
|
|
190
|
+
this.leases.delete(lease.id); this.tabLeases.delete(tabId)
|
|
191
|
+
if (this.active === tabId) await this.suspend()
|
|
192
|
+
throw Error('quiet-mode interception is unavailable on this browser/tab; no control lease was granted')
|
|
193
|
+
}
|
|
194
|
+
} finally { this.attaching.delete(tabId) }
|
|
195
|
+
}
|
|
196
|
+
request(operation) {
|
|
197
|
+
const generation = this.generation
|
|
198
|
+
return this.enqueue(async () => {
|
|
199
|
+
if (generation !== this.generation) throw Error('connection released')
|
|
200
|
+
try { return await this.perform(operation) }
|
|
201
|
+
finally {
|
|
202
|
+
if (this.active !== undefined) {
|
|
203
|
+
this.idleAt = Date.now() + DEBUGGER_IDLE_TIMEOUT_MS
|
|
204
|
+
await this.api.alarms?.create(DEBUGGER_IDLE_ALARM, { when: this.idleAt })
|
|
205
|
+
}
|
|
206
|
+
await this.persist()
|
|
207
|
+
}
|
|
208
|
+
})
|
|
209
|
+
}
|
|
210
|
+
async perform(operation) {
|
|
211
|
+
if (!operation || typeof operation !== 'object' || !validScope(operation.scope)) throw Error('a scoped operation is required')
|
|
212
|
+
const { kind, scope } = operation
|
|
213
|
+
if (kind === 'create') {
|
|
214
|
+
if (!validScope(operation.view)) throw Error('view identity is required')
|
|
215
|
+
const generation = this.generation
|
|
216
|
+
const windows = await this.api.windows.getAll({ windowTypes: ['normal'] })
|
|
217
|
+
const window = windows.find(value => !value.incognito && Number.isInteger(value.id))
|
|
218
|
+
if (!window) throw Error('open a normal browser window first; quiet mode never creates a window')
|
|
219
|
+
const tab = await this.api.tabs.create({ windowId: window.id, active: false, url: 'about:blank' })
|
|
220
|
+
this.created.set(tab.id, scope)
|
|
221
|
+
if (generation !== this.generation) throw Error('connection released during creation; inactive tab was left open')
|
|
222
|
+
try { return await this.attach(tab.id, scope, operation.view) }
|
|
223
|
+
catch (error) { throw Error(`${error.message}; the inactive agent tab was left open (id ${tab.id})`) }
|
|
224
|
+
}
|
|
225
|
+
if (kind === 'list') {
|
|
226
|
+
const tabs = await this.api.tabs.query({})
|
|
227
|
+
return tabs.filter(tab => !tab.incognito && allowedUrl(tab.url) && !this.tabLeases.has(tab.id) && (!this.created.has(tab.id) || this.created.get(tab.id) === scope))
|
|
228
|
+
.slice(0, 256).map(tab => ({ tabId: tab.id, title: tab.title ?? '', url: tab.url, created: this.created.get(tab.id) === scope }))
|
|
229
|
+
}
|
|
230
|
+
if (kind === 'attach') return this.attach(operation.tabId, scope, operation.view)
|
|
231
|
+
if (kind === 'close') {
|
|
232
|
+
if (!Number.isInteger(operation.tabId) || this.created.get(operation.tabId) !== scope) throw Error('personal, adopted or other-session tabs are detach-only')
|
|
233
|
+
if (this.active === operation.tabId) await this.suspend()
|
|
234
|
+
await this.api.tabs.remove(operation.tabId)
|
|
235
|
+
const lease = this.tabLeases.get(operation.tabId)
|
|
236
|
+
if (lease) this.leases.delete(lease.id)
|
|
237
|
+
this.tabLeases.delete(operation.tabId)
|
|
238
|
+
this.created.delete(operation.tabId)
|
|
239
|
+
return {}
|
|
240
|
+
}
|
|
241
|
+
const lease = this.leases.get(operation.lease)
|
|
242
|
+
if (kind === 'detach' && !lease) return {}
|
|
243
|
+
if (!lease || lease.scope !== scope || lease.view !== operation.view) throw Error('stale or foreign tab lease; explicitly reacquire the tab')
|
|
244
|
+
if (kind === 'detach') {
|
|
245
|
+
this.leases.delete(lease.id); this.tabLeases.delete(lease.tabId)
|
|
246
|
+
if (this.active === lease.tabId) await this.suspend()
|
|
247
|
+
return {}
|
|
248
|
+
}
|
|
249
|
+
if (kind === 'events') return lease.notices.splice(0)
|
|
250
|
+
if (kind !== 'cdp') throw Error('unsupported extension operation')
|
|
251
|
+
if (lease.blockingNotices?.length) throw Error(lease.blockingNotices.shift())
|
|
252
|
+
let { method, params = {}, sessionId } = operation
|
|
253
|
+
if (typeof method !== 'string' || !DOMAINS.has(method.split('.')[0]) || DENIED.has(method)
|
|
254
|
+
|| /Cookies|Cookie/.test(method) || method.startsWith('Input.') && !method.startsWith('Input.dispatch') && method !== 'Input.insertText'
|
|
255
|
+
|| sessionId !== undefined && (typeof sessionId !== 'string' || sessionId.length > 128)
|
|
256
|
+
|| !params || typeof params !== 'object' || Array.isArray(params)) throw Error('CDP capability is unavailable in personal-browser quiet mode')
|
|
257
|
+
if (method === 'Page.navigate' && !allowedUrl(params.url)) throw Error('navigation requires an http(s) URL')
|
|
258
|
+
await this.activate(lease)
|
|
259
|
+
if (!this.leases.has(lease.id)) throw Error('tab detached during request')
|
|
260
|
+
if (method === 'Input.insertText') {
|
|
261
|
+
for (const text of String(params.text ?? '')) {
|
|
262
|
+
await this.api.debugger.sendCommand({ tabId: lease.tabId, ...(sessionId ? { sessionId } : {}) }, 'Input.dispatchKeyEvent', { type: 'char', text })
|
|
263
|
+
}
|
|
264
|
+
return {}
|
|
265
|
+
}
|
|
266
|
+
if (method === 'Page.captureScreenshot') {
|
|
267
|
+
if (!params.clip) {
|
|
268
|
+
const metrics = await this.api.debugger.sendCommand({ tabId: lease.tabId, ...(sessionId ? { sessionId } : {}) }, 'Page.getLayoutMetrics', {})
|
|
269
|
+
const viewport = metrics.cssVisualViewport ?? metrics.visualViewport
|
|
270
|
+
const width = viewport?.clientWidth ?? EXTENSION_LIMITS.screenshotWidth, height = viewport?.clientHeight ?? EXTENSION_LIMITS.screenshotHeight
|
|
271
|
+
params = { ...params, clip: { x: viewport?.pageX ?? 0, y: viewport?.pageY ?? 0, width, height, scale: Math.min(1, EXTENSION_LIMITS.screenshotWidth / width, EXTENSION_LIMITS.screenshotHeight / height) } }
|
|
272
|
+
}
|
|
273
|
+
if (params.captureBeyondViewport === true || params.fromSurface === false || params.clip && (
|
|
274
|
+
!Number.isFinite(params.clip.width) || !Number.isFinite(params.clip.height) || !Number.isFinite(params.clip.scale)
|
|
275
|
+
|| params.clip.width <= 0 || params.clip.height <= 0 || !Number.isFinite(params.clip.x) || !Number.isFinite(params.clip.y)
|
|
276
|
+
|| params.clip.width * params.clip.scale > EXTENSION_LIMITS.screenshotWidth || params.clip.height * params.clip.scale > EXTENSION_LIMITS.screenshotHeight || params.clip.scale <= 0)) throw Error('screenshot exceeds quiet-mode dimensions')
|
|
277
|
+
params = { ...params, fromSurface: true, captureBeyondViewport: false }
|
|
278
|
+
}
|
|
279
|
+
return this.api.debugger.sendCommand({ tabId: lease.tabId, ...(sessionId ? { sessionId } : {}) }, method, params)
|
|
280
|
+
}
|
|
281
|
+
release() {
|
|
282
|
+
this.generation++
|
|
283
|
+
const interrupt = this.ready.then(() => this.suspend())
|
|
284
|
+
interrupt.catch(() => {})
|
|
285
|
+
return this.enqueue(async () => {
|
|
286
|
+
await interrupt.catch(() => {})
|
|
287
|
+
await this.suspend()
|
|
288
|
+
this.related.clear()
|
|
289
|
+
this.leases.clear(); this.tabLeases.clear()
|
|
290
|
+
await this.persist()
|
|
291
|
+
})
|
|
292
|
+
}
|
|
293
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
title: 'DSH Browser Bridge status',
|
|
3
|
+
heading: 'DSH Browser Bridge',
|
|
4
|
+
consent: 'This explicitly grants DSH control of tabs in this browser profile. Browser debugging warnings remain visible. No extension popup or automatic window activation is used.',
|
|
5
|
+
automatic: 'DSH registers the native host automatically. This extension connects automatically; no token or configuration is needed.',
|
|
6
|
+
disconnect: 'Disconnect',
|
|
7
|
+
pause: 'Disconnect leaves all tabs open and pauses reconnects. Remove and add the extension again to resume. The native-host --revoke command disables access persistently, including across plugin restarts.',
|
|
8
|
+
quiet: 'Quiet-mode limits: the normal debugger infobar cannot be hidden; browser/OS permission prompts, website-initiated downloads and page-created windows cannot be guaranteed invisible. File choosers are intercepted on attached tabs. Never use this mode when absolutely no browser-owned UI is acceptable.',
|
|
9
|
+
identity: 'Extension ID: {id}',
|
|
10
|
+
accepted: 'Request accepted. Refreshing connection status…',
|
|
11
|
+
unavailable: 'Extension worker unavailable.',
|
|
12
|
+
disconnected: 'Native host is disconnected.',
|
|
13
|
+
reconnect: 'Native host disconnected or is not installed. Reconnect after installing.',
|
|
14
|
+
debuggerCanceled: 'Debugging was canceled. The detached tab requires an explicit new request to reacquire it.',
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA1hDzFuWdQi+Tu5v9275Mqd8Ql6F/Kgl72RyLiX6hTh1/TU89i/0pX5DK9L6NFZAuTTrAXWaP86gKJO/XUvDr+cTI0fJ4lpKn6EGTK75/r1g2m23LGPgNQZRwVM6xnx4t5qaKvgrW7F+E7xUwtO6NkzDNsh3Lw6piDzVuN8MhWxAkwCKxQ3S4PFQA4U/yD+knEq6rQk/7MILe+rrZ1SgMOMuxm01I0Dgbkowvu/LHRkQnrNTMAhQW0VRjb8c1947HTwc5t4inN4fIFY3Vl8RMZSH4FbaSir7CwZZrpC8yjSlnRuGHDBXXnVSWe6Qw/ZhNGQqdgXH+vuiqrMYTyQFUEwIDAQAB",
|
|
4
|
+
"name": "DSH Browser Bridge",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"description": "Explicitly pair DSH with this Edge or Chrome profile. Browser debugging warnings remain visible.",
|
|
7
|
+
"minimum_chrome_version": "125",
|
|
8
|
+
"permissions": ["debugger", "tabs", "storage", "nativeMessaging", "alarms"],
|
|
9
|
+
"background": { "service_worker": "worker.mjs", "type": "module" },
|
|
10
|
+
"options_page": "options.html",
|
|
11
|
+
"incognito": "not_allowed"
|
|
12
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head><meta charset="utf-8"><meta name="viewport" content="width=device-width"><title data-message="title"></title></head>
|
|
4
|
+
<body>
|
|
5
|
+
<h1 data-message="heading"></h1>
|
|
6
|
+
<p data-message="consent"></p>
|
|
7
|
+
<p data-message="automatic"></p>
|
|
8
|
+
<p id="identity"></p><pre id="status" role="status"></pre>
|
|
9
|
+
<p><button id="disconnect" type="button" data-message="disconnect"></button></p>
|
|
10
|
+
<p data-message="pause"></p>
|
|
11
|
+
<p data-message="quiet"></p>
|
|
12
|
+
<script type="module" src="options.mjs"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { en } from './locales.mjs'
|
|
2
|
+
|
|
3
|
+
for (const element of document.querySelectorAll('[data-message]')) element.textContent = en[element.dataset.message]
|
|
4
|
+
const status = document.getElementById('status')
|
|
5
|
+
document.getElementById('identity').textContent = en.identity.replace('{id}', chrome.runtime.id)
|
|
6
|
+
const show = value => { status.textContent = value.error ?? value.detail ?? (value.ok ? en.accepted : JSON.stringify(value)) }
|
|
7
|
+
async function request(message) { try { show(await chrome.runtime.sendMessage(message)) } catch { show({ error: en.unavailable }) } }
|
|
8
|
+
document.getElementById('disconnect').addEventListener('click', () => { void request({ type: 'disconnect' }) })
|
|
9
|
+
void request({ type: 'status' })
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const permissionGuard = `(()=>{
|
|
2
|
+
const denied=()=>Promise.reject(new DOMException('Permission request denied in DSH agent tab','NotAllowedError'));
|
|
3
|
+
const replace=(object,key,value)=>{try{if(object&&typeof object[key]==='function')Object.defineProperty(object,key,{value,configurable:true,writable:true})}catch{}};
|
|
4
|
+
replace(globalThis.Notification,'requestPermission',callback=>{if(typeof callback==='function')queueMicrotask(()=>callback('denied'));return Promise.resolve('denied')});
|
|
5
|
+
for(const [object,keys] of [
|
|
6
|
+
[navigator.mediaDevices,['getUserMedia','getDisplayMedia']],
|
|
7
|
+
[navigator.clipboard,['read','readText','write','writeText']],
|
|
8
|
+
[navigator.bluetooth,['requestDevice']], [navigator.usb,['requestDevice']],
|
|
9
|
+
[navigator.hid,['requestDevice']], [navigator.serial,['requestPort']],
|
|
10
|
+
[globalThis,['showOpenFilePicker','showSaveFilePicker','showDirectoryPicker']]
|
|
11
|
+
])for(const key of keys)replace(object,key,denied);
|
|
12
|
+
for(const key of ['getCurrentPosition','watchPosition'])replace(navigator.geolocation,key,(_success,error)=>{if(typeof error==='function')queueMicrotask(()=>error({code:1,message:'Permission denied in DSH agent tab',PERMISSION_DENIED:1}));return -1});
|
|
13
|
+
})()`
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { nativeHostName, MAX_MESSAGE, CHUNK_BYTES, MAX_IN_FLIGHT, MAX_ERROR_LENGTH, RECONNECT_ALARM, RECONNECT_DELAY_MINUTES } from './constants.mjs'
|
|
2
|
+
import { ExtensionController } from './controller.mjs'
|
|
3
|
+
import { en } from './locales.mjs'
|
|
4
|
+
|
|
5
|
+
const browser = /Edg\//.test(navigator.userAgent) ? 'edge' : 'chrome'
|
|
6
|
+
let port, connecting, inFlight = 0, reconnectAllowed = true
|
|
7
|
+
let status = { state: 'extension-missing', detail: en.disconnected }
|
|
8
|
+
const controller = new ExtensionController(chrome, event => { try { port?.postMessage(event) } catch {} })
|
|
9
|
+
|
|
10
|
+
async function connect() {
|
|
11
|
+
if (port) return
|
|
12
|
+
connecting ??= (async () => {
|
|
13
|
+
await controller.ready
|
|
14
|
+
const stored = await chrome.storage.local.get('installId')
|
|
15
|
+
const installId = stored.installId ?? crypto.randomUUID()
|
|
16
|
+
if (!stored.installId) await chrome.storage.local.set({ installId })
|
|
17
|
+
const native = chrome.runtime.connectNative(nativeHostName(browser))
|
|
18
|
+
port = native
|
|
19
|
+
native.onMessage.addListener(message => {
|
|
20
|
+
if (native !== port) return
|
|
21
|
+
if (message.type === 'status') status = { state: message.state, detail: message.detail }
|
|
22
|
+
else if (message.type === 'release') void controller.release().catch(() => {})
|
|
23
|
+
else if (message.type === 'request') {
|
|
24
|
+
if (inFlight >= MAX_IN_FLIGHT) { native.postMessage({ type: 'result', id: message.id, error: 'extension concurrency limit' }); return }
|
|
25
|
+
inFlight++
|
|
26
|
+
void controller.request(message.operation).then(
|
|
27
|
+
value => respond(native, { type: 'result', id: message.id, value }),
|
|
28
|
+
error => respond(native, { type: 'result', id: message.id, error: String(error.message ?? error).slice(0, MAX_ERROR_LENGTH) }),
|
|
29
|
+
).catch(() => native.disconnect()).finally(() => { inFlight-- })
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
native.onDisconnect.addListener(() => {
|
|
33
|
+
void chrome.runtime.lastError
|
|
34
|
+
if (native !== port) return
|
|
35
|
+
port = undefined
|
|
36
|
+
status = { state: 'extension-missing', detail: en.reconnect }
|
|
37
|
+
void controller.release().catch(() => {})
|
|
38
|
+
if (reconnectAllowed) void chrome.alarms.create(RECONNECT_ALARM, { delayInMinutes: RECONNECT_DELAY_MINUTES })
|
|
39
|
+
})
|
|
40
|
+
native.postMessage({ type: 'hello', installId, browser })
|
|
41
|
+
})().finally(() => { connecting = undefined })
|
|
42
|
+
return connecting
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function respond(native, value) {
|
|
46
|
+
if (native !== port) return
|
|
47
|
+
let text = JSON.stringify(value)
|
|
48
|
+
if (new TextEncoder().encode(text).length > MAX_MESSAGE) text = JSON.stringify({ type: 'result', id: value.id, error: 'extension response exceeds 8 MiB limit' })
|
|
49
|
+
const total = Math.ceil(text.length / CHUNK_BYTES)
|
|
50
|
+
for (let index = 0; index < total; index++) native.postMessage({ type: 'chunk', id: value.id, index, total, data: text.slice(index * CHUNK_BYTES, (index + 1) * CHUNK_BYTES) })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
chrome.runtime.onMessage.addListener((message, sender, reply) => {
|
|
54
|
+
if (sender.id !== chrome.runtime.id || sender.url !== chrome.runtime.getURL('options.html')) return false
|
|
55
|
+
void (async () => {
|
|
56
|
+
if (message.type === 'status') return { ...status, browser, extensionId: chrome.runtime.id }
|
|
57
|
+
if (message.type === 'disconnect') {
|
|
58
|
+
reconnectAllowed = false; await chrome.storage.local.set({ paused: true }); await chrome.alarms.clear(RECONNECT_ALARM)
|
|
59
|
+
port?.disconnect(); return { ok: true }
|
|
60
|
+
}
|
|
61
|
+
throw Error('unsupported options request')
|
|
62
|
+
})().then(reply, error => reply({ ok: false, error: String(error.message ?? error) }))
|
|
63
|
+
return true
|
|
64
|
+
})
|
|
65
|
+
chrome.debugger.onDetach.addListener((_source, reason) => {
|
|
66
|
+
if (reason === 'canceled_by_user') {
|
|
67
|
+
status = { ...status, detail: en.debuggerCanceled }
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
chrome.alarms.onAlarm.addListener(alarm => { if (alarm.name === RECONNECT_ALARM && reconnectAllowed) void connect().catch(() => {}) })
|
|
71
|
+
const autoConnect = () => chrome.storage.local.get('paused').then(({ paused }) => { reconnectAllowed = !paused; if (reconnectAllowed) return connect() }).catch(() => {})
|
|
72
|
+
chrome.runtime.onInstalled.addListener(() => { void autoConnect() })
|
|
73
|
+
chrome.runtime.onStartup.addListener(() => { void autoConnect() })
|
|
74
|
+
void autoConnect()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-builtin-browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Sidebar browser for DeepSeek Harness with navigation, structured references and dsh_browser_* tools. Browser tools require a controllable host-provided sidebar. External Chrome or Edge requires explicit opt-in; no standalone Electron fallback.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"browser",
|
|
@@ -16,6 +16,24 @@
|
|
|
16
16
|
"type": "git",
|
|
17
17
|
"url": "https://github.com/wqty123/dsh-browser.git"
|
|
18
18
|
},
|
|
19
|
+
"files": [
|
|
20
|
+
"lib",
|
|
21
|
+
"src",
|
|
22
|
+
"scripts",
|
|
23
|
+
"tools/accept-desktop.mjs",
|
|
24
|
+
"desktop-bridge",
|
|
25
|
+
"dsh-host-patch",
|
|
26
|
+
"!dsh-host-patch/sources",
|
|
27
|
+
"browser-extension",
|
|
28
|
+
"native-host",
|
|
29
|
+
"cordis.patch.yml",
|
|
30
|
+
"CHANGELOG.md",
|
|
31
|
+
"README.md",
|
|
32
|
+
"docs",
|
|
33
|
+
"skills",
|
|
34
|
+
"assets",
|
|
35
|
+
"!src/**/__tests__"
|
|
36
|
+
],
|
|
19
37
|
"type": "module",
|
|
20
38
|
"packageManager": "pnpm@11.7.0",
|
|
21
39
|
"exports": {
|
|
@@ -70,4 +88,4 @@
|
|
|
70
88
|
]
|
|
71
89
|
}
|
|
72
90
|
}
|
|
73
|
-
}
|
|
91
|
+
}
|