@capyclaw/browser-suite 0.2.37 → 0.2.38
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/composition.lock.json +5 -5
- package/contract/browser-contract.json +45 -19
- package/dsh-suite.json +6 -6
- package/node_modules/@capyclaw/asset-service/src/index.mjs +6 -1
- package/node_modules/@capyclaw/browser-skill-api/contract/browser-contract.json +45 -19
- package/node_modules/@capyclaw/browser-skill-api/skills/browser-api/references/tool-contract.md +1 -1
- package/node_modules/@capyclaw/browser-skill-browser/contract/browser-contract.json +45 -19
- package/node_modules/@capyclaw/browser-skill-ops/contract/browser-contract.json +45 -19
- package/node_modules/@capyclaw/browser-workbench/contract/browser-contract.json +45 -19
- package/node_modules/@capyclaw/browser-workbench/package.json +2 -2
- package/node_modules/@capyclaw/browser-workbench/server/contract.mjs +1 -1
- package/node_modules/@capyclaw/browser-workbench/server/embedded-host.mjs +10 -1
- package/node_modules/@capyclaw/browser-workbench/server/shared/SHARED_MANIFEST.json +1 -1
- package/node_modules/@capyclaw/browser-workbench/server/workbench-framework.mjs +34 -0
- package/node_modules/@capyclaw/foundation/abi/loader.mjs +8 -1
- package/node_modules/@capyclaw/foundation/abi/spec.mjs +5 -2
- package/node_modules/@capyclaw/foundation/abi/version.mjs +63 -5
- package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +29 -2
- package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +12 -2
- package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +3 -82
- package/node_modules/@capyclaw/service-broker/lib/control.mjs +23 -7
- package/node_modules/@capyclaw/service-broker/lib/engine.mjs +60 -6
- package/node_modules/@capyclaw/service-broker/lib/manifest.mjs +15 -2
- package/node_modules/@capyclaw/service-broker/lib/recovery.mjs +0 -50
- package/node_modules/@capyclaw/service-broker/lib/skills-client.mjs +17 -5
- package/node_modules/@capyclaw/service-host/src/index.mjs +9 -1
- package/node_modules/@capyclaw/tool-host/dsh-suite.json +2 -2
- package/node_modules/@capyclaw/tool-host/lib/host.mjs +23 -4
- package/node_modules/@capyclaw/tool-host/package.json +1 -1
- package/node_modules/@capyclaw/tool-host/src/admit-images.mjs +80 -0
- package/node_modules/@capyclaw/tool-host/src/caller-session.mjs +25 -0
- package/node_modules/@capyclaw/tool-host/src/index.mjs +45 -14
- package/node_modules/@capyclaw/tool-host/src/mode-gate.mjs +204 -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 +6 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"contractVersion": "1.3.0",
|
|
3
|
-
"packageVersion": "0.1.
|
|
3
|
+
"packageVersion": "0.1.20",
|
|
4
4
|
"toolCount": 18,
|
|
5
5
|
"tools": [
|
|
6
6
|
{
|
|
@@ -632,6 +632,7 @@
|
|
|
632
632
|
"features": [
|
|
633
633
|
"browser.contract"
|
|
634
634
|
],
|
|
635
|
+
"domain": "",
|
|
635
636
|
"tools": [
|
|
636
637
|
{
|
|
637
638
|
"name": "browser_capabilities",
|
|
@@ -651,7 +652,8 @@
|
|
|
651
652
|
"additionalProperties": false
|
|
652
653
|
},
|
|
653
654
|
"kind": "read",
|
|
654
|
-
"since": "1.0.0"
|
|
655
|
+
"since": "1.0.0",
|
|
656
|
+
"domain": ""
|
|
655
657
|
}
|
|
656
658
|
]
|
|
657
659
|
},
|
|
@@ -670,6 +672,7 @@
|
|
|
670
672
|
"features": [
|
|
671
673
|
"browser.navigation"
|
|
672
674
|
],
|
|
675
|
+
"domain": "",
|
|
673
676
|
"tools": [
|
|
674
677
|
{
|
|
675
678
|
"name": "browser_navigate",
|
|
@@ -694,7 +697,8 @@
|
|
|
694
697
|
"additionalProperties": false
|
|
695
698
|
},
|
|
696
699
|
"kind": "write",
|
|
697
|
-
"since": "1.0.0"
|
|
700
|
+
"since": "1.0.0",
|
|
701
|
+
"domain": ""
|
|
698
702
|
}
|
|
699
703
|
]
|
|
700
704
|
},
|
|
@@ -713,6 +717,7 @@
|
|
|
713
717
|
"features": [
|
|
714
718
|
"browser.snapshot"
|
|
715
719
|
],
|
|
720
|
+
"domain": "",
|
|
716
721
|
"tools": [
|
|
717
722
|
{
|
|
718
723
|
"name": "browser_snapshot",
|
|
@@ -729,7 +734,8 @@
|
|
|
729
734
|
"additionalProperties": false
|
|
730
735
|
},
|
|
731
736
|
"kind": "read",
|
|
732
|
-
"since": "1.0.0"
|
|
737
|
+
"since": "1.0.0",
|
|
738
|
+
"domain": ""
|
|
733
739
|
}
|
|
734
740
|
]
|
|
735
741
|
},
|
|
@@ -748,6 +754,7 @@
|
|
|
748
754
|
"features": [
|
|
749
755
|
"browser.interaction"
|
|
750
756
|
],
|
|
757
|
+
"domain": "",
|
|
751
758
|
"tools": [
|
|
752
759
|
{
|
|
753
760
|
"name": "browser_click",
|
|
@@ -779,7 +786,8 @@
|
|
|
779
786
|
"additionalProperties": false
|
|
780
787
|
},
|
|
781
788
|
"kind": "write",
|
|
782
|
-
"since": "1.0.0"
|
|
789
|
+
"since": "1.0.0",
|
|
790
|
+
"domain": ""
|
|
783
791
|
},
|
|
784
792
|
{
|
|
785
793
|
"name": "browser_drag",
|
|
@@ -838,7 +846,8 @@
|
|
|
838
846
|
"additionalProperties": false
|
|
839
847
|
},
|
|
840
848
|
"kind": "write",
|
|
841
|
-
"since": "1.2.0"
|
|
849
|
+
"since": "1.2.0",
|
|
850
|
+
"domain": ""
|
|
842
851
|
},
|
|
843
852
|
{
|
|
844
853
|
"name": "browser_fill",
|
|
@@ -873,7 +882,8 @@
|
|
|
873
882
|
"additionalProperties": false
|
|
874
883
|
},
|
|
875
884
|
"kind": "write",
|
|
876
|
-
"since": "1.0.0"
|
|
885
|
+
"since": "1.0.0",
|
|
886
|
+
"domain": ""
|
|
877
887
|
},
|
|
878
888
|
{
|
|
879
889
|
"name": "browser_press",
|
|
@@ -903,7 +913,8 @@
|
|
|
903
913
|
"additionalProperties": false
|
|
904
914
|
},
|
|
905
915
|
"kind": "write",
|
|
906
|
-
"since": "1.0.0"
|
|
916
|
+
"since": "1.0.0",
|
|
917
|
+
"domain": ""
|
|
907
918
|
},
|
|
908
919
|
{
|
|
909
920
|
"name": "browser_select",
|
|
@@ -934,7 +945,8 @@
|
|
|
934
945
|
"additionalProperties": false
|
|
935
946
|
},
|
|
936
947
|
"kind": "write",
|
|
937
|
-
"since": "1.0.0"
|
|
948
|
+
"since": "1.0.0",
|
|
949
|
+
"domain": ""
|
|
938
950
|
},
|
|
939
951
|
{
|
|
940
952
|
"name": "browser_upload",
|
|
@@ -973,7 +985,8 @@
|
|
|
973
985
|
"additionalProperties": false
|
|
974
986
|
},
|
|
975
987
|
"kind": "write",
|
|
976
|
-
"since": "1.3.0"
|
|
988
|
+
"since": "1.3.0",
|
|
989
|
+
"domain": ""
|
|
977
990
|
},
|
|
978
991
|
{
|
|
979
992
|
"name": "browser_scroll",
|
|
@@ -1002,7 +1015,8 @@
|
|
|
1002
1015
|
"additionalProperties": false
|
|
1003
1016
|
},
|
|
1004
1017
|
"kind": "write",
|
|
1005
|
-
"since": "1.0.0"
|
|
1018
|
+
"since": "1.0.0",
|
|
1019
|
+
"domain": ""
|
|
1006
1020
|
},
|
|
1007
1021
|
{
|
|
1008
1022
|
"name": "browser_act",
|
|
@@ -1116,7 +1130,8 @@
|
|
|
1116
1130
|
"additionalProperties": false
|
|
1117
1131
|
},
|
|
1118
1132
|
"kind": "write",
|
|
1119
|
-
"since": "1.1.0"
|
|
1133
|
+
"since": "1.1.0",
|
|
1134
|
+
"domain": ""
|
|
1120
1135
|
}
|
|
1121
1136
|
]
|
|
1122
1137
|
},
|
|
@@ -1135,6 +1150,7 @@
|
|
|
1135
1150
|
"features": [
|
|
1136
1151
|
"browser.tabs"
|
|
1137
1152
|
],
|
|
1153
|
+
"domain": "",
|
|
1138
1154
|
"tools": [
|
|
1139
1155
|
{
|
|
1140
1156
|
"name": "browser_tabs",
|
|
@@ -1166,7 +1182,8 @@
|
|
|
1166
1182
|
"additionalProperties": false
|
|
1167
1183
|
},
|
|
1168
1184
|
"kind": "control",
|
|
1169
|
-
"since": "1.0.0"
|
|
1185
|
+
"since": "1.0.0",
|
|
1186
|
+
"domain": ""
|
|
1170
1187
|
}
|
|
1171
1188
|
]
|
|
1172
1189
|
},
|
|
@@ -1186,6 +1203,7 @@
|
|
|
1186
1203
|
"features": [
|
|
1187
1204
|
"browser.screenshot"
|
|
1188
1205
|
],
|
|
1206
|
+
"domain": "",
|
|
1189
1207
|
"tools": [
|
|
1190
1208
|
{
|
|
1191
1209
|
"name": "browser_screenshot",
|
|
@@ -1206,7 +1224,8 @@
|
|
|
1206
1224
|
"additionalProperties": false
|
|
1207
1225
|
},
|
|
1208
1226
|
"kind": "read",
|
|
1209
|
-
"since": "1.0.0"
|
|
1227
|
+
"since": "1.0.0",
|
|
1228
|
+
"domain": ""
|
|
1210
1229
|
}
|
|
1211
1230
|
]
|
|
1212
1231
|
},
|
|
@@ -1225,6 +1244,7 @@
|
|
|
1225
1244
|
"features": [
|
|
1226
1245
|
"browser.session"
|
|
1227
1246
|
],
|
|
1247
|
+
"domain": "",
|
|
1228
1248
|
"tools": [
|
|
1229
1249
|
{
|
|
1230
1250
|
"name": "browser_status",
|
|
@@ -1235,7 +1255,8 @@
|
|
|
1235
1255
|
"additionalProperties": false
|
|
1236
1256
|
},
|
|
1237
1257
|
"kind": "read",
|
|
1238
|
-
"since": "1.0.0"
|
|
1258
|
+
"since": "1.0.0",
|
|
1259
|
+
"domain": ""
|
|
1239
1260
|
},
|
|
1240
1261
|
{
|
|
1241
1262
|
"name": "browser_wait",
|
|
@@ -1261,7 +1282,8 @@
|
|
|
1261
1282
|
"additionalProperties": false
|
|
1262
1283
|
},
|
|
1263
1284
|
"kind": "control",
|
|
1264
|
-
"since": "1.0.0"
|
|
1285
|
+
"since": "1.0.0",
|
|
1286
|
+
"domain": ""
|
|
1265
1287
|
},
|
|
1266
1288
|
{
|
|
1267
1289
|
"name": "browser_history",
|
|
@@ -1287,7 +1309,8 @@
|
|
|
1287
1309
|
"additionalProperties": false
|
|
1288
1310
|
},
|
|
1289
1311
|
"kind": "control",
|
|
1290
|
-
"since": "1.0.0"
|
|
1312
|
+
"since": "1.0.0",
|
|
1313
|
+
"domain": ""
|
|
1291
1314
|
},
|
|
1292
1315
|
{
|
|
1293
1316
|
"name": "browser_close",
|
|
@@ -1298,7 +1321,8 @@
|
|
|
1298
1321
|
"additionalProperties": false
|
|
1299
1322
|
},
|
|
1300
1323
|
"kind": "control",
|
|
1301
|
-
"since": "1.0.0"
|
|
1324
|
+
"since": "1.0.0",
|
|
1325
|
+
"domain": ""
|
|
1302
1326
|
}
|
|
1303
1327
|
]
|
|
1304
1328
|
},
|
|
@@ -1317,6 +1341,7 @@
|
|
|
1317
1341
|
"features": [
|
|
1318
1342
|
"browser.evaluate"
|
|
1319
1343
|
],
|
|
1344
|
+
"domain": "",
|
|
1320
1345
|
"tools": [
|
|
1321
1346
|
{
|
|
1322
1347
|
"name": "browser_evaluate",
|
|
@@ -1341,7 +1366,8 @@
|
|
|
1341
1366
|
"additionalProperties": false
|
|
1342
1367
|
},
|
|
1343
1368
|
"kind": "write",
|
|
1344
|
-
"since": "1.0.0"
|
|
1369
|
+
"since": "1.0.0",
|
|
1370
|
+
"domain": ""
|
|
1345
1371
|
}
|
|
1346
1372
|
]
|
|
1347
1373
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capyclaw/browser-workbench",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.20",
|
|
4
4
|
"description": "浏览器操控工作台运行时:18 个 browser_* MCP 工具(导航/快照/点击/填写/按键/下拉/上传/滚动/批量连做/拖拽/标签页/截图)+ Playwright 引擎(有头可见、登录态持久化)+ 可视化工作台。",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./plugin.mjs",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"@capyclaw/foundation": "^0.1.9",
|
|
52
52
|
"@capyclaw/plugin-kit": "^0.2.6",
|
|
53
53
|
"@capyclaw/service-host": "^0.1.5",
|
|
54
|
-
"@capyclaw/tool-host": "^0.
|
|
54
|
+
"@capyclaw/tool-host": "^0.3.0",
|
|
55
55
|
"playwright": "^1.64.0"
|
|
56
56
|
},
|
|
57
57
|
"author": {
|
|
@@ -10,7 +10,7 @@ import { createCapabilityReport } from './shared/tool-host.mjs'
|
|
|
10
10
|
export const CONTRACT_VERSION = '1.3.0'
|
|
11
11
|
|
|
12
12
|
/** 工作台包版本。 */
|
|
13
|
-
export const PACKAGE_VERSION = '0.1.
|
|
13
|
+
export const PACKAGE_VERSION = '0.1.20'
|
|
14
14
|
|
|
15
15
|
/** 生成模型可读的能力报告。 */
|
|
16
16
|
export function capabilityReport(args, workbenchUrl = '', runtime = {}) {
|
|
@@ -128,6 +128,14 @@ async function activate(ctx, config) {
|
|
|
128
128
|
const registry = relay.tools
|
|
129
129
|
const tools = safeGet(ctx, 'tools')
|
|
130
130
|
const toolState = { registered: [], errors: [], hasTools: !!(tools && typeof tools.register === 'function') }
|
|
131
|
+
/* 会话模式锁(框架级强制):把本套件工具声明为 browser 领域,注册时逐个挂 when
|
|
132
|
+
* 可见性条件,并装全局 guard 兜底。锁定其他领域的会话里,本套件工具从工具面消失
|
|
133
|
+
* 且被硬拒。toolHost/modeGate 缺席(老宿主)时优雅降级为不屏蔽。 */
|
|
134
|
+
const modeGate = toolHost && toolHost.modeGate
|
|
135
|
+
if (modeGate && registry && Array.isArray(registry.TOOLS)) {
|
|
136
|
+
modeGate.declareTools('browser', registry.TOOLS.map((t) => t.name), 'browser')
|
|
137
|
+
if (toolState.hasTools) modeGate.install(tools)
|
|
138
|
+
}
|
|
131
139
|
const OUTPUT_SCHEMA = { type: 'object', additionalProperties: true }
|
|
132
140
|
|
|
133
141
|
function toolText(value) {
|
|
@@ -146,6 +154,7 @@ async function activate(ctx, config) {
|
|
|
146
154
|
if (registry && Array.isArray(registry.TOOLS) && toolState.hasTools) {
|
|
147
155
|
for (const tool of registry.TOOLS) {
|
|
148
156
|
try {
|
|
157
|
+
const when = modeGate && modeGate.whenFor(tool.name)
|
|
149
158
|
const dispose = tools.register({
|
|
150
159
|
name: tool.name,
|
|
151
160
|
description: tool.description,
|
|
@@ -157,7 +166,7 @@ async function activate(ctx, config) {
|
|
|
157
166
|
/* 第二个参数是 DSH 的 exec(含 exec.agent.session.id):工具靠它知道是哪个
|
|
158
167
|
* 会话在调用,多会话工作台才能把读写落到调用者自己那份文档上。 */
|
|
159
168
|
execute: async (args, exec) => registry.TOOL_IMPL[tool.name](args || {}, exec),
|
|
160
|
-
})
|
|
169
|
+
}, when ? { when } : {})
|
|
161
170
|
if (typeof dispose === 'function') disposers.push(dispose)
|
|
162
171
|
toolState.registered.push(tool.name)
|
|
163
172
|
} catch (error) {
|
|
@@ -111,7 +111,13 @@ export function createWorkbench(spec) {
|
|
|
111
111
|
* 已创建的资源——否则引擎/仓库泄漏在仍存活的进程里(reused 分支的 stop 是
|
|
112
112
|
* no-op,不会有人替它清理)。外部传入的 assetStore 不归本框架关。 */
|
|
113
113
|
let app
|
|
114
|
+
/* 资产仓库周期 GC:默认只清孤儿临时文件(安全——内容寻址资产被稿件引用,
|
|
115
|
+
* 按龄/LRU 淘汰会毁掉旧稿渲染,必须经 tuning 显式 opt-in)。定时器 unref,
|
|
116
|
+
* 不拖住进程退出;所有关闭路径都要清掉它。 */
|
|
117
|
+
let assetGcTimer = null
|
|
118
|
+
const stopAssetGc = () => { if (assetGcTimer) { clearInterval(assetGcTimer); assetGcTimer = null } }
|
|
114
119
|
const closeCreatedResources = async (why) => {
|
|
120
|
+
stopAssetGc()
|
|
115
121
|
try { if (spec.beforeStop) await spec.beforeStop(ctx) } catch (error) { console.error(`[${spec.id}] ${why}:beforeStop 失败`, error?.message || error) }
|
|
116
122
|
try { if (!givenAssetStore) await assetStore?.close?.() } catch (error) { console.error(`[${spec.id}] ${why}:assetStore 关闭失败`, error?.message || error) }
|
|
117
123
|
try { await store?.close?.() } catch (error) { console.error(`[${spec.id}] ${why}:store 关闭失败`, error?.message || error) }
|
|
@@ -213,6 +219,32 @@ export function createWorkbench(spec) {
|
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
|
|
222
|
+
/* 只有真正提供服务的形态才起周期 GC(reused 形态已回收资源,不起定时器)。
|
|
223
|
+
* tuning.assetGcIntervalMs<=0 可整体关闭;maxAgeMs/maxBytes 缺省 0=不按龄/量淘汰。 */
|
|
224
|
+
if (assetStore && typeof assetStore.gc === 'function') {
|
|
225
|
+
const gcIntervalMs = Number(tuning.assetGcIntervalMs ?? 3600000)
|
|
226
|
+
if (gcIntervalMs > 0) {
|
|
227
|
+
const gcOptions = {
|
|
228
|
+
maxAgeMs: Number(tuning.assetGcMaxAgeMs) || 0,
|
|
229
|
+
maxBytes: Number(tuning.assetGcMaxBytes) || 0,
|
|
230
|
+
}
|
|
231
|
+
const runGc = async () => {
|
|
232
|
+
try {
|
|
233
|
+
const result = await assetStore.gc(gcOptions)
|
|
234
|
+
if (result?.removed || result?.orphanTmpRemoved) {
|
|
235
|
+
console.log(`[${spec.id}] 资产 GC:清理 ${result.removed || 0} 项、孤儿临时文件 ${result.orphanTmpRemoved || 0} 个,释放 ${result.freedBytes || 0} 字节`)
|
|
236
|
+
}
|
|
237
|
+
} catch (error) {
|
|
238
|
+
console.error(`[${spec.id}] 资产 GC 失败(下轮再试):`, error?.message || error)
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
assetGcTimer = setInterval(runGc, gcIntervalMs)
|
|
242
|
+
assetGcTimer.unref?.()
|
|
243
|
+
/* 启动即跑一轮:清掉上次进程崩溃留下的孤儿 tmp,不必等第一个周期。 */
|
|
244
|
+
runGc()
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
216
248
|
try {
|
|
217
249
|
/* 业务钩子:设置 URL 环境变量、崩溃恢复等(必须在工具装载之前)。 */
|
|
218
250
|
if (spec.onListening) await spec.onListening(ctx, info, url)
|
|
@@ -255,12 +287,14 @@ export function createWorkbench(spec) {
|
|
|
255
287
|
tools: ctx.toolsRegistry || null,
|
|
256
288
|
...(spec.resultExtras ? spec.resultExtras(ctx) : {}),
|
|
257
289
|
stop: async () => {
|
|
290
|
+
stopAssetGc()
|
|
258
291
|
if (!ctx.embedded) removeDiscovery(hostDir)
|
|
259
292
|
if (spec.beforeStop) await spec.beforeStop(ctx)
|
|
260
293
|
await info.stop()
|
|
261
294
|
},
|
|
262
295
|
}
|
|
263
296
|
} catch (error) {
|
|
297
|
+
stopAssetGc()
|
|
264
298
|
try { if (!ctx.embedded) removeDiscovery(hostDir) } catch { /* 忽略 */ }
|
|
265
299
|
try { if (spec.beforeStop) await spec.beforeStop(ctx) } catch { /* 忽略 */ }
|
|
266
300
|
try { await info.stop() } catch { /* 忽略 */ }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { ABI_MAJOR, getInterfaceKind } from './kinds.mjs'
|
|
3
3
|
import { validateInterface } from './validate.mjs'
|
|
4
4
|
import { AbiError, ERROR_CODES, toAbiError } from './errors.mjs'
|
|
5
|
-
import { satisfies } from './version.mjs'
|
|
5
|
+
import { satisfies, isValidRange } from './version.mjs'
|
|
6
6
|
|
|
7
7
|
const thenable = (value) => value && typeof value.then === 'function'
|
|
8
8
|
|
|
@@ -164,6 +164,13 @@ export function createLoader({ adapters = {}, capabilities = {}, log = null, abi
|
|
|
164
164
|
plugins.delete(spec.name)
|
|
165
165
|
void previous.handle?.dispose?.()
|
|
166
166
|
}
|
|
167
|
+
/* 非法范围单独报 E_SCHEMA:旧实现把「range 写错」和「能力真缺」都归成
|
|
168
|
+
* E_CAP_MISSING「能力不可用」,误导排障。先区分两者。 */
|
|
169
|
+
const badRanges = spec.requires.filter((need) => need.name.startsWith('os.') && !isValidRange(need.range))
|
|
170
|
+
if (badRanges.length) {
|
|
171
|
+
throw error(ERROR_CODES.E_SCHEMA, `插件 ${spec.name} 能力范围非法:${badRanges.map((r) => r.raw).join(', ')}`,
|
|
172
|
+
{ plugin: spec.name, invalid: badRanges })
|
|
173
|
+
}
|
|
167
174
|
const missing = spec.requires.filter((need) => need.name.startsWith('os.')
|
|
168
175
|
&& !satisfies(capabilityMap()[need.name] || '', need.range))
|
|
169
176
|
if (missing.length) {
|
|
@@ -191,9 +191,12 @@ export function definePlugin(options = {}) {
|
|
|
191
191
|
const requiresEntries = requires.map((entry) => parseCapability(entry, 'requires'))
|
|
192
192
|
const providesEntries = provides.map((entry) => parseCapability(entry, 'provides'))
|
|
193
193
|
for (const entry of providesEntries) {
|
|
194
|
-
|
|
194
|
+
/* 白名单而非黑名单:provides 必须是完整 x.y.z(可带 prerelease)。旧实现只拒
|
|
195
|
+
* ^~<>= 前缀,'1.x' / '1.*' / 裸 '1' 漏网被当成版本发布,消费方 parseVersion
|
|
196
|
+
* 解析不了 → satisfies 恒 false,能力永远「不可用」。 */
|
|
197
|
+
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(entry.range)) {
|
|
195
198
|
throw new AbiError(ERROR_CODES.E_PLUGIN_SHAPE,
|
|
196
|
-
`provides
|
|
199
|
+
`provides 必须写精确版本(x.y.z),不能写范围:${entry.raw}`, { entry: entry.raw })
|
|
197
200
|
}
|
|
198
201
|
}
|
|
199
202
|
|
|
@@ -2,25 +2,57 @@
|
|
|
2
2
|
* 版本与范围:能力声明用 `^1` / `^1.2.0` / `>=1.2` / `1.x` / 精确版本。
|
|
3
3
|
*
|
|
4
4
|
* 只实现这份 ABI 需要的语义,不引入 semver 依赖:
|
|
5
|
-
* - `^1.2.3` → >=1.2.3 且同主版本;`^0.2.3` → >=0.2.3
|
|
5
|
+
* - `^1.2.3` → >=1.2.3 且同主版本;`^0.2.3` → >=0.2.3 且同次版本;
|
|
6
|
+
* `^0.0.3` → >=0.0.3 且同补丁(0.0.x 约定,semver 标准)
|
|
6
7
|
* - `~1.2.3` → >=1.2.3 且同次版本
|
|
7
8
|
* - `1.x` / `1.*` → 同主版本
|
|
8
9
|
* - `>=` `>` `<=` `<` `=` 前缀
|
|
9
10
|
* - 裸版本 → 精确匹配(比较时忽略末位 0)
|
|
11
|
+
* - prerelease 保留并参与比较:1.0.0-beta < 1.0.0;带 prerelease 的版本只满足
|
|
12
|
+
* 同 [major,minor,patch] 且同样带 prerelease 的范围(semver 标准,避免预发布
|
|
13
|
+
* 版本被当成正式版本放行)。
|
|
10
14
|
*/
|
|
11
15
|
|
|
12
16
|
export function parseVersion(text) {
|
|
13
17
|
if (typeof text !== 'string') return null
|
|
14
|
-
const match = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-[0-9A-Za-z.-]+)?$/.exec(text.trim())
|
|
18
|
+
const match = /^v?(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([0-9A-Za-z.-]+))?$/.exec(text.trim())
|
|
15
19
|
if (!match) return null
|
|
16
|
-
|
|
20
|
+
const parts = [Number(match[1]), Number(match[2] || 0), Number(match[3] || 0)]
|
|
21
|
+
parts.prerelease = match[4] || null
|
|
22
|
+
return parts
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function comparePrerelease(a, b) {
|
|
26
|
+
/* 无 prerelease > 有 prerelease(1.0.0 > 1.0.0-beta)。 */
|
|
27
|
+
if (!a && !b) return 0
|
|
28
|
+
if (!a) return 1
|
|
29
|
+
if (!b) return -1
|
|
30
|
+
const left = a.split('.')
|
|
31
|
+
const right = b.split('.')
|
|
32
|
+
for (let i = 0; i < Math.max(left.length, right.length); i++) {
|
|
33
|
+
const x = left[i]
|
|
34
|
+
const y = right[i]
|
|
35
|
+
if (x === undefined) return -1
|
|
36
|
+
if (y === undefined) return 1
|
|
37
|
+
const xn = /^\d+$/.test(x)
|
|
38
|
+
const yn = /^\d+$/.test(y)
|
|
39
|
+
if (xn && yn) {
|
|
40
|
+
const d = Number(x) - Number(y)
|
|
41
|
+
if (d !== 0) return d < 0 ? -1 : 1
|
|
42
|
+
} else if (xn !== yn) {
|
|
43
|
+
return xn ? -1 : 1 // 数字标识符 < 字母数字标识符
|
|
44
|
+
} else if (x !== y) {
|
|
45
|
+
return x < y ? -1 : 1
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return 0
|
|
17
49
|
}
|
|
18
50
|
|
|
19
51
|
function compareParts(a, b) {
|
|
20
52
|
for (let i = 0; i < 3; i++) {
|
|
21
53
|
if (a[i] !== b[i]) return a[i] < b[i] ? -1 : 1
|
|
22
54
|
}
|
|
23
|
-
return
|
|
55
|
+
return comparePrerelease(a.prerelease || null, b.prerelease || null)
|
|
24
56
|
}
|
|
25
57
|
|
|
26
58
|
export function compareVersions(a, b) {
|
|
@@ -44,12 +76,23 @@ export function satisfies(version, range) {
|
|
|
44
76
|
if (raw.startsWith('^')) {
|
|
45
77
|
const base = parseVersion(raw.slice(1))
|
|
46
78
|
if (!base) return false
|
|
79
|
+
/* prerelease 只满足同 [major,minor,patch] 且带 prerelease 的范围(semver 标准),
|
|
80
|
+
* 避免 1.1.0-beta 被 ^1.0.0 当正式版本放行。 */
|
|
81
|
+
if (current.prerelease && (!base.prerelease
|
|
82
|
+
|| current[0] !== base[0] || current[1] !== base[1] || current[2] !== base[2])) return false
|
|
47
83
|
if (compareParts(current, base) < 0) return false
|
|
48
|
-
|
|
84
|
+
if (base[0] === 0) {
|
|
85
|
+
/* 0.0.x caret 收紧到补丁位:^0.0.3 只容 0.0.3,不容 0.0.9。 */
|
|
86
|
+
if (base[1] === 0) return current[0] === 0 && current[1] === 0 && current[2] === base[2]
|
|
87
|
+
return current[0] === 0 && current[1] === base[1]
|
|
88
|
+
}
|
|
89
|
+
return current[0] === base[0]
|
|
49
90
|
}
|
|
50
91
|
if (raw.startsWith('~')) {
|
|
51
92
|
const base = parseVersion(raw.slice(1))
|
|
52
93
|
if (!base) return false
|
|
94
|
+
if (current.prerelease && (!base.prerelease
|
|
95
|
+
|| current[0] !== base[0] || current[1] !== base[1] || current[2] !== base[2])) return false
|
|
53
96
|
return compareParts(current, base) >= 0 && current[0] === base[0] && current[1] === base[1]
|
|
54
97
|
}
|
|
55
98
|
if (raw.startsWith('>=')) {
|
|
@@ -80,3 +123,18 @@ export function satisfies(version, range) {
|
|
|
80
123
|
const exact = parseVersion(raw)
|
|
81
124
|
return Boolean(exact) && compareParts(current, exact) === 0
|
|
82
125
|
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* 范围是否「语义合法」(区别于「合法但不满足」)。供加载器把非法范围单独报
|
|
129
|
+
* E_SCHEMA,而不是误归因成「能力不可用」误导排障。空范围视为「任意」,合法。
|
|
130
|
+
*/
|
|
131
|
+
export function isValidRange(range) {
|
|
132
|
+
const raw = String(range ?? '').trim()
|
|
133
|
+
if (!raw || raw === '*' || raw === 'x') return true
|
|
134
|
+
if (/^[\^~]/.test(raw)) return Boolean(parseVersion(raw.slice(1)))
|
|
135
|
+
if (/^(>=|<=)/.test(raw)) return Boolean(parseVersion(raw.slice(2)))
|
|
136
|
+
if (/^[><]/.test(raw)) return Boolean(parseVersion(raw.slice(1)))
|
|
137
|
+
if (raw.startsWith('=')) return isValidRange(raw.slice(1))
|
|
138
|
+
if (/^(\d+)(?:\.(\d+))?\.[x*]$/.test(raw)) return true
|
|
139
|
+
return Boolean(parseVersion(raw))
|
|
140
|
+
}
|
|
@@ -11,6 +11,10 @@ import { BASE_CAPABILITIES } from './caps.mjs'
|
|
|
11
11
|
|
|
12
12
|
const NOOP_LOG = { debug() {}, info() {}, warn() {}, error() {} }
|
|
13
13
|
|
|
14
|
+
/* 内存宿主也要有界:app 不 dispose、asset 只 put 不 delete 的用法会让数组/Map
|
|
15
|
+
* 无限增长。app 提供 dispose() 摘除自己;assets 提供 delete() 与上限 LRU 淘汰。 */
|
|
16
|
+
const DEFAULT_MAX_ASSETS = 1024
|
|
17
|
+
|
|
14
18
|
export function createMemoryHost(options = {}) {
|
|
15
19
|
const state = {
|
|
16
20
|
providers: [],
|
|
@@ -24,6 +28,9 @@ export function createMemoryHost(options = {}) {
|
|
|
24
28
|
plugins: [],
|
|
25
29
|
}
|
|
26
30
|
const log = options.log ?? NOOP_LOG
|
|
31
|
+
const maxAssets = Number(options.maxAssets) > 0 ? Number(options.maxAssets) : DEFAULT_MAX_ASSETS
|
|
32
|
+
/* 单调序号:不能用 size+1 拼 id——淘汰后 size 回落,同毫秒内会撞掉已有资产。 */
|
|
33
|
+
let assetSeq = 0
|
|
27
34
|
|
|
28
35
|
function http() {
|
|
29
36
|
return {
|
|
@@ -41,6 +48,11 @@ export function createMemoryHost(options = {}) {
|
|
|
41
48
|
}
|
|
42
49
|
},
|
|
43
50
|
async dispatch() {},
|
|
51
|
+
dispose() {
|
|
52
|
+
const index = state.apps.indexOf(app)
|
|
53
|
+
if (index >= 0) state.apps.splice(index, 1)
|
|
54
|
+
routes.length = 0
|
|
55
|
+
},
|
|
44
56
|
}
|
|
45
57
|
state.apps.push(app)
|
|
46
58
|
return app
|
|
@@ -149,12 +161,27 @@ export function createMemoryHost(options = {}) {
|
|
|
149
161
|
}),
|
|
150
162
|
assets: () => ({
|
|
151
163
|
async put(value, contentType = 'application/octet-stream') {
|
|
152
|
-
const id = `asset-${state.assets.size + 1}`
|
|
153
164
|
const buffer = Buffer.isBuffer(value) ? value : Buffer.from(String(value))
|
|
165
|
+
/* Map 保持插入序:超限淘汰最旧(LRU 近似),get 命中会刷新到队尾。 */
|
|
166
|
+
while (state.assets.size >= maxAssets) {
|
|
167
|
+
const oldest = state.assets.keys().next().value
|
|
168
|
+
state.assets.delete(oldest)
|
|
169
|
+
}
|
|
170
|
+
const id = `asset-${++assetSeq}`
|
|
154
171
|
state.assets.set(id, { data: buffer, contentType })
|
|
155
172
|
return { id, url: `/assets/${id}`, size: buffer.length, contentType }
|
|
156
173
|
},
|
|
157
|
-
get(id) {
|
|
174
|
+
get(id) {
|
|
175
|
+
const entry = state.assets.get(id)
|
|
176
|
+
if (entry) { state.assets.delete(id); state.assets.set(id, entry) }
|
|
177
|
+
return entry
|
|
178
|
+
},
|
|
179
|
+
delete(id) { return state.assets.delete(id) },
|
|
180
|
+
gc() {
|
|
181
|
+
const removed = state.assets.size
|
|
182
|
+
state.assets.clear()
|
|
183
|
+
return { removed }
|
|
184
|
+
},
|
|
158
185
|
}),
|
|
159
186
|
}
|
|
160
187
|
}
|
|
@@ -91,7 +91,11 @@ export function createNet(host, config = {}) {
|
|
|
91
91
|
}
|
|
92
92
|
return
|
|
93
93
|
}
|
|
94
|
-
await new Promise((resolve) =>
|
|
94
|
+
await new Promise((resolve) => {
|
|
95
|
+
/* unref:迟到补挂的轮询定时器不得拖住进程退出(最长 60s 的尾延迟)。 */
|
|
96
|
+
const timer = setTimeout(resolve, WEB_LATE_POLL_MS)
|
|
97
|
+
timer.unref?.()
|
|
98
|
+
})
|
|
95
99
|
}
|
|
96
100
|
})().catch(() => {})
|
|
97
101
|
}
|
|
@@ -116,7 +120,10 @@ export function createNet(host, config = {}) {
|
|
|
116
120
|
if (!web && shouldWaitForWeb()) {
|
|
117
121
|
const deadline = Date.now() + WEB_WAIT_MS
|
|
118
122
|
while (!web && Date.now() < deadline && !closed) {
|
|
119
|
-
await new Promise((resolve) =>
|
|
123
|
+
await new Promise((resolve) => {
|
|
124
|
+
const timer = setTimeout(resolve, WEB_POLL_MS)
|
|
125
|
+
timer.unref?.()
|
|
126
|
+
})
|
|
120
127
|
web = webServer()
|
|
121
128
|
}
|
|
122
129
|
}
|
|
@@ -140,6 +147,9 @@ export function createNet(host, config = {}) {
|
|
|
140
147
|
disposal = (async () => {
|
|
141
148
|
if (!sharedHost) return
|
|
142
149
|
// listen 失败由 ready/start 报告;清理仍需执行,且 close 失败不能被吞掉。
|
|
150
|
+
// 注意:dispose 在 listen 失败时仍 RESOLVE(错误经 ready/start 上报)——这是
|
|
151
|
+
// 被 network-lifecycle 测试固化的契约,close 不再二次上抛 listen 错,避免
|
|
152
|
+
// 破坏「清理成功即 dispose 成功」的语义。
|
|
143
153
|
await listening.catch(() => {})
|
|
144
154
|
// 迟到补挂的路由要一起撤掉,否则共享宿主关了、宿主网页端口上还留着分发器。
|
|
145
155
|
try {
|