@capyclaw/browser-workbench 0.1.0 → 0.1.18
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.md +29 -7
- package/contract/browser-contract.json +484 -25
- package/demo/form.html +27 -0
- package/lib/host.mjs +1 -68
- package/node_modules/@capyclaw/asset-service/README.md +48 -0
- package/node_modules/@capyclaw/asset-service/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/asset-service/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/asset-service/lib/host.mjs +14 -0
- package/node_modules/@capyclaw/asset-service/package.json +59 -0
- package/node_modules/@capyclaw/asset-service/src/index.mjs +304 -0
- package/node_modules/@capyclaw/document-workbench/README.md +125 -0
- package/node_modules/@capyclaw/document-workbench/package.json +44 -0
- package/node_modules/@capyclaw/document-workbench/src/bridge/index.mjs +321 -0
- package/node_modules/@capyclaw/document-workbench/src/client/index.mjs +625 -0
- package/node_modules/@capyclaw/document-workbench/src/client/screenshot.mjs +98 -0
- package/node_modules/@capyclaw/document-workbench/src/index.mjs +9 -0
- package/node_modules/@capyclaw/document-workbench/src/model/audit.mjs +101 -0
- package/node_modules/@capyclaw/document-workbench/src/model/conformance.mjs +92 -0
- package/node_modules/@capyclaw/document-workbench/src/model/ids.mjs +56 -0
- package/node_modules/@capyclaw/document-workbench/src/model/index.mjs +18 -0
- package/node_modules/@capyclaw/document-workbench/src/model/locate.mjs +118 -0
- package/node_modules/@capyclaw/document-workbench/src/model/manifest.mjs +148 -0
- package/node_modules/@capyclaw/document-workbench/src/model/ops.mjs +160 -0
- package/node_modules/@capyclaw/document-workbench/src/model/validate.mjs +72 -0
- package/node_modules/@capyclaw/document-workbench/src/ops/index.mjs +93 -0
- package/node_modules/@capyclaw/document-workbench/src/session/context.mjs +103 -0
- package/node_modules/@capyclaw/document-workbench/src/session/index.mjs +394 -0
- package/node_modules/@capyclaw/document-workbench/src/session/lease.mjs +105 -0
- package/node_modules/@capyclaw/document-workbench/src/session/mode.mjs +80 -0
- package/node_modules/@capyclaw/document-workbench/src/session/sanitize.mjs +107 -0
- package/node_modules/@capyclaw/document-workbench/src/session/state.mjs +159 -0
- package/node_modules/@capyclaw/document-workbench/src/session/watch.mjs +63 -0
- package/{server/shared/state-service.mjs → node_modules/@capyclaw/document-workbench/src/store/file-backend.mjs} +6 -97
- package/node_modules/@capyclaw/document-workbench/src/testing/index.mjs +75 -0
- package/node_modules/@capyclaw/foundation/README.md +51 -0
- package/node_modules/@capyclaw/foundation/abi/bridge.mjs +86 -0
- package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
- package/node_modules/@capyclaw/foundation/abi/index.mjs +35 -0
- package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +345 -0
- package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +255 -0
- package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
- package/node_modules/@capyclaw/foundation/abi/version.mjs +82 -0
- package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
- package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +55 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +69 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +120 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
- package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
- package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +34 -0
- package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +85 -0
- package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +50 -0
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +160 -0
- package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
- package/node_modules/@capyclaw/foundation/lib/kernel.mjs +185 -0
- package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +115 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +188 -0
- package/node_modules/@capyclaw/foundation/package.json +53 -0
- package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
- package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
- package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
- package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
- package/node_modules/@capyclaw/plugin-kit/package.json +69 -0
- package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
- package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +129 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +139 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
- package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
- package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
- package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
- package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
- package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
- package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
- package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
- package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
- package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
- package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +656 -0
- package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
- package/node_modules/@capyclaw/service-host/README.md +86 -0
- package/node_modules/@capyclaw/service-host/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/service-host/dsh-suite.json +29 -0
- package/node_modules/@capyclaw/service-host/lib/host.mjs +22 -0
- package/node_modules/@capyclaw/service-host/package.json +60 -0
- package/node_modules/@capyclaw/service-host/src/index.mjs +571 -0
- package/node_modules/@capyclaw/service-host/src/tuning.mjs +63 -0
- package/node_modules/@capyclaw/tool-host/README.md +56 -0
- package/node_modules/@capyclaw/tool-host/cordis.patch.yml +4 -0
- package/node_modules/@capyclaw/tool-host/dsh-suite.json +30 -0
- package/node_modules/@capyclaw/tool-host/lib/host.mjs +16 -0
- package/node_modules/@capyclaw/tool-host/package.json +59 -0
- package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +166 -0
- package/node_modules/@capyclaw/tool-host/src/index.mjs +416 -0
- package/node_modules/playwright/LICENSE +202 -0
- package/node_modules/playwright/NOTICE +5 -0
- package/node_modules/playwright/README.md +318 -0
- package/node_modules/playwright/ThirdPartyNotices.txt +14 -0
- package/node_modules/playwright/cli.js +19 -0
- package/node_modules/playwright/index.d.ts +17 -0
- package/node_modules/playwright/index.js +17 -0
- package/node_modules/playwright/index.mjs +18 -0
- package/node_modules/playwright/lib/agents/agentParser.js +89 -0
- package/node_modules/playwright/lib/agents/copilot-setup-steps.yml +34 -0
- package/node_modules/playwright/lib/agents/generateAgents.js +395 -0
- package/node_modules/playwright/lib/agents/playwright-test-coverage.prompt.md +31 -0
- package/node_modules/playwright/lib/agents/playwright-test-generate.prompt.md +8 -0
- package/node_modules/playwright/lib/agents/playwright-test-generator.agent.md +88 -0
- package/node_modules/playwright/lib/agents/playwright-test-heal.prompt.md +6 -0
- package/node_modules/playwright/lib/agents/playwright-test-healer.agent.md +56 -0
- package/node_modules/playwright/lib/agents/playwright-test-plan.prompt.md +9 -0
- package/node_modules/playwright/lib/agents/playwright-test-planner.agent.md +74 -0
- package/node_modules/playwright/lib/cli/reportActions.js +78 -0
- package/node_modules/playwright/lib/cli/testActions.js +217 -0
- package/node_modules/playwright/lib/common/index.js +2937 -0
- package/node_modules/playwright/lib/common/index.js.txt +33 -0
- package/node_modules/playwright/lib/errorContext.js +129 -0
- package/node_modules/playwright/lib/globals.js +58 -0
- package/node_modules/playwright/lib/index.js +827 -0
- package/node_modules/playwright/lib/isomorphic.js +260 -0
- package/node_modules/playwright/lib/isomorphic.js.txt +9 -0
- package/node_modules/playwright/lib/loader/loaderProcessEntry.js +34 -0
- package/node_modules/playwright/lib/loader/loaderProcessEntry.js.txt +9 -0
- package/node_modules/playwright/lib/matchers/expect.js +13496 -0
- package/node_modules/playwright/lib/matchers/expect.js.LICENSE +640 -0
- package/node_modules/playwright/lib/matchers/expect.js.txt +67 -0
- package/node_modules/playwright/lib/package.js +47 -0
- package/node_modules/playwright/lib/program.js +242 -0
- package/node_modules/playwright/lib/runner/index.js +8721 -0
- package/node_modules/playwright/lib/runner/index.js.txt +62 -0
- package/node_modules/playwright/lib/transform/babelBundle.js +72490 -0
- package/node_modules/playwright/lib/transform/babelBundle.js.LICENSE +2384 -0
- package/node_modules/playwright/lib/transform/babelBundle.js.txt +328 -0
- package/node_modules/playwright/lib/transform/esmLoader.js +8066 -0
- package/node_modules/playwright/lib/transform/esmLoader.js.LICENSE +355 -0
- package/node_modules/playwright/lib/transform/esmLoader.js.txt +60 -0
- package/node_modules/playwright/lib/util.js +373 -0
- package/node_modules/playwright/lib/worker/workerProcessEntry.js +1860 -0
- package/node_modules/playwright/lib/worker/workerProcessEntry.js.txt +19 -0
- package/node_modules/playwright/package.json +50 -0
- package/node_modules/playwright/test.d.ts +18 -0
- package/node_modules/playwright/test.js +24 -0
- package/node_modules/playwright/test.mjs +35 -0
- package/node_modules/playwright/types/test.d.ts +11191 -0
- package/node_modules/playwright/types/testReporter.d.ts +950 -0
- package/node_modules/playwright-core/LICENSE +202 -0
- package/node_modules/playwright-core/NOTICE +5 -0
- package/node_modules/playwright-core/README.md +3 -0
- package/node_modules/playwright-core/ThirdPartyNotices.txt +13 -0
- package/node_modules/playwright-core/bin/install_media_pack.ps1 +5 -0
- package/node_modules/playwright-core/bin/install_webkit_wsl.ps1 +33 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_linux.sh +42 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_linux.sh +42 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/node_modules/playwright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_linux.sh +48 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_linux.sh +48 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_linux.sh +48 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/node_modules/playwright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/node_modules/playwright-core/browsers.json +52 -0
- package/node_modules/playwright-core/cli.js +22 -0
- package/node_modules/playwright-core/index.d.ts +17 -0
- package/node_modules/playwright-core/index.js +17 -0
- package/node_modules/playwright-core/index.mjs +28 -0
- package/node_modules/playwright-core/lib/bootstrap.js +149 -0
- package/node_modules/playwright-core/lib/coreBundle.js +78041 -0
- package/node_modules/playwright-core/lib/entry/cliDaemon.js +5 -0
- package/node_modules/playwright-core/lib/entry/dashboardApp.js +3 -0
- package/node_modules/playwright-core/lib/entry/mcp.js +10 -0
- package/node_modules/playwright-core/lib/entry/oopBrowserDownload.js +3 -0
- package/node_modules/playwright-core/lib/package.js +50 -0
- package/node_modules/playwright-core/lib/server/chromium/appIcon.png +0 -0
- package/node_modules/playwright-core/lib/server/electron/loader.js +123 -0
- package/node_modules/playwright-core/lib/serverRegistry.js +1939 -0
- package/node_modules/playwright-core/lib/serverRegistry.js.LICENSE +65 -0
- package/node_modules/playwright-core/lib/tools/cli-client/channelSessions.js +141 -0
- package/node_modules/playwright-core/lib/tools/cli-client/cli.js +7 -0
- package/node_modules/playwright-core/lib/tools/cli-client/help.json +808 -0
- package/node_modules/playwright-core/lib/tools/cli-client/minimist.js +128 -0
- package/node_modules/playwright-core/lib/tools/cli-client/output.js +352 -0
- package/node_modules/playwright-core/lib/tools/cli-client/program.js +422 -0
- package/node_modules/playwright-core/lib/tools/cli-client/registry.js +180 -0
- package/node_modules/playwright-core/lib/tools/cli-client/session.js +261 -0
- package/node_modules/playwright-core/lib/tools/dashboard/appIcon.png +0 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/SKILL.md +493 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
- package/node_modules/playwright-core/lib/tools/skills/playwright-trace/SKILL.md +174 -0
- package/node_modules/playwright-core/lib/tools/utils/extension.js +112 -0
- package/node_modules/playwright-core/lib/tools/utils/socketConnection.js +108 -0
- package/node_modules/playwright-core/lib/utilsBundle.js +86078 -0
- package/node_modules/playwright-core/lib/utilsBundle.js.LICENSE +1890 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
- package/node_modules/playwright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
- package/node_modules/playwright-core/lib/vite/dashboard/index.html +29 -0
- package/node_modules/playwright-core/lib/vite/dashboard/playwright-logo.svg +24 -0
- package/node_modules/playwright-core/lib/vite/htmlReport/index.html +16 -0
- package/node_modules/playwright-core/lib/vite/htmlReport/report.css +2 -0
- package/node_modules/playwright-core/lib/vite/htmlReport/report.js +32 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/codeMirrorModule-DK72OMRi.js +32 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
- package/node_modules/playwright-core/lib/vite/recorder/assets/index-Cn0mmDuv.js +129 -0
- package/node_modules/playwright-core/lib/vite/recorder/index.html +29 -0
- package/node_modules/playwright-core/lib/vite/recorder/playwright-logo.svg +9 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/codeMirrorModule-BEB2e8M3.js +32 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/defaultSettingsView-D-g2vrvf.js +184 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/assets/xtermModule-B794rD2Z.js +7 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/index.html +44 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/index.oNry3Hjv.js +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/manifest.webmanifest +16 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/snapshot.html +10 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/sw.bundle.js +4 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CYwC_gH1.js +5 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/uiMode.html +18 -0
- package/node_modules/playwright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
- package/node_modules/playwright-core/lib/webp_codec.LICENSE +173 -0
- package/node_modules/playwright-core/lib/webp_codec.wasm +0 -0
- package/node_modules/playwright-core/lib/xdg-open +1267 -0
- package/node_modules/playwright-core/package.json +34 -0
- package/node_modules/playwright-core/types/protocol.d.ts +24776 -0
- package/node_modules/playwright-core/types/structs.d.ts +52 -0
- package/node_modules/playwright-core/types/types.d.ts +27167 -0
- package/package.json +30 -12
- package/plugin.mjs +1 -0
- package/server/contract.mjs +3 -3
- package/server/embedded-host.mjs +247 -0
- package/server/engine.mjs +1906 -115
- package/server/governor.mjs +189 -0
- package/server/http-utils.mjs +1 -1
- package/server/human.mjs +628 -0
- package/server/infra/http.mjs +2 -113
- package/server/infra/tuning.mjs +2 -82
- package/server/input.mjs +154 -0
- package/server/login-vault.mjs +109 -0
- package/server/mcp/handler.mjs +1 -1
- package/server/mcp/instructions.mjs +5 -2
- package/server/orphans.mjs +163 -0
- package/server/relay.mjs +160 -188
- package/server/routes/api.mjs +126 -13
- package/server/routes/assets.mjs +1 -1
- package/server/session-engines.mjs +223 -0
- package/server/shared/SHARED_MANIFEST.json +47 -24
- package/server/shared/asset-service.mjs +2 -217
- package/server/shared/editor-host.mjs +2 -125
- package/server/shared/kit/editor/lease.mjs +2 -139
- package/server/shared/kit/service/api.mjs +2 -45
- package/server/shared/kit/service/http.mjs +2 -113
- package/server/shared/kit/service/mcp-http.mjs +2 -142
- package/server/shared/kit/tools/validate.mjs +2 -115
- package/server/shared/kit/tuning.mjs +2 -82
- package/server/shared/kit/util/fs-lock.mjs +2 -132
- package/server/shared/service-host.mjs +2 -511
- package/server/shared/tool-host.mjs +2 -341
- package/server/shared/tuning.mjs +2 -63
- package/server/tools/capabilities/contract.mjs +25 -5
- package/server/tools/capabilities/interaction.mjs +113 -9
- package/server/tools/capabilities/navigation.mjs +5 -2
- package/server/tools/capabilities/screenshot.mjs +25 -8
- package/server/tools/capabilities/session.mjs +13 -7
- package/server/tools/capabilities/snapshot.mjs +1 -1
- package/server/tools/capabilities/tabs.mjs +2 -2
- package/server/tools/kernel/define.mjs +1 -1
- package/server/tools/kernel/output.mjs +8 -0
- package/server/tools/kernel/ports.mjs +12 -7
- package/server/tools/kernel/registry.mjs +1 -1
- package/server/workbench-framework.mjs +305 -0
- package/ui/app.js +409 -119
- package/ui/index.html +29 -39
- package/ui/style.css +131 -63
- package/cordis.patch.yml +0 -25
|
@@ -1,341 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* 把“能力声明 → 注册表 → 工具 schema/实现 → 契约报告 → MCP 协议壳”收成一套:
|
|
5
|
-
* defineTool / defineCapability / createRegistry / createMcpHandler /
|
|
6
|
-
* createCapabilityReport / buildInstructions
|
|
7
|
-
*
|
|
8
|
-
* 功能插件只写业务能力,不再复制 kernel/registry/dispatch/validate/contract。
|
|
9
|
-
*/
|
|
10
|
-
import { createMcpHandler as createKitMcpHandler } from '@capyclaw/plugin-kit/service/mcp-http'
|
|
11
|
-
import { validateToolArguments } from '@capyclaw/plugin-kit/tools/validate'
|
|
12
|
-
import { createServiceApi } from '@capyclaw/plugin-kit/service/api'
|
|
13
|
-
|
|
14
|
-
const KINDS = new Set(['read', 'write', 'control'])
|
|
15
|
-
|
|
16
|
-
export function defineTool({
|
|
17
|
-
name,
|
|
18
|
-
description = '',
|
|
19
|
-
inputSchema = { type: 'object', properties: {}, additionalProperties: false },
|
|
20
|
-
kind = 'write',
|
|
21
|
-
since = '1.0.0',
|
|
22
|
-
handler,
|
|
23
|
-
} = {}) {
|
|
24
|
-
if (!name || typeof name !== 'string') throw new Error('defineTool 需要 name')
|
|
25
|
-
if (typeof handler !== 'function') throw new Error(`工具 ${name} 需要 handler`)
|
|
26
|
-
if (!KINDS.has(kind)) throw new Error(`工具 ${name} 的 kind 非法: ${kind}`)
|
|
27
|
-
return Object.freeze({ name, description, inputSchema, kind, since, handler })
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function defineCapability({
|
|
31
|
-
id,
|
|
32
|
-
title,
|
|
33
|
-
description = '',
|
|
34
|
-
tags = [],
|
|
35
|
-
requires = [],
|
|
36
|
-
dependsOn = [],
|
|
37
|
-
provides = {},
|
|
38
|
-
features = [],
|
|
39
|
-
tools = [],
|
|
40
|
-
} = {}) {
|
|
41
|
-
if (!id || typeof id !== 'string') throw new Error('defineCapability 需要 id')
|
|
42
|
-
if (!Array.isArray(tools) || !tools.length) throw new Error(`能力 ${id} 至少需要一个工具`)
|
|
43
|
-
return Object.freeze({
|
|
44
|
-
id,
|
|
45
|
-
title: title || id,
|
|
46
|
-
description,
|
|
47
|
-
tags: Object.freeze([...tags]),
|
|
48
|
-
requires: Object.freeze([...requires]),
|
|
49
|
-
dependsOn: Object.freeze([...dependsOn]),
|
|
50
|
-
provides: Object.freeze({ ...provides }),
|
|
51
|
-
features: Object.freeze([...features]),
|
|
52
|
-
tools: Object.freeze([...tools]),
|
|
53
|
-
})
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function validateCapabilities(capabilities) {
|
|
57
|
-
const ids = new Set()
|
|
58
|
-
const toolNames = new Set()
|
|
59
|
-
for (const cap of capabilities) {
|
|
60
|
-
if (ids.has(cap.id)) throw new Error(`重复的 capability id: ${cap.id}`)
|
|
61
|
-
ids.add(cap.id)
|
|
62
|
-
for (const tool of cap.tools) {
|
|
63
|
-
if (toolNames.has(tool.name)) throw new Error(`重复的工具名: ${tool.name}`)
|
|
64
|
-
toolNames.add(tool.name)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
for (const cap of capabilities) {
|
|
68
|
-
for (const dep of cap.dependsOn) {
|
|
69
|
-
if (!ids.has(dep)) throw new Error(`能力 ${cap.id} 依赖不存在的能力: ${dep}`)
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function selectCapabilities(capabilities, enabled) {
|
|
75
|
-
if (!enabled || !enabled.length) return capabilities
|
|
76
|
-
const byId = new Map(capabilities.map((cap) => [cap.id, cap]))
|
|
77
|
-
for (const id of enabled) {
|
|
78
|
-
if (!byId.has(id)) throw new Error(`enabled 里有未知能力: ${id}`)
|
|
79
|
-
}
|
|
80
|
-
const ids = new Set(enabled)
|
|
81
|
-
let changed = true
|
|
82
|
-
while (changed) {
|
|
83
|
-
changed = false
|
|
84
|
-
for (const cap of capabilities) {
|
|
85
|
-
if (!ids.has(cap.id)) continue
|
|
86
|
-
for (const dep of cap.dependsOn) {
|
|
87
|
-
if (!ids.has(dep)) { ids.add(dep); changed = true }
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return capabilities.filter((cap) => ids.has(cap.id))
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* @param {Array} capabilities
|
|
96
|
-
* @param {{ enabled?: string[], ports?: object, report?: Function, reserved?: string[] }} options
|
|
97
|
-
*/
|
|
98
|
-
export function createRegistry(capabilities, { enabled = null, ports = null, report = null, reserved = [] } = {}) {
|
|
99
|
-
validateCapabilities(capabilities)
|
|
100
|
-
const selected = selectCapabilities(capabilities, enabled)
|
|
101
|
-
|
|
102
|
-
const kernelPorts = { ...(ports || {}) }
|
|
103
|
-
const reservedNames = new Set([...(reserved || []), 'contract'])
|
|
104
|
-
const providers = new Map()
|
|
105
|
-
for (const cap of selected) {
|
|
106
|
-
for (const [ns, api] of Object.entries(cap.provides || {})) {
|
|
107
|
-
if (reservedNames.has(ns)) throw new Error(`能力 ${cap.id} 不能覆盖内核端口: ${ns}`)
|
|
108
|
-
if (providers.has(ns)) throw new Error(`服务命名空间重复: ${ns}(${providers.get(ns).cap.id} / ${cap.id})`)
|
|
109
|
-
providers.set(ns, { cap, api })
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
const available = new Set([...Object.keys(kernelPorts), ...reservedNames, ...providers.keys()])
|
|
114
|
-
for (const cap of selected) {
|
|
115
|
-
for (const req of cap.requires) {
|
|
116
|
-
if (!available.has(req)) throw new Error(`能力 ${cap.id} 需要未提供的端口/服务: ${req}`)
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const ctx = { ...kernelPorts }
|
|
121
|
-
for (const [ns, { api }] of providers) {
|
|
122
|
-
ctx[ns] = {}
|
|
123
|
-
for (const [method, fn] of Object.entries(api)) {
|
|
124
|
-
if (typeof fn !== 'function') throw new Error(`服务 ${ns}.${method} 必须是函数`)
|
|
125
|
-
ctx[ns][method] = (...args) => fn(ctx, ...args)
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const TOOLS = []
|
|
130
|
-
const TOOL_IMPL = {}
|
|
131
|
-
const TOOL_META = {}
|
|
132
|
-
const FEATURES = []
|
|
133
|
-
const CAPABILITIES = []
|
|
134
|
-
|
|
135
|
-
for (const cap of selected) {
|
|
136
|
-
for (const feature of cap.features) {
|
|
137
|
-
if (!FEATURES.includes(feature)) FEATURES.push(feature)
|
|
138
|
-
}
|
|
139
|
-
CAPABILITIES.push({
|
|
140
|
-
id: cap.id,
|
|
141
|
-
title: cap.title,
|
|
142
|
-
description: cap.description,
|
|
143
|
-
tags: [...cap.tags],
|
|
144
|
-
tools: cap.tools.map((tool) => tool.name),
|
|
145
|
-
})
|
|
146
|
-
for (const tool of cap.tools) {
|
|
147
|
-
TOOLS.push({ name: tool.name, description: tool.description, inputSchema: tool.inputSchema })
|
|
148
|
-
TOOL_META[tool.name] = { kind: tool.kind, since: tool.since, capability: cap.id }
|
|
149
|
-
TOOL_IMPL[tool.name] = (args) => tool.handler(args || {}, ctx)
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
const reportFn = report || createCapabilityReport
|
|
154
|
-
ctx.contract = {
|
|
155
|
-
report: (editorUrl = '', runtime = {}) => reportFn({
|
|
156
|
-
tools: TOOLS,
|
|
157
|
-
toolMeta: TOOL_META,
|
|
158
|
-
features: FEATURES,
|
|
159
|
-
capabilities: CAPABILITIES,
|
|
160
|
-
editorUrl,
|
|
161
|
-
runtime,
|
|
162
|
-
}),
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
return { TOOLS, TOOL_IMPL, TOOL_META, FEATURES, CAPABILITIES, ctx }
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/** 与 MCP 工具面解耦:调用前统一校验。 */
|
|
169
|
-
export function createToolDispatcher({ tools, callTool }) {
|
|
170
|
-
const toolMap = new Map((tools || []).map((tool) => [tool.name, tool]))
|
|
171
|
-
return {
|
|
172
|
-
listTools() {
|
|
173
|
-
return { tools }
|
|
174
|
-
},
|
|
175
|
-
async callTool(name, args = {}) {
|
|
176
|
-
const tool = toolMap.get(name)
|
|
177
|
-
if (!tool) {
|
|
178
|
-
return { content: [{ type: 'text', text: `未知工具: ${String(name)}` }], isError: true }
|
|
179
|
-
}
|
|
180
|
-
const check = validateToolArguments(tool, args)
|
|
181
|
-
if (!check.ok) {
|
|
182
|
-
return { content: [{ type: 'text', text: '参数不合法:' + check.errors.join(';') }], isError: true }
|
|
183
|
-
}
|
|
184
|
-
const out = await callTool(name, args)
|
|
185
|
-
if (out && out.content) return out
|
|
186
|
-
return { content: [{ type: 'text', text: out?.text || 'ok' }] }
|
|
187
|
-
},
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* MCP Streamable HTTP 处理器。registry 可直接传 createRegistry 的返回值。
|
|
193
|
-
* 兼容两种调用:
|
|
194
|
-
* { registry } 或 { tools, toolImpl }
|
|
195
|
-
* { tools, callTool }(旧 relay 形态)
|
|
196
|
-
* @param {{ registry?: object, tools?: Array, toolImpl?: object, callTool?: Function, serverInfo?: object, instructions?: string }} options
|
|
197
|
-
*/
|
|
198
|
-
export function createMcpHandler({ registry, tools, toolImpl, callTool, serverInfo, instructions } = {}) {
|
|
199
|
-
const list = tools || registry?.TOOLS || []
|
|
200
|
-
const impl = toolImpl || registry?.TOOL_IMPL || null
|
|
201
|
-
if (!Array.isArray(list) || !list.length) throw new Error('createMcpHandler: 没有工具可暴露')
|
|
202
|
-
if (!impl && typeof callTool !== 'function') throw new Error('createMcpHandler: 需要 toolImpl 或 callTool')
|
|
203
|
-
return createKitMcpHandler({
|
|
204
|
-
tools: list,
|
|
205
|
-
callTool: (name, args, context) => {
|
|
206
|
-
if (typeof callTool === 'function' && !impl) return callTool(name, args, context)
|
|
207
|
-
const fn = impl[name]
|
|
208
|
-
if (!fn) throw new Error(`未知工具: ${name}`)
|
|
209
|
-
return fn(args, context)
|
|
210
|
-
},
|
|
211
|
-
serverInfo: serverInfo || { name: 'dsh-tool-host', version: '0.1.0' },
|
|
212
|
-
instructions,
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export function createCapabilityReport({
|
|
217
|
-
tools = [],
|
|
218
|
-
toolMeta = {},
|
|
219
|
-
features = [],
|
|
220
|
-
capabilities = [],
|
|
221
|
-
contractVersion = '1.0.0',
|
|
222
|
-
packageVersion = '0.0.0',
|
|
223
|
-
editorUrl = '',
|
|
224
|
-
runtime = {},
|
|
225
|
-
} = {}) {
|
|
226
|
-
return {
|
|
227
|
-
contractVersion,
|
|
228
|
-
packageVersion,
|
|
229
|
-
editorUrl,
|
|
230
|
-
...runtime,
|
|
231
|
-
toolCount: tools.length,
|
|
232
|
-
tools: tools.map((tool) => ({
|
|
233
|
-
name: tool.name,
|
|
234
|
-
kind: toolMeta[tool.name]?.kind ?? 'write',
|
|
235
|
-
since: toolMeta[tool.name]?.since ?? '1.0.0',
|
|
236
|
-
capability: toolMeta[tool.name]?.capability ?? '',
|
|
237
|
-
})),
|
|
238
|
-
features,
|
|
239
|
-
capabilities: capabilities.map((cap) => ({
|
|
240
|
-
id: cap.id,
|
|
241
|
-
title: cap.title,
|
|
242
|
-
description: cap.description || '',
|
|
243
|
-
tags: cap.tags || [],
|
|
244
|
-
tools: cap.tools || [],
|
|
245
|
-
})),
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* 生成 MCP server instructions(≤32KB)。业务只提供数据,不再手写排版。
|
|
251
|
-
*/
|
|
252
|
-
export function buildInstructions({
|
|
253
|
-
title = '',
|
|
254
|
-
intro = '',
|
|
255
|
-
startup = [],
|
|
256
|
-
capabilities = [],
|
|
257
|
-
tools = [],
|
|
258
|
-
rules = [],
|
|
259
|
-
output = [],
|
|
260
|
-
} = {}) {
|
|
261
|
-
const rows = capabilities.length
|
|
262
|
-
? capabilities.map((cap) => `| ${cap.title} | ${cap.tools.map((name) => `\`${name}\``).join(', ')} | ${cap.description || ''} |`)
|
|
263
|
-
: [{
|
|
264
|
-
title: '工具',
|
|
265
|
-
tools: tools.map((tool) => tool.name),
|
|
266
|
-
description: '',
|
|
267
|
-
}].map((cap) => `| ${cap.title} | ${cap.tools.map((name) => `\`${name}\``).join(', ')} | |`)
|
|
268
|
-
|
|
269
|
-
const lines = []
|
|
270
|
-
if (title) lines.push(`# ${title}`, '')
|
|
271
|
-
if (intro) lines.push(intro, '')
|
|
272
|
-
if (startup.length) {
|
|
273
|
-
lines.push('## 启动检查')
|
|
274
|
-
startup.forEach((line, index) => lines.push(`${index + 1}. ${line}`))
|
|
275
|
-
lines.push('')
|
|
276
|
-
}
|
|
277
|
-
lines.push('## 能力面', '| 能力 | 工具 | 用途 |', '|---|---|---|', ...rows, '')
|
|
278
|
-
if (rules.length) {
|
|
279
|
-
lines.push('## 硬规则')
|
|
280
|
-
rules.forEach((line) => lines.push(`- ${line}`))
|
|
281
|
-
lines.push('')
|
|
282
|
-
}
|
|
283
|
-
if (output.length) {
|
|
284
|
-
lines.push('## 输出')
|
|
285
|
-
output.forEach((line) => lines.push(`- ${line}`))
|
|
286
|
-
}
|
|
287
|
-
return lines.join('\n')
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* 把能力注册表直接注册到 DSH 的 ctx.tools(同进程原生工具面)。
|
|
292
|
-
* 注册后不再需要单独的 loopback /mcp 端口和 @deepseek-ai/dsh-mcp-client row。
|
|
293
|
-
* @param {object} ctx DSH cordis context
|
|
294
|
-
* @param {object} registry createRegistry() 的返回值
|
|
295
|
-
* @param {{ namespace?: string }} options
|
|
296
|
-
* @returns {() => void} 反注册全部工具
|
|
297
|
-
*/
|
|
298
|
-
export function registerWithDsh(ctx, registry, { namespace = '' } = {}) {
|
|
299
|
-
if (!ctx?.tools?.register) throw new Error('registerWithDsh: 当前 DSH 没有 ctx.tools.register')
|
|
300
|
-
const disposers = []
|
|
301
|
-
for (const tool of registry?.TOOLS || []) {
|
|
302
|
-
const impl = registry.TOOL_IMPL?.[tool.name]
|
|
303
|
-
if (typeof impl !== 'function') throw new Error(`registerWithDsh: 工具缺少实现 ${tool.name}`)
|
|
304
|
-
const name = namespace ? `${namespace}_${tool.name}` : tool.name
|
|
305
|
-
disposers.push(ctx.tools.register({
|
|
306
|
-
name,
|
|
307
|
-
description: tool.description || '',
|
|
308
|
-
parameters: tool.inputSchema || { type: 'object', properties: {}, additionalProperties: false },
|
|
309
|
-
output: {
|
|
310
|
-
schema: { type: 'object', additionalProperties: true },
|
|
311
|
-
render: (args, value) => (value && Array.isArray(value.content)
|
|
312
|
-
? value.content
|
|
313
|
-
: [{ type: 'text', text: typeof value === 'string' ? value : JSON.stringify(value) }]),
|
|
314
|
-
},
|
|
315
|
-
execute: (args) => impl(args),
|
|
316
|
-
}))
|
|
317
|
-
}
|
|
318
|
-
return () => {
|
|
319
|
-
for (const dispose of disposers) {
|
|
320
|
-
try { dispose() } catch { /* 忽略重复释放 */ }
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
export function createToolHost(config = {}) {
|
|
326
|
-
return {
|
|
327
|
-
api: createServiceApi('toolHost', '1.0.0', ['dsl', 'registry', 'validate', 'contract', 'mcp', 'instructions', 'native-tools']),
|
|
328
|
-
version: '0.1.0',
|
|
329
|
-
defineTool,
|
|
330
|
-
defineCapability,
|
|
331
|
-
createRegistry: (capabilities, options = {}) => createRegistry(capabilities, { ...config, ...options }),
|
|
332
|
-
createMcpHandler,
|
|
333
|
-
createToolDispatcher,
|
|
334
|
-
createCapabilityReport,
|
|
335
|
-
buildInstructions,
|
|
336
|
-
registerWithDsh,
|
|
337
|
-
validateToolArguments,
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
export { validateToolArguments }
|
|
1
|
+
/** 由 build/sync-shared.mjs 生成:实现只存在于 @capyclaw/tool-host/src,此处零拷贝。 */
|
|
2
|
+
export * from '@capyclaw/tool-host/src'
|
package/server/shared/tuning.mjs
CHANGED
|
@@ -1,63 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* 默认值与进化搜索(evolution/ NSGA-II)的 founder 基线保持一致;
|
|
5
|
-
* 生产环境可用 DSH_TUNING_JSON 覆盖(按包名分组),测试/评估用 setTuning 注入。
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const DEFAULTS = {
|
|
9
|
-
/* 端口被占时向后顺延扫描的次数上限(非 strictPort) */
|
|
10
|
-
portScanLimit: 50,
|
|
11
|
-
/* 复用既有实例的 /healthz 探测超时
|
|
12
|
-
* 200ms 由进化搜索固化(evolution/,2026-11-01):黑洞端口启动阻塞 425→227ms;
|
|
13
|
-
* 健康实例 RTT 1-3ms,仍有 60 倍以上余量。 */
|
|
14
|
-
reuseProbeTimeoutMs: 200,
|
|
15
|
-
/* 单实例锁:空/坏锁视为残留前的宽限 */
|
|
16
|
-
lockFreshGraceMs: 2000,
|
|
17
|
-
/* 优雅关闭:先等 N ms 再断开全部连接 */
|
|
18
|
-
closeGraceMs: 50,
|
|
19
|
-
/* 优雅关闭:强制完成的兜底时限 */
|
|
20
|
-
closeForceMs: 1000,
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
let overrides = {}
|
|
24
|
-
let envLoaded = false
|
|
25
|
-
|
|
26
|
-
function loadEnv() {
|
|
27
|
-
if (envLoaded) return
|
|
28
|
-
envLoaded = true
|
|
29
|
-
try {
|
|
30
|
-
const raw = process.env.DSH_TUNING_JSON
|
|
31
|
-
if (!raw) return
|
|
32
|
-
const parsed = JSON.parse(raw)
|
|
33
|
-
if (!parsed || typeof parsed !== 'object') return
|
|
34
|
-
const own = parsed['dsh-service-host'] && typeof parsed['dsh-service-host'] === 'object'
|
|
35
|
-
? parsed['dsh-service-host']
|
|
36
|
-
: parsed
|
|
37
|
-
for (const key of Object.keys(DEFAULTS)) {
|
|
38
|
-
if (own[key] !== undefined) overrides[key] = own[key]
|
|
39
|
-
}
|
|
40
|
-
} catch { /* 非法 JSON 静默忽略:调优失败不能阻塞启动 */ }
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/** 当前生效参数(默认值 + env + setTuning 覆盖)。 */
|
|
44
|
-
export function tuning() {
|
|
45
|
-
loadEnv()
|
|
46
|
-
return { ...DEFAULTS, ...overrides }
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/** 测试/评估注入。只接受已知键,避免拼写错误静默生效。 */
|
|
50
|
-
export function setTuning(patch = {}) {
|
|
51
|
-
loadEnv()
|
|
52
|
-
for (const [key, value] of Object.entries(patch)) {
|
|
53
|
-
if (key in DEFAULTS) overrides[key] = value
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/** 恢复到默认值 + env 覆盖。 */
|
|
58
|
-
export function resetTuning() {
|
|
59
|
-
overrides = {}
|
|
60
|
-
envLoaded = false
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export const TUNING_DEFAULTS = { ...DEFAULTS }
|
|
1
|
+
/** 由 build/sync-shared.mjs 生成:实现只存在于 @capyclaw/service-host/tuning,此处零拷贝。 */
|
|
2
|
+
export * from '@capyclaw/service-host/tuning'
|
|
@@ -11,14 +11,18 @@ export const contractCapability = defineCapability({
|
|
|
11
11
|
tools: [
|
|
12
12
|
defineTool({
|
|
13
13
|
name: 'browser_capabilities',
|
|
14
|
-
description: '返回工作台契约版本、工具清单、能力清单与引擎状态。skill 加载后先调用一次;工具缺失或 major
|
|
15
|
-
inputSchema: {
|
|
14
|
+
description: '返回工作台契约版本、工具清单、能力清单与引擎状态。skill 加载后先调用一次;工具缺失或 major 版本不一致时停止并提示升级。默认紧凑模式(只给名字/状态,省 token);需要能力描述与 tags 时传 detail="full"。',
|
|
15
|
+
inputSchema: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
properties: { detail: { type: 'string', enum: ['compact', 'full'], description: '报告详细度,默认 compact' } },
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
},
|
|
16
20
|
kind: 'read',
|
|
17
21
|
since: '1.0.0',
|
|
18
|
-
handler: async (
|
|
22
|
+
handler: async (args, ctx) => runTool(async () => {
|
|
19
23
|
let runtime = { engineRunning: false, tabs: 0, headless: null, evaluateEnabled: false }
|
|
20
24
|
try {
|
|
21
|
-
const status = ctx.engine.status()
|
|
25
|
+
const status = await ctx.engine.status()
|
|
22
26
|
runtime = {
|
|
23
27
|
engineRunning: !!status.running,
|
|
24
28
|
tabs: status.tabs.length,
|
|
@@ -28,7 +32,23 @@ export const contractCapability = defineCapability({
|
|
|
28
32
|
} catch { /* 引擎未绑定时仍返回静态契约 */ }
|
|
29
33
|
let workbenchUrl = ''
|
|
30
34
|
try { workbenchUrl = ctx.server.url() } catch { /* 保持空 */ }
|
|
31
|
-
|
|
35
|
+
const report = ctx.contract.report(workbenchUrl, runtime)
|
|
36
|
+
if ((args && args.detail) === 'full') return JSON.stringify(report, null, 2)
|
|
37
|
+
/* 紧凑模式:保留契约/状态/工具名,去掉能力描述、tags、features 等模型路由用不到的胖字段。 */
|
|
38
|
+
const compact = {
|
|
39
|
+
contractVersion: report.contractVersion,
|
|
40
|
+
packageVersion: report.packageVersion,
|
|
41
|
+
editorUrl: report.editorUrl,
|
|
42
|
+
editorPath: report.editorPath,
|
|
43
|
+
engineRunning: report.engineRunning,
|
|
44
|
+
tabs: report.tabs,
|
|
45
|
+
headless: report.headless,
|
|
46
|
+
evaluateEnabled: report.evaluateEnabled,
|
|
47
|
+
toolCount: report.toolCount,
|
|
48
|
+
tools: (report.tools || []).map((t) => t.name),
|
|
49
|
+
capabilities: (report.capabilities || []).map((c) => ({ id: c.id, tools: c.tools })),
|
|
50
|
+
}
|
|
51
|
+
return JSON.stringify(compact, null, 2)
|
|
32
52
|
}),
|
|
33
53
|
}),
|
|
34
54
|
],
|
|
@@ -13,18 +13,52 @@ export const interactionCapability = defineCapability({
|
|
|
13
13
|
tools: [
|
|
14
14
|
defineTool({
|
|
15
15
|
name: 'browser_click',
|
|
16
|
-
description: '点击元素。ref
|
|
16
|
+
description: '点击元素。ref 来自最近一次快照(首选);快照里没有的元素(无 role 的 div 按钮等)用 selector 或 text 兜底。元素已变化时报 STALE_SNAPSHOT,重新快照后用新 ref。动作成功后返回新快照。',
|
|
17
17
|
inputSchema: {
|
|
18
18
|
type: 'object',
|
|
19
|
-
properties: {
|
|
20
|
-
|
|
19
|
+
properties: {
|
|
20
|
+
ref: { type: 'string', maxLength: 16, description: '快照里的元素引用,如 e5(首选)' },
|
|
21
|
+
selector: { type: 'string', maxLength: 300, description: 'CSS 选择器兜底,如 .next-btn' },
|
|
22
|
+
text: { type: 'string', maxLength: 120, description: '可见文案兜底,如「下一步」' },
|
|
23
|
+
tab: TAB_PROP,
|
|
24
|
+
},
|
|
21
25
|
additionalProperties: false,
|
|
22
26
|
},
|
|
23
27
|
kind: 'write',
|
|
24
28
|
since: '1.0.0',
|
|
25
29
|
handler: async (args, ctx) => runTool(async () => {
|
|
26
|
-
const out = await ctx.engine.click({ ref: args.ref, tab: args.tab })
|
|
27
|
-
return `已点击 ${out.clicked}(标签页 ${out.tab}
|
|
30
|
+
const out = await ctx.engine.click({ ref: args.ref, selector: args.selector, text: args.text, tab: args.tab })
|
|
31
|
+
return `已点击 ${out.clicked}(标签页 ${out.tab})${out.snapshot.authWall ? `\n⚠ ${out.snapshot.authWall}` : ''}\n\n${out.snapshot.text}`
|
|
32
|
+
}),
|
|
33
|
+
}),
|
|
34
|
+
defineTool({
|
|
35
|
+
name: 'browser_drag',
|
|
36
|
+
description: '拖拽:滑块验证、拖放排序。起点可以给 ref / selector / text;终点给 toRef / toSelector / toText,或直接用 dx/dy 相对位移(滑块常用 dx)。内部按多步轨迹移动再松手,比一步到位更像人。成功后返回新快照。',
|
|
37
|
+
inputSchema: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
ref: { type: 'string', maxLength: 16, description: '起点 ref(首选)' },
|
|
41
|
+
selector: { type: 'string', maxLength: 300, description: '起点 CSS 选择器兜底' },
|
|
42
|
+
text: { type: 'string', maxLength: 120, description: '起点可见文案兜底' },
|
|
43
|
+
toRef: { type: 'string', maxLength: 16, description: '终点 ref' },
|
|
44
|
+
toSelector: { type: 'string', maxLength: 300, description: '终点 CSS 选择器' },
|
|
45
|
+
toText: { type: 'string', maxLength: 120, description: '终点可见文案' },
|
|
46
|
+
dx: { type: 'number', description: '相对起点的横向位移(滑块向右为正)' },
|
|
47
|
+
dy: { type: 'number', description: '相对起点的纵向位移' },
|
|
48
|
+
steps: { type: 'number', description: '轨迹分几步(默认 24,越大越平滑)' },
|
|
49
|
+
tab: TAB_PROP,
|
|
50
|
+
},
|
|
51
|
+
additionalProperties: false,
|
|
52
|
+
},
|
|
53
|
+
kind: 'write',
|
|
54
|
+
since: '1.2.0',
|
|
55
|
+
handler: async (args, ctx) => runTool(async () => {
|
|
56
|
+
const out = await ctx.engine.drag({
|
|
57
|
+
ref: args.ref, selector: args.selector, text: args.text,
|
|
58
|
+
toRef: args.toRef, toSelector: args.toSelector, toText: args.toText,
|
|
59
|
+
dx: args.dx, dy: args.dy, steps: args.steps, tab: args.tab,
|
|
60
|
+
})
|
|
61
|
+
return `已拖拽 ${out.moved.from} → (${out.moved.to}),位移 ${out.moved.distance}px(标签页 ${out.tab})${out.snapshot.authWall ? `\n⚠ ${out.snapshot.authWall}` : ''}\n\n${out.snapshot.text}`
|
|
28
62
|
}),
|
|
29
63
|
}),
|
|
30
64
|
defineTool({
|
|
@@ -45,7 +79,7 @@ export const interactionCapability = defineCapability({
|
|
|
45
79
|
since: '1.0.0',
|
|
46
80
|
handler: async (args, ctx) => runTool(async () => {
|
|
47
81
|
const out = await ctx.engine.fill({ ref: args.ref, text: args.text, submit: args.submit, tab: args.tab })
|
|
48
|
-
return `已填写 ${out.filled}${out.submit ? ' 并回车提交' : ''}(标签页 ${out.tab}
|
|
82
|
+
return `已填写 ${out.filled}${out.submit ? ' 并回车提交' : ''}(标签页 ${out.tab})${out.snapshot.authWall ? `\n⚠ ${out.snapshot.authWall}` : ''}\n\n${out.snapshot.text}`
|
|
49
83
|
}),
|
|
50
84
|
}),
|
|
51
85
|
defineTool({
|
|
@@ -65,7 +99,7 @@ export const interactionCapability = defineCapability({
|
|
|
65
99
|
since: '1.0.0',
|
|
66
100
|
handler: async (args, ctx) => runTool(async () => {
|
|
67
101
|
const out = await ctx.engine.press({ key: args.key, ref: args.ref, tab: args.tab })
|
|
68
|
-
return `已按键 ${out.key}(标签页 ${out.tab}
|
|
102
|
+
return `已按键 ${out.key}(标签页 ${out.tab})${out.snapshot.authWall ? `\n⚠ ${out.snapshot.authWall}` : ''}\n\n${out.snapshot.text}`
|
|
69
103
|
}),
|
|
70
104
|
}),
|
|
71
105
|
defineTool({
|
|
@@ -85,7 +119,28 @@ export const interactionCapability = defineCapability({
|
|
|
85
119
|
since: '1.0.0',
|
|
86
120
|
handler: async (args, ctx) => runTool(async () => {
|
|
87
121
|
const out = await ctx.engine.select({ ref: args.ref, value: args.value, tab: args.tab })
|
|
88
|
-
return `已选择 ${out.selected}(标签页 ${out.tab}
|
|
122
|
+
return `已选择 ${out.selected}(标签页 ${out.tab})${out.snapshot.authWall ? `\n⚠ ${out.snapshot.authWall}` : ''}\n\n${out.snapshot.text}`
|
|
123
|
+
}),
|
|
124
|
+
}),
|
|
125
|
+
defineTool({
|
|
126
|
+
name: 'browser_upload',
|
|
127
|
+
description: '给文件上传控件(<input type="file">)设置本机文件。ref/selector 定位上传控件;files 是本机绝对路径数组(可多选),空数组=清空已选。闭环里 ppt 等套件产出的文件先物化成本机路径再传这里。成功后返回新快照。',
|
|
128
|
+
inputSchema: {
|
|
129
|
+
type: 'object',
|
|
130
|
+
properties: {
|
|
131
|
+
ref: { type: 'string', maxLength: 16, description: '上传控件的 ref(首选)' },
|
|
132
|
+
selector: { type: 'string', maxLength: 300, description: 'CSS 选择器兜底,如 input[type=file]' },
|
|
133
|
+
files: { type: 'array', items: { type: 'string', maxLength: 1000 }, maxItems: 20, description: '本机绝对路径数组;空数组=清空已选' },
|
|
134
|
+
tab: TAB_PROP,
|
|
135
|
+
},
|
|
136
|
+
required: ['files'],
|
|
137
|
+
additionalProperties: false,
|
|
138
|
+
},
|
|
139
|
+
kind: 'write',
|
|
140
|
+
since: '1.3.0',
|
|
141
|
+
handler: async (args, ctx) => runTool(async () => {
|
|
142
|
+
const out = await ctx.engine.upload({ ref: args.ref, selector: args.selector, files: args.files, tab: args.tab })
|
|
143
|
+
return `已上传 ${out.count} 个文件到 ${out.target}(标签页 ${out.tab}):${out.uploaded.join(', ') || '(清空)'}${out.snapshot.authWall ? `\n⚠ ${out.snapshot.authWall}` : ''}\n\n${out.snapshot.text}`
|
|
89
144
|
}),
|
|
90
145
|
}),
|
|
91
146
|
defineTool({
|
|
@@ -104,7 +159,56 @@ export const interactionCapability = defineCapability({
|
|
|
104
159
|
since: '1.0.0',
|
|
105
160
|
handler: async (args, ctx) => runTool(async () => {
|
|
106
161
|
const out = await ctx.engine.scroll({ direction: args.direction, amount: args.amount, tab: args.tab })
|
|
107
|
-
return `已滚动 ${out.scrolled}(标签页 ${out.tab}
|
|
162
|
+
return `已滚动 ${out.scrolled}(标签页 ${out.tab})${out.snapshot.authWall ? `\n⚠ ${out.snapshot.authWall}` : ''}\n\n${out.snapshot.text}`
|
|
163
|
+
}),
|
|
164
|
+
}),
|
|
165
|
+
defineTool({
|
|
166
|
+
name: 'browser_act',
|
|
167
|
+
description: '把同一页面上多个不跳转的动作打包成一次调用(最多 10 步),只返回一份最终快照——替代「一步一次往返」,每条消息省下多次模型往返。典型:填账号 + 填密码 + 勾选协议 + 选城市 + 拖滑块。注意:会跳转或整页重排的动作(提交、下单、翻页)放最后一步或单独调用;中途不重拍快照,ref 沿用打包前的快照。失败会停在该步并给出原因,仍返回最新快照。',
|
|
168
|
+
inputSchema: {
|
|
169
|
+
type: 'object',
|
|
170
|
+
properties: {
|
|
171
|
+
steps: {
|
|
172
|
+
type: 'array',
|
|
173
|
+
maxItems: 10,
|
|
174
|
+
description: '按顺序执行的动作列表',
|
|
175
|
+
items: {
|
|
176
|
+
type: 'object',
|
|
177
|
+
properties: {
|
|
178
|
+
op: { type: 'string', enum: ['click', 'fill', 'press', 'select', 'drag', 'scroll', 'wait'], description: '动作类型' },
|
|
179
|
+
ref: { type: 'string', maxLength: 16, description: '目标 ref(click/fill/press/select/drag 的起点)' },
|
|
180
|
+
selector: { type: 'string', maxLength: 300, description: 'click/fill/press 的 CSS 兜底;wait 时是等待的选择器' },
|
|
181
|
+
text: { type: 'string', maxLength: 10000, description: 'fill 的文字;click 时是目标文案' },
|
|
182
|
+
submit: { type: 'boolean', description: 'fill 之后回车提交' },
|
|
183
|
+
key: { type: 'string', maxLength: 40, description: 'press 的键名,如 Enter / Tab' },
|
|
184
|
+
value: { type: 'string', maxLength: 300, description: 'select 的选项 value 或文本' },
|
|
185
|
+
toRef: { type: 'string', maxLength: 16, description: 'drag 的终点 ref' },
|
|
186
|
+
toSelector: { type: 'string', maxLength: 300, description: 'drag 的终点选择器' },
|
|
187
|
+
dx: { type: 'number', description: 'drag 的相对横向位移(滑块向右为正)' },
|
|
188
|
+
dy: { type: 'number', description: 'drag 的相对纵向位移' },
|
|
189
|
+
direction: { type: 'string', enum: ['up', 'down'], description: 'scroll 方向' },
|
|
190
|
+
amount: { type: 'number', description: 'scroll 像素数(默认 600)' },
|
|
191
|
+
ms: { type: 'number', description: 'wait 毫秒数' },
|
|
192
|
+
},
|
|
193
|
+
required: ['op'],
|
|
194
|
+
additionalProperties: false,
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
stopOnError: { type: 'boolean', description: '某步失败后是否停止(默认 true)' },
|
|
198
|
+
tab: TAB_PROP,
|
|
199
|
+
},
|
|
200
|
+
required: ['steps'],
|
|
201
|
+
additionalProperties: false,
|
|
202
|
+
},
|
|
203
|
+
kind: 'write',
|
|
204
|
+
since: '1.1.0',
|
|
205
|
+
handler: async (args, ctx) => runTool(async () => {
|
|
206
|
+
const out = await ctx.engine.act({ steps: args.steps, tab: args.tab, stopOnError: args.stopOnError !== false })
|
|
207
|
+
const lines = out.results.map((r) => `${r.index + 1}. ${r.op || '(空)'} ${r.ok ? '✓' : `✗ ${r.error}`}`)
|
|
208
|
+
const head = out.failed < 0
|
|
209
|
+
? `已连做 ${out.results.length} 步(标签页 ${out.tab})`
|
|
210
|
+
: `第 ${out.failed + 1} 步失败,此前已完成 ${out.results.filter((r) => r.ok).length} 步(标签页 ${out.tab})`
|
|
211
|
+
return `${head}\n${lines.join('\n')}${out.snapshot.authWall ? `\n⚠ ${out.snapshot.authWall}` : ''}\n\n${out.snapshot.text}`
|
|
108
212
|
}),
|
|
109
213
|
}),
|
|
110
214
|
],
|
|
@@ -11,7 +11,7 @@ export const navigationCapability = defineCapability({
|
|
|
11
11
|
tools: [
|
|
12
12
|
defineTool({
|
|
13
13
|
name: 'browser_navigate',
|
|
14
|
-
description: '打开网址(仅 http/https;URL 内嵌用户名密码会被拒绝)。首次调用会自动拉起浏览器(默认有头可见,登录态持久化)。返回新页面的元素快照,后续动作直接引用其中的 ref
|
|
14
|
+
description: '打开网址(仅 http/https;URL 内嵌用户名密码会被拒绝)。首次调用会自动拉起浏览器(默认有头可见,登录态持久化)。返回新页面的元素快照,后续动作直接引用其中的 ref。导航超时会返回当前已渲染的快照并标注 [NAV_TIMEOUT],不是空错误。',
|
|
15
15
|
inputSchema: {
|
|
16
16
|
type: 'object',
|
|
17
17
|
properties: {
|
|
@@ -25,7 +25,10 @@ export const navigationCapability = defineCapability({
|
|
|
25
25
|
since: '1.0.0',
|
|
26
26
|
handler: async (args, ctx) => runTool(async () => {
|
|
27
27
|
const out = await ctx.engine.navigate({ url: args.url, tab: args.tab })
|
|
28
|
-
|
|
28
|
+
const head = out.timedOut
|
|
29
|
+
? `[NAV_TIMEOUT] ${out.timeoutMs}ms 内没等到 domcontentloaded(站点慢或被拦)。下面是当前已渲染的内容,可先用 ref 继续操作,或 browser_screenshot 确认。\n已打开 ${out.url} — ${out.title || '(无标题)'}(标签页 ${out.tab})`
|
|
30
|
+
: `已打开 ${out.url} — ${out.title || '(无标题)'}(标签页 ${out.tab})`
|
|
31
|
+
return `${head}${out.note ? `\n⚠ ${out.note}` : ''}\n\n${out.snapshot.text}`
|
|
29
32
|
}),
|
|
30
33
|
}),
|
|
31
34
|
],
|