dsh-builtin-browser 1.0.1 → 1.0.3
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 +55 -0
- package/README.md +1 -1
- package/assets/browser-panel-locales.mjs +37 -5
- package/assets/browser-policy.d.mts +29 -0
- package/assets/browser-policy.mjs +40 -0
- package/desktop-bridge/desktop-discovery.d.mts +1 -1
- package/desktop-bridge/desktop-discovery.mjs +59 -9
- package/desktop-bridge/desktop-identity.json +12 -0
- package/desktop-bridge/install.mjs +14 -7
- package/desktop-bridge/plugin-browser-bridge.js +19 -7
- package/docs/acceptance-2026-11-27.md +67 -0
- package/docs/architecture.md +1 -1
- package/docs/development.md +33 -4
- package/docs/dsh-0.2.3-host-patch-task.md +34 -0
- package/docs/hardcoding-audit.md +28 -8
- package/docs/known-issues.md +26 -0
- package/docs/limitations.md +6 -2
- package/docs/tool-reference.md +1 -1
- package/docs/v1.1.0-bu-data-batching-task.md +66 -0
- package/docs/v1.1.0-compat-hardcoding-task.md +85 -0
- package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
- package/dsh-builtin-browser-1.0.3.tgz +0 -0
- package/dsh-host-patch/README.md +4 -0
- package/dsh-host-patch/apply.mjs +61 -13
- package/dsh-host-patch/rc3-revision9.json.gz +0 -0
- package/dsh-host-patch/rc5-revision9.json.gz +0 -0
- package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/manifest.json +218 -0
- package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/series.json +260 -0
- package/dsh-host-patch/tauri/desktop-main.cjs +62 -0
- package/dsh-host-patch/tauri/sidebar-session.cjs +104 -0
- package/dsh-host-patch/tauri-revision1.json +39 -0
- package/dsh-host-patch/tauri.json +43 -0
- package/dsh-host-patch/v023-alpha2.json +153 -0
- package/lib/browser/anti-bot.js +215 -0
- package/lib/browser/deep-dom.js +39 -0
- package/lib/browser/runtime.js +15 -0
- package/lib/browser/takeover-target.js +13 -6
- package/lib/browser/types.js +30 -1
- package/lib/browser-electron/authenticated-route.js +16 -2
- package/lib/browser-electron/automatic-maintenance.js +16 -10
- package/lib/browser-electron/bridge-connection.js +3 -8
- package/lib/browser-electron/bridge-install.js +2 -1
- package/lib/browser-electron/bridge-status.js +55 -26
- package/lib/browser-electron/desktop-bridge-host.js +7 -6
- package/lib/browser-electron/desktop-identity.js +28 -5
- package/lib/browser-electron/desktop-shell.js +64 -0
- package/lib/browser-electron/electron-provision.js +105 -18
- package/lib/browser-electron/entry.js +129 -44
- package/lib/browser-electron/extension-browser.js +4 -4
- package/lib/browser-electron/foreground-watch.js +134 -0
- package/lib/browser-electron/guest-cookie-jar.js +13 -13
- package/lib/browser-electron/guest-route.js +181 -32
- package/lib/browser-electron/guest-runtime.js +61 -10
- package/lib/browser-electron/guest-storage.js +2 -2
- package/lib/browser-electron/history-store.js +1 -5
- package/lib/browser-electron/host-main.js +8 -4
- package/lib/browser-electron/host-patch-maintenance.js +14 -8
- package/lib/browser-electron/maintenance-route.js +2 -1
- package/lib/browser-electron/missing-system-browser.js +5 -9
- package/lib/browser-electron/preferred-browser.js +7 -3
- package/lib/browser-electron/preview-route.js +9 -13
- package/lib/browser-electron/process-ownership.js +1 -1
- package/lib/browser-electron/profile-command.js +2 -1
- package/lib/browser-electron/profile-extension.js +5 -0
- package/lib/browser-electron/profile-lease.js +152 -47
- package/lib/browser-electron/provider-core.js +527 -0
- package/lib/browser-electron/provider-interaction.js +963 -0
- package/lib/browser-electron/provider-media.js +518 -0
- package/lib/browser-electron/provider-navigation.js +301 -0
- package/lib/browser-electron/provider-observation.js +623 -0
- package/lib/browser-electron/provider-tabs.js +372 -0
- package/lib/browser-electron/provider.js +150 -3301
- package/lib/browser-electron/reference-route.js +9 -18
- package/lib/browser-electron/remote-host.js +79 -34
- package/lib/browser-electron/runtime-status.js +56 -6
- package/lib/browser-electron/settings-store.js +3 -6
- package/lib/browser-electron/sidebar-only-host.js +1 -1
- package/lib/browser-electron/system-browser.js +539 -172
- package/lib/browser-electron/tauri-host.js +208 -0
- package/lib/browser-electron/virtual-cursor.js +23 -13
- package/lib/browser-reference/service.js +22 -4
- package/lib/browser-reference/web-sources.js +1 -1
- package/lib/client.js +43409 -0
- package/lib/compat/host-features.js +75 -0
- package/lib/reference-source.js +1 -1
- package/lib/reference-text.js +23 -1
- package/lib/takeover-protocol.js +1 -1
- package/lib/tool-browser/block-recovery.js +69 -0
- package/lib/tool-browser/code-tool.js +170 -19
- package/lib/tool-browser/code-worker.js +115 -20
- package/lib/tool-browser/errors.js +34 -0
- package/lib/tool-browser/index.js +66 -3593
- package/lib/tool-browser/page-probe.js +227 -28
- package/lib/tool-browser/panel-page.js +2 -1
- package/lib/tool-browser/probe-client.js +157 -0
- package/lib/tool-browser/screenshot-annotations.js +108 -0
- package/lib/tool-browser/state.js +337 -0
- package/lib/tool-browser/takeover.js +1 -1
- package/lib/tool-browser/tools-debug.js +862 -0
- package/lib/tool-browser/tools-interaction.js +993 -0
- package/lib/tool-browser/tools-navigation.js +807 -0
- package/lib/tool-browser/tools-observation.js +461 -0
- package/lib/tool-browser/tools-reference.js +293 -0
- package/lib/web-guest.js +1 -0
- package/package.json +15 -53
- package/README.en.md +0 -89
- package/browser-extension/constants.mjs +0 -20
- package/browser-extension/controller.mjs +0 -293
- package/browser-extension/locales.mjs +0 -15
- package/browser-extension/manifest.json +0 -12
- package/browser-extension/options.html +0 -14
- package/browser-extension/options.mjs +0 -9
- package/browser-extension/permission-guard.mjs +0 -13
- package/browser-extension/worker.mjs +0 -74
- package/dist/client.cjs +0 -43167
- package/lib/browser-reference/submission-receipts.js +0 -139
- package/scripts/build.mjs +0 -66
- package/scripts/bundle-host.mjs +0 -28
- package/scripts/fix-exports.mjs +0 -50
- package/scripts/install-electron.mjs +0 -51
- package/scripts/verify-exports.mjs +0 -47
- package/scripts/verify-preview-sdk.mjs +0 -93
- package/skills/dsh-builtin-browser/SKILL.md +0 -73
- package/skills/dsh-builtin-browser/references/batch.md +0 -53
- package/skills/dsh-builtin-browser/references/deliver.md +0 -31
- package/skills/dsh-builtin-browser/references/locate.md +0 -11
- package/skills/dsh-builtin-browser/references/recover.md +0 -11
- package/skills/dsh-builtin-browser/references/verify.md +0 -13
- package/skills/dsh-debug-host/SKILL.md +0 -56
- package/skills/dsh-debug-self/SKILL.md +0 -50
- package/src/bridge-compatibility.ts +0 -39
- package/src/browser/handles.ts +0 -89
- package/src/browser/runtime.ts +0 -560
- package/src/browser/takeover-target.ts +0 -36
- package/src/browser/types.ts +0 -817
- package/src/browser-electron/authenticated-route.ts +0 -84
- package/src/browser-electron/automatic-maintenance.ts +0 -726
- package/src/browser-electron/bridge-auto.ts +0 -159
- package/src/browser-electron/bridge-connection.ts +0 -385
- package/src/browser-electron/bridge-endpoint.ts +0 -129
- package/src/browser-electron/bridge-install.ts +0 -289
- package/src/browser-electron/bridge-maintenance.ts +0 -189
- package/src/browser-electron/bridge-status.ts +0 -347
- package/src/browser-electron/desktop-bridge-host.ts +0 -251
- package/src/browser-electron/desktop-identity.ts +0 -320
- package/src/browser-electron/document-readiness.ts +0 -45
- package/src/browser-electron/electron-provision.ts +0 -261
- package/src/browser-electron/entry.ts +0 -1299
- package/src/browser-electron/ephemeral-profile.ts +0 -189
- package/src/browser-electron/extension-browser.ts +0 -223
- package/src/browser-electron/extension-setup.ts +0 -67
- package/src/browser-electron/file-write.ts +0 -31
- package/src/browser-electron/guest-cookie-jar.ts +0 -176
- package/src/browser-electron/guest-cookie-store.ts +0 -59
- package/src/browser-electron/guest-css-runtime.ts +0 -76
- package/src/browser-electron/guest-css.ts +0 -68
- package/src/browser-electron/guest-route.ts +0 -568
- package/src/browser-electron/guest-runtime.ts +0 -357
- package/src/browser-electron/guest-storage-runtime.ts +0 -54
- package/src/browser-electron/guest-storage.ts +0 -117
- package/src/browser-electron/history-store.ts +0 -227
- package/src/browser-electron/host-main.ts +0 -1381
- package/src/browser-electron/host-patch-maintenance.ts +0 -112
- package/src/browser-electron/http-body.ts +0 -65
- package/src/browser-electron/json-reply.ts +0 -47
- package/src/browser-electron/maintenance-broker.ts +0 -166
- package/src/browser-electron/maintenance-lifecycle.ts +0 -91
- package/src/browser-electron/maintenance-route.ts +0 -67
- package/src/browser-electron/missing-system-browser.ts +0 -113
- package/src/browser-electron/open-slot.ts +0 -49
- package/src/browser-electron/paths.ts +0 -25
- package/src/browser-electron/preferred-browser.ts +0 -120
- package/src/browser-electron/preview-route.ts +0 -218
- package/src/browser-electron/process-ownership.ts +0 -168
- package/src/browser-electron/process.ts +0 -23
- package/src/browser-electron/profile-checkpoint.ts +0 -187
- package/src/browser-electron/profile-command.ts +0 -46
- package/src/browser-electron/profile-extension.ts +0 -124
- package/src/browser-electron/profile-lease.ts +0 -115
- package/src/browser-electron/profile-residue.ts +0 -49
- package/src/browser-electron/provider.ts +0 -4571
- package/src/browser-electron/reference-route.ts +0 -608
- package/src/browser-electron/remote-host.ts +0 -1462
- package/src/browser-electron/rpc-input.ts +0 -13
- package/src/browser-electron/rpc-ops.ts +0 -41
- package/src/browser-electron/runtime-diagnostics.ts +0 -38
- package/src/browser-electron/runtime-route.ts +0 -105
- package/src/browser-electron/runtime-status.ts +0 -242
- package/src/browser-electron/settings-route.ts +0 -64
- package/src/browser-electron/settings-store.ts +0 -589
- package/src/browser-electron/shortcuts-route.ts +0 -112
- package/src/browser-electron/sidebar-only-host.ts +0 -298
- package/src/browser-electron/startpage-shortcuts.ts +0 -213
- package/src/browser-electron/system-browser.ts +0 -1497
- package/src/browser-electron/timing.ts +0 -16
- package/src/browser-electron/virtual-cursor.ts +0 -152
- package/src/browser-electron/windows-system.ts +0 -24
- package/src/browser-reference/delivery.ts +0 -384
- package/src/browser-reference/entry.ts +0 -631
- package/src/browser-reference/export.ts +0 -339
- package/src/browser-reference/import.ts +0 -303
- package/src/browser-reference/page-script.ts +0 -1537
- package/src/browser-reference/service.ts +0 -1315
- package/src/browser-reference/store.ts +0 -172
- package/src/browser-reference/submission-receipts.ts +0 -122
- package/src/browser-reference/text-quote.ts +0 -219
- package/src/browser-reference/types.ts +0 -195
- package/src/browser-reference/visible.ts +0 -367
- package/src/browser-reference/web-sources.ts +0 -103
- package/src/client/browser/BrowserController.ts +0 -693
- package/src/client/browser/BrowserFrame.ts +0 -78
- package/src/client/browser/BrowserNavigation.ts +0 -169
- package/src/client/browser/BrowserPage.ts +0 -23
- package/src/client/browser/BrowserPersistence.ts +0 -44
- package/src/client/browser/IframeImpl.ts +0 -176
- package/src/client/browser/child-tabs.ts +0 -14
- package/src/client/browser/iframe-reference.ts +0 -67
- package/src/client/browser/initialization.ts +0 -262
- package/src/client/browser/omnibox.ts +0 -243
- package/src/client/browser/store.ts +0 -38
- package/src/client/browser/takeover-channel.ts +0 -72
- package/src/client/browser/url.ts +0 -46
- package/src/client/browser/web-reference-source.ts +0 -52
- package/src/client/css-modules.d.ts +0 -4
- package/src/client/definition.tsx +0 -30
- package/src/client/electron/ElectronWebViewImpl.ts +0 -364
- package/src/client/electron/ElectronWebviewPresentation.ts +0 -138
- package/src/client/electron/NativeChildPresentation.ts +0 -45
- package/src/client/electron/NativeViewPage.ts +0 -251
- package/src/client/electron/pages.ts +0 -23
- package/src/client/electron/reference-overlay.ts +0 -53
- package/src/client/electron/workspace.ts +0 -33
- package/src/client/index.ts +0 -293
- package/src/client/locales.ts +0 -857
- package/src/client/pages.ts +0 -28
- package/src/client/reference/client/BrowserRefLink.tsx +0 -142
- package/src/client/reference/client/draft-reference.ts +0 -167
- package/src/client/reference/client/index.ts +0 -7
- package/src/client/reference/client/ordered-submission.ts +0 -108
- package/src/client/reference/client/pending-delivery.ts +0 -216
- package/src/client/reference/client/plugin.ts +0 -189
- package/src/client/reference/client/production/ReferenceCapsules.tsx +0 -345
- package/src/client/reference/client/production/ReferenceDock.module.css +0 -193
- package/src/client/reference/client/production/ReferenceDock.tsx +0 -6
- package/src/client/reference/client/production/ReferenceFeedback.tsx +0 -15
- package/src/client/reference/client/production/ReferenceMath.tsx +0 -44
- package/src/client/reference/client/production/ReferenceText.tsx +0 -36
- package/src/client/reference/client/production/assembly.ts +0 -471
- package/src/client/reference/client/production/asset-store.ts +0 -144
- package/src/client/reference/client/production/availability.ts +0 -74
- package/src/client/reference/client/production/bytes.ts +0 -36
- package/src/client/reference/client/production/delivery-client.ts +0 -211
- package/src/client/reference/client/production/draft-adapter.ts +0 -508
- package/src/client/reference/client/production/http-transport.ts +0 -217
- package/src/client/reference/client/production/production-submission.ts +0 -310
- package/src/client/reference/client/production/protocol.ts +0 -231
- package/src/client/reference/client/production/reference-card.ts +0 -240
- package/src/client/reference/client/production/reference-labels.ts +0 -29
- package/src/client/reference/client/production/reply-link-bridge.ts +0 -222
- package/src/client/reference/client/production/reveal.ts +0 -215
- package/src/client/reference/client/production/runtime.ts +0 -1101
- package/src/client/reference/client/production/snapshot-adapter.ts +0 -154
- package/src/client/reference/client/production/source-marker.ts +0 -63
- package/src/client/reference/client/production/source-opener.ts +0 -55
- package/src/client/reference/client/production/styles.ts +0 -104
- package/src/client/reference/client/production/user-text-rule.ts +0 -58
- package/src/client/reference/client/reveal.ts +0 -107
- package/src/client/reference/client/scheme.ts +0 -114
- package/src/client/reference/client/types.ts +0 -168
- package/src/client/reference/css-modules.d.ts +0 -4
- package/src/client/reference/index.ts +0 -11
- package/src/client/reference-capture-owner.ts +0 -162
- package/src/client/reference-intents.ts +0 -36
- package/src/client/settings/index.ts +0 -34
- package/src/client/settings/panel.ts +0 -2657
- package/src/client/shortcut-open.ts +0 -30
- package/src/client/startpage/binding.ts +0 -99
- package/src/client/startpage/controller.ts +0 -303
- package/src/client/startpage/model.ts +0 -279
- package/src/client/view/Browser.module.css +0 -751
- package/src/client/view/BrowserBody.tsx +0 -314
- package/src/client/view/BrowserPresentation.ts +0 -9
- package/src/client/view/BrowserTitle.tsx +0 -17
- package/src/client/view/IframePresentation.ts +0 -344
- package/src/client/view/StartPage.tsx +0 -597
- package/src/client/view/TakeoverBanner.tsx +0 -21
- package/src/index.ts +0 -110
- package/src/reference-owner.ts +0 -5
- package/src/reference-page.ts +0 -9
- package/src/reference-source.ts +0 -3
- package/src/reference-text.ts +0 -197
- package/src/startpage-settings.ts +0 -103
- package/src/startpage.ts +0 -71
- package/src/takeover-protocol.ts +0 -19
- package/src/tool-browser/code-tool.ts +0 -401
- package/src/tool-browser/code-worker.ts +0 -639
- package/src/tool-browser/element-fields.ts +0 -167
- package/src/tool-browser/index.ts +0 -3733
- package/src/tool-browser/page-probe.ts +0 -474
- package/src/tool-browser/panel-page.ts +0 -124
- package/src/tool-browser/screenshot-image.ts +0 -49
- package/src/tool-browser/takeover.ts +0 -198
- package/src/types/electron-shim.d.ts +0 -144
- package/src/types.ts +0 -85
- package/src/web-guest.ts +0 -34
- package/tools/accept-desktop.mjs +0 -148
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
import { createHash, randomUUID } from 'node:crypto';
|
|
2
|
-
import { referenceOwnerKey } from '../reference-owner.js';
|
|
3
|
-
import { linkSync, mkdirSync, readdirSync, readFileSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
|
-
import { join } from 'node:path';
|
|
5
|
-
import { deliveryStorePath } from './delivery.js';
|
|
6
|
-
const uuid = /^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$/i;
|
|
7
|
-
const absent = (error) => error.code === 'ENOENT';
|
|
8
|
-
function acceptedIds(event) {
|
|
9
|
-
const messages = event?.type === 'agent/inbox/spliced' ? (event.data?.inserted ?? [])
|
|
10
|
-
: event?.type === 'user/message' && event.data !== undefined ? [event.data] : [];
|
|
11
|
-
return messages.flatMap(({ source }) => source?.kind === 'user' && typeof source.rpcId === 'string' && uuid.test(source.rpcId)
|
|
12
|
-
? [source.rpcId] : []);
|
|
13
|
-
}
|
|
14
|
-
/** The HTTP client binds its frozen reference ids before sending. The Host
|
|
15
|
-
* joins that receipt to its own accepted request id, including after restart. */
|
|
16
|
-
export function createSubmissionReceipts(queue, sessionFor, root = deliveryStorePath() + '.submissions') {
|
|
17
|
-
const directory = (sessionId) => join(root, createHash('sha256').update(sessionId).digest('hex'));
|
|
18
|
-
const file = (sessionId, requestId) => join(directory(sessionId), requestId + '.json');
|
|
19
|
-
const read = (path) => {
|
|
20
|
-
try {
|
|
21
|
-
return JSON.parse(readFileSync(path, 'utf8'));
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
if (absent(error))
|
|
25
|
-
return undefined;
|
|
26
|
-
throw error;
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
const remove = (path) => {
|
|
30
|
-
try {
|
|
31
|
-
unlinkSync(path);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (!absent(error))
|
|
35
|
-
throw error;
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
const length = (session) => session.seq ?? session.events?.length ?? 0;
|
|
39
|
-
const settle = (sessionId, path, attempt) => {
|
|
40
|
-
for (const id of attempt.intentIds)
|
|
41
|
-
queue.consume(id, sessionId);
|
|
42
|
-
remove(path);
|
|
43
|
-
};
|
|
44
|
-
return {
|
|
45
|
-
bind(sessionId, requestId, ids) {
|
|
46
|
-
sessionId = referenceOwnerKey(sessionId);
|
|
47
|
-
if (!uuid.test(requestId) || ids.length === 0)
|
|
48
|
-
return false;
|
|
49
|
-
if (ids.some(id => {
|
|
50
|
-
const row = queue.get(id);
|
|
51
|
-
return row?.sessionId !== sessionId || row.state === 'consumed' || row.state === 'removed';
|
|
52
|
-
}))
|
|
53
|
-
return false;
|
|
54
|
-
const dir = directory(sessionId);
|
|
55
|
-
mkdirSync(dir, { recursive: true });
|
|
56
|
-
const path = file(sessionId, requestId);
|
|
57
|
-
const session = sessionFor(sessionId);
|
|
58
|
-
const tmp = join(dir, randomUUID() + '.tmp');
|
|
59
|
-
const attempt = { intentIds: [...new Set(ids)], offset: session === undefined ? 0 : length(session) };
|
|
60
|
-
try {
|
|
61
|
-
writeFileSync(tmp, JSON.stringify(attempt), { flag: 'wx' });
|
|
62
|
-
// Publish a complete receipt atomically; a duplicate request cannot replace it.
|
|
63
|
-
try {
|
|
64
|
-
linkSync(tmp, path);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
if (error.code !== 'EEXIST')
|
|
68
|
-
throw error;
|
|
69
|
-
return JSON.stringify(read(path)?.intentIds) === JSON.stringify(attempt.intentIds);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
finally {
|
|
73
|
-
remove(tmp);
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
},
|
|
77
|
-
observe(sessionId, event) {
|
|
78
|
-
sessionId = referenceOwnerKey(sessionId);
|
|
79
|
-
for (const id of acceptedIds(event)) {
|
|
80
|
-
const path = file(sessionId, id);
|
|
81
|
-
const attempt = read(path);
|
|
82
|
-
if (attempt !== undefined)
|
|
83
|
-
settle(sessionId, path, attempt);
|
|
84
|
-
}
|
|
85
|
-
},
|
|
86
|
-
/** Called before a session's delivery feed is exposed. If the Session is
|
|
87
|
-
* still loading, only its previously submitted cards need a retry. */
|
|
88
|
-
recover(sessionId) {
|
|
89
|
-
sessionId = referenceOwnerKey(sessionId);
|
|
90
|
-
const dir = directory(sessionId);
|
|
91
|
-
let names;
|
|
92
|
-
try {
|
|
93
|
-
names = readdirSync(dir);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
if (absent(error))
|
|
97
|
-
return [];
|
|
98
|
-
throw error;
|
|
99
|
-
}
|
|
100
|
-
const pending = new Map();
|
|
101
|
-
for (const name of names) {
|
|
102
|
-
const id = name.slice(0, -5);
|
|
103
|
-
if (!name.endsWith('.json') || !uuid.test(id))
|
|
104
|
-
continue;
|
|
105
|
-
const path = file(sessionId, id);
|
|
106
|
-
const attempt = read(path);
|
|
107
|
-
if (attempt === undefined)
|
|
108
|
-
continue;
|
|
109
|
-
if (attempt.intentIds.every(intent => {
|
|
110
|
-
const state = queue.get(intent)?.state;
|
|
111
|
-
return state === 'consumed' || state === 'removed';
|
|
112
|
-
}))
|
|
113
|
-
remove(path);
|
|
114
|
-
else
|
|
115
|
-
pending.set(id, attempt);
|
|
116
|
-
}
|
|
117
|
-
if (pending.size === 0)
|
|
118
|
-
return [];
|
|
119
|
-
const session = sessionFor(sessionId);
|
|
120
|
-
if (session === undefined)
|
|
121
|
-
return [...new Set([...pending.values()].flatMap(row => row.intentIds))];
|
|
122
|
-
const end = length(session);
|
|
123
|
-
let offset = end;
|
|
124
|
-
for (const row of pending.values())
|
|
125
|
-
offset = Math.min(offset, row.offset > end ? 0 : row.offset);
|
|
126
|
-
for (; offset < end && pending.size > 0; offset++) {
|
|
127
|
-
const event = session.eventAt ? session.eventAt(offset) : session.events?.[offset];
|
|
128
|
-
for (const id of acceptedIds(event)) {
|
|
129
|
-
const attempt = pending.get(id);
|
|
130
|
-
if (attempt === undefined)
|
|
131
|
-
continue;
|
|
132
|
-
settle(sessionId, file(sessionId, id), attempt);
|
|
133
|
-
pending.delete(id);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
return [];
|
|
137
|
-
},
|
|
138
|
-
};
|
|
139
|
-
}
|
package/scripts/build.mjs
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// 构建入口:宿主侧用 tsc 编到 `lib/`(类型错误不阻断——迁移来的源码在更严格的配置下仍有既有类型问题,
|
|
2
|
-
// 但这些文件本来就能跑,发布形态由 0.5.8 验证过),客户端半交给 tsdown,最后收尾出口并守卫形态。
|
|
3
|
-
//
|
|
4
|
-
// 顺序有意为之:**先删 ESM 薄壳,再守卫**,否则守卫会在删除前就看到残留而误报。
|
|
5
|
-
import { spawnSync } from 'node:child_process'
|
|
6
|
-
import { existsSync, rmSync } from 'node:fs'
|
|
7
|
-
import { join } from 'node:path'
|
|
8
|
-
|
|
9
|
-
const cwd = process.cwd()
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* 跑一条 node 命令并打印输出。
|
|
13
|
-
* @param args - node 的参数(第一个是脚本路径)。
|
|
14
|
-
* @param allowFailure - 非零退出是否可接受。
|
|
15
|
-
*/
|
|
16
|
-
function runNode(args, allowFailure = false) {
|
|
17
|
-
const result = spawnSync(process.execPath, args, { stdio: 'inherit' })
|
|
18
|
-
const code = result.status ?? 1
|
|
19
|
-
if (code !== 0 && !allowFailure) {
|
|
20
|
-
console.error(`[build] node ${args.join(' ')} 失败,退出码 ${code}`)
|
|
21
|
-
process.exit(code)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 定位包内可执行脚本(向仓库根方向查找 node_modules)。
|
|
27
|
-
* @param relative - 相对 node_modules 的路径。
|
|
28
|
-
* @param packageName - 包名,用于报错。
|
|
29
|
-
* @returns 绝对路径。
|
|
30
|
-
*/
|
|
31
|
-
function entryOf(relative, packageName) {
|
|
32
|
-
let dir = cwd
|
|
33
|
-
for (let depth = 0; depth < 6; depth += 1) {
|
|
34
|
-
const candidate = join(dir, 'node_modules', relative)
|
|
35
|
-
if (existsSync(candidate)) return candidate
|
|
36
|
-
const parent = join(dir, '..')
|
|
37
|
-
if (parent === dir) break
|
|
38
|
-
dir = parent
|
|
39
|
-
}
|
|
40
|
-
console.error(`[build] 找不到 ${packageName} 的入口(已向上查找 6 层):node_modules/${relative}`)
|
|
41
|
-
process.exit(1)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// 1) 宿主侧:tsc → lib/(`rewriteRelativeImportExtensions` 把 `./x.ts` 改写成 `./x.js`)
|
|
45
|
-
runNode([entryOf('typescript/bin/tsc', 'typescript'), '-p', 'tsconfig.build.json'], true)
|
|
46
|
-
runNode(['scripts/bundle-host.mjs'])
|
|
47
|
-
|
|
48
|
-
// 2) 客户端半:tsdown → dist/client.cjs(另有一份无用的 ESM 薄壳,第 3 步删掉)
|
|
49
|
-
runNode([entryOf('tsdown/dist/run.mjs', 'tsdown')])
|
|
50
|
-
|
|
51
|
-
// 3) 删掉客户端 ESM 薄壳:内容是 `export { apply, inject } from "./client/index.ts"`——按源码路径
|
|
52
|
-
// 转发,被 vite 加载即 `Failed to resolve import`,整页被遮罩。发布只用 dist/client.cjs。
|
|
53
|
-
for (const file of [join(cwd, 'dist', 'client.mjs'), join(cwd, 'dist', 'client.mjs.map')]) {
|
|
54
|
-
if (existsSync(file)) {
|
|
55
|
-
rmSync(file, { force: true })
|
|
56
|
-
console.log(`[build] 已删除客户端 ESM 薄壳:${file}`)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// 4) 出口收尾:写回 dev→src / publish→lib+dist 的两套出口(构建链会覆盖 exports)
|
|
61
|
-
runNode(['scripts/fix-exports.mjs'])
|
|
62
|
-
|
|
63
|
-
// 5) 出口守卫:形态不合格直接失败(含「dev 指向 dist」这条反复出过的事故)
|
|
64
|
-
runNode(['scripts/verify-exports.mjs'])
|
|
65
|
-
|
|
66
|
-
console.log('[build] 完成:lib/<宿主侧> + dist/client.cjs<客户端半>')
|
package/scripts/bundle-host.mjs
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module'
|
|
2
|
-
import { readFile, writeFile } from 'node:fs/promises'
|
|
3
|
-
import { dirname, join, resolve } from 'node:path'
|
|
4
|
-
import { fileURLToPath, pathToFileURL } from 'node:url'
|
|
5
|
-
|
|
6
|
-
const require = createRequire(import.meta.url)
|
|
7
|
-
|
|
8
|
-
export async function bundleHostCookies(destination = new URL('../lib/browser-electron/guest-cookie-jar.js', import.meta.url)) {
|
|
9
|
-
const { rolldown } = await import(pathToFileURL(createRequire(require.resolve('tsdown')).resolve('rolldown')).href)
|
|
10
|
-
const bundle = await rolldown({
|
|
11
|
-
input: fileURLToPath(new URL('../src/browser-electron/guest-cookie-jar.ts', import.meta.url)),
|
|
12
|
-
platform: 'node',
|
|
13
|
-
resolve: { mainFields: ['module', 'main'] },
|
|
14
|
-
})
|
|
15
|
-
const { output } = await bundle.write({
|
|
16
|
-
file: fileURLToPath(destination),
|
|
17
|
-
format: 'esm',
|
|
18
|
-
banner: '/*! Includes tldts and tldts-core (MIT); see guest-cookie-jar.LICENSE.txt. */',
|
|
19
|
-
}).finally(() => bundle.close())
|
|
20
|
-
const tldts = require.resolve('tldts/package.json')
|
|
21
|
-
const core = createRequire(tldts).resolve('tldts-core/package.json')
|
|
22
|
-
const licenses = await Promise.all([tldts, core].map(async manifest =>
|
|
23
|
-
JSON.parse(await readFile(manifest, 'utf8')).name + '\n\n' + await readFile(join(dirname(manifest), 'LICENSE'), 'utf8')))
|
|
24
|
-
await writeFile(new URL('guest-cookie-jar.LICENSE.txt', destination), licenses.join('\n\n'))
|
|
25
|
-
return output.flatMap(chunk => Object.keys(chunk.modules ?? {}))
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (process.argv[1] && pathToFileURL(resolve(process.argv[1])).href === import.meta.url) await bundleHostCookies()
|
package/scripts/fix-exports.mjs
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
// 出口收尾:写回两套出口(构建链会按打包产物覆盖 `exports`,所以每次构建后都要重写)。
|
|
2
|
-
//
|
|
3
|
-
// `exports` —— 工作区/dev:指向 **源码**。与仓库其它包一致;dev 宿主的客户端半按源码
|
|
4
|
-
// 加载,如果指向打包产物,产物顶部那句 `window.__ModuleLoader__.load(…)`
|
|
5
|
-
// 在 dev 的首屏引导阶段还没有全局可用,整页会白屏(实测)。
|
|
6
|
-
// `publishConfig.exports` —— 发布/安装:宿主侧 `lib/*.js`(tsc 编译、说明符已改写成 .js),
|
|
7
|
-
// 客户端半 `dist/client.cjs`(tsdown 打的完整工厂)。
|
|
8
|
-
import { readFileSync, writeFileSync } from 'node:fs'
|
|
9
|
-
|
|
10
|
-
const path = new URL('../package.json', import.meta.url)
|
|
11
|
-
const manifest = JSON.parse(readFileSync(path, 'utf8'))
|
|
12
|
-
|
|
13
|
-
/** dev/工作区出口:源码。 */
|
|
14
|
-
const devExports = {
|
|
15
|
-
'.': './src/index.ts',
|
|
16
|
-
'./browser': './src/browser/runtime.ts',
|
|
17
|
-
'./browser-electron': './src/browser-electron/entry.ts',
|
|
18
|
-
'./tool-browser': './src/tool-browser/index.ts',
|
|
19
|
-
'./startpage': './src/startpage.ts',
|
|
20
|
-
'./client': './src/client/index.ts',
|
|
21
|
-
'./cordis.patch.yml': './cordis.patch.yml',
|
|
22
|
-
'./package.json': './package.json',
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/** 发布出口:lib(宿主)+ dist(客户端半,只给 CJS——ESM 那份是薄壳,浏览器里解析不到)。 */
|
|
26
|
-
const publishExports = {
|
|
27
|
-
'.': './lib/index.js',
|
|
28
|
-
'./browser': './lib/browser/runtime.js',
|
|
29
|
-
'./browser-electron': './lib/browser-electron/entry.js',
|
|
30
|
-
'./tool-browser': './lib/tool-browser/index.js',
|
|
31
|
-
'./startpage': './lib/startpage.js',
|
|
32
|
-
'./client': './dist/client.cjs',
|
|
33
|
-
'./cordis.patch.yml': './cordis.patch.yml',
|
|
34
|
-
'./package.json': './package.json',
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
manifest.exports = devExports
|
|
38
|
-
manifest.publishConfig = { exports: publishExports }
|
|
39
|
-
// `CHANGELOG.md` 必须在 `files` 里:这个数组每次构建都被本脚本重写,历史上因此一直把它漏在包外,
|
|
40
|
-
// 结果是 0.6.0 之后更新日志既不在包里、也无处可查(迁入 monorepo 后就断档了)。
|
|
41
|
-
// `README.md` / `docs` / `skills` / `assets` 同理:迁移时它们没被带过来,包内因此既没有门面文档,
|
|
42
|
-
// 也没有随包发布的技能卡与截图。
|
|
43
|
-
// `desktop-bridge` 是最要命的一项:`bridge-install.ts`、`bridge-maintenance.ts`、`bridge-status.ts`
|
|
44
|
-
// 与 `automatic-maintenance.ts` 全都按 `../../desktop-bridge/…` 取安装器、桥本体与两个 PowerShell 脚本,
|
|
45
|
-
// 少了它桌面端的桥接功能在安装后就是坏的(缺文件,不是逻辑问题)。
|
|
46
|
-
// `tests` 不进包(发布不需要),它跑在仓库里。
|
|
47
|
-
manifest.files = ['lib', 'dist', 'src', 'scripts', 'tools/accept-desktop.mjs', 'desktop-bridge', 'dsh-host-patch', '!dsh-host-patch/sources', 'browser-extension', 'native-host', 'cordis.patch.yml', 'CHANGELOG.md', 'README.md', 'docs', 'skills', 'assets', '!src/**/__tests__']
|
|
48
|
-
|
|
49
|
-
writeFileSync(path, `${JSON.stringify(manifest, null, 2)}\n`, 'utf8')
|
|
50
|
-
console.log('exports 已写回:dev→src(源码),publish→lib + dist/client.cjs')
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/** Provision an operator-owned runtime outside the plugin installation closure. */
|
|
3
|
-
import { spawn } from 'node:child_process'
|
|
4
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
5
|
-
import { isAbsolute, join } from 'node:path'
|
|
6
|
-
|
|
7
|
-
const label = '[dsh-builtin-browser]'
|
|
8
|
-
|
|
9
|
-
function retryInstructions() {
|
|
10
|
-
console.error(`${label} Set DSH_BROWSER_ELECTRON_PACKAGE to an absolute external electron package directory, then run npx --no dsh-browser-install-electron. The sidebar needs no standalone runtime.`)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
async function install() {
|
|
14
|
-
if (process.env.ELECTRON_SKIP_BINARY_DOWNLOAD) {
|
|
15
|
-
console.log(`${label} Electron download skipped: ELECTRON_SKIP_BINARY_DOWNLOAD is set.`)
|
|
16
|
-
return 0
|
|
17
|
-
}
|
|
18
|
-
const directory = process.env.DSH_BROWSER_ELECTRON_PACKAGE
|
|
19
|
-
if (!directory || !isAbsolute(directory)) throw new Error('An absolute external electron package directory is required; this plugin does not depend on electron.')
|
|
20
|
-
const manifest = join(directory, 'package.json')
|
|
21
|
-
const metadata = JSON.parse(readFileSync(manifest, 'utf8'))
|
|
22
|
-
if (metadata.name !== 'electron') throw new Error('The external package must be named electron.')
|
|
23
|
-
const installer = join(directory, 'install.js')
|
|
24
|
-
if (!existsSync(installer)) throw new Error(`The installed electron package is incomplete: missing ${installer}`)
|
|
25
|
-
const { version } = metadata
|
|
26
|
-
console.log(`${label} Preparing Electron ${String(version)}. A missing runtime needs a network download; an existing runtime is reused.`)
|
|
27
|
-
const result = await new Promise((resolve, reject) => {
|
|
28
|
-
const child = spawn(process.execPath, [installer], {
|
|
29
|
-
env: { ...process.env, ELECTRON_RUN_AS_NODE: '1' },
|
|
30
|
-
stdio: ['ignore', 'inherit', 'inherit'],
|
|
31
|
-
windowsHide: true,
|
|
32
|
-
})
|
|
33
|
-
child.once('error', reject)
|
|
34
|
-
child.once('close', (code, signal) => resolve({ code, signal }))
|
|
35
|
-
})
|
|
36
|
-
if (result.code !== 0) {
|
|
37
|
-
console.error(`${label} Electron installation failed (${result.signal ? `signal ${result.signal}` : `exit ${String(result.code)}`}). Fix the reported network, checksum or permission error before retrying.`)
|
|
38
|
-
retryInstructions()
|
|
39
|
-
return result.code ?? 1
|
|
40
|
-
}
|
|
41
|
-
console.log(`${label} Electron runtime is ready.`)
|
|
42
|
-
return 0
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
process.exitCode = await install()
|
|
47
|
-
} catch (error) {
|
|
48
|
-
console.error(`${label} ${error instanceof Error ? error.message : String(error)}`)
|
|
49
|
-
retryInstructions()
|
|
50
|
-
process.exitCode = 1
|
|
51
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
// 出口守卫:在构建结束时断言两套出口的形态,避免「dev 指向打包产物」这类问题再次复发。
|
|
2
|
-
//
|
|
3
|
-
// 反复出现过的两个事故:
|
|
4
|
-
// 1. dev 出口指向 `dist/client.cjs` → vite 把 CJS 当 ESM 导入,浏览器里 `window.__ModuleLoader__`
|
|
5
|
-
// 还是 undefined,整页红屏 `Cannot read properties of undefined (reading 'load')`。
|
|
6
|
-
// 2. 包里留着 `dist/client.mjs` → 它是薄壳(`export { apply } from "./client/index.ts"`),
|
|
7
|
-
// 被加载时 vite 报 `Failed to resolve import "./client/index.ts"` 并遮住整页。
|
|
8
|
-
// 这两条都属于「动作之前的拦截」:构建期直接失败,而不是等运行时红屏。
|
|
9
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
10
|
-
|
|
11
|
-
const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8').replace(/^\uFEFF/, ''))
|
|
12
|
-
const problems = []
|
|
13
|
-
|
|
14
|
-
if (manifest.exports?.['./host-main'] !== undefined || manifest.publishConfig?.exports?.['./host-main'] !== undefined) {
|
|
15
|
-
problems.push('standalone host-main must not be exported by the sidebar-only package')
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const devClient = manifest.exports?.['./client']
|
|
19
|
-
const publishClient = manifest.publishConfig?.exports?.['./client']
|
|
20
|
-
|
|
21
|
-
if (typeof devClient !== 'string' || !devClient.endsWith('src/client/index.ts')) {
|
|
22
|
-
problems.push(`exports['./client'] 必须指向源码(当前 ${JSON.stringify(devClient)}):dev 由宿主打包链处理客户端半,`
|
|
23
|
-
+ '指向 dist 会让浏览器在 `window.__ModuleLoader__` 就绪前加载 CJS 工厂并抛 `Cannot read properties of undefined (reading \'load\')`')
|
|
24
|
-
}
|
|
25
|
-
if (publishClient !== './dist/client.cjs') {
|
|
26
|
-
problems.push(`publishConfig.exports['./client'] 必须是 ./dist/client.cjs(当前 ${JSON.stringify(publishClient)})`)
|
|
27
|
-
}
|
|
28
|
-
if (typeof manifest.exports?.['.'] !== 'string' || !manifest.exports['.'].endsWith('src/index.ts')) {
|
|
29
|
-
problems.push('exports[\'.\'] 必须指向源码 src/index.ts(dev 形态)')
|
|
30
|
-
}
|
|
31
|
-
if (manifest.publishConfig?.exports?.['.'] !== './lib/index.js') {
|
|
32
|
-
problems.push("publishConfig.exports['.'] 必须是 ./lib/index.js(tsc 产物;打包产物会残留 .ts 说明符)")
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const distDir = new URL('../dist/', import.meta.url)
|
|
36
|
-
for (const forbidden of ['client.mjs', 'client.mjs.map']) {
|
|
37
|
-
if (existsSync(new URL(forbidden, distDir))) {
|
|
38
|
-
problems.push(`dist/${forbidden} 必须不存在:它是按源码路径转发的 ESM 薄壳,被加载即报 Failed to resolve import`)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (problems.length > 0) {
|
|
43
|
-
console.error('[exports-guard] 出口形态不合格:')
|
|
44
|
-
for (const problem of problems) console.error(` - ${problem}`)
|
|
45
|
-
process.exit(1)
|
|
46
|
-
}
|
|
47
|
-
console.log('[exports-guard] 通过:dev→src / publish→lib+dist/client.cjs,且无 ESM 薄壳')
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { LOOPBACK_IPV4 } from '../assets/browser-policy.mjs'
|
|
2
|
-
import assert from 'node:assert/strict'
|
|
3
|
-
import { readFile } from 'node:fs/promises'
|
|
4
|
-
import { createServer } from 'node:http'
|
|
5
|
-
import { createRequire } from 'node:module'
|
|
6
|
-
import { resolve } from 'node:path'
|
|
7
|
-
import { pathToFileURL } from 'node:url'
|
|
8
|
-
import { pairedRoute } from '../lib/browser-electron/authenticated-route.js'
|
|
9
|
-
import { handlePreviewFrame, handlePreviewSessions, PREVIEW_ROUTE, PREVIEW_SESSIONS_ROUTE } from '../lib/browser-electron/preview-route.js'
|
|
10
|
-
|
|
11
|
-
const sdk = process.argv[2]
|
|
12
|
-
assert.ok(sdk, 'usage: node scripts/verify-preview-sdk.mjs <published-SDK-install-directory>')
|
|
13
|
-
const require = createRequire(resolve(sdk, 'package.json'))
|
|
14
|
-
const load = name => import(pathToFileURL(require.resolve(name)).href)
|
|
15
|
-
const version = async name => JSON.parse(await readFile(require.resolve(name + '/package.json'), 'utf8')).version
|
|
16
|
-
const connectionVersion = await version('@deepseek-ai/dsh-client-connection')
|
|
17
|
-
const cordisVersion = await version('@deepseek-ai/cordis')
|
|
18
|
-
const { Context } = await load('@deepseek-ai/cordis')
|
|
19
|
-
const { apply } = await load('@deepseek-ai/dsh-client-connection')
|
|
20
|
-
const ctx = new Context()
|
|
21
|
-
let record
|
|
22
|
-
ctx.provide('credentials', {
|
|
23
|
-
async modifyRecord(_key, modify) {
|
|
24
|
-
record = await modify(record) ?? record
|
|
25
|
-
return record
|
|
26
|
-
},
|
|
27
|
-
})
|
|
28
|
-
let captures = 0
|
|
29
|
-
let lists = 0
|
|
30
|
-
const browser = {
|
|
31
|
-
exists: session => session === 'visible-session',
|
|
32
|
-
watchableSessions() { lists++; return ['visible-session'] },
|
|
33
|
-
async capturePassive() { captures++; return { dataUrl: 'data:image/png;base64,aW1hZ2U=' } },
|
|
34
|
-
}
|
|
35
|
-
const settings = { get: () => ({ remoteView: { enabled: true } }) }
|
|
36
|
-
const preview = pairedRoute(() => ctx.get('connection'), (request, response) => {
|
|
37
|
-
return request.url.startsWith(PREVIEW_SESSIONS_ROUTE)
|
|
38
|
-
? handlePreviewSessions(request, response, settings, browser)
|
|
39
|
-
: handlePreviewFrame(request, response, settings, browser)
|
|
40
|
-
})
|
|
41
|
-
let connection
|
|
42
|
-
const server = createServer((request, response) => {
|
|
43
|
-
if (request.url.startsWith('/?')) {
|
|
44
|
-
if (connection.authorizeIndex(request, response)) response.end('index')
|
|
45
|
-
} else {
|
|
46
|
-
Promise.resolve(preview(request, response)).catch(error => {
|
|
47
|
-
response.writeHead(500)
|
|
48
|
-
response.end(String(error))
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
try {
|
|
53
|
-
await apply(ctx)
|
|
54
|
-
connection = ctx.get('connection')
|
|
55
|
-
assert.equal(typeof connection?.requestRejection, 'function')
|
|
56
|
-
await new Promise(resolve => server.listen(0, LOOPBACK_IPV4, resolve))
|
|
57
|
-
const base = 'http://' + LOOPBACK_IPV4 + ':' + server.address().port
|
|
58
|
-
const paths = [PREVIEW_SESSIONS_ROUTE, PREVIEW_ROUTE + '?session=visible-session']
|
|
59
|
-
for (const path of paths) {
|
|
60
|
-
const response = await fetch(base + path, { headers: { origin: base } })
|
|
61
|
-
assert.equal(response.status, 401)
|
|
62
|
-
await response.text()
|
|
63
|
-
}
|
|
64
|
-
assert.deepEqual({ captures, lists }, { captures: 0, lists: 0 })
|
|
65
|
-
const login = await fetch(connection.authenticatedUrl(base + '/'), { redirect: 'manual' })
|
|
66
|
-
assert.equal(login.status, 303)
|
|
67
|
-
const cookie = login.headers.get('set-cookie')?.split(';')[0]
|
|
68
|
-
assert.ok(cookie)
|
|
69
|
-
await login.text()
|
|
70
|
-
const headers = { cookie, origin: base }
|
|
71
|
-
const list = await fetch(base + paths[0], { headers })
|
|
72
|
-
assert.equal(list.status, 200)
|
|
73
|
-
assert.deepEqual((await list.json()).sessions, ['visible-session'])
|
|
74
|
-
assert.equal(captures, 0)
|
|
75
|
-
const frame = await fetch(base + paths[1], { headers })
|
|
76
|
-
assert.equal(frame.status, 200)
|
|
77
|
-
assert.equal(await frame.text(), 'image')
|
|
78
|
-
const foreign = await fetch(base + paths[1], { headers: { cookie, origin: 'https://foreign.example' } })
|
|
79
|
-
assert.equal(foreign.status, 403)
|
|
80
|
-
await foreign.text()
|
|
81
|
-
assert.deepEqual({ captures, lists }, { captures: 1, lists: 1 })
|
|
82
|
-
await ctx.fiber.dispose()
|
|
83
|
-
const revoked = await fetch(base + paths[1], { headers })
|
|
84
|
-
assert.equal(revoked.status, 503)
|
|
85
|
-
await revoked.text()
|
|
86
|
-
assert.equal(captures, 1)
|
|
87
|
-
console.log(`SDK @deepseek-ai/dsh-client-connection ${connectionVersion}, @deepseek-ai/cordis ${cordisVersion}`)
|
|
88
|
-
console.log('PASS: unpaired 401; paired list 200 and frame 200; foreign origin 403; disposed host 503; passive captures 1')
|
|
89
|
-
} finally {
|
|
90
|
-
server.closeAllConnections()
|
|
91
|
-
if (server.listening) await new Promise(resolve => server.close(resolve))
|
|
92
|
-
await ctx.fiber.dispose()
|
|
93
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: dsh-builtin-browser
|
|
3
|
-
description: Use when a task needs a real web page — opening a URL, reading or extracting from it, filling and submitting a form, uploading an attachment, checking whether a result actually happened, or recovering after a page or carrier goes away. Covers how to drive the browser with dsh_browser_code, how to batch steps, and how to verify instead of guessing.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Driving the browser
|
|
7
|
-
|
|
8
|
-
On a supported Desktop sidebar, the user can watch and take over the same browser tab.
|
|
9
|
-
Manual Web sidebar browsing supports references and human takeover, not native CDP.
|
|
10
|
-
If an operation reports a missing or stale carrier, explain the limitation and ask the user
|
|
11
|
-
to repair the bridge or select another supported carrier. Do not open another browser
|
|
12
|
-
as a fallback on your own.
|
|
13
|
-
|
|
14
|
-
The default surface exposes core `dsh_browser_*` tools. For a missing native tool, use
|
|
15
|
-
`dsh_browser_load_tools` with an array of group names, such as `{groups: ['debug']}`.
|
|
16
|
-
Groups: `forms`, `navigation`, `debug`, `session`, `more`.
|
|
17
|
-
|
|
18
|
-
Use `dsh_browser_do` for a fixed list of steps. In standard mode, use `dsh_browser_code`
|
|
19
|
-
for loops and branching; in PTC mode with the default surface, use DSH's `run_code`.
|
|
20
|
-
The code tool runs JavaScript cells in a persistent per-task REPL. Top-level bindings
|
|
21
|
-
survive between cells. Call any browser tool with
|
|
22
|
-
`await tools.dsh_browser_<name>(args)` and the same arguments as its native tool.
|
|
23
|
-
Independent reads may overlap under `Promise.all`; actions run in order. Print findings
|
|
24
|
-
as you go; output printed before a deadline or mid-run cancellation is returned.
|
|
25
|
-
|
|
26
|
-
```js
|
|
27
|
-
await goto_url('https://example.com/search')
|
|
28
|
-
await type('input[name=q]', 'wireless headphones', { submit: true })
|
|
29
|
-
await wait_for_element('.result')
|
|
30
|
-
const rows = await js(`[...document.querySelectorAll('.result')].slice(0, 10).map(r => ({
|
|
31
|
-
title: r.querySelector('h3')?.innerText, price: r.querySelector('.price')?.innerText }))`)
|
|
32
|
-
rows.length
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
The next cell can keep using `rows`.
|
|
36
|
-
|
|
37
|
-
## Helpers
|
|
38
|
-
|
|
39
|
-
- Navigation: `goto_url(url)`, `new_tab(url)`, `wait_for_load()`, `page_info()`, `back()`, `forward()`,
|
|
40
|
-
`refresh()`, `list_tabs()`, `switch_tab(tabId)`, `close_tab(tabId)`.
|
|
41
|
-
- Page data: `js(expr)` (objects, arrays and exact strings come back as data; `return` works),
|
|
42
|
-
`read({selector, maxChars})`, `snapshot()`, `find(text)`, `state()`, `screenshot()`.
|
|
43
|
-
- Input: `click(target)`, `type(target, text, {submit})`, `fill_input(target, text)`, `select(target, optionText)`,
|
|
44
|
-
`fill(fields, {submit})`, `click_at_xy(x, y)`, `type_text(text)`, `press_key(key)`, `scroll(dy)` or `scroll(x, y, dy)`,
|
|
45
|
-
`upload_file(selector, path)`. A `target` is visible text, a CSS selector, `{text|css|xpath, index}` or `{x, y}`.
|
|
46
|
-
- Waiting: `wait_for_element(selector)`, `wait_for_network_idle()`, `sleep(ms)` only as a last resort.
|
|
47
|
-
- References: `refs.capture({excerptText})`, `refs.list()`, `refs.reveal({referenceId})`.
|
|
48
|
-
- Everything else: `call(name, args)` (download, console, network, wait_for_response, dialog, hover,
|
|
49
|
-
drag, set_value, check, scrape, a11y, assert, do, reset_session, ...). `await help()` lists the
|
|
50
|
-
actions and `await help(name)` describes one.
|
|
51
|
-
|
|
52
|
-
## Batch, do not drip
|
|
53
|
-
|
|
54
|
-
Every call is a full model turn. Put a run of steps in one cell, and use loops for lists and
|
|
55
|
-
pagination. A failing helper throws, so wrap the risky step in try/catch and try another selector
|
|
56
|
-
in the same cell. Return only what you need: a few fields from `js()` beat a whole `read()`.
|
|
57
|
-
|
|
58
|
-
## Verify, then retry
|
|
59
|
-
|
|
60
|
-
"Clicked" and "the form accepted it" are different claims: check the URL, a confirmation message,
|
|
61
|
-
or a server response before moving on. Arm `wait_for_response` before the triggering action
|
|
62
|
-
inside a code cell; see [batch examples](references/batch.md). If a cell timed out or was
|
|
63
|
-
cancelled, inspect the current page before repeating anything that changes server state.
|
|
64
|
-
If access is denied, report what you verified. For a research task, you can use a different,
|
|
65
|
-
publicly available source without bypassing the original site's access restrictions.
|
|
66
|
-
|
|
67
|
-
## Never
|
|
68
|
-
|
|
69
|
-
- For a CAPTCHA, slider, login, 2FA or payment, call `dsh_browser_request_takeover` with a short
|
|
70
|
-
reason. Inspect the page after `done`; never report `skipped` or `cancelled` as success.
|
|
71
|
-
- Do not paste cookies, tokens or exported login state into the conversation.
|
|
72
|
-
- Do not assume another task's tabs or navigation are visible to you: each task has its own
|
|
73
|
-
session and its own REPL.
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# Batching browser actions
|
|
2
|
-
|
|
3
|
-
## Fixed steps with dsh_browser_do
|
|
4
|
-
|
|
5
|
-
One call, one result, and it stops at the first step that cannot proceed:
|
|
6
|
-
|
|
7
|
-
```json
|
|
8
|
-
{"steps": [
|
|
9
|
-
{"open": "https://example.com/search"},
|
|
10
|
-
{"field": {"target": {"by": "css", "value": "#q"}, "text": "invoice"}},
|
|
11
|
-
{"key": "Enter"},
|
|
12
|
-
{"wait_idle": {}},
|
|
13
|
-
{"check": {"text": "3 results"}}
|
|
14
|
-
]}
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Rules that keep a batch honest:
|
|
18
|
-
|
|
19
|
-
- Give each step exactly one key; anything else is refused before the first action runs.
|
|
20
|
-
- Put a `check` after the steps that change server state — the batch then fails at the step where
|
|
21
|
-
the outcome was already wrong, not three steps later.
|
|
22
|
-
- `wait_idle` waits for in-flight requests to drain and the page to go quiet for 300 ms; use it
|
|
23
|
-
instead of `sleep_ms` unless the page genuinely needs wall-clock time.
|
|
24
|
-
- A failed batch reports `stoppedAt`, `completed` and a per-step log, so re-running only the
|
|
25
|
-
remainder is a deliberate choice, and it starts with a fresh `state`.
|
|
26
|
-
|
|
27
|
-
## JavaScript cells
|
|
28
|
-
|
|
29
|
-
Use `dsh_browser_code` in standard mode for branching, loops, or overlapping reads.
|
|
30
|
-
In DSH PTC mode with the default tool surface, use `run_code` and the same native
|
|
31
|
-
browser tool definitions. On the plugin REPL, print incremental results and keep
|
|
32
|
-
variables for the next cell:
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
await tools.dsh_browser_open({ url: 'https://example.com' })
|
|
36
|
-
const [content, matches] = await Promise.all([
|
|
37
|
-
tools.dsh_browser_content({ format: 'markdown', maxChars: 400 }),
|
|
38
|
-
tools.dsh_browser_find({ text: 'Example Domain' }),
|
|
39
|
-
])
|
|
40
|
-
print({ content, matches })
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
To verify a response in the same REPL cell, issue the wait first, then the action:
|
|
44
|
-
|
|
45
|
-
```js
|
|
46
|
-
const response = tools.dsh_browser_wait_for_response({ urlContains: '/search', timeoutMs: 5000 })
|
|
47
|
-
await tools.dsh_browser_click({ target: { by: 'css', value: 'button[type=submit]' } })
|
|
48
|
-
print(await response)
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Adapt the URL and selector to the current page. The scheduler arms the response
|
|
52
|
-
wait before it lets the action run. Issue unrelated reads in parallel, not competing
|
|
53
|
-
mutations. A timeout or cancellation does not undo actions that already ran.
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
# Delivering a file somewhere else
|
|
2
|
-
|
|
3
|
-
The browser's job ends with a file on disk. Sending it to Feishu (Lark) drive, Baidu Netdisk or any
|
|
4
|
-
other storage is a separate capability the user connects as an MCP server — both platforms ship an
|
|
5
|
-
official one (`lark_drive_upload`, `baidu-netdisk/mcp`'s upload tool). The plugin does not hold
|
|
6
|
-
their credentials and should not.
|
|
7
|
-
|
|
8
|
-
## The path
|
|
9
|
-
|
|
10
|
-
1. `dsh_browser_download` saves the URL through the directory admission gate and returns an
|
|
11
|
-
**absolute path**. It never overwrites an existing file; if the name is taken, ask for another.
|
|
12
|
-
2. Hand that exact path to the upload tool the user connected, e.g.
|
|
13
|
-
`lark_drive_upload({ file_path: "<returned path>", folder_token: "<the user's folder>" })`.
|
|
14
|
-
3. Report both facts: where the file now sits locally, and what the upload tool answered.
|
|
15
|
-
|
|
16
|
-
## Rules
|
|
17
|
-
|
|
18
|
-
- **Never** report "saved to Feishu" from the download alone. The download proves a local file; only
|
|
19
|
-
the upload tool's reply proves the remote copy.
|
|
20
|
-
- If the upload tool fails or is not connected, say so plainly and leave the local path — the file
|
|
21
|
-
is still usable and the human can move it by hand. Do not silently retry somewhere else.
|
|
22
|
-
- A folder id / token belongs to the user's workspace: ask for it, or read it from the tool's own
|
|
23
|
-
documentation, instead of guessing a default.
|
|
24
|
-
- Before uploading something sensitive (an invoice, a screenshot with an account name), say what is
|
|
25
|
-
about to leave the machine.
|
|
26
|
-
|
|
27
|
-
## When the user wants this to happen automatically
|
|
28
|
-
|
|
29
|
-
A per-call handoff (`dsh_browser_download` with a `handoff` argument) and a settings field for the
|
|
30
|
-
default tool are planned; until they exist, the two-step form above is the supported path and it
|
|
31
|
-
keeps the human in control of where their files go.
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# Locating things
|
|
2
|
-
|
|
3
|
-
- Prefer roles and names (`dsh_browser_a11y`) over CSS when the page is a normal app: a label
|
|
4
|
-
survives a re-render, a generated class does not.
|
|
5
|
-
- `dsh_browser_snapshot` numbers every interactive element and appends `{#id}` / `{[name=x]}`
|
|
6
|
-
when it can derive one — copy that straight into `{by:"css", value:"#id"}`.
|
|
7
|
-
- Text targets match the element's own visible text or aria-label; if two match, pass `index`.
|
|
8
|
-
- `dsh_browser_find` searches the page text and returns viewport points — use it to find a table
|
|
9
|
-
row or a sentence, then click at the point or scroll the element into view.
|
|
10
|
-
- An element inside an iframe or shadow root is reachable, but only when same-origin; a
|
|
11
|
-
cross-origin frame is a wall — report it instead of guessing coordinates at random.
|