dsh-builtin-browser 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +89 -0
- package/browser-extension/constants.mjs +20 -0
- package/browser-extension/controller.mjs +293 -0
- package/browser-extension/locales.mjs +15 -0
- package/browser-extension/manifest.json +12 -0
- package/browser-extension/options.html +14 -0
- package/browser-extension/options.mjs +9 -0
- package/browser-extension/permission-guard.mjs +13 -0
- package/browser-extension/worker.mjs +74 -0
- package/package.json +20 -2
- package/scripts/build-client.mjs +305 -0
- package/scripts/build.mjs +69 -0
- package/scripts/bundle-host.mjs +28 -0
- package/scripts/fix-exports.mjs +40 -0
- package/scripts/install-electron.mjs +101 -0
- package/scripts/pack.mjs +99 -0
- package/scripts/publish-manifest.mjs +56 -0
- package/scripts/verify-exports.mjs +58 -0
- package/scripts/verify-preview-sdk.mjs +93 -0
- package/skills/dsh-builtin-browser/SKILL.md +98 -0
- package/skills/dsh-builtin-browser/references/batch.md +68 -0
- package/skills/dsh-builtin-browser/references/deliver.md +31 -0
- package/skills/dsh-builtin-browser/references/locate.md +11 -0
- package/skills/dsh-builtin-browser/references/recover.md +11 -0
- package/skills/dsh-builtin-browser/references/verify.md +13 -0
- package/skills/dsh-debug-host/SKILL.md +56 -0
- package/skills/dsh-debug-self/SKILL.md +50 -0
- package/src/bridge-compatibility.ts +39 -0
- package/src/browser/anti-bot.ts +251 -0
- package/src/browser/deep-dom.ts +40 -0
- package/src/browser/handles.ts +89 -0
- package/src/browser/runtime.ts +578 -0
- package/src/browser/takeover-target.ts +45 -0
- package/src/browser/types.ts +870 -0
- package/src/browser-electron/authenticated-route.ts +109 -0
- package/src/browser-electron/automatic-maintenance.ts +736 -0
- package/src/browser-electron/bridge-auto.ts +159 -0
- package/src/browser-electron/bridge-connection.ts +386 -0
- package/src/browser-electron/bridge-endpoint.ts +129 -0
- package/src/browser-electron/bridge-install.ts +290 -0
- package/src/browser-electron/bridge-maintenance.ts +189 -0
- package/src/browser-electron/bridge-status.ts +386 -0
- package/src/browser-electron/desktop-bridge-host.ts +253 -0
- package/src/browser-electron/desktop-identity.ts +353 -0
- package/src/browser-electron/desktop-shell.ts +100 -0
- package/src/browser-electron/document-readiness.ts +45 -0
- package/src/browser-electron/electron-provision.ts +347 -0
- package/src/browser-electron/entry.ts +1378 -0
- package/src/browser-electron/ephemeral-profile.ts +189 -0
- package/src/browser-electron/extension-browser.ts +230 -0
- package/src/browser-electron/extension-setup.ts +67 -0
- package/src/browser-electron/file-write.ts +31 -0
- package/src/browser-electron/foreground-watch.ts +142 -0
- package/src/browser-electron/guest-cookie-jar.ts +177 -0
- package/src/browser-electron/guest-cookie-store.ts +59 -0
- package/src/browser-electron/guest-css-runtime.ts +76 -0
- package/src/browser-electron/guest-css.ts +68 -0
- package/src/browser-electron/guest-route.ts +716 -0
- package/src/browser-electron/guest-runtime.ts +408 -0
- package/src/browser-electron/guest-storage-runtime.ts +54 -0
- package/src/browser-electron/guest-storage.ts +120 -0
- package/src/browser-electron/history-store.ts +224 -0
- package/src/browser-electron/host-main.ts +1385 -0
- package/src/browser-electron/host-patch-maintenance.ts +121 -0
- package/src/browser-electron/http-body.ts +65 -0
- package/src/browser-electron/json-reply.ts +47 -0
- package/src/browser-electron/maintenance-broker.ts +166 -0
- package/src/browser-electron/maintenance-lifecycle.ts +91 -0
- package/src/browser-electron/maintenance-route.ts +68 -0
- package/src/browser-electron/missing-system-browser.ts +114 -0
- package/src/browser-electron/open-slot.ts +49 -0
- package/src/browser-electron/paths.ts +25 -0
- package/src/browser-electron/preferred-browser.ts +130 -0
- package/src/browser-electron/preview-route.ts +215 -0
- package/src/browser-electron/process-ownership.ts +174 -0
- package/src/browser-electron/process.ts +23 -0
- package/src/browser-electron/profile-checkpoint.ts +187 -0
- package/src/browser-electron/profile-command.ts +47 -0
- package/src/browser-electron/profile-extension.ts +129 -0
- package/src/browser-electron/profile-lease.ts +211 -0
- package/src/browser-electron/profile-residue.ts +49 -0
- package/src/browser-electron/provider-core.ts +1107 -0
- package/src/browser-electron/provider-interaction.ts +1034 -0
- package/src/browser-electron/provider-media.ts +589 -0
- package/src/browser-electron/provider-navigation.ts +323 -0
- package/src/browser-electron/provider-observation.ts +664 -0
- package/src/browser-electron/provider-tabs.ts +372 -0
- package/src/browser-electron/provider.ts +666 -0
- package/src/browser-electron/reference-route.ts +598 -0
- package/src/browser-electron/remote-host.ts +1538 -0
- package/src/browser-electron/rpc-input.ts +13 -0
- package/src/browser-electron/rpc-ops.ts +41 -0
- package/src/browser-electron/runtime-diagnostics.ts +38 -0
- package/src/browser-electron/runtime-route.ts +105 -0
- package/src/browser-electron/runtime-status.ts +309 -0
- package/src/browser-electron/settings-route.ts +64 -0
- package/src/browser-electron/settings-store.ts +593 -0
- package/src/browser-electron/shortcuts-route.ts +112 -0
- package/src/browser-electron/sidebar-only-host.ts +300 -0
- package/src/browser-electron/startpage-shortcuts.ts +213 -0
- package/src/browser-electron/system-browser.ts +1850 -0
- package/src/browser-electron/tauri-host.ts +194 -0
- package/src/browser-electron/timing.ts +16 -0
- package/src/browser-electron/virtual-cursor.ts +162 -0
- package/src/browser-electron/windows-system.ts +24 -0
- package/src/browser-reference/delivery.ts +384 -0
- package/src/browser-reference/entry.ts +631 -0
- package/src/browser-reference/export.ts +339 -0
- package/src/browser-reference/import.ts +303 -0
- package/src/browser-reference/page-script.ts +1537 -0
- package/src/browser-reference/service.ts +1346 -0
- package/src/browser-reference/store.ts +172 -0
- package/src/browser-reference/text-quote.ts +219 -0
- package/src/browser-reference/types.ts +195 -0
- package/src/browser-reference/visible.ts +367 -0
- package/src/browser-reference/web-sources.ts +106 -0
- package/src/client/apply-guard.ts +22 -0
- package/src/client/browser/BrowserController.ts +693 -0
- package/src/client/browser/BrowserFrame.ts +78 -0
- package/src/client/browser/BrowserNavigation.ts +169 -0
- package/src/client/browser/BrowserPage.ts +23 -0
- package/src/client/browser/BrowserPersistence.ts +44 -0
- package/src/client/browser/IframeImpl.ts +182 -0
- package/src/client/browser/child-tabs.ts +14 -0
- package/src/client/browser/frame-history.ts +125 -0
- package/src/client/browser/frame-state.ts +27 -0
- package/src/client/browser/iframe-reference.ts +67 -0
- package/src/client/browser/initialization.ts +262 -0
- package/src/client/browser/omnibox.ts +243 -0
- package/src/client/browser/store.ts +38 -0
- package/src/client/browser/takeover-channel.ts +72 -0
- package/src/client/browser/url.ts +46 -0
- package/src/client/browser/web-reference-source.ts +56 -0
- package/src/client/css-modules.d.ts +4 -0
- package/src/client/definition.tsx +36 -0
- package/src/client/electron/ElectronWebViewImpl.ts +371 -0
- package/src/client/electron/ElectronWebviewPresentation.ts +140 -0
- package/src/client/electron/NativeChildPresentation.ts +53 -0
- package/src/client/electron/NativeViewPage.ts +265 -0
- package/src/client/electron/pages.ts +23 -0
- package/src/client/electron/reference-overlay.ts +53 -0
- package/src/client/electron/workspace.ts +33 -0
- package/src/client/index.ts +333 -0
- package/src/client/locales.ts +860 -0
- package/src/client/pages.ts +28 -0
- package/src/client/reference/client/BrowserRefLink.tsx +142 -0
- package/src/client/reference/client/draft-reference.ts +167 -0
- package/src/client/reference/client/index.ts +7 -0
- package/src/client/reference/client/ordered-submission.ts +108 -0
- package/src/client/reference/client/pending-delivery.ts +216 -0
- package/src/client/reference/client/plugin.ts +208 -0
- package/src/client/reference/client/production/ReferenceCapsules.tsx +345 -0
- package/src/client/reference/client/production/ReferenceDock.module.css +193 -0
- package/src/client/reference/client/production/ReferenceDock.tsx +6 -0
- package/src/client/reference/client/production/ReferenceFeedback.tsx +15 -0
- package/src/client/reference/client/production/ReferenceMath.tsx +44 -0
- package/src/client/reference/client/production/ReferenceText.tsx +36 -0
- package/src/client/reference/client/production/assembly.ts +447 -0
- package/src/client/reference/client/production/asset-store.ts +144 -0
- package/src/client/reference/client/production/availability.ts +72 -0
- package/src/client/reference/client/production/bytes.ts +36 -0
- package/src/client/reference/client/production/composer-attachments.ts +44 -0
- package/src/client/reference/client/production/delivery-client.ts +211 -0
- package/src/client/reference/client/production/draft-adapter.ts +512 -0
- package/src/client/reference/client/production/http-transport.ts +212 -0
- package/src/client/reference/client/production/production-submission.ts +70 -0
- package/src/client/reference/client/production/protocol.ts +234 -0
- package/src/client/reference/client/production/reference-card.ts +240 -0
- package/src/client/reference/client/production/reference-labels.ts +29 -0
- package/src/client/reference/client/production/reply-link-bridge.ts +222 -0
- package/src/client/reference/client/production/reveal.ts +215 -0
- package/src/client/reference/client/production/runtime.ts +1056 -0
- package/src/client/reference/client/production/snapshot-adapter.ts +154 -0
- package/src/client/reference/client/production/source-marker.ts +99 -0
- package/src/client/reference/client/production/source-opener.ts +55 -0
- package/src/client/reference/client/production/styles.ts +104 -0
- package/src/client/reference/client/production/user-text-rule.ts +67 -0
- package/src/client/reference/client/reveal.ts +109 -0
- package/src/client/reference/client/scheme.ts +114 -0
- package/src/client/reference/client/session-schedule.ts +36 -0
- package/src/client/reference/client/types.ts +168 -0
- package/src/client/reference/css-modules.d.ts +4 -0
- package/src/client/reference/index.ts +11 -0
- package/src/client/reference-capture-owner.ts +162 -0
- package/src/client/reference-intents.ts +36 -0
- package/src/client/settings/index.ts +42 -0
- package/src/client/settings/mount-guard.ts +31 -0
- package/src/client/settings/panel.ts +2768 -0
- package/src/client/shortcut-open.ts +30 -0
- package/src/client/startpage/binding.ts +99 -0
- package/src/client/startpage/controller.ts +300 -0
- package/src/client/startpage/model.ts +279 -0
- package/src/client/view/Browser.module.css +751 -0
- package/src/client/view/BrowserBody.tsx +315 -0
- package/src/client/view/BrowserPresentation.ts +9 -0
- package/src/client/view/BrowserTitle.tsx +17 -0
- package/src/client/view/IframePresentation.ts +365 -0
- package/src/client/view/StartPage.tsx +598 -0
- package/src/client/view/TakeoverBanner.tsx +21 -0
- package/src/compat/host-features.ts +92 -0
- package/src/index.ts +110 -0
- package/src/reference-owner.ts +5 -0
- package/src/reference-page.ts +9 -0
- package/src/reference-source.ts +3 -0
- package/src/reference-text.ts +219 -0
- package/src/startpage-settings.ts +103 -0
- package/src/startpage.ts +71 -0
- package/src/takeover-protocol.ts +28 -0
- package/src/tool-browser/block-recovery.ts +85 -0
- package/src/tool-browser/code-tool.ts +555 -0
- package/src/tool-browser/code-worker.ts +725 -0
- package/src/tool-browser/element-fields.ts +167 -0
- package/src/tool-browser/errors.ts +40 -0
- package/src/tool-browser/index.ts +265 -0
- package/src/tool-browser/page-probe.ts +675 -0
- package/src/tool-browser/panel-page.ts +126 -0
- package/src/tool-browser/probe-client.ts +183 -0
- package/src/tool-browser/screenshot-annotations.ts +131 -0
- package/src/tool-browser/screenshot-image.ts +49 -0
- package/src/tool-browser/state.ts +375 -0
- package/src/tool-browser/takeover.ts +199 -0
- package/src/tool-browser/tools-debug.ts +806 -0
- package/src/tool-browser/tools-interaction.ts +956 -0
- package/src/tool-browser/tools-navigation.ts +786 -0
- package/src/tool-browser/tools-observation.ts +474 -0
- package/src/tool-browser/tools-reference.ts +294 -0
- package/src/types/electron-shim.d.ts +144 -0
- package/src/types.ts +85 -0
- package/src/web-guest.ts +35 -0
- package/tools/accept-desktop.mjs +148 -0
- package/dist/client.d.cts +0 -516
- package/dist/client.d.mts +0 -516
- package/dist/index.cjs +0 -92
- package/dist/index.d.mts +0 -2960
- package/dist/index.mjs +0 -24
- package/dsh-builtin-browser-1.0.3-publish.tgz +0 -0
- package/dsh-builtin-browser-1.0.3.tgz +0 -0
- package/dsh-host-patch/sources/main/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/main/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/manifest.json +0 -218
- package/dsh-host-patch/sources/rc3/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/rc3/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0001-feat-sidebar-right-add-session-rendering-holds.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0002-feat-desktop-load-trusted-profile-main-extensions.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0003-feat-desktop-report-resolved-and-running-main-extens.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0004-feat-desktop-compose-admitted-native-sidebar-views.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0005-fix-client-admit-coded-browser-errors-in-native-comp.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0006-fix-desktop-acknowledge-native-same-document-navigat.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0007-fix-desktop-restore-auth-in-the-native-lease-partiti.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0008-feat-desktop-adopt-native-children-in-admitted-sideb.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0009-fix-desktop-publish-complete-native-child-close-reco.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0010-fix-desktop-bundle-structured-errors-in-sandboxed-pr.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0011-feat-desktop-offer-persistent-Sidebar-sessions-per-D.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0012-feat-desktop-retain-sidebar-session-cookies-across-r.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0013-fix-desktop-honor-sidebar-session-cookie-sidecar-con.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0014-fix-desktop-retry-cookie-protection-without-failing-.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0015-fix-desktop-preserve-host-only-cookie-identity-in-se.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0016-fix-desktop-restore-session-cookies-before-checkpoin.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0017-fix-desktop-restore-sidebar-cookies-once-before-gues.patch.gz +0 -0
- package/dsh-host-patch/sources/rc5/0018-fix-sidebar-right-follow-animated-native-slot-placem.patch.gz +0 -0
- package/dsh-host-patch/sources/series.json +0 -260
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turn the development manifest into the one a consumer receives (tarball or npm).
|
|
3
|
+
*
|
|
4
|
+
* WHY THIS EXISTS
|
|
5
|
+
* The workspace manifest is written for pnpm inside the monorepo: `exports` points at TypeScript
|
|
6
|
+
* sources, and every host peer is declared as `workspace:^`. npm applies `publishConfig` when it
|
|
7
|
+
* publishes, and pnpm rewrites `workspace:` when it packs — but a hand-made tarball (which is how
|
|
8
|
+
* this plugin is handed to users: `pnpm add file:<tarball>.tgz`) keeps both, so the installed
|
|
9
|
+
* package advertises an unresolvable `workspace:^` peer range and a `./client` that is a `.ts` file.
|
|
10
|
+
* That is the shape that produced "the panel stays on its skeleton" for directory installs.
|
|
11
|
+
*
|
|
12
|
+
* This module produces the consumer manifest explicitly, so both distribution routes agree.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** The oldest DSH this plugin is verified against (single source for the peer range). */
|
|
16
|
+
export const HOST_PEER_RANGE = '>=0.2.2-rc.3 <0.3.0'
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Rewrite one manifest for consumers.
|
|
20
|
+
* @param manifest - the development manifest (parsed package.json).
|
|
21
|
+
* @param options - the host peer range to write.
|
|
22
|
+
* @returns a new manifest: publish-form exports, real peer ranges, no dev-only fields.
|
|
23
|
+
*/
|
|
24
|
+
export function stagePublishManifest(manifest, options = {}) {
|
|
25
|
+
const peerRange = options.peerRange ?? HOST_PEER_RANGE
|
|
26
|
+
const publishExports = manifest.publishConfig?.exports
|
|
27
|
+
if (publishExports === undefined) throw new Error('package.json has no publishConfig.exports; run the build first')
|
|
28
|
+
const peers = { ...(manifest.peerDependencies ?? {}) }
|
|
29
|
+
let rewritten = 0
|
|
30
|
+
for (const [name, range] of Object.entries(peers)) {
|
|
31
|
+
if (typeof range === 'string' && range.startsWith('workspace:')) {
|
|
32
|
+
peers[name] = peerRange
|
|
33
|
+
rewritten += 1
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const staged = {
|
|
37
|
+
...manifest,
|
|
38
|
+
exports: publishExports,
|
|
39
|
+
...(Object.keys(peers).length === 0 ? {} : { peerDependencies: peers }),
|
|
40
|
+
}
|
|
41
|
+
delete staged.publishConfig
|
|
42
|
+
delete staged.devDependencies
|
|
43
|
+
delete staged.scripts
|
|
44
|
+
return { manifest: staged, rewrittenPeers: rewritten }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Report every peer range that a consumer could not resolve.
|
|
49
|
+
* @param manifest - any manifest.
|
|
50
|
+
* @returns the offending entries, empty when the manifest is consumer-safe.
|
|
51
|
+
*/
|
|
52
|
+
export function unresolvedPeerRanges(manifest) {
|
|
53
|
+
return Object.entries(manifest.peerDependencies ?? {})
|
|
54
|
+
.filter(([, range]) => typeof range === 'string' && (range.startsWith('workspace:') || range.trim() === ''))
|
|
55
|
+
.map(([name]) => name)
|
|
56
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// 出口守卫:在构建结束时断言两套出口与 DSH 0.2.3 客户端产物信封形态,避免「dev 指向打包产物」
|
|
2
|
+
// 或「旧自注入 <style> 逻辑回流」等问题再次复发。
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs'
|
|
4
|
+
|
|
5
|
+
const manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8').replace(/^\uFEFF/, ''))
|
|
6
|
+
const problems = []
|
|
7
|
+
|
|
8
|
+
if (manifest.exports?.['./host-main'] !== undefined || manifest.publishConfig?.exports?.['./host-main'] !== undefined) {
|
|
9
|
+
problems.push('standalone host-main must not be exported by the sidebar-only package')
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const devClient = manifest.exports?.['./client']
|
|
13
|
+
const publishClient = manifest.publishConfig?.exports?.['./client']
|
|
14
|
+
|
|
15
|
+
if (typeof devClient !== 'string' || !devClient.endsWith('src/client/index.ts')) {
|
|
16
|
+
problems.push(`exports['./client'] 必须指向源码(当前 ${JSON.stringify(devClient)}):dev 由宿主打包链处理客户端半,`
|
|
17
|
+
+ '指向打包产物会让浏览器在 `window.__ModuleLoader__` 就绪前加载 CJS 工厂并抛 `Cannot read properties of undefined (reading \'load\')`')
|
|
18
|
+
}
|
|
19
|
+
if (publishClient !== './lib/client.js') {
|
|
20
|
+
problems.push(`publishConfig.exports['./client'] 必须是 ./lib/client.js(当前 ${JSON.stringify(publishClient)})`)
|
|
21
|
+
}
|
|
22
|
+
if (typeof manifest.exports?.['.'] !== 'string' || !manifest.exports['.'].endsWith('src/index.ts')) {
|
|
23
|
+
problems.push('exports[\'.\'] 必须指向源码 src/index.ts(dev 形态)')
|
|
24
|
+
}
|
|
25
|
+
if (manifest.publishConfig?.exports?.['.'] !== './lib/index.js') {
|
|
26
|
+
problems.push("publishConfig.exports['.'] 必须是 ./lib/index.js(tsc 产物;打包产物会残留 .ts 说明符)")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const clientBundleUrl = new URL('../lib/client.js', import.meta.url)
|
|
30
|
+
if (!existsSync(clientBundleUrl)) {
|
|
31
|
+
problems.push('lib/client.js 缺失:构建未产出 DSH 0.2.3 客户端工厂')
|
|
32
|
+
} else {
|
|
33
|
+
const clientCode = readFileSync(clientBundleUrl, 'utf8')
|
|
34
|
+
const expectedBanner = `window.__ModuleLoader__.load({ id: ${JSON.stringify(manifest.name)}, factory: (require) => {`
|
|
35
|
+
if (!clientCode.startsWith(expectedBanner)) {
|
|
36
|
+
problems.push(`lib/client.js 必须以 ${expectedBanner} 开头`)
|
|
37
|
+
}
|
|
38
|
+
if (!clientCode.includes('meta: () => ({ stylesheets:')) {
|
|
39
|
+
problems.push('lib/client.js 必须通过 meta: () => ({ stylesheets: ... }) 向宿主移交样式表')
|
|
40
|
+
}
|
|
41
|
+
if (clientCode.includes('data-plugin-css')) {
|
|
42
|
+
problems.push('lib/client.js 不得残留旧版运行期 <style data-plugin-css> 自注入逻辑')
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const distDir = new URL('../dist/', import.meta.url)
|
|
47
|
+
for (const forbidden of ['client.cjs', 'client.mjs', 'client.mjs.map']) {
|
|
48
|
+
if (existsSync(new URL(forbidden, distDir))) {
|
|
49
|
+
problems.push(`dist/${forbidden} 必须不存在:客户端产物已统一切至 lib/client.js`)
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (problems.length > 0) {
|
|
54
|
+
console.error('[exports-guard] 出口或客户端产物形态不合格:')
|
|
55
|
+
for (const problem of problems) console.error(` - ${problem}`)
|
|
56
|
+
process.exit(1)
|
|
57
|
+
}
|
|
58
|
+
console.log('[exports-guard] 通过:dev→src / publish→lib + lib/client.js(0.2.3 信封与 meta().stylesheets)')
|
|
@@ -0,0 +1,93 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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_text(text)`, `wait_for_gone(text)`,
|
|
47
|
+
`wait_until(jsExpression, { timeoutMs, intervalMs })` (returns the truthy value; a timeout quotes
|
|
48
|
+
the last result), `wait_for_response(urlContains, trigger, { status, timeoutMs })`,
|
|
49
|
+
`wait_for_network_idle()`. Each returns as soon as its condition holds and throws when it never
|
|
50
|
+
does; `sleep(ms)` only as a last resort (capped at 60 s; a cell that keeps sleeping gets a hint).
|
|
51
|
+
- Data: `inspect_data_sources()` reports embedded state (`__NEXT_DATA__`, `__INITIAL_STATE__`,
|
|
52
|
+
JSON and ld+json scripts) with sizes, keys and array paths, the JSON APIs the page called,
|
|
53
|
+
data-like resources (including requests made before the probe) and declared endpoints.
|
|
54
|
+
`fetch_json(url, { method, headers, body })` fetches from the page with its same-origin cookies
|
|
55
|
+
and returns parsed JSON; a non-2xx status throws with the status and the start of the body.
|
|
56
|
+
- References: `refs.capture({excerptText})`, `refs.list()`, `refs.reveal({referenceId})`.
|
|
57
|
+
- Everything else: `call(name, args)` (download, console, network, wait_for_response, dialog, hover,
|
|
58
|
+
drag, set_value, check, scrape, a11y, assert, do, reset_session, ...). `await help()` lists the
|
|
59
|
+
actions and `await help(name)` describes one.
|
|
60
|
+
|
|
61
|
+
## Data before DOM
|
|
62
|
+
|
|
63
|
+
Before scraping a list, a directory, paginated or lazy-loaded data, call `inspect_data_sources()`.
|
|
64
|
+
When the page already holds the rows as JSON or calls an API for them, read that source instead
|
|
65
|
+
of the DOM, and check the count you collected against the total the site states:
|
|
66
|
+
|
|
67
|
+
```js
|
|
68
|
+
const sources = await inspect_data_sources()
|
|
69
|
+
print(JSON.stringify(sources.embedded.map(s => [s.name, s.arrays])), JSON.stringify(sources.apis))
|
|
70
|
+
// The page called /api/stores?page=1: fetch every page at once with its cookies.
|
|
71
|
+
const pages = await Promise.all([1, 2, 3, 4].map(n => fetch_json(`/api/stores?page=${n}`)))
|
|
72
|
+
const stores = pages.flatMap(p => p.items)
|
|
73
|
+
print(stores.length, JSON.stringify(stores.slice(0, 3)))
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Batch, do not drip
|
|
77
|
+
|
|
78
|
+
Every call is a full model turn. Put a run of steps in one cell, and use loops for lists and
|
|
79
|
+
pagination. A failing helper throws, so wrap the risky step in try/catch and try another selector
|
|
80
|
+
in the same cell. Return only what you need: a few fields from `js()` beat a whole `read()`.
|
|
81
|
+
|
|
82
|
+
## Verify, then retry
|
|
83
|
+
|
|
84
|
+
"Clicked" and "the form accepted it" are different claims: check the URL, a confirmation message,
|
|
85
|
+
or a server response before moving on. Arm `wait_for_response` before the triggering action
|
|
86
|
+
inside a code cell; see [batch examples](references/batch.md). Each action's printed result ends with a `→` line: the URL or tab change, the page title after
|
|
87
|
+
a change, new alert messages and dialogs answered. If a cell timed out or was
|
|
88
|
+
cancelled, inspect the current page before repeating anything that changes server state.
|
|
89
|
+
If access is denied, report what you verified. For a research task, you can use a different,
|
|
90
|
+
publicly available source without bypassing the original site's access restrictions.
|
|
91
|
+
|
|
92
|
+
## Never
|
|
93
|
+
|
|
94
|
+
- For a CAPTCHA, slider, login, 2FA or payment, call `dsh_browser_request_takeover` with a short
|
|
95
|
+
reason. Inspect the page after `done`; never report `skipped` or `cancelled` as success.
|
|
96
|
+
- Do not paste cookies, tokens or exported login state into the conversation.
|
|
97
|
+
- Do not assume another task's tabs or navigation are visible to you: each task has its own
|
|
98
|
+
session and its own REPL.
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
The REPL helper does the same in one call: `wait_for_response(urlContains, trigger, opts)`
|
|
52
|
+
starts watching before it calls `trigger()` and returns the matching response row:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
const saved = await wait_for_response('/api/profile', () => click('Save'), { status: 200 })
|
|
56
|
+
await wait_for_text('Profile saved')
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
When the condition is page state rather than text or a response, poll an expression instead of
|
|
60
|
+
sleeping; the timeout error quotes the last value it saw:
|
|
61
|
+
|
|
62
|
+
```js
|
|
63
|
+
const count = await wait_until(`document.querySelectorAll('.result').length >= 20 && document.querySelectorAll('.result').length`, { timeoutMs: 8000 })
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Adapt the URL and selector to the current page. The scheduler arms the response
|
|
67
|
+
wait before it lets the action run. Issue unrelated reads in parallel, not competing
|
|
68
|
+
mutations. A timeout or cancellation does not undo actions that already ran.
|
|
@@ -0,0 +1,31 @@
|
|
|
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.
|
|
@@ -0,0 +1,11 @@
|
|
|
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.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Recovering
|
|
2
|
+
|
|
3
|
+
- Page stuck or a script half-applied: `dsh_browser_refresh`.
|
|
4
|
+
- Session wedged after a carrier loss: `dsh_browser_reset_session` (this task only), then re-open
|
|
5
|
+
and re-read the page. A lost carrier means the page context is gone — nothing you knew about it
|
|
6
|
+
still holds.
|
|
7
|
+
- A call fails with a reason you cannot place: `dsh_browser_doctor` (session, page state, probe
|
|
8
|
+
buffers, which tools this task restricted away), then `dsh_browser_help` for the topic.
|
|
9
|
+
- Everything is refused with "restricted": the task restricted its own tools. `dsh_browser_restrict`
|
|
10
|
+
with the needed names lifts it; observation tools are never blocked.
|
|
11
|
+
- Do not retry a state-changing call blindly after an error. Read first, decide second.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Verifying
|
|
2
|
+
|
|
3
|
+
| Question | Tool |
|
|
4
|
+
| --- | --- |
|
|
5
|
+
| Is the element there / the text there / the URL changed? | `dsh_browser_assert` |
|
|
6
|
+
| Did a request reach the server? | `dsh_browser_wait_for_response` |
|
|
7
|
+
| What did the page log or fetch? | `dsh_browser_console`, `dsh_browser_network` |
|
|
8
|
+
| Did a field take the value? | `dsh_browser_get_value` |
|
|
9
|
+
|
|
10
|
+
A submit is the dangerous case. After clicking submit: wait for the response, assert the visible
|
|
11
|
+
outcome, and if the call died before either answer arrived, **read the site's own record** (the
|
|
12
|
+
list page, the order history) before acting again. "Result unknown" is an acceptable answer to
|
|
13
|
+
report; a second submit is not.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dsh-debug-host
|
|
3
|
+
description: Use when the thing under test IS DSH itself - a client bundle, the settings panel, the sidebar UI - and the page has to be refreshed and inspected. Covers which surface to open DSH on, why the sidebar cannot host it, and how to read the result.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debugging DSH itself
|
|
7
|
+
|
|
8
|
+
Testing DSH is different from testing a page. The subject is the shell that is running your tools, so it
|
|
9
|
+
must be opened on a surface you control directly.
|
|
10
|
+
|
|
11
|
+
## Which surface
|
|
12
|
+
|
|
13
|
+
- **Built-in browser for DSH.** Open the DSH URL (the one carrying the token) in the plugin's own browser
|
|
14
|
+
and work in that page: refresh it, inspect it, read its DOM. That window is yours to drive.
|
|
15
|
+
- **Sidebar for everything else.** Ordinary pages belong in the DSH sidebar, where the reader can watch
|
|
16
|
+
and take over. Do not open DSH there.
|
|
17
|
+
|
|
18
|
+
## Why the sidebar cannot host DSH
|
|
19
|
+
|
|
20
|
+
The sidebar serves pages through the same-origin guest proxy. Pointing it at DSH makes the host fetch the
|
|
21
|
+
very server that is serving the request; what comes back is a network-looking failure
|
|
22
|
+
(`guest proxy: cannot reach 127.0.0.1:PORT: fetch failed`) that says nothing about the real mistake.
|
|
23
|
+
The proxy now refuses loopback and private targets outright, so the answer is a plain refusal instead of a
|
|
24
|
+
timeout - treat it as a routing reminder, not a bug in the page.
|
|
25
|
+
|
|
26
|
+
## Refresh, do not restart
|
|
27
|
+
|
|
28
|
+
Client-side plugin code is fetched once per page load. A rebuilt `client.js`, a new settings row, a changed
|
|
29
|
+
handler - none of that reaches a page that is already open. Refresh the DSH page. Restarting the host is a
|
|
30
|
+
different, heavier action and does not fix a stale page.
|
|
31
|
+
|
|
32
|
+
Tool handlers are registered when the host starts. A rebuilt tool body may therefore need a host restart,
|
|
33
|
+
while a rebuilt client body needs only a page refresh. Know which of the two you changed.
|
|
34
|
+
|
|
35
|
+
## Reading the result
|
|
36
|
+
|
|
37
|
+
1. `dsh_browser_state` first: URL, title, load state, counts. A blank title with no elements is a signal,
|
|
38
|
+
not an empty page - compare it against what that surface is expected to return.
|
|
39
|
+
2. Then `dsh_browser_execute` for the specific fact (`document.title`, a computed style, a dataset value).
|
|
40
|
+
3. Keep the DSH tab open between steps; reopening it each time loses the very state you were testing.
|
|
41
|
+
|
|
42
|
+
## Rule of thumb
|
|
43
|
+
|
|
44
|
+
If the question is "does DSH behave correctly", the answer comes from a DSH page in the built-in browser,
|
|
45
|
+
refreshed after every client change. If the question is "does this site work", the answer comes from the
|
|
46
|
+
sidebar.
|
|
47
|
+
|
|
48
|
+
## panel 模式能做什么、不能做什么
|
|
49
|
+
|
|
50
|
+
`surface: "panel"` 在创建浏览器会话之前就返回,所以:
|
|
51
|
+
|
|
52
|
+
- 能做:把页面放进 DSH 侧栏、让读者看到(`open`)。
|
|
53
|
+
- 不能做:`snapshot` / `execute` / `scrape` / `click` / `fill` 这些依赖会话的工具,会以“无会话”失败。
|
|
54
|
+
|
|
55
|
+
要读页面内容或操作页面,用 `surface: "builtin"`(仅本机地址允许),或改用侧栏的引用通道(划选 → 浮条 → 引用)。
|
|
56
|
+
不要把“panel 下读不到页面”当成 bug 反复排查:那是这一档的既定边界。
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: dsh-debug-self
|
|
3
|
+
description: Use when a browser or DSH behaviour has failed more than once, or when the obvious explanation is environmental (needs a restart, a cache, a stale build). Turns a repeated failure into one measurable check so the same cause is not re-guessed, and records the check next to the work.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debugging without re-guessing
|
|
7
|
+
|
|
8
|
+
A repeated failure is not a new situation. It is the same one arriving again, and the second arrival
|
|
9
|
+
means the first explanation was never actually checked.
|
|
10
|
+
|
|
11
|
+
## The loop
|
|
12
|
+
|
|
13
|
+
1. **Write down what was observed, not what was concluded.** A tool returned `{title: "", elements: []}`;
|
|
14
|
+
a file contains `surface: "builtin"`; a log line printed `surface=panel`. Inferences ("needs a
|
|
15
|
+
restart", "the cache is stale") are hypotheses and belong in the next step, not this one.
|
|
16
|
+
2. **Move one variable per trial.** If two things changed between a working and a broken run, the result
|
|
17
|
+
distinguishes nothing. Change one, re-run, note the outcome.
|
|
18
|
+
3. **Prefer a value the system prints over a value you compute.** A field in a response, a log line at
|
|
19
|
+
registration, a file's own contents — these are facts. Reconstructing the same fact from behaviour
|
|
20
|
+
("it must be X because it did not do Y") is how the same wrong guess survives a whole session.
|
|
21
|
+
4. **Turn the conclusion into a check.** Something a later run can evaluate in one call: a field to read,
|
|
22
|
+
a path to stat, a line to grep. If it cannot be written as a check, it is not a conclusion yet.
|
|
23
|
+
5. **Run the check first, every time after that.** Before touching code again, evaluate the check. That
|
|
24
|
+
is what stops the loop.
|
|
25
|
+
|
|
26
|
+
## Signs the loop is happening
|
|
27
|
+
|
|
28
|
+
- The same wording appears in two rounds of notes ("this needs a restart").
|
|
29
|
+
- A change was made and its effect was never isolated from another change.
|
|
30
|
+
- Behaviour is explained by the environment while a fact that would settle it is one call away.
|
|
31
|
+
- The same file is edited repeatedly without any observation in between.
|
|
32
|
+
|
|
33
|
+
## What to record when closing one
|
|
34
|
+
|
|
35
|
+
Next to the fix, in the repo rather than in chat: the observed fact, the check, and the one-line rule it
|
|
36
|
+
implies. A note that cannot be re-evaluated by the next reader is a story, not a finding.
|
|
37
|
+
## 判据必须落在动作之前
|
|
38
|
+
|
|
39
|
+
事后报错等于没有预防:调用已经发生,代价已经付出,用户看到的是"你又犯了一次"。
|
|
40
|
+
|
|
41
|
+
因此每一条要留下的教训,最终形态必须是**动作前的一次判定**,而不是动作后的一条消息:
|
|
42
|
+
|
|
43
|
+
1. 把错误写成前置条件:「当 X 成立时,动作 A 不可执行」。
|
|
44
|
+
2. 这个判定要放在**最早能拦住 A 的位置**——能写进代码就写进代码(拒绝在发起之前),只能人工就写进调用前的检查清单。
|
|
45
|
+
3. 只在"事后"出现的提示不算完成。判据的验收标准是:**违规的那次调用根本没有发出去**。
|
|
46
|
+
4. 反例(不合格):代理返回 403 并附带说明。合格:代理在收到请求之前就拒绝,或工具在发起之前就不允许这次调用。
|
|
47
|
+
|
|
48
|
+
例:侧栏(同源代理)不能承载本机地址,因为那等于让代理去抓自己所在的服务器。
|
|
49
|
+
不合格做法——先发起,再由代理返回"不能到达 127.0.0.1";
|
|
50
|
+
合格做法——`panel` 面遇到 loopback 目标时,在 `open` 发起之前就拒绝,并指出应当改用 `builtin` 面。
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export const BRIDGE_VERSION_MESSAGE = '桥接版本过旧,请点击 卸载并重装'
|
|
2
|
+
export const BRIDGE_PACKAGE_MESSAGE = '浏览器桥接不可用,请点击 卸载并重装'
|
|
3
|
+
export const NATIVE_SURFACE_MESSAGE = '浏览器桥接不可用(原生侧栏未就绪),请打开 Desktop 浏览器侧栏后重试'
|
|
4
|
+
|
|
5
|
+
export class BridgeVersionError extends Error {
|
|
6
|
+
readonly code = 'BROWSER_BRIDGE_VERSION_MISMATCH'
|
|
7
|
+
constructor(message = BRIDGE_VERSION_MESSAGE) {
|
|
8
|
+
super(message)
|
|
9
|
+
this.name = 'BridgeVersionError'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export class NativeSurfaceUnavailableError extends Error {
|
|
14
|
+
readonly code = 'BROWSER_NATIVE_SURFACE_UNAVAILABLE'
|
|
15
|
+
constructor() {
|
|
16
|
+
super(NATIVE_SURFACE_MESSAGE)
|
|
17
|
+
this.name = 'NativeSurfaceUnavailableError'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function bridgePackageError(value: unknown): BridgeVersionError | NativeSurfaceUnavailableError | undefined {
|
|
22
|
+
const fields = typeof value === 'object' && value !== null
|
|
23
|
+
? ['code', 'name', 'message', 'error', 'reason', 'note'].map(key => (value as Record<string, unknown>)[key])
|
|
24
|
+
: [value]
|
|
25
|
+
const hasCode = (code: string): boolean => fields.some(field => typeof field === 'string'
|
|
26
|
+
&& new RegExp(`(?:^|[^A-Z0-9_])${code}(?:$|[^A-Z0-9_])`).test(field))
|
|
27
|
+
if (hasCode('BROWSER_BRIDGE_OUTDATED')) return new BridgeVersionError()
|
|
28
|
+
if (hasCode('DSH_BRIDGE_PACKAGE_UNAVAILABLE')) return new BridgeVersionError(BRIDGE_PACKAGE_MESSAGE)
|
|
29
|
+
if (hasCode('BROWSER_NATIVE_SURFACE_UNAVAILABLE')) return new NativeSurfaceUnavailableError()
|
|
30
|
+
return undefined
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isBridgeVersionMismatch(answer: Record<string, unknown>): boolean {
|
|
34
|
+
return (typeof answer.protocol === 'number' && answer.protocol < 4)
|
|
35
|
+
|| answer.code === 'BROWSER_BRIDGE_OUTDATED'
|
|
36
|
+
|| (typeof answer.code === 'string' && /(?:protocol|version)[-_]mismatch|unsupported[-_]protocol/i.test(answer.code))
|
|
37
|
+
|| (typeof answer.error === 'string' && /\b(?:protocol|bridge version)\b.*\b(?:mismatch|unsupported|incompatible|too old|required)\b/i.test(answer.error))
|
|
38
|
+
|| (typeof answer.error === 'string' && /\b(?:unsupported|incompatible)\s+protocol\b/i.test(answer.error))
|
|
39
|
+
}
|