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
|
@@ -15,18 +15,32 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import type { Context } from '@deepseek-ai/cordis'
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
18
|
+
import type { ToolRunContext } from '@deepseek-ai/dsh-tools'
|
|
19
|
+
import type { ImageBlock } from '@deepseek-ai/dsh-llm'
|
|
20
|
+
import { SCREENSHOT_MAX_WIDTH, SCREENSHOT_MAX_HEIGHT, screenshotDimension, screenshotBytes, screenshotVisionEnabled, saveScreenshotImage } from './screenshot-image.ts'
|
|
21
|
+
import { BrowserTakeovers, installTakeovers } from './takeover.ts'
|
|
22
|
+
import { TAKEOVER_TOOL, type TakeoverDecision, type TakeoverOutcome, type TakeoverSummary } from '../takeover-protocol.ts'
|
|
23
|
+
import { clearLastOpen, getLastOpen, setLastOpen } from '../browser-electron/open-slot.ts'
|
|
24
|
+
import { readFileSync, statSync } from 'node:fs'
|
|
25
|
+
import { join } from 'node:path'
|
|
26
|
+
import { defineTool } from '@deepseek-ai/dsh-tools'
|
|
27
|
+
import { pageOperationScript } from './page-probe.ts'
|
|
28
|
+
import { CODE_PROMPT, CODE_TOOL, createCodeTool, type CatalogTool } from './code-tool.ts'
|
|
29
|
+
import { SettingsStore, settingsPath } from '../browser-electron/settings-store.ts'
|
|
30
|
+
import { createShortcutStore, type ShortcutSettings } from '../browser-electron/startpage-shortcuts.ts'
|
|
31
|
+
import { createReferenceService, summarizeReference, type BrowserReferenceService } from '../browser-reference/service.ts'
|
|
32
|
+
import type { BrowserReferenceCarrier } from '../browser-reference/types.ts'
|
|
22
33
|
import type {} from '@deepseek-ai/dsh-system-prompt'
|
|
23
|
-
import type { BrowserSessionId, BrowserPageOperationRequest, BrowserProbeMethod } from '../browser/types.
|
|
34
|
+
import type { BrowserSessionId, BrowserPageOperationRequest, BrowserProbeMethod } from '../browser/types.ts'
|
|
35
|
+
import { browserSessionHandle, resolveSessionHandle, resolveTabHandle, scopedTabs, sessionWireId, tabWireId } from '../browser/handles.ts'
|
|
24
36
|
import {
|
|
25
37
|
ELEMENT_ITEM_SCHEMA,
|
|
26
38
|
NODE_ITEM_SCHEMA,
|
|
27
39
|
projectElement,
|
|
28
40
|
projectNode,
|
|
29
|
-
} from './element-fields.
|
|
41
|
+
} from './element-fields.ts'
|
|
42
|
+
|
|
43
|
+
type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue }
|
|
30
44
|
|
|
31
45
|
/**
|
|
32
46
|
* Register a cleanup that runs once when the process exits.
|
|
@@ -50,6 +64,83 @@ function registerExitCleanup(cleanup: () => void): void {
|
|
|
50
64
|
|
|
51
65
|
|
|
52
66
|
/** Plugin name used by loader diagnostics. */
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Which surface an open should use.
|
|
70
|
+
*
|
|
71
|
+
* "panel" - place the page in the DSH sidebar and open nothing else (the normal Web behaviour).
|
|
72
|
+
* "builtin"- drive the plugin's own browser; needed when the thing under test IS DSH.
|
|
73
|
+
* @returns the configured surface, defaulting to "panel".
|
|
74
|
+
*/
|
|
75
|
+
function readSurface(): 'panel' | 'builtin' {
|
|
76
|
+
// Try every plausible location and take the first file that actually carries the key. The plugin's
|
|
77
|
+
// own settingsPath() is preferred, but a module instance can hold a stale home while another module in
|
|
78
|
+
// the same process holds the live one — which is exactly why channel read fine and surface did not.
|
|
79
|
+
const declared = (globalThis as unknown as Record<string, unknown>).__dshBrowserSurface
|
|
80
|
+
if (declared === 'panel' || declared === 'builtin') return declared
|
|
81
|
+
const candidates: string[] = []
|
|
82
|
+
try { candidates.push(settingsPath()) } catch { /* no module home */ }
|
|
83
|
+
candidates.push('D:/dsh-home/dsh-builtin-browser-host/settings.json')
|
|
84
|
+
for (const candidate of candidates) {
|
|
85
|
+
if (typeof candidate !== 'string' || candidate === '') continue
|
|
86
|
+
try {
|
|
87
|
+
const parsed = JSON.parse(readFileSync(candidate, 'utf8')) as { browser?: { surface?: unknown } }
|
|
88
|
+
const surface = parsed.browser?.surface
|
|
89
|
+
if (surface === 'builtin' || surface === 'panel') return surface
|
|
90
|
+
} catch { /* next candidate */ }
|
|
91
|
+
}
|
|
92
|
+
return 'panel'
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
// One line at registration: tool handlers are registered once per host start, and a recomposition does
|
|
98
|
+
// not re-register them. Printing the resolved surface here is the only reliable way to tell WHICH build a
|
|
99
|
+
// live host is actually running, instead of inferring it from behaviour.
|
|
100
|
+
try { console.log('[tool-browser] registered, surface=' + readSurface()) } catch { /* logging only */ }
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Keep the built-in browser for DSH itself.
|
|
105
|
+
*
|
|
106
|
+
* "builtin" exists to debug DSH: a client bundle, the settings panel, the sidebar UI. Using it for an
|
|
107
|
+
* ordinary site opens a window the reader did not ask for — measured as "why did you open the built-in
|
|
108
|
+
* browser again". A non-loopback target therefore degrades to "panel" silently; the caller's intent does
|
|
109
|
+
* not override the rule.
|
|
110
|
+
* @param surface - the requested surface.
|
|
111
|
+
* @param url - the page being opened.
|
|
112
|
+
* @returns the surface that will actually be used.
|
|
113
|
+
*/
|
|
114
|
+
function enforceSurface(surface: 'panel' | 'builtin', _url: string): 'panel' | 'builtin' {
|
|
115
|
+
// The caller decides the surface. An earlier version degraded "builtin" to "panel" for anything but a
|
|
116
|
+
// loopback URL, which also blocked the agent from driving the human's OWN browser — the opposite of what
|
|
117
|
+
// the setting is for. Which window appears is decided by the carrier (bundled Electron vs. the human's
|
|
118
|
+
// Edge), not by the URL. Keeping ordinary tests on the sidebar is a working rule, not a code constraint.
|
|
119
|
+
return surface
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Refuse a request that cannot work BEFORE anything is opened.
|
|
125
|
+
*
|
|
126
|
+
* The sidebar renders pages through a same-origin proxy, so asking it to load this machine answers with a
|
|
127
|
+
* network-level failure that reads like a bug in the page. Reporting that afterwards is useless — the call
|
|
128
|
+
* already happened. The rule is therefore enforced up front: a loopback target on the panel surface is
|
|
129
|
+
* refused, and the message names the surface that does work.
|
|
130
|
+
* @param surface - the surface this call would use.
|
|
131
|
+
* @param url - the page being opened.
|
|
132
|
+
*/
|
|
133
|
+
function assertSurfaceCanHost(surface: 'panel' | 'builtin', url: string): void {
|
|
134
|
+
if (surface !== 'panel') return
|
|
135
|
+
let host: string
|
|
136
|
+
try { host = new URL(url).hostname.toLowerCase() } catch { return }
|
|
137
|
+
const local = host === 'localhost' || host === '127.0.0.1' || host === '::1' || host === '[::1]' || /^127\./u.test(host)
|
|
138
|
+
if (!local) return
|
|
139
|
+
throw new Error('dsh-builtin-browser: the sidebar cannot host this machine (' + host
|
|
140
|
+
+ '). It proxies pages through itself, so loading DSH there is the proxy fetching its own server. '
|
|
141
|
+
+ '调试 DSH 请用 surface: "builtin"(内置浏览器),普通网页才走侧栏。')
|
|
142
|
+
}
|
|
143
|
+
|
|
53
144
|
export const name = 'tool-browser'
|
|
54
145
|
/** The tool registry, browser seam, and system-prompt registry this tool layer consumes. */
|
|
55
146
|
export const inject = ['tools', 'browser', 'systemPrompt']
|
|
@@ -62,6 +153,13 @@ export interface Config {
|
|
|
62
153
|
readonly tabTools?: boolean
|
|
63
154
|
/** Optional initial allow-list of browser tool names; other tools are refused. */
|
|
64
155
|
readonly allowedActions?: readonly string[]
|
|
156
|
+
/**
|
|
157
|
+
* What the model sees. "core" (default): core browser tools, dsh_browser_load_tools and
|
|
158
|
+
* dsh_browser_code (which steps aside under PTC). "code": one dsh_browser_code tool whose
|
|
159
|
+
* script calls every browser action as a helper, plus dsh_browser_request_takeover. "tools":
|
|
160
|
+
* every action as its own tool.
|
|
161
|
+
*/
|
|
162
|
+
readonly surface?: 'core' | 'code' | 'tools'
|
|
65
163
|
}
|
|
66
164
|
|
|
67
165
|
/** Per-apply (per-context) tool state: sessions, in-flight opens, restriction. */
|
|
@@ -82,10 +180,16 @@ interface ToolBrowserState {
|
|
|
82
180
|
*/
|
|
83
181
|
configRestrictedTo: readonly string[] | undefined
|
|
84
182
|
restrictedByTask: Map<string, readonly string[]>
|
|
183
|
+
/** Active panel opens, including Web iframes that cannot be driven over CDP. */
|
|
184
|
+
panelUrlByTask: Map<string, string>
|
|
185
|
+
pendingPanelOpens: Map<string, Promise<void>>
|
|
85
186
|
}
|
|
86
187
|
|
|
87
188
|
function createState(): ToolBrowserState {
|
|
88
|
-
return {
|
|
189
|
+
return {
|
|
190
|
+
sessionsByTask: new Map(), pendingOpens: new Map(), configRestrictedTo: undefined,
|
|
191
|
+
restrictedByTask: new Map(), panelUrlByTask: new Map(), pendingPanelOpens: new Map(),
|
|
192
|
+
}
|
|
89
193
|
}
|
|
90
194
|
|
|
91
195
|
/** Every live state, for the test hook (introspection only, never shared). */
|
|
@@ -104,6 +208,36 @@ const liveStates = new Set<ToolBrowserState>()
|
|
|
104
208
|
* blind it or trap it, and the tool descriptions promise as much. dsh_browser_restrict
|
|
105
209
|
* is in here so a task that restricted everything can still lift it.
|
|
106
210
|
*/
|
|
211
|
+
/** Tool loaded on demand: registers a group of browser tools for the rest of the run. */
|
|
212
|
+
export const LOAD_TOOL = 'dsh_browser_load_tools'
|
|
213
|
+
|
|
214
|
+
/** Tools the model sees from the start on the default `core` surface. */
|
|
215
|
+
export const CORE_TOOLS: ReadonlySet<string> = new Set([
|
|
216
|
+
'dsh_browser_open', 'dsh_browser_snapshot', 'dsh_browser_a11y', 'dsh_browser_click', 'dsh_browser_type',
|
|
217
|
+
'dsh_browser_key', 'dsh_browser_scroll', 'dsh_browser_select', 'dsh_browser_fill', 'dsh_browser_wait',
|
|
218
|
+
'dsh_browser_content', 'dsh_browser_find', 'dsh_browser_scrape', 'dsh_browser_screenshot',
|
|
219
|
+
'dsh_browser_execute', 'dsh_browser_do', 'dsh_browser_state', 'dsh_browser_challenge',
|
|
220
|
+
'dsh_browser_list_tabs', 'dsh_browser_switch_tab', 'dsh_browser_close_tab', 'dsh_browser_back',
|
|
221
|
+
'dsh_browser_reference_capture', 'dsh_browser_reference_reveal', 'dsh_browser_reference_list',
|
|
222
|
+
'dsh_browser_request_takeover', 'dsh_browser_help',
|
|
223
|
+
])
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* The rest of the catalog, loaded by group with dsh_browser_load_tools. A loaded tool is never
|
|
227
|
+
* unregistered, so the tool list only grows and the request prefix stays cacheable. Any tool not
|
|
228
|
+
* named here or in CORE_TOOLS belongs to `more`.
|
|
229
|
+
*/
|
|
230
|
+
export const TOOL_GROUPS: Readonly<Record<string, readonly string[]>> = {
|
|
231
|
+
forms: ['dsh_browser_check', 'dsh_browser_clear', 'dsh_browser_set_value', 'dsh_browser_get_value', 'dsh_browser_upload', 'dsh_browser_drag', 'dsh_browser_hover', 'dsh_browser_dialog', 'dsh_browser_click_sequence'],
|
|
232
|
+
navigation: ['dsh_browser_forward', 'dsh_browser_refresh', 'dsh_browser_history', 'dsh_browser_replay', 'dsh_browser_visited', 'dsh_browser_download'],
|
|
233
|
+
debug: ['dsh_browser_console', 'dsh_browser_network', 'dsh_browser_wait_for_response', 'dsh_browser_assert', 'dsh_browser_doctor'],
|
|
234
|
+
session: ['dsh_browser_session', 'dsh_browser_reset', 'dsh_browser_reset_session', 'dsh_browser_restrict', 'dsh_browser_auth', 'dsh_browser_shortcuts'],
|
|
235
|
+
more: [],
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Guide for the `core` surface. Static, so the prompt prefix caches. */
|
|
239
|
+
const CORE_PROMPT = 'Operate the built-in browser with the dsh_browser_* tools. Each task has its own browser session and window: the human can watch and take over, and other tasks\' pages are not visible to you. The core tools are loaded: dsh_browser_open; dsh_browser_snapshot or dsh_browser_a11y to map a page; click, type, key, scroll, select and fill to act; wait; content, find and scrape to read; screenshot; execute for page JavaScript; the tab tools and back; and reference_capture/reveal/list for citations. Load the other tools by group with dsh_browser_load_tools when a task needs them; loaded tools stay available. To batch, use dsh_browser_do for a fixed list of steps, or dsh_browser_code for a JavaScript program that calls any browser tool as `await tools.dsh_browser_<name>(args)`, loops and branches over the results, overlaps independent reads with Promise.all and prints only what you need. Prefer dsh_browser_code whenever a task takes more than a few actions or spans many pages, and print findings as you go: on a deadline or cancellation everything already printed is still returned. When run_code is available, call the same tools from run_code instead. A blocked page (403, access denied, bot wall) is not the end of the task. Look for another route to the same public information: other pages of the site, its own JSON/API endpoints or sitemap, search-engine results, archived or reader copies, and other reputable sources. Keep each value tied to the source it came from. Report a blocker only once those routes are exhausted, and still deliver everything you did find. On a CAPTCHA, slider or other human verification (dsh_browser_challenge, or a CHALLENGE banner in a result), never retry or solve it: call dsh_browser_request_takeover.'
|
|
240
|
+
|
|
107
241
|
export const READ_ONLY_TOOLS: ReadonlySet<string> = new Set([
|
|
108
242
|
// Tools that only observe.
|
|
109
243
|
'dsh_browser_snapshot', 'dsh_browser_a11y', 'dsh_browser_content', 'dsh_browser_scrape',
|
|
@@ -116,6 +250,9 @@ export const READ_ONLY_TOOLS: ReadonlySet<string> = new Set([
|
|
|
116
250
|
'dsh_browser_assert', 'dsh_browser_doctor', 'dsh_browser_help',
|
|
117
251
|
// Reading the page's own digest and searching its text: observation like the rest.
|
|
118
252
|
'dsh_browser_find', 'dsh_browser_state',
|
|
253
|
+
// References read the page the human already has open and write only this plugin's own store;
|
|
254
|
+
// restricting an agent's actions must not stop it from recording what it was told to read.
|
|
255
|
+
'dsh_browser_reference_capture', 'dsh_browser_reference_reveal', 'dsh_browser_reference_list',
|
|
119
256
|
// dsh_browser_auth reads cookies out of the browser: an observation, and one the
|
|
120
257
|
// credentials switch gates on its own (see credentials.allowRead in the settings).
|
|
121
258
|
// dsh_browser_auth is deliberately NOT here. It reads cookies on "flush" but WRITES them on
|
|
@@ -217,6 +354,71 @@ function taskKey(exec: { agent?: { id?: string } } | undefined): string {
|
|
|
217
354
|
return exec?.agent?.id ?? 'default'
|
|
218
355
|
}
|
|
219
356
|
|
|
357
|
+
const effectProperties = {
|
|
358
|
+
verified: { type: 'boolean' as const, description: 'Whether a visible change was observed. Absent when it could not be checked.' },
|
|
359
|
+
note: { type: 'string' as const, description: 'Why the effect is uncertain.' },
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async function pageFingerprint(browser: NonNullable<Context['browser']>, session: BrowserSessionId): Promise<string | undefined> {
|
|
363
|
+
try {
|
|
364
|
+
const result = await browser.execute(session, {
|
|
365
|
+
script: `(() => {
|
|
366
|
+
const a = document.activeElement
|
|
367
|
+
return JSON.stringify([
|
|
368
|
+
location.href, document.title,
|
|
369
|
+
a ? [a.tagName, a.id || a.getAttribute('name') || a.className || '',
|
|
370
|
+
typeof a.value === 'string' ? a.value.length : null, a.checked, a.selectedIndex,
|
|
371
|
+
a.selectionStart, a.selectionEnd, a.scrollLeft, a.scrollTop] : null,
|
|
372
|
+
window.scrollX, window.scrollY,
|
|
373
|
+
document.body ? document.body.childElementCount : 0,
|
|
374
|
+
document.body ? document.body.innerHTML.length : 0,
|
|
375
|
+
])
|
|
376
|
+
})()`,
|
|
377
|
+
})
|
|
378
|
+
return result.ok && typeof result.value === 'string' ? result.value : undefined
|
|
379
|
+
} catch {
|
|
380
|
+
return undefined
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
async function observedEffect(browser: NonNullable<Context['browser']>, session: BrowserSessionId, before: string | undefined): Promise<{ verified?: boolean; note?: string }> {
|
|
385
|
+
const after = await pageFingerprint(browser, session)
|
|
386
|
+
if (before === undefined || after === undefined) return { note: 'The effect could not be checked.' }
|
|
387
|
+
return before !== after
|
|
388
|
+
? { verified: true }
|
|
389
|
+
: { verified: false, note: 'No visible change observed; the effect is uncertain.' }
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
function effectText(value: { verified?: boolean; note?: string }): string {
|
|
393
|
+
return value.verified === true ? ' Visible change observed.' : ` ${value.note ?? 'The effect could not be checked.'}`
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function rememberSession(browser: NonNullable<Context['browser']>, state: ToolBrowserState, key: string, agent: ExecAgent | undefined, session: BrowserSessionId | undefined, panelUrl?: string): void {
|
|
397
|
+
const previous = state.sessionsByTask.get(key)
|
|
398
|
+
const previousPanelUrl = state.panelUrlByTask.get(key)
|
|
399
|
+
if (session === undefined) state.sessionsByTask.delete(key)
|
|
400
|
+
else state.sessionsByTask.set(key, session)
|
|
401
|
+
if (panelUrl === undefined) state.panelUrlByTask.delete(key)
|
|
402
|
+
else state.panelUrlByTask.set(key, panelUrl)
|
|
403
|
+
if (previous === session && (previousPanelUrl !== undefined) === (panelUrl !== undefined)) return
|
|
404
|
+
const cleanup = (): void => {
|
|
405
|
+
if (state.sessionsByTask.get(key) !== session || state.panelUrlByTask.has(key) !== (panelUrl !== undefined)) return
|
|
406
|
+
state.sessionsByTask.delete(key)
|
|
407
|
+
state.panelUrlByTask.delete(key)
|
|
408
|
+
if (session !== undefined) void browser.close(session).catch(() => {})
|
|
409
|
+
}
|
|
410
|
+
try {
|
|
411
|
+
if (agent?.ctx !== undefined) agent.ctx.effect(() => cleanup)
|
|
412
|
+
else if (key === 'default' && session !== undefined) registerExitCleanup(() => browser.close(session).catch(() => {}))
|
|
413
|
+
} catch (error) {
|
|
414
|
+
cleanup()
|
|
415
|
+
if (previous !== undefined) state.sessionsByTask.set(key, previous)
|
|
416
|
+
if (previousPanelUrl !== undefined) state.panelUrlByTask.set(key, previousPanelUrl)
|
|
417
|
+
throw error
|
|
418
|
+
}
|
|
419
|
+
if (previous !== undefined && previous !== session) void browser.close(previous).catch(() => {})
|
|
420
|
+
}
|
|
421
|
+
|
|
220
422
|
/**
|
|
221
423
|
* Resolve the calling task's browser session, opening one on first use.
|
|
222
424
|
* Concurrent first calls for the same key share a single open. When the call
|
|
@@ -229,7 +431,8 @@ function taskKey(exec: { agent?: { id?: string } } | undefined): string {
|
|
|
229
431
|
* @param agent - the calling agent, when any (its ctx owns the session).
|
|
230
432
|
* @returns the task's session id.
|
|
231
433
|
*/
|
|
232
|
-
async function ensureSession(browser: NonNullable<Context['browser']>, state: ToolBrowserState, key: string, agent?: ExecAgent): Promise<BrowserSessionId> {
|
|
434
|
+
async function ensureSession(browser: NonNullable<Context['browser']>, state: ToolBrowserState, key: string, agent?: ExecAgent, create = false): Promise<BrowserSessionId> {
|
|
435
|
+
await state.pendingPanelOpens.get(key)
|
|
233
436
|
const existing = state.sessionsByTask.get(key)
|
|
234
437
|
if (existing !== undefined) {
|
|
235
438
|
// The human closing a browser window ends that session, so a cached id can
|
|
@@ -239,39 +442,26 @@ async function ensureSession(browser: NonNullable<Context['browser']>, state: To
|
|
|
239
442
|
}
|
|
240
443
|
const pending = state.pendingOpens.get(key)
|
|
241
444
|
if (pending !== undefined) return pending
|
|
445
|
+
if (state.panelUrlByTask.has(key)) {
|
|
446
|
+
throw new Error('dsh-builtin-browser: the panel surface has no live CDP session for this operation. '
|
|
447
|
+
+ 'Use the CDP-backed DSH desktop sidebar with a connected desktop bridge and call dsh_browser_open again. '
|
|
448
|
+
+ 'The Web iframe panel cannot provide live snapshots, a11y, content, scrape, screenshots, interactions, '
|
|
449
|
+
+ 'uploads, downloads, or reference capture. Reading tools never start a separate browser.')
|
|
450
|
+
}
|
|
451
|
+
// Starting a browser is `dsh_browser_open`'s job and nobody else's. A read tool asking "what is on
|
|
452
|
+
// screen" used to start one — which, with the human's own Edge already running, handed the command over
|
|
453
|
+
// and opened yet another window, reported as "one look, two Edge windows". A reader with nothing open
|
|
454
|
+
// reports that instead of launching anything.
|
|
455
|
+
if (!create) {
|
|
456
|
+
throw new Error('dsh-builtin-browser: nothing is open in this task yet — call dsh_browser_open first. '
|
|
457
|
+
+ 'Reading tools never start a browser.')
|
|
458
|
+
}
|
|
242
459
|
// The task key rides along as the session label so the window title shows
|
|
243
460
|
// which task's page is currently visible to the human.
|
|
244
461
|
const opening = browser.open(key).then(
|
|
245
462
|
session => {
|
|
246
|
-
// Tie the session's lifetime to the agent's scoped context FIRST: when
|
|
247
|
-
// the agent (and its DSH session) is disposed, the effect's disposer
|
|
248
|
-
// runs and closes the browser session. Registration happens once per
|
|
249
|
-
// session (only on first open for the key). If the agent is already
|
|
250
|
-
// gone, close the fresh session instead of leaking it.
|
|
251
|
-
state.sessionsByTask.set(key, session)
|
|
252
463
|
state.pendingOpens.delete(key)
|
|
253
|
-
|
|
254
|
-
if (agent?.ctx !== undefined) {
|
|
255
|
-
agent.ctx.effect(() => () => {
|
|
256
|
-
const current = state.sessionsByTask.get(key)
|
|
257
|
-
if (current === undefined) return
|
|
258
|
-
state.sessionsByTask.delete(key)
|
|
259
|
-
void browser.close(current).catch(() => {})
|
|
260
|
-
})
|
|
261
|
-
} else if (key === 'default') {
|
|
262
|
-
// Agentless / CLI probe: close the session on process exit so the
|
|
263
|
-
// window is not orphaned.
|
|
264
|
-
// One hook for the whole process, not one listener per session: a default session can
|
|
265
|
-
// be created repeatedly (a CLI probe does), and each registration lived for the life of
|
|
266
|
-
// the process — so the listener list grew without bound and Node warned at eleven.
|
|
267
|
-
registerExitCleanup(() => browser.close(session).catch(() => {}))
|
|
268
|
-
}
|
|
269
|
-
} catch (error) {
|
|
270
|
-
// effect() failed — undo the registration so future calls retry.
|
|
271
|
-
state.sessionsByTask.delete(key)
|
|
272
|
-
void browser.close(session).catch(() => {})
|
|
273
|
-
throw error
|
|
274
|
-
}
|
|
464
|
+
rememberSession(browser, state, key, agent, session)
|
|
275
465
|
return session
|
|
276
466
|
},
|
|
277
467
|
error => { state.pendingOpens.delete(key); throw error },
|
|
@@ -335,6 +525,7 @@ function formatSnapshot(snapshot: {
|
|
|
335
525
|
/** Register all browser tools with `ctx.tools`. */
|
|
336
526
|
export function apply(ctx: Context, config: Config = {}): void {
|
|
337
527
|
const timeoutMs = config.timeoutMs ?? 60_000
|
|
528
|
+
const surface = config.surface ?? 'core'
|
|
338
529
|
/**
|
|
339
530
|
* Longest wait `dsh_browser_wait` may poll for, leaving room for the tool call itself to
|
|
340
531
|
* finish and report.
|
|
@@ -358,17 +549,35 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
358
549
|
// scoped to THIS plugin apply, so parallel contexts never share sessions
|
|
359
550
|
// or leak restrictions into each other.
|
|
360
551
|
const state = createState()
|
|
552
|
+
const takeovers = new BrowserTakeovers()
|
|
553
|
+
installTakeovers(ctx, takeovers)
|
|
361
554
|
liveStates.add(state)
|
|
362
555
|
ctx.effect(() => () => { liveStates.delete(state) })
|
|
363
556
|
// Re-apply resets the restriction: an omitted allowedActions lifts it.
|
|
364
557
|
state.configRestrictedTo = config.allowedActions !== undefined ? [...config.allowedActions] : undefined
|
|
365
558
|
|
|
366
559
|
ctx.systemPrompt.section({
|
|
367
|
-
name: 'tool:browser',
|
|
560
|
+
name: 'tool:browser-human-takeover',
|
|
561
|
+
order: 152,
|
|
562
|
+
text: 'For CAPTCHAs, sliders, logins, two-factor authentication (2FA), and payments, call dsh_browser_request_takeover with a clear reason and any instructions. Never attempt automatic CAPTCHA or slider solving. Wait for the human, then re-read the fresh page summary and inspect the page before continuing. A skipped or cancelled takeover is not successful completion; do not bypass it or retry protected actions automatically.',
|
|
563
|
+
})
|
|
564
|
+
|
|
565
|
+
ctx.systemPrompt.section({
|
|
566
|
+
name: 'tool:dsh-browser-reference-presentation',
|
|
567
|
+
order: 151,
|
|
568
|
+
text: 'Browser references are already displayed as interactive capsules. The capsules provide source navigation. Do not repeat browser-reference markers, dsh-browser-ref: URIs, source URLs, or source/citation links in replies; answer using the quoted content instead.',
|
|
569
|
+
})
|
|
570
|
+
|
|
571
|
+
ctx.systemPrompt.section({
|
|
572
|
+
name: 'tool:dsh-builtin-browser',
|
|
368
573
|
// Tool guidance band is 100-199; 150 keeps clear of the common 110/120
|
|
369
574
|
// tool sections so ordering does not depend on plugin load sequence.
|
|
370
575
|
order: 150,
|
|
371
|
-
text:
|
|
576
|
+
text: surface === 'code'
|
|
577
|
+
? CODE_PROMPT
|
|
578
|
+
: surface === 'core'
|
|
579
|
+
? CORE_PROMPT
|
|
580
|
+
: 'Use dsh_browser_* tools to operate the built-in browser. Each task has its own session and window (real toolbar): the human can watch and take over, and other tasks\' pages are not visible to you. Map a page with dsh_browser_a11y (semantic roles/names/states) or dsh_browser_snapshot (numbered elements), then drive it: dsh_browser_click/dsh_browser_type take a target {by: css|text|xpath, value}, or coordinates from dsh_browser_screenshot. Prefer dsh_browser_fill (batch) or dsh_browser_set_value/check/select/clear for forms; verify with dsh_browser_get_value. Use dsh_browser_scrape (not hand-written dsh_browser_execute) for list pages; dsh_browser_wait after slow navigation. Use dsh_browser_do for a run of steps, dsh_browser_assert to check results, and dsh_browser_console/network when the screen is unclear. Say what you are doing on the page. On a CAPTCHA (dsh_browser_challenge), stop retrying and ask the human to solve it in the browser window, then re-check.',
|
|
372
581
|
})
|
|
373
582
|
|
|
374
583
|
/**
|
|
@@ -386,9 +595,56 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
386
595
|
// One store for this apply: it caches by mtime, so reading it per download is a stat, not a parse.
|
|
387
596
|
const settingsStore = new SettingsStore()
|
|
388
597
|
|
|
598
|
+
// Built on first use, not at apply time: the provider is registered by another plugin's apply,
|
|
599
|
+
// and a tool registered before the browser exists must still work once it does.
|
|
600
|
+
let referenceService: BrowserReferenceService | undefined
|
|
601
|
+
const references = (): BrowserReferenceService => {
|
|
602
|
+
if (referenceService !== undefined) return referenceService
|
|
603
|
+
const browser = ctx.get('browser')
|
|
604
|
+
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
605
|
+
// Keep the SAME image fallback as the floating bar and the HTTP capture
|
|
606
|
+
// (browser-electron/entry.ts): a clipped visible-region read lets an image
|
|
607
|
+
// whose source URL cannot be downloaded still become a real reference.
|
|
608
|
+
referenceService = createReferenceService(browser, {
|
|
609
|
+
visibleCapture: async (sessionId, clip, signal) => {
|
|
610
|
+
const shot = await browser.screenshot(sessionWireId(resolveSessionHandle(sessionId)), { clip, format: 'png' }, signal)
|
|
611
|
+
return { dataUrl: shot.dataUrl, mime: 'image/png' }
|
|
612
|
+
},
|
|
613
|
+
})
|
|
614
|
+
return referenceService
|
|
615
|
+
}
|
|
616
|
+
const referenceCarrier = (): BrowserReferenceCarrier => {
|
|
617
|
+
const channel = settingsStore.get().browser.channel
|
|
618
|
+
return channel === 'sidebar' || channel === 'chrome' || channel === 'edge' ? channel : 'bundled'
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
const catalog = new Map<string, CatalogTool>()
|
|
622
|
+
const loaded = new Set<string>()
|
|
389
623
|
const registerSafely = (definition: ReturnType<typeof defineTool>): void => {
|
|
390
624
|
try {
|
|
391
|
-
|
|
625
|
+
const execute = definition.execute.bind(definition)
|
|
626
|
+
const name = definition.name
|
|
627
|
+
definition = { ...definition, execute: async (args, exec) => {
|
|
628
|
+
const owner = taskKey(exec)
|
|
629
|
+
if (name !== TAKEOVER_TOOL && takeovers.blocks(owner)
|
|
630
|
+
&& (!READ_ONLY_TOOLS.has(name) || ['dsh_browser_reset', 'dsh_browser_reset_session', 'dsh_browser_reference_reveal'].includes(name))) {
|
|
631
|
+
const requested = (args as { tabId?: string }).tabId
|
|
632
|
+
let tab = requested
|
|
633
|
+
if (requested?.startsWith('dsh-tab:')) {
|
|
634
|
+
const session = state.sessionsByTask.get(owner)
|
|
635
|
+
if (session) tab = resolveTabHandle(browserSessionHandle(owner, session), requested).tab
|
|
636
|
+
}
|
|
637
|
+
if (tab === undefined || takeovers.blocks(owner, tab)) {
|
|
638
|
+
throw new Error('Browser tab is awaiting human takeover. Agent browser actions are refused until the human confirms completion or skips the request.')
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
return execute(args, exec)
|
|
642
|
+
} }
|
|
643
|
+
catalog.set(definition.name, definition as unknown as CatalogTool)
|
|
644
|
+
if (surface === 'tools' || definition.name === TAKEOVER_TOOL || (surface === 'core' && CORE_TOOLS.has(definition.name))) {
|
|
645
|
+
ctx.tools.register(definition)
|
|
646
|
+
loaded.add(definition.name)
|
|
647
|
+
}
|
|
392
648
|
} catch (error) {
|
|
393
649
|
ctx.logger?.warn?.(
|
|
394
650
|
`dsh-builtin-browser: could not register ${definition.name} (${String(error)}). Another `
|
|
@@ -398,12 +654,153 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
398
654
|
}
|
|
399
655
|
}
|
|
400
656
|
|
|
657
|
+
registerSafely(defineTool({
|
|
658
|
+
name: 'dsh_browser_request_takeover',
|
|
659
|
+
description: 'Hand the selected visible sidebar browser tab in this conversation to the human for a CAPTCHA/slider, login, 2FA or payment. Works on the Web iframe without CDP, including user-opened tabs: adopts the selected tab for this request only, without granting agent control. Never solve CAPTCHAs automatically. Requires an active turn; waits for the sidebar connection and the native card or sidebar Confirm/Skip. Repeated calls on the same tab share one request. Returns done/skipped/cancelled plus a fresh page summary; inspect it before resuming. Never treat skipped/cancelled as success.',
|
|
660
|
+
parameters: {
|
|
661
|
+
reason: { type: 'string', required: true, description: 'Why the human must take over (1–1000 characters).' },
|
|
662
|
+
instructions: { type: 'string', description: 'Optional concise instructions for the human (up to 2000 characters).' },
|
|
663
|
+
},
|
|
664
|
+
output: { schema: { type: 'object', additionalProperties: false, properties: {
|
|
665
|
+
outcome: { type: 'string', required: true, enum: ['done', 'skipped', 'cancelled'] },
|
|
666
|
+
page: { type: 'object', required: true, additionalProperties: false, properties: {
|
|
667
|
+
url: { type: 'string', required: true }, title: { type: 'string', required: true },
|
|
668
|
+
snapshotHint: { type: 'string', required: true }, fresh: { type: 'boolean', required: true },
|
|
669
|
+
} },
|
|
670
|
+
} }, render: (_args, value) => [{ type: 'text', text: JSON.stringify(value) }] },
|
|
671
|
+
async execute(args, exec) {
|
|
672
|
+
if (!exec.agent?.session) throw new Error('Browser takeover requires an active agent turn.')
|
|
673
|
+
if (!args.reason.trim()) throw new Error('Browser takeover reason must not be empty.')
|
|
674
|
+
if (args.reason.length > 1000 || (args.instructions?.length ?? 0) > 2000) throw new Error('Browser takeover reason or instructions are too long.')
|
|
675
|
+
const owner = taskKey(exec)
|
|
676
|
+
const opening = state.pendingPanelOpens.get(owner)
|
|
677
|
+
if (opening) await opening
|
|
678
|
+
const open = getLastOpen()
|
|
679
|
+
const navigationUrl = open?.owner === owner && Date.now() - open.at < 10000 ? open.url : undefined
|
|
680
|
+
const page = await takeovers.adopt(owner, exec.signal, navigationUrl)
|
|
681
|
+
if (navigationUrl !== undefined && getLastOpen()?.owner === owner) clearLastOpen(open!.at)
|
|
682
|
+
return takeovers.run(page, args.reason.trim(), args.instructions, exec.signal, async (pending): Promise<{ outcome: TakeoverOutcome; page: TakeoverSummary }> => {
|
|
683
|
+
const approval = ctx.get('approval' as never) as unknown as { request(request: {
|
|
684
|
+
agent: ToolRunContext['agent']; toolName: string; reason: string; displayReason: { en: string; zh: string };
|
|
685
|
+
callId: ToolRunContext['callId']; signal: AbortSignal;
|
|
686
|
+
}): Promise<TakeoverDecision> } | undefined
|
|
687
|
+
let decision: TakeoverDecision = 'unavailable'
|
|
688
|
+
try {
|
|
689
|
+
if (approval) decision = await approval.request({ agent: exec.agent, toolName: TAKEOVER_TOOL, callId: exec.callId,
|
|
690
|
+
reason: pending.reason, displayReason: {
|
|
691
|
+
en: `Please take over the browser: ${pending.reason}. When finished, click Allow once or Confirm completion in the sidebar.${pending.instructions ? '\n' + pending.instructions : ''}`,
|
|
692
|
+
zh: `请接管浏览器:${pending.reason}(完成后点「允许一次」或侧栏「确认完成」)${pending.instructions ? '\n' + pending.instructions : ''}`,
|
|
693
|
+
}, signal: pending.controller.signal })
|
|
694
|
+
} finally { pending.controller.abort() }
|
|
695
|
+
const outcome = decision === 'allowed-once' ? 'done' : decision === 'rejected' ? 'skipped' : 'cancelled'
|
|
696
|
+
const unavailable = (error: unknown): TakeoverSummary => ({ url: page.url, title: '', snapshotHint: `Live page summary unavailable: ${String(error).slice(0, 300)}. Re-read the page before continuing.`, fresh: false })
|
|
697
|
+
if (exec.signal.aborted) return { outcome: 'cancelled', page: unavailable('turn stopped') }
|
|
698
|
+
pending.phase = 'summary'
|
|
699
|
+
let fresh: TakeoverSummary
|
|
700
|
+
try {
|
|
701
|
+
if (!page.pageId.startsWith('iframe:')) {
|
|
702
|
+
const browser = ctx.get('browser')!
|
|
703
|
+
const session = await browser.bindPanelPage(`session-${page.owner}`, page.pageId)
|
|
704
|
+
const snapshot = await browser.snapshot(session, AbortSignal.any([exec.signal, AbortSignal.timeout(5000)]))
|
|
705
|
+
fresh = { url: snapshot.url, title: (snapshot.title ?? '').slice(0, 1000), snapshotHint: formatSnapshot(snapshot, {}).slice(0, 1500), fresh: true }
|
|
706
|
+
} else {
|
|
707
|
+
fresh = await new Promise<TakeoverSummary>((resolve, reject) => {
|
|
708
|
+
const finish = (value?: TakeoverSummary, error?: unknown): void => {
|
|
709
|
+
clearTimeout(timer); exec.signal.removeEventListener('abort', abort)
|
|
710
|
+
if (error !== undefined) reject(error); else resolve(value!)
|
|
711
|
+
}
|
|
712
|
+
const abort = (): void => { finish(undefined, exec.signal.reason) }
|
|
713
|
+
const timer = setTimeout(() => { finish(undefined, new Error('sidebar summary timed out')) }, 8000)
|
|
714
|
+
exec.signal.addEventListener('abort', abort, { once: true })
|
|
715
|
+
void pending.summary.then(value => { finish(value) })
|
|
716
|
+
if (exec.signal.aborted) abort()
|
|
717
|
+
})
|
|
718
|
+
}
|
|
719
|
+
} catch (error) { fresh = unavailable(error) }
|
|
720
|
+
return { outcome: exec.signal.aborted ? 'cancelled' : outcome, page: fresh }
|
|
721
|
+
})
|
|
722
|
+
},
|
|
723
|
+
}))
|
|
724
|
+
|
|
725
|
+
// The start page's shared shortcut list, reached through the settings section the
|
|
726
|
+
// sidebar edits. Built lazily for the same reason `references()` is: the settings
|
|
727
|
+
// service is registered by another entry and may not exist yet at apply time.
|
|
728
|
+
const startpageShortcuts = createShortcutStore(() => ctx.get('settings') as unknown as ShortcutSettings | undefined)
|
|
729
|
+
registerSafely(defineTool({
|
|
730
|
+
name: 'dsh_browser_shortcuts',
|
|
731
|
+
description: 'Read or edit the Sidebar Browser start page shortcuts — the shared website entries a human sees on an empty tab. action=list returns them, action=add appends one (title + http(s) url required, http:// or https:// only, at most 48 entries), action=remove drops one by id. The list is shared with the sidebar UI: an entry added here appears on the next empty tab for every conversation, and one a human adds appears here.',
|
|
732
|
+
parameters: {
|
|
733
|
+
action: { type: 'string', required: true, enum: ['list', 'add', 'remove'], description: 'list the shortcuts, add one, or remove one by id.' },
|
|
734
|
+
title: { type: 'string', description: 'Display title (add). At most 80 characters.' },
|
|
735
|
+
url: { type: 'string', description: 'Destination (add): a full http:// or https:// address.' },
|
|
736
|
+
id: { type: 'string', description: 'Shortcut id (remove), as returned by list or add.' },
|
|
737
|
+
},
|
|
738
|
+
output: {
|
|
739
|
+
schema: {
|
|
740
|
+
type: 'object',
|
|
741
|
+
additionalProperties: false,
|
|
742
|
+
properties: {
|
|
743
|
+
shortcuts: {
|
|
744
|
+
type: 'array',
|
|
745
|
+
required: true,
|
|
746
|
+
items: {
|
|
747
|
+
type: 'object',
|
|
748
|
+
additionalProperties: false,
|
|
749
|
+
properties: {
|
|
750
|
+
id: { type: 'string', required: true },
|
|
751
|
+
title: { type: 'string', required: true },
|
|
752
|
+
url: { type: 'string', required: true },
|
|
753
|
+
iconKey: { type: 'string' },
|
|
754
|
+
},
|
|
755
|
+
},
|
|
756
|
+
},
|
|
757
|
+
changed: { type: 'string', description: 'What the call changed: added <id>, removed <id>, or empty for list.' },
|
|
758
|
+
},
|
|
759
|
+
},
|
|
760
|
+
render: (_args, value) => {
|
|
761
|
+
const rows = value.shortcuts as Array<{ id: string; title: string; url: string }>
|
|
762
|
+
const changed = typeof value.changed === 'string' && value.changed !== '' ? `${value.changed}\n` : ''
|
|
763
|
+
const body = rows.length === 0
|
|
764
|
+
? '(the start page has no shortcuts)'
|
|
765
|
+
: rows.map(row => `- ${row.title} -> ${row.url} [${row.id}]`).join('\n')
|
|
766
|
+
return [{ type: 'text', text: `${changed}${rows.length} shortcut(s):\n${body}` }]
|
|
767
|
+
},
|
|
768
|
+
},
|
|
769
|
+
timeoutMs,
|
|
770
|
+
isConcurrencySafe: () => false,
|
|
771
|
+
async execute(args, exec) {
|
|
772
|
+
assertAllowed(state, 'dsh_browser_shortcuts', taskKey(exec))
|
|
773
|
+
try {
|
|
774
|
+
if (args.action === 'list') {
|
|
775
|
+
const reading = startpageShortcuts.list()
|
|
776
|
+
return { shortcuts: reading.shortcuts.map(row => ({ ...row })), changed: '' }
|
|
777
|
+
}
|
|
778
|
+
if (args.action === 'add') {
|
|
779
|
+
const result = await startpageShortcuts.add({ title: args.title, url: args.url })
|
|
780
|
+
return { shortcuts: result.shortcuts.map(row => ({ ...row })), changed: `added ${result.shortcut.id}` }
|
|
781
|
+
}
|
|
782
|
+
if (typeof args.id !== 'string' || args.id === '') throw new Error('remove needs the shortcut id')
|
|
783
|
+
const result = await startpageShortcuts.remove(args.id)
|
|
784
|
+
return {
|
|
785
|
+
shortcuts: result.shortcuts.map(row => ({ ...row })),
|
|
786
|
+
changed: result.removed ? `removed ${args.id}` : `${args.id} was not in the list`,
|
|
787
|
+
}
|
|
788
|
+
} catch (error) {
|
|
789
|
+
// The store reports refusals as typed errors; a tool must not answer with a stack.
|
|
790
|
+
throw new Error(`start page shortcuts: ${error instanceof Error ? error.message : String(error)}`)
|
|
791
|
+
}
|
|
792
|
+
},
|
|
793
|
+
}))
|
|
794
|
+
|
|
401
795
|
registerSafely(defineTool({
|
|
402
796
|
name: 'dsh_browser_open',
|
|
403
|
-
description: 'Open a URL
|
|
797
|
+
description: 'Open a URL on the selected controllable surface (default: panel). Success returns a live snapshot and supports subsequent browser tools on that same page. A Web iframe or unavailable desktop bridge is refused; no manual-only navigation is queued. Reading tools never start another browser. newTab is optional on CDP surfaces. Never treat the bare DSH host (e.g. http://127.0.0.1:3080/) as the target — it needs the authenticated URL printed by `dsh web`, and the bare root is refused.',
|
|
404
798
|
parameters: {
|
|
405
799
|
url: { type: 'string', required: true, description: 'The URL to open (HTTP/HTTPS).' },
|
|
406
800
|
newTab: { type: 'boolean', description: 'Open in a new tab instead of the active one.' },
|
|
801
|
+
// Explicit per-call surface. "panel" (default) places the page in the DSH sidebar and opens no
|
|
802
|
+
// window; "builtin" drives the plugin's own browser, which is what debugging DSH itself needs.
|
|
803
|
+
surface: { type: 'string', enum: ['panel', 'builtin'], description: 'panel (default): the DSH sidebar only; builtin: the plugin browser, for debugging DSH itself.' },
|
|
407
804
|
},
|
|
408
805
|
output: {
|
|
409
806
|
schema: {
|
|
@@ -412,6 +809,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
412
809
|
properties: {
|
|
413
810
|
url: { type: 'string', required: true },
|
|
414
811
|
title: { type: 'string' },
|
|
812
|
+
carrier: { type: 'string' },
|
|
415
813
|
truncated: { type: 'boolean' },
|
|
416
814
|
elements: {
|
|
417
815
|
type: 'array',
|
|
@@ -440,16 +838,104 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
440
838
|
async execute(args, exec) {
|
|
441
839
|
assertAllowed(state, 'dsh_browser_open', taskKey(exec))
|
|
442
840
|
assertNotBareDshWebUrl(args.url)
|
|
841
|
+
// ONE surface per open. On the Web shell the reader's sidebar is the browsing surface; opening the
|
|
842
|
+
// plugin's own browser as well produced two live views of the same page (reported as "you opened the
|
|
843
|
+
// built-in browser AND the sidebar at once"). `browser.surface` decides: "panel" (default on Web)
|
|
844
|
+
// places the page in the sidebar and opens no window; "builtin" is the debugging surface.
|
|
845
|
+
const surfaceHint = (args as { surface?: 'panel' | 'builtin' }).surface
|
|
846
|
+
const surface = enforceSurface(surfaceHint ?? readSurface(), args.url)
|
|
443
847
|
const browser = ctx.get('browser')
|
|
444
848
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
445
|
-
const
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
849
|
+
const key = taskKey(exec)
|
|
850
|
+
if (surface === 'panel') {
|
|
851
|
+
const preceding = state.pendingPanelOpens.get(key)
|
|
852
|
+
let previous: BrowserSessionId | undefined
|
|
853
|
+
let session: BrowserSessionId | undefined
|
|
854
|
+
const opening = (async () => {
|
|
855
|
+
await preceding
|
|
856
|
+
await state.pendingOpens.get(key)
|
|
857
|
+
previous = state.sessionsByTask.get(key)
|
|
858
|
+
const target = new URL(args.url)
|
|
859
|
+
if (target.protocol !== 'http:' && target.protocol !== 'https:') throw new Error('dsh_browser_open: panel requires an HTTP/HTTPS URL')
|
|
860
|
+
exec.signal?.throwIfAborted()
|
|
861
|
+
session = state.panelUrlByTask.has(key) && previous !== undefined && browser.exists(previous)
|
|
862
|
+
? previous : await browser.openPanel?.(key)
|
|
863
|
+
if (session === undefined) {
|
|
864
|
+
assertSurfaceCanHost(surface, args.url)
|
|
865
|
+
exec.signal?.throwIfAborted()
|
|
866
|
+
setLastOpen(args.url, Date.now(), key)
|
|
867
|
+
rememberSession(browser, state, key, agentOf(exec), undefined, args.url)
|
|
868
|
+
return { url: args.url, carrier: 'panel-iframe-navigation-requested', title: '', elements: [], truncated: false }
|
|
869
|
+
}
|
|
870
|
+
await browser.openUrl(session, { url: args.url, ...args.newTab === true ? { newTab: true } : {} }, exec.signal)
|
|
871
|
+
const snapshot = await browser.snapshot(session, exec.signal)
|
|
872
|
+
exec.signal?.throwIfAborted()
|
|
873
|
+
rememberSession(browser, state, key, agentOf(exec), session, args.url)
|
|
874
|
+
return {
|
|
875
|
+
url: snapshot.url,
|
|
876
|
+
...snapshot.title !== undefined ? { title: snapshot.title } : {},
|
|
877
|
+
elements: snapshot.elements.map(el => projectElement(el)),
|
|
878
|
+
truncated: snapshot.truncated,
|
|
879
|
+
...snapshot.challenge !== undefined ? { challenge: snapshot.challenge } : {},
|
|
880
|
+
}
|
|
881
|
+
})()
|
|
882
|
+
const pending = opening.then(() => {})
|
|
883
|
+
state.pendingPanelOpens.set(key, pending)
|
|
884
|
+
void pending.catch(() => {})
|
|
885
|
+
try { return await opening } catch (error) {
|
|
886
|
+
if (session !== undefined && session !== previous) await browser.close(session).catch(() => {})
|
|
887
|
+
throw error
|
|
888
|
+
} finally {
|
|
889
|
+
if (state.pendingPanelOpens.get(key) === pending) state.pendingPanelOpens.delete(key)
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
await state.pendingPanelOpens.get(key)
|
|
893
|
+
await state.pendingOpens.get(key)
|
|
894
|
+
if (state.panelUrlByTask.has(key)) {
|
|
895
|
+
const previous = state.sessionsByTask.get(key)
|
|
896
|
+
state.sessionsByTask.delete(key)
|
|
897
|
+
state.panelUrlByTask.delete(key)
|
|
898
|
+
if (previous !== undefined) await browser.close(previous)
|
|
899
|
+
}
|
|
900
|
+
const session = await ensureSession(browser, state, key, agentOf(exec), true)
|
|
901
|
+
try {
|
|
902
|
+
await browser.openUrl(session, {
|
|
903
|
+
url: args.url,
|
|
904
|
+
...args.newTab === true ? { newTab: true } : {},
|
|
905
|
+
}, exec.signal)
|
|
906
|
+
} catch (error) {
|
|
907
|
+
// The human's browser is already running on its own profile: the launch hands the request over and
|
|
908
|
+
// exits with code 0. A new window opened inside THEIR browser with their logins — what "use my
|
|
909
|
+
// Edge" means — it is simply not driveable, because their instance has no debugging port.
|
|
910
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
911
|
+
if (!/exited immediately after launch \(exit code 0\)/u.test(message)) throw error
|
|
912
|
+
return { url: args.url, carrier: 'launched-user-profile', title: '', elements: [], truncated: false }
|
|
913
|
+
}
|
|
914
|
+
// Hand the page to the Web sidebar as well. The desktop shell is told through the bridge; the Web
|
|
915
|
+
// shell has no such channel, so the client polls this slot and places the tab itself. Written in the
|
|
916
|
+
// TOOL (not a provider) on purpose: every open passes through here whatever serves it.
|
|
917
|
+
try { setLastOpen(args.url, Date.now()) } catch { /* best effort */ }
|
|
918
|
+
let snapshot: Awaited<ReturnType<typeof browser.snapshot>>
|
|
919
|
+
try {
|
|
920
|
+
snapshot = await browser.snapshot(session, exec.signal)
|
|
921
|
+
} catch (error) {
|
|
922
|
+
// The human's browser is ALREADY running on its own profile, so a launch hands the request over
|
|
923
|
+
// and the launcher exits with code 0. That is not a failure: a new window opened inside THEIR
|
|
924
|
+
// browser, with their logins, which is exactly what "use my Edge" means. It is only undriveable,
|
|
925
|
+
// because their instance has no debugging port. Report the page, not an error.
|
|
926
|
+
const message = error instanceof Error ? error.message : String(error)
|
|
927
|
+
if (!/exited immediately after launch \(exit code 0\)/u.test(message)) throw error
|
|
928
|
+
return {
|
|
929
|
+
url: args.url,
|
|
930
|
+
carrier: 'launched-user-profile',
|
|
931
|
+
title: '',
|
|
932
|
+
elements: [],
|
|
933
|
+
truncated: false,
|
|
934
|
+
}
|
|
935
|
+
}
|
|
451
936
|
return {
|
|
452
937
|
url: snapshot.url,
|
|
938
|
+
carrier: String((globalThis as unknown as Record<string, unknown>).__dshBrowserCarrier ?? 'bundled'),
|
|
453
939
|
...snapshot.title !== undefined ? { title: snapshot.title } : {},
|
|
454
940
|
elements: snapshot.elements.map(el => projectElement(el)),
|
|
455
941
|
truncated: snapshot.truncated,
|
|
@@ -512,7 +998,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
512
998
|
async execute(_args, exec) {
|
|
513
999
|
const browser = ctx.get('browser')
|
|
514
1000
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
515
|
-
const
|
|
1001
|
+
const key = taskKey(exec)
|
|
1002
|
+
const session = await ensureSession(browser, state, key, agentOf(exec))
|
|
516
1003
|
const snapshot = await browser.snapshot(session, exec.signal)
|
|
517
1004
|
return {
|
|
518
1005
|
url: snapshot.url,
|
|
@@ -841,8 +1328,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
841
1328
|
y: { type: 'number', description: 'Viewport y coordinate (CSS px), taken from the same screenshot as x.' },
|
|
842
1329
|
},
|
|
843
1330
|
output: {
|
|
844
|
-
schema: { type: 'object', additionalProperties: false, properties: { clicked: { type: 'boolean', required: true } } },
|
|
845
|
-
render: (_args, value) => [{ type: 'text', text: value.clicked ? 'Clicked.' : 'Click failed.' }],
|
|
1331
|
+
schema: { type: 'object', additionalProperties: false, properties: { clicked: { type: 'boolean', required: true }, ...effectProperties } },
|
|
1332
|
+
render: (_args, value) => [{ type: 'text', text: value.clicked ? 'Clicked.' + effectText(value) : 'Click failed.' }],
|
|
846
1333
|
},
|
|
847
1334
|
timeoutMs,
|
|
848
1335
|
isConcurrencySafe: () => false,
|
|
@@ -859,6 +1346,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
859
1346
|
throw new Error('target.value is empty; pass a css selector, visible text or XPath, or omit target entirely to use x/y')
|
|
860
1347
|
}
|
|
861
1348
|
const index = targetIndex(target)
|
|
1349
|
+
const before = await pageFingerprint(browser, session)
|
|
862
1350
|
if (target !== undefined && typeof target.value === 'string' && target.value !== '') {
|
|
863
1351
|
await browser.click(session, {
|
|
864
1352
|
target: {
|
|
@@ -873,7 +1361,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
873
1361
|
}
|
|
874
1362
|
await browser.click(session, { x: args.x, y: args.y }, exec.signal)
|
|
875
1363
|
}
|
|
876
|
-
return { clicked: true }
|
|
1364
|
+
return { clicked: true, ...await observedEffect(browser, session, before) }
|
|
877
1365
|
},
|
|
878
1366
|
}))
|
|
879
1367
|
|
|
@@ -902,6 +1390,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
902
1390
|
additionalProperties: false,
|
|
903
1391
|
properties: {
|
|
904
1392
|
clicked: { type: 'number', required: true, description: 'How many points landed.' },
|
|
1393
|
+
...effectProperties,
|
|
905
1394
|
failedAt: { type: 'number', description: 'Index of the point that failed, when one did.' },
|
|
906
1395
|
error: { type: 'string', description: 'Why that point failed.' },
|
|
907
1396
|
},
|
|
@@ -909,7 +1398,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
909
1398
|
render: (_args, value) => [{
|
|
910
1399
|
type: 'text',
|
|
911
1400
|
text: value.failedAt === undefined
|
|
912
|
-
? `Clicked ${String(value.clicked)} point(s).`
|
|
1401
|
+
? `Clicked ${String(value.clicked)} point(s).` + effectText(value)
|
|
913
1402
|
: `Clicked ${String(value.clicked)} point(s), then stopped at index ${String(value.failedAt)}: ${String(value.error ?? 'unknown')}`,
|
|
914
1403
|
}],
|
|
915
1404
|
},
|
|
@@ -922,7 +1411,9 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
922
1411
|
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
923
1412
|
const points = Array.isArray(args.points) ? args.points : []
|
|
924
1413
|
const intervalMs = typeof args.intervalMs === 'number' ? args.intervalMs : undefined
|
|
925
|
-
|
|
1414
|
+
const before = await pageFingerprint(browser, session)
|
|
1415
|
+
const result = await browser.clickSequence(session, { points, ...intervalMs === undefined ? {} : { intervalMs } })
|
|
1416
|
+
return { ...result, ...await observedEffect(browser, session, before) }
|
|
926
1417
|
},
|
|
927
1418
|
}))
|
|
928
1419
|
|
|
@@ -943,8 +1434,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
943
1434
|
},
|
|
944
1435
|
},
|
|
945
1436
|
output: {
|
|
946
|
-
schema: { type: 'object', additionalProperties: false, properties: { typed: { type: 'boolean', required: true } } },
|
|
947
|
-
render: (_args, value) => [{ type: 'text', text: value.typed ? `Typed ${String(_args.text).length} chars.` : 'Type failed.' }],
|
|
1437
|
+
schema: { type: 'object', additionalProperties: false, properties: { typed: { type: 'boolean', required: true }, ...effectProperties } },
|
|
1438
|
+
render: (_args, value) => [{ type: 'text', text: value.typed ? `Typed ${String(_args.text).length} chars.` + effectText(value) : 'Type failed.' }],
|
|
948
1439
|
},
|
|
949
1440
|
timeoutMs,
|
|
950
1441
|
isConcurrencySafe: () => false,
|
|
@@ -961,6 +1452,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
961
1452
|
throw new Error('target.value is empty; pass a css selector, visible text or XPath, or omit target entirely to use x/y')
|
|
962
1453
|
}
|
|
963
1454
|
const index = targetIndex(target)
|
|
1455
|
+
const before = await pageFingerprint(browser, session)
|
|
964
1456
|
if (target !== undefined && typeof target.value === 'string' && target.value !== '') {
|
|
965
1457
|
await browser.type(session, {
|
|
966
1458
|
text: args.text,
|
|
@@ -973,7 +1465,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
973
1465
|
} else {
|
|
974
1466
|
await browser.type(session, { text: args.text }, exec.signal)
|
|
975
1467
|
}
|
|
976
|
-
return { typed: true }
|
|
1468
|
+
return { typed: true, ...await observedEffect(browser, session, before) }
|
|
977
1469
|
},
|
|
978
1470
|
}))
|
|
979
1471
|
|
|
@@ -988,8 +1480,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
988
1480
|
toBottom: { type: 'boolean', description: 'Scroll to the bottom of the page.' },
|
|
989
1481
|
},
|
|
990
1482
|
output: {
|
|
991
|
-
schema: { type: 'object', additionalProperties: false, properties: { scrolled: { type: 'boolean', required: true } } },
|
|
992
|
-
render: (_args, value) => [{ type: 'text', text: value.scrolled ? 'Scrolled.' : 'Scroll failed.' }],
|
|
1483
|
+
schema: { type: 'object', additionalProperties: false, properties: { scrolled: { type: 'boolean', required: true }, ...effectProperties } },
|
|
1484
|
+
render: (_args, value) => [{ type: 'text', text: value.scrolled ? 'Scrolled.' + effectText(value) : 'Scroll failed.' }],
|
|
993
1485
|
},
|
|
994
1486
|
timeoutMs,
|
|
995
1487
|
isConcurrencySafe: () => false, // mutates page scroll state; exclusive within a task
|
|
@@ -998,6 +1490,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
998
1490
|
const browser = ctx.get('browser')
|
|
999
1491
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
1000
1492
|
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
1493
|
+
const before = await pageFingerprint(browser, session)
|
|
1001
1494
|
await browser.scroll(session, {
|
|
1002
1495
|
...args.deltaX !== undefined ? { deltaX: args.deltaX } : {},
|
|
1003
1496
|
...args.deltaY !== undefined ? { deltaY: args.deltaY } : {},
|
|
@@ -1005,7 +1498,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1005
1498
|
...args.toTop === true ? { toTop: true } : {},
|
|
1006
1499
|
...args.toBottom === true ? { toBottom: true } : {},
|
|
1007
1500
|
}, exec.signal)
|
|
1008
|
-
return { scrolled: true }
|
|
1501
|
+
return { scrolled: true, ...await observedEffect(browser, session, before) }
|
|
1009
1502
|
},
|
|
1010
1503
|
}))
|
|
1011
1504
|
|
|
@@ -1076,8 +1569,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1076
1569
|
key: { type: 'string', required: true, enum: ['Enter', 'Tab', 'Escape', 'Backspace', 'Delete', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown', 'Space'], description: 'The key to press.' },
|
|
1077
1570
|
},
|
|
1078
1571
|
output: {
|
|
1079
|
-
schema: { type: 'object', additionalProperties: false, properties: { pressed: { type: 'boolean', required: true } } },
|
|
1080
|
-
render: (_args, value) => [{ type: 'text', text: value.pressed ? `Pressed ${String(_args.key)}.` : 'Key press failed.' }],
|
|
1572
|
+
schema: { type: 'object', additionalProperties: false, properties: { pressed: { type: 'boolean', required: true }, ...effectProperties } },
|
|
1573
|
+
render: (_args, value) => [{ type: 'text', text: value.pressed ? `Pressed ${String(_args.key)}.` + effectText(value) : 'Key press failed.' }],
|
|
1081
1574
|
},
|
|
1082
1575
|
timeoutMs,
|
|
1083
1576
|
isConcurrencySafe: () => false, // mutates page state; exclusive within a task
|
|
@@ -1086,8 +1579,9 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1086
1579
|
const browser = ctx.get('browser')
|
|
1087
1580
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
1088
1581
|
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
1582
|
+
const before = await pageFingerprint(browser, session)
|
|
1089
1583
|
await browser.key(session, { key: args.key }, exec.signal)
|
|
1090
|
-
return { pressed: true }
|
|
1584
|
+
return { pressed: true, ...await observedEffect(browser, session, before) }
|
|
1091
1585
|
},
|
|
1092
1586
|
}))
|
|
1093
1587
|
|
|
@@ -1390,10 +1884,10 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1390
1884
|
|
|
1391
1885
|
registerSafely(defineTool({
|
|
1392
1886
|
name: 'dsh_browser_screenshot',
|
|
1393
|
-
description: 'Screenshot the
|
|
1887
|
+
description: 'Screenshot the Desktop browser (PNG default, JPEG where supported). Vision-capable active models receive the image directly; non-vision or unknown models receive text metadata only. Images are downscaled to at most 1280x960 and limited to 4 MiB; retry with smaller dimensions if encoding exceeds the limit. Supports fullPage and savePath. Web iframe screenshots are unavailable. Never solve CAPTCHAs automatically; request human takeover instead.',
|
|
1394
1888
|
parameters: {
|
|
1395
1889
|
fullPage: { type: 'boolean', description: 'Capture the full scrollable page instead of the viewport (default false).' },
|
|
1396
|
-
savePath: { type: 'string', description: 'Absolute file path to also save the image to
|
|
1890
|
+
savePath: { type: 'string', description: 'Absolute file path to also save the image to. Must resolve inside the configured downloadDir (default: the system Downloads folder, localized names such as ~/下载 included); an existing file is never overwritten.' },
|
|
1397
1891
|
format: { type: 'string', enum: ['png', 'jpeg'], description: 'Image format (default png; jpeg needs the self-hosted browser or an installed Chrome/Edge; the desktop sidebar returns PNG because the Electron CDP JPEG encoder hangs).' },
|
|
1398
1892
|
quality: { type: 'number', description: 'JPEG quality 1-100 (default 80); ignored for PNG.' },
|
|
1399
1893
|
maxWidth: { type: 'number', description: 'Downscale to fit within this width (aspect preserved).' },
|
|
@@ -1404,35 +1898,58 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1404
1898
|
type: 'object',
|
|
1405
1899
|
additionalProperties: false,
|
|
1406
1900
|
properties: {
|
|
1407
|
-
|
|
1901
|
+
bytes: { type: 'number', required: true, description: 'Encoded screenshot byte count.' },
|
|
1902
|
+
attachment: {
|
|
1903
|
+
type: 'object', additionalProperties: false,
|
|
1904
|
+
properties: {
|
|
1905
|
+
attachmentId: { type: 'string', required: true },
|
|
1906
|
+
mediaType: { type: 'string', required: true },
|
|
1907
|
+
bytes: { type: 'number', required: true },
|
|
1908
|
+
width: { type: 'number', required: true },
|
|
1909
|
+
height: { type: 'number', required: true },
|
|
1910
|
+
},
|
|
1911
|
+
},
|
|
1408
1912
|
width: { type: 'number', description: 'Pixel width of the returned image, when the capture was measured (present with maxWidth/maxHeight).' },
|
|
1409
1913
|
height: { type: 'number', description: 'Pixel height of the returned image, when the capture was measured.' },
|
|
1410
1914
|
path: { type: 'string', description: 'The file path the screenshot was saved to, when savePath was given.' },
|
|
1411
1915
|
},
|
|
1412
1916
|
},
|
|
1413
|
-
render: (_args, value) => [
|
|
1917
|
+
render: (_args, value) => [
|
|
1918
|
+
{ type: 'text', text: `Screenshot captured (${Math.round(value.bytes / 1024)} KiB${value.width !== undefined && value.height !== undefined ? `, ${value.width}x${value.height}` : ''})${value.path !== undefined ? ` saved to ${value.path}` : ''}.` },
|
|
1919
|
+
...value.attachment === undefined ? [] : [{ type: 'image' as const, attachment: value.attachment as ImageBlock['attachment'] }],
|
|
1920
|
+
],
|
|
1414
1921
|
},
|
|
1415
1922
|
timeoutMs,
|
|
1416
1923
|
isConcurrencySafe: () => true,
|
|
1417
1924
|
async execute(args, exec) {
|
|
1418
1925
|
const browser = ctx.get('browser')
|
|
1419
1926
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
1927
|
+
const key = taskKey(exec)
|
|
1928
|
+
await state.pendingPanelOpens.get(key)
|
|
1929
|
+
const existing = state.sessionsByTask.get(key)
|
|
1930
|
+
if (state.panelUrlByTask.has(key) && (existing === undefined || !browser.exists(existing))) {
|
|
1931
|
+
throw new Error('Web 侧栏暂不支持截图:iframe 无法被网页静默截图 (panel surface unavailable). Use the CDP-backed DSH desktop sidebar with a connected desktop bridge for screenshots.')
|
|
1932
|
+
}
|
|
1420
1933
|
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
1934
|
+
const vision = await screenshotVisionEnabled(ctx, exec, exec.signal)
|
|
1935
|
+
const maxWidth = screenshotDimension(args.maxWidth, SCREENSHOT_MAX_WIDTH)
|
|
1936
|
+
const maxHeight = screenshotDimension(args.maxHeight, SCREENSHOT_MAX_HEIGHT)
|
|
1421
1937
|
const shot = await browser.screenshot(session, {
|
|
1422
1938
|
...args.fullPage === true ? { fullPage: true } : {},
|
|
1423
1939
|
...args.savePath !== undefined ? { savePath: args.savePath } : {},
|
|
1424
1940
|
...args.format !== undefined ? { format: args.format } : {},
|
|
1425
1941
|
...args.quality !== undefined ? { quality: args.quality } : {},
|
|
1426
|
-
|
|
1427
|
-
|
|
1942
|
+
maxWidth,
|
|
1943
|
+
maxHeight,
|
|
1428
1944
|
}, exec.signal)
|
|
1945
|
+
exec.signal?.throwIfAborted()
|
|
1946
|
+
const image = screenshotBytes(shot.dataUrl)
|
|
1947
|
+
const attachment = vision ? await saveScreenshotImage(ctx, image, maxWidth, maxHeight) : undefined
|
|
1948
|
+
exec.signal?.throwIfAborted()
|
|
1429
1949
|
return {
|
|
1430
|
-
|
|
1950
|
+
bytes: image.data.length,
|
|
1951
|
+
...attachment === undefined ? {} : { attachment },
|
|
1431
1952
|
...shot.path !== undefined ? { path: shot.path } : {},
|
|
1432
|
-
// The provider measures these when it scales, the schema declares them, and the seam
|
|
1433
|
-
// type carries them — but this mapping is an allow-list, so leaving them out dropped
|
|
1434
|
-
// them silently. Same shape of bug as the a11y selector, found the same way: by
|
|
1435
|
-
// reading the three places that mention a field and noticing this one did not.
|
|
1436
1953
|
...shot.width !== undefined ? { width: shot.width } : {},
|
|
1437
1954
|
...shot.height !== undefined ? { height: shot.height } : {},
|
|
1438
1955
|
}
|
|
@@ -1477,7 +1994,7 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1477
1994
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
1478
1995
|
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
1479
1996
|
const tabs = await browser.listTabs(session)
|
|
1480
|
-
return { tabs: tabs.map(t => ({ id: t.id, url: t.url, active: t.active })) }
|
|
1997
|
+
return { tabs: scopedTabs(browserSessionHandle(taskKey(exec), session), tabs).map(t => ({ id: t.id, url: t.url, active: t.active })) }
|
|
1481
1998
|
},
|
|
1482
1999
|
}))
|
|
1483
2000
|
|
|
@@ -1498,7 +2015,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1498
2015
|
const browser = ctx.get('browser')
|
|
1499
2016
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
1500
2017
|
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
1501
|
-
|
|
2018
|
+
const handle = resolveTabHandle(browserSessionHandle(taskKey(exec), session), args.tabId)
|
|
2019
|
+
await browser.switchTab(session, tabWireId(handle))
|
|
1502
2020
|
return { switched: true }
|
|
1503
2021
|
},
|
|
1504
2022
|
}))
|
|
@@ -1520,7 +2038,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1520
2038
|
const browser = ctx.get('browser')
|
|
1521
2039
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
1522
2040
|
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
1523
|
-
|
|
2041
|
+
const handle = resolveTabHandle(browserSessionHandle(taskKey(exec), session), args.tabId)
|
|
2042
|
+
await browser.closeTab(session, tabWireId(handle))
|
|
1524
2043
|
return { closed: true }
|
|
1525
2044
|
},
|
|
1526
2045
|
}))
|
|
@@ -1881,7 +2400,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1881
2400
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
1882
2401
|
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
1883
2402
|
const tabs = await browser.listTabs(session)
|
|
1884
|
-
|
|
2403
|
+
const scope = browserSessionHandle(taskKey(exec), session)
|
|
2404
|
+
return { session: sessionWireId(scope), tabs: scopedTabs(scope, tabs).map(t => ({ id: t.id, url: t.url, active: t.active })) }
|
|
1885
2405
|
},
|
|
1886
2406
|
}))
|
|
1887
2407
|
|
|
@@ -1900,6 +2420,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
1900
2420
|
const browser = ctx.get('browser')
|
|
1901
2421
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
1902
2422
|
const key = taskKey(exec)
|
|
2423
|
+
await state.pendingPanelOpens.get(key)
|
|
2424
|
+
state.panelUrlByTask.delete(key)
|
|
1903
2425
|
const session = state.sessionsByTask.get(key)
|
|
1904
2426
|
if (session !== undefined) {
|
|
1905
2427
|
try {
|
|
@@ -2344,6 +2866,8 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
2344
2866
|
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
2345
2867
|
await installProbe(browser, session, exec.signal)
|
|
2346
2868
|
const cursor = await probe<{ startedAt: number; sequence: number }>(browser, session, 'networkCursor', [], exec.signal)
|
|
2869
|
+
// Batched code holds back the triggering action until the cursor is captured.
|
|
2870
|
+
;(exec as { armed?: () => void }).armed?.()
|
|
2347
2871
|
const budget = Math.min(args.timeoutMs ?? 15_000, maxWaitMs)
|
|
2348
2872
|
const found = await poll(async () => {
|
|
2349
2873
|
const current = await probe<{ startedAt: number; sequence: number }>(browser, session, 'networkCursor', [], exec.signal)
|
|
@@ -2877,12 +3401,319 @@ export function apply(ctx: Context, config: Config = {}): void {
|
|
|
2877
3401
|
async execute(_args, exec) {
|
|
2878
3402
|
const browser = ctx.get('browser')
|
|
2879
3403
|
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
2880
|
-
const
|
|
3404
|
+
const key = taskKey(exec)
|
|
3405
|
+
const session = await ensureSession(browser, state, key, agentOf(exec))
|
|
2881
3406
|
await installProbe(browser, session, exec.signal)
|
|
2882
3407
|
const summary = await probe<ProbeRow>(browser, session, 'summary', [], exec.signal)
|
|
2883
3408
|
return { summary }
|
|
2884
3409
|
},
|
|
2885
3410
|
}))
|
|
3411
|
+
|
|
3412
|
+
registerSafely(defineTool({
|
|
3413
|
+
name: 'dsh_browser_reference_capture',
|
|
3414
|
+
description: 'Capture what the human has selected in the shared-browser page as a durable reference, so it can be quoted and found again later. The reference keeps the selected text with enough surrounding context to relocate it, any images selected with their real bytes, and any table as a structural snapshot. Tool-only captures are stored for later dsh_browser_reference_reveal or export and do not create a chat capsule; do not emit dsh-browser-ref: URIs, reference markers, or synthetic source links in the reply. Re-capturing the same region creates a NEW reference, because a stored reference is an immutable snapshot.',
|
|
3415
|
+
parameters: {
|
|
3416
|
+
allowPartial: { type: 'boolean', description: 'Commit the fragments that succeeded when another fragment failed (default false: a group with a broken image or oversized table is refused as a whole).' },
|
|
3417
|
+
tableSelector: { type: 'string', description: 'Capture this table whole (CSS selector) even when the selection does not touch it.' },
|
|
3418
|
+
excerptText: { type: 'string', description: 'With no live selection, register the first occurrence of this exact page text as an agent excerpt. Two occurrences make it ambiguous and are refused.' },
|
|
3419
|
+
},
|
|
3420
|
+
output: {
|
|
3421
|
+
schema: {
|
|
3422
|
+
type: 'object',
|
|
3423
|
+
additionalProperties: false,
|
|
3424
|
+
properties: {
|
|
3425
|
+
ok: { type: 'boolean', required: true },
|
|
3426
|
+
referenceId: { type: 'string' },
|
|
3427
|
+
pageUrl: { type: 'string' },
|
|
3428
|
+
title: { type: 'string' },
|
|
3429
|
+
parts: {
|
|
3430
|
+
type: 'array',
|
|
3431
|
+
required: true,
|
|
3432
|
+
items: {
|
|
3433
|
+
type: 'object',
|
|
3434
|
+
additionalProperties: false,
|
|
3435
|
+
properties: {
|
|
3436
|
+
partId: { type: 'string', required: true },
|
|
3437
|
+
type: { type: 'string', required: true },
|
|
3438
|
+
preview: { type: 'string', required: true },
|
|
3439
|
+
},
|
|
3440
|
+
},
|
|
3441
|
+
},
|
|
3442
|
+
failures: {
|
|
3443
|
+
type: 'array',
|
|
3444
|
+
required: true,
|
|
3445
|
+
items: {
|
|
3446
|
+
type: 'object',
|
|
3447
|
+
additionalProperties: false,
|
|
3448
|
+
properties: {
|
|
3449
|
+
kind: { type: 'string', required: true },
|
|
3450
|
+
reason: { type: 'string', required: true },
|
|
3451
|
+
},
|
|
3452
|
+
},
|
|
3453
|
+
},
|
|
3454
|
+
},
|
|
3455
|
+
},
|
|
3456
|
+
render: (_args, value) => {
|
|
3457
|
+
if (value.ok !== true) {
|
|
3458
|
+
const reasons = value.failures.map(failure => `${failure.kind}: ${failure.reason}`).join('; ')
|
|
3459
|
+
return [{ type: 'text', text: `Nothing was captured. ${reasons}` }]
|
|
3460
|
+
}
|
|
3461
|
+
const lines = [
|
|
3462
|
+
`Reference ${value.referenceId} captured from ${value.title !== undefined && value.title !== '' ? value.title : value.pageUrl}.`,
|
|
3463
|
+
'Stored in the reference library for dsh_browser_reference_reveal or export (tool-only captures do not create a chat capsule). Do not emit dsh-browser-ref: URIs or reference markers in the reply.',
|
|
3464
|
+
...value.parts.map(part => ` ${part.partId} (${part.type}): ${part.preview}`),
|
|
3465
|
+
]
|
|
3466
|
+
if (value.failures.length > 0) lines.push(`(${value.failures.length} fragment(s) failed and were left out: ${value.failures.map(failure => failure.reason).join('; ')})`)
|
|
3467
|
+
return [{ type: 'text', text: lines.join('\n') }]
|
|
3468
|
+
},
|
|
3469
|
+
},
|
|
3470
|
+
timeoutMs,
|
|
3471
|
+
isConcurrencySafe: () => false,
|
|
3472
|
+
async execute(args, exec) {
|
|
3473
|
+
const browser = ctx.get('browser')
|
|
3474
|
+
if (browser === undefined) throw new Error('tool-browser: browser service unavailable')
|
|
3475
|
+
const session = await ensureSession(browser, state, taskKey(exec), agentOf(exec))
|
|
3476
|
+
const outcome = await references().capture({
|
|
3477
|
+
// The DSH session owns the reference; the provider session holds the page. They are
|
|
3478
|
+
// different ids, and reveal needs the second one even after the first is long gone.
|
|
3479
|
+
sessionId: taskKey(exec),
|
|
3480
|
+
browserSessionId: session,
|
|
3481
|
+
origin: args.excerptText !== undefined ? 'agent-excerpt' : 'user-selection',
|
|
3482
|
+
entry: 'agent-tool',
|
|
3483
|
+
carrier: state.panelUrlByTask.has(taskKey(exec)) ? 'sidebar' : referenceCarrier(),
|
|
3484
|
+
...args.allowPartial !== undefined ? { allowPartial: args.allowPartial } : {},
|
|
3485
|
+
...args.tableSelector !== undefined ? { tableSelector: args.tableSelector } : {},
|
|
3486
|
+
...args.excerptText !== undefined ? { excerptText: args.excerptText } : {},
|
|
3487
|
+
}, exec.signal)
|
|
3488
|
+
const failures = outcome.failures.map(failure => ({ kind: failure.kind, reason: failure.reason }))
|
|
3489
|
+
if (outcome.reference === undefined) return { ok: false, parts: [], failures }
|
|
3490
|
+
const summary = summarizeReference(outcome.reference)
|
|
3491
|
+
return {
|
|
3492
|
+
ok: true,
|
|
3493
|
+
referenceId: summary.referenceId,
|
|
3494
|
+
pageUrl: summary.pageUrl,
|
|
3495
|
+
title: summary.title,
|
|
3496
|
+
// The summary's arrays are readonly; the schema declares a mutable array,
|
|
3497
|
+
// so the parts are projected into plain objects rather than cast away.
|
|
3498
|
+
parts: summary.parts.map(part => ({ partId: part.partId, type: part.type, preview: part.preview })),
|
|
3499
|
+
failures,
|
|
3500
|
+
}
|
|
3501
|
+
},
|
|
3502
|
+
}))
|
|
3503
|
+
|
|
3504
|
+
registerSafely(defineTool({
|
|
3505
|
+
name: 'dsh_browser_reference_reveal',
|
|
3506
|
+
description: 'Return to a stored browser reference: select the browser session that captured it, verify the page is still the same one, then scroll to and highlight the part. Without partId the reference\'s first part is located; pass a partId to locate one specific fragment. A result status of page-mismatch means the session is showing another page (open the stored pageUrl first); ambiguous means several candidates matched equally and the exact one cannot be chosen; session-unavailable means the browser that captured it is gone.',
|
|
3507
|
+
parameters: {
|
|
3508
|
+
referenceId: { type: 'string', required: true, description: 'The reference id, with or without the dsh-browser-ref: prefix.' },
|
|
3509
|
+
partId: { type: 'string', description: 'Locate this fragment instead of the whole reference\'s first part.' },
|
|
3510
|
+
},
|
|
3511
|
+
output: {
|
|
3512
|
+
schema: {
|
|
3513
|
+
type: 'object',
|
|
3514
|
+
additionalProperties: false,
|
|
3515
|
+
properties: {
|
|
3516
|
+
status: { type: 'string', required: true },
|
|
3517
|
+
pageUrl: { type: 'string', required: true },
|
|
3518
|
+
currentUrl: { type: 'string' },
|
|
3519
|
+
note: { type: 'string' },
|
|
3520
|
+
parts: {
|
|
3521
|
+
type: 'array',
|
|
3522
|
+
required: true,
|
|
3523
|
+
items: {
|
|
3524
|
+
type: 'object',
|
|
3525
|
+
additionalProperties: false,
|
|
3526
|
+
properties: {
|
|
3527
|
+
partId: { type: 'string', required: true },
|
|
3528
|
+
type: { type: 'string', required: true },
|
|
3529
|
+
status: { type: 'string', required: true },
|
|
3530
|
+
matches: { type: 'number' },
|
|
3531
|
+
collapsed: { type: 'boolean' },
|
|
3532
|
+
note: { type: 'string' },
|
|
3533
|
+
},
|
|
3534
|
+
},
|
|
3535
|
+
},
|
|
3536
|
+
},
|
|
3537
|
+
},
|
|
3538
|
+
render: (_args, value) => {
|
|
3539
|
+
const head = value.status === 'revealed'
|
|
3540
|
+
? 'Located the reference in the page.'
|
|
3541
|
+
: `Could not locate the reference: ${value.status}${value.note !== undefined ? ` — ${value.note}` : ''}`
|
|
3542
|
+
const lines = [head, ...value.parts.map(part => ` ${part.partId} (${part.type}): ${part.status}${part.matches !== undefined ? `, ${part.matches} match(es)` : ''}${part.collapsed === true ? ', whitespace-collapsed' : ''}${part.note !== undefined ? ` — ${part.note}` : ''}`)]
|
|
3543
|
+
return [{ type: 'text', text: lines.join('\n') }]
|
|
3544
|
+
},
|
|
3545
|
+
},
|
|
3546
|
+
timeoutMs,
|
|
3547
|
+
isConcurrencySafe: () => false,
|
|
3548
|
+
async execute(args, exec) {
|
|
3549
|
+
// The documented citation form is `dsh-browser-ref:<referenceId>/<partId?>`; accept it
|
|
3550
|
+
// whole so a model can paste what it wrote instead of splitting the id by hand.
|
|
3551
|
+
let referenceId = args.referenceId.startsWith('dsh-browser-ref:') ? args.referenceId.slice('dsh-browser-ref:'.length) : args.referenceId
|
|
3552
|
+
let partId = args.partId
|
|
3553
|
+
const slash = referenceId.indexOf('/')
|
|
3554
|
+
if (slash !== -1) {
|
|
3555
|
+
if (partId === undefined) partId = referenceId.slice(slash + 1)
|
|
3556
|
+
referenceId = referenceId.slice(0, slash)
|
|
3557
|
+
}
|
|
3558
|
+
const outcome = await references().reveal(referenceId, {
|
|
3559
|
+
ownerSessionId: taskKey(exec),
|
|
3560
|
+
...partId !== undefined && partId !== '' ? { partId } : {},
|
|
3561
|
+
}, exec.signal)
|
|
3562
|
+
return {
|
|
3563
|
+
status: outcome.status,
|
|
3564
|
+
pageUrl: outcome.pageUrl,
|
|
3565
|
+
...outcome.currentUrl !== undefined ? { currentUrl: outcome.currentUrl } : {},
|
|
3566
|
+
...outcome.note !== undefined ? { note: outcome.note } : {},
|
|
3567
|
+
parts: outcome.parts.map(part => ({
|
|
3568
|
+
partId: part.partId,
|
|
3569
|
+
type: part.type,
|
|
3570
|
+
status: part.status,
|
|
3571
|
+
...part.matches !== undefined ? { matches: part.matches } : {},
|
|
3572
|
+
...part.collapsed !== undefined ? { collapsed: part.collapsed } : {},
|
|
3573
|
+
...part.note !== undefined ? { note: part.note } : {},
|
|
3574
|
+
})),
|
|
3575
|
+
}
|
|
3576
|
+
},
|
|
3577
|
+
}))
|
|
3578
|
+
|
|
3579
|
+
registerSafely(defineTool({
|
|
3580
|
+
name: 'dsh_browser_reference_list',
|
|
3581
|
+
description: 'List the browser references stored for this task, newest first: id, page, capture time, and one preview line per fragment. Use it to identify a reference from earlier in the conversation. Source navigation is provided by reference capsules; do not repeat reference URIs, source URLs, markers, or source/citation links in the reply.',
|
|
3582
|
+
parameters: {
|
|
3583
|
+
limit: { type: 'number', description: 'Most references to return (default 20, maximum 100).' },
|
|
3584
|
+
},
|
|
3585
|
+
output: {
|
|
3586
|
+
schema: {
|
|
3587
|
+
type: 'object',
|
|
3588
|
+
additionalProperties: false,
|
|
3589
|
+
properties: {
|
|
3590
|
+
references: {
|
|
3591
|
+
type: 'array',
|
|
3592
|
+
required: true,
|
|
3593
|
+
items: {
|
|
3594
|
+
type: 'object',
|
|
3595
|
+
additionalProperties: false,
|
|
3596
|
+
properties: {
|
|
3597
|
+
referenceId: { type: 'string', required: true },
|
|
3598
|
+
title: { type: 'string', required: true },
|
|
3599
|
+
pageUrl: { type: 'string', required: true },
|
|
3600
|
+
capturedAt: { type: 'string', required: true },
|
|
3601
|
+
carrier: { type: 'string', required: true },
|
|
3602
|
+
origin: { type: 'string', required: true },
|
|
3603
|
+
entry: { type: 'string', required: true },
|
|
3604
|
+
partCount: { type: 'number', required: true },
|
|
3605
|
+
parts: {
|
|
3606
|
+
type: 'array',
|
|
3607
|
+
required: true,
|
|
3608
|
+
items: {
|
|
3609
|
+
type: 'object',
|
|
3610
|
+
additionalProperties: false,
|
|
3611
|
+
properties: {
|
|
3612
|
+
partId: { type: 'string', required: true },
|
|
3613
|
+
type: { type: 'string', required: true },
|
|
3614
|
+
preview: { type: 'string', required: true },
|
|
3615
|
+
},
|
|
3616
|
+
},
|
|
3617
|
+
},
|
|
3618
|
+
},
|
|
3619
|
+
},
|
|
3620
|
+
},
|
|
3621
|
+
},
|
|
3622
|
+
},
|
|
3623
|
+
render: (_args, value) => {
|
|
3624
|
+
if (value.references.length === 0) return [{ type: 'text', text: 'No browser references are stored for this task.' }]
|
|
3625
|
+
return [{
|
|
3626
|
+
type: 'text',
|
|
3627
|
+
text: value.references.map(reference => [
|
|
3628
|
+
`Reference ${reference.referenceId} — ${reference.title !== '' ? reference.title : reference.pageUrl} (${reference.capturedAt}); source navigation is in its capsule, not a reply link.`,
|
|
3629
|
+
...reference.parts.map(part => ` ${part.partId} (${part.type}): ${part.preview}`),
|
|
3630
|
+
].join('\n')).join('\n\n'),
|
|
3631
|
+
}]
|
|
3632
|
+
},
|
|
3633
|
+
},
|
|
3634
|
+
timeoutMs,
|
|
3635
|
+
isConcurrencySafe: () => true,
|
|
3636
|
+
async execute(args, exec) {
|
|
3637
|
+
const key = taskKey(exec)
|
|
3638
|
+
const limit = Math.min(Math.max(Math.trunc(args.limit ?? 20), 1), 100)
|
|
3639
|
+
// Always scoped: with no agent the key is `default`, and an unfiltered read
|
|
3640
|
+
// would hand this task every conversation's references.
|
|
3641
|
+
const stored = references().list({ sessionId: key, limit })
|
|
3642
|
+
return {
|
|
3643
|
+
references: stored.slice().reverse().map(reference => {
|
|
3644
|
+
const summary = summarizeReference(reference)
|
|
3645
|
+
return {
|
|
3646
|
+
referenceId: summary.referenceId,
|
|
3647
|
+
title: summary.title,
|
|
3648
|
+
pageUrl: summary.pageUrl,
|
|
3649
|
+
capturedAt: summary.capturedAt,
|
|
3650
|
+
carrier: summary.carrier,
|
|
3651
|
+
origin: summary.origin,
|
|
3652
|
+
entry: summary.entry,
|
|
3653
|
+
partCount: summary.partCount,
|
|
3654
|
+
parts: summary.parts.map(part => ({ partId: part.partId, type: part.type, preview: part.preview })),
|
|
3655
|
+
}
|
|
3656
|
+
}),
|
|
3657
|
+
}
|
|
3658
|
+
},
|
|
3659
|
+
}))
|
|
3660
|
+
|
|
3661
|
+
// Under DSH's PTC executor run_code already batches every tool, so the code tool steps aside.
|
|
3662
|
+
const ptcMode = (): boolean => {
|
|
3663
|
+
try { return (ctx as { get?: (name: string) => unknown }).get?.('ptcRuntime') !== undefined } catch { return false }
|
|
3664
|
+
}
|
|
3665
|
+
if (surface !== 'tools') {
|
|
3666
|
+
try {
|
|
3667
|
+
const code = createCodeTool(catalog)
|
|
3668
|
+
// Registration options (`when`) arrived with DSH 0.2.2; older registries ignore them.
|
|
3669
|
+
// On the code surface it is the only browser tool, so it stays even under PTC.
|
|
3670
|
+
;(ctx.tools.register as (tool: unknown, options?: { when: () => boolean }) => unknown)(code.tool, surface === 'core' ? { when: () => !ptcMode() } : undefined)
|
|
3671
|
+
ctx.effect(() => code.dispose)
|
|
3672
|
+
} catch (error) {
|
|
3673
|
+
ctx.logger?.warn?.(`dsh-builtin-browser: could not register ${CODE_TOOL} (${String(error)}).`)
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3676
|
+
if (surface === 'core') {
|
|
3677
|
+
const grouped = new Set(Object.values(TOOL_GROUPS).flat())
|
|
3678
|
+
const members = (group: string): string[] => group === 'more'
|
|
3679
|
+
? [...catalog.keys()].filter(name => !CORE_TOOLS.has(name) && !grouped.has(name)).sort()
|
|
3680
|
+
: (TOOL_GROUPS[group] ?? []).filter(name => catalog.has(name))
|
|
3681
|
+
try {
|
|
3682
|
+
const loader = defineTool({
|
|
3683
|
+
name: LOAD_TOOL,
|
|
3684
|
+
description: `Load more browser tools by group; they stay available for the rest of the run. Groups: ${Object.entries(TOOL_GROUPS).map(([group, names]) => `${group} (${group === 'more' ? 'every other browser tool' : names.map(name => name.slice('dsh_browser_'.length)).join(', ')})`).join('; ')}. dsh_browser_code can already call every tool without loading it.`,
|
|
3685
|
+
parameters: {
|
|
3686
|
+
groups: { type: 'array', items: { type: 'string', enum: Object.keys(TOOL_GROUPS) }, required: true, description: 'Groups to load.' },
|
|
3687
|
+
},
|
|
3688
|
+
output: {
|
|
3689
|
+
schema: { type: 'object', additionalProperties: false, properties: {
|
|
3690
|
+
loaded: { type: 'array', items: { type: 'string' }, required: true },
|
|
3691
|
+
available: { type: 'array', items: { type: 'string' }, required: true },
|
|
3692
|
+
} },
|
|
3693
|
+
render: (_args, value) => [{ type: 'text', text: value.loaded.length > 0 ? `Loaded: ${value.loaded.join(', ')}.` : `Already loaded: ${value.available.join(', ')}.` }],
|
|
3694
|
+
},
|
|
3695
|
+
isConcurrencySafe: () => false,
|
|
3696
|
+
async execute(args) {
|
|
3697
|
+
const groups = Array.isArray(args.groups) ? args.groups.map(String) : []
|
|
3698
|
+
const unknown = groups.filter(group => !(group in TOOL_GROUPS))
|
|
3699
|
+
if (groups.length === 0 || unknown.length > 0) throw new Error(`unknown tool group(s): ${unknown.join(', ') || '(none given)'}; groups are ${Object.keys(TOOL_GROUPS).join(', ')}`)
|
|
3700
|
+
const names = [...new Set(groups.flatMap(members))]
|
|
3701
|
+
const fresh: string[] = []
|
|
3702
|
+
for (const name of names) {
|
|
3703
|
+
const definition = catalog.get(name)
|
|
3704
|
+
if (definition === undefined || loaded.has(name)) continue
|
|
3705
|
+
ctx.tools.register(definition as unknown as ReturnType<typeof defineTool>)
|
|
3706
|
+
loaded.add(name)
|
|
3707
|
+
fresh.push(name)
|
|
3708
|
+
}
|
|
3709
|
+
return { loaded: fresh, available: names }
|
|
3710
|
+
},
|
|
3711
|
+
})
|
|
3712
|
+
ctx.tools.register(loader)
|
|
3713
|
+
} catch (error) {
|
|
3714
|
+
ctx.logger?.warn?.(`dsh-builtin-browser: could not register ${LOAD_TOOL} (${String(error)}).`)
|
|
3715
|
+
}
|
|
3716
|
+
}
|
|
2886
3717
|
}
|
|
2887
3718
|
|
|
2888
3719
|
/** Test hook: inspect and reset session mappings across every live plugin apply. */
|