@web-auto/webauto 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/desktop-console/default-settings.json +1 -0
- package/apps/desktop-console/dist/main/index.mjs +1618 -0
- package/apps/desktop-console/{src → dist}/main/preload.mjs +10 -0
- package/apps/desktop-console/dist/renderer/index.js +3063 -0
- package/apps/desktop-console/entry/ui-console.mjs +299 -0
- package/apps/webauto/entry/account.mjs +356 -0
- package/apps/webauto/entry/lib/account-detect.mjs +160 -0
- package/apps/webauto/entry/lib/account-store.mjs +587 -0
- package/apps/webauto/entry/lib/profilepool.mjs +1 -1
- package/apps/webauto/entry/xhs-install.mjs +27 -3
- package/apps/webauto/entry/xhs-status.mjs +152 -0
- package/apps/webauto/entry/xhs-unified.mjs +595 -17
- package/bin/webauto.mjs +263 -15
- package/dist/apps/webauto/server.js +66 -0
- package/dist/modules/camo-backend/src/index.js +575 -0
- package/dist/modules/camo-backend/src/internal/BrowserSession.js +817 -0
- package/dist/modules/camo-backend/src/internal/ElementRegistry.js +61 -0
- package/dist/modules/camo-backend/src/internal/ProfileLock.js +85 -0
- package/dist/modules/camo-backend/src/internal/SessionManager.js +172 -0
- package/dist/modules/camo-backend/src/internal/container-matcher.js +852 -0
- package/dist/modules/camo-backend/src/internal/engine-manager.js +258 -0
- package/dist/modules/camo-backend/src/internal/fingerprint.js +203 -0
- package/dist/modules/camo-backend/src/internal/pageRuntime.js +29 -0
- package/dist/modules/camo-backend/src/internal/runtimeInjector.js +30 -0
- package/dist/modules/camo-backend/src/internal/state-bus.js +46 -0
- package/dist/modules/camo-backend/src/internal/storage-paths.js +36 -0
- package/dist/modules/camo-backend/src/internal/ws-server.js +1202 -0
- package/dist/modules/camo-runtime/src/utils/browser-service.mjs +423 -0
- package/dist/modules/camo-runtime/src/utils/config.mjs +77 -0
- package/dist/modules/container-registry/src/index.js +184 -0
- package/dist/modules/logging/src/index.js +92 -0
- package/dist/modules/operations/src/builtin.js +27 -0
- package/dist/modules/operations/src/container-binding.js +75 -0
- package/dist/modules/operations/src/executor.js +146 -0
- package/dist/modules/operations/src/operations/click.js +167 -0
- package/dist/modules/operations/src/operations/extract.js +204 -0
- package/dist/modules/operations/src/operations/find-child.js +17 -0
- package/dist/modules/operations/src/operations/highlight.js +138 -0
- package/dist/modules/operations/src/operations/key.js +61 -0
- package/dist/modules/operations/src/operations/navigate.js +148 -0
- package/dist/modules/operations/src/operations/scroll.js +126 -0
- package/dist/modules/operations/src/operations/type.js +190 -0
- package/dist/modules/operations/src/queue.js +100 -0
- package/dist/modules/operations/src/registry.js +11 -0
- package/dist/modules/operations/src/system/mouse.js +33 -0
- package/dist/modules/state/src/atomic-json.js +33 -0
- package/dist/modules/workflow/blocks/AnchorVerificationBlock.js +71 -0
- package/dist/modules/workflow/blocks/BehaviorRandomizer.js +26 -0
- package/dist/modules/workflow/blocks/CallWorkflowBlock.js +38 -0
- package/dist/modules/workflow/blocks/CloseDetailBlock.js +209 -0
- package/dist/modules/workflow/blocks/CollectBatch.js +137 -0
- package/dist/modules/workflow/blocks/CollectCommentsBlock.js +415 -0
- package/dist/modules/workflow/blocks/CollectSearchListBlock.js +599 -0
- package/dist/modules/workflow/blocks/CollectWeiboPosts.js +229 -0
- package/dist/modules/workflow/blocks/DetectPageStateBlock.js +259 -0
- package/dist/modules/workflow/blocks/EnsureLoginBlock.js +162 -0
- package/dist/modules/workflow/blocks/EnsureSession.js +426 -0
- package/dist/modules/workflow/blocks/ErrorClassifier.js +164 -0
- package/dist/modules/workflow/blocks/ErrorRecoveryBlock.js +319 -0
- package/dist/modules/workflow/blocks/ExpandCommentsBlock.js +1032 -0
- package/dist/modules/workflow/blocks/ExtractDetailBlock.js +310 -0
- package/dist/modules/workflow/blocks/ExtractPostFields.js +88 -0
- package/dist/modules/workflow/blocks/GenerateSmartReplyBlock.js +68 -0
- package/dist/modules/workflow/blocks/GoToSearchBlock.js +497 -0
- package/dist/modules/workflow/blocks/GracefulFallbackBlock.js +104 -0
- package/dist/modules/workflow/blocks/HighlightBlock.js +66 -0
- package/dist/modules/workflow/blocks/InitAutoScroll.js +65 -0
- package/dist/modules/workflow/blocks/LoadContainerDefinition.js +50 -0
- package/dist/modules/workflow/blocks/LoadContainerIndex.js +43 -0
- package/dist/modules/workflow/blocks/LocateAndGuardBlock.js +176 -0
- package/dist/modules/workflow/blocks/LoginRecoveryBlock.js +242 -0
- package/dist/modules/workflow/blocks/MatchContainers.js +64 -0
- package/dist/modules/workflow/blocks/MonitoringBlock.js +190 -0
- package/dist/modules/workflow/blocks/OpenDetailBlock.js +1240 -0
- package/dist/modules/workflow/blocks/OrganizeXhsNotesBlock.js +117 -0
- package/dist/modules/workflow/blocks/PersistXhsNoteBlock.js +270 -0
- package/dist/modules/workflow/blocks/PickSinglePost.js +69 -0
- package/dist/modules/workflow/blocks/ProgressTracker.js +125 -0
- package/dist/modules/workflow/blocks/RecordFixtureBlock.js +44 -0
- package/dist/modules/workflow/blocks/RenderMarkdown.js +48 -0
- package/dist/modules/workflow/blocks/SaveFile.js +54 -0
- package/dist/modules/workflow/blocks/ScrollNextBatch.js +72 -0
- package/dist/modules/workflow/blocks/SessionHealthBlock.js +73 -0
- package/dist/modules/workflow/blocks/StartBrowserService.js +45 -0
- package/dist/modules/workflow/blocks/ValidateContainerDefinition.js +67 -0
- package/dist/modules/workflow/blocks/ValidateExtract.js +35 -0
- package/dist/modules/workflow/blocks/WaitSearchPermitBlock.js +162 -0
- package/dist/modules/workflow/blocks/WaitStable.js +74 -0
- package/dist/modules/workflow/blocks/WarmupCommentsBlock.js +120 -0
- package/dist/modules/workflow/blocks/WorkflowExecutor.js +156 -0
- package/dist/modules/workflow/blocks/XiaohongshuCollectFromLinksBlock.js +1004 -0
- package/dist/modules/workflow/blocks/XiaohongshuCollectLinksBlock.js +1049 -0
- package/dist/modules/workflow/blocks/XiaohongshuFullCollectBlock.js +782 -0
- package/dist/modules/workflow/blocks/helpers/anchorVerify.js +198 -0
- package/dist/modules/workflow/blocks/helpers/asyncWorkQueue.js +53 -0
- package/dist/modules/workflow/blocks/helpers/commentScroller.js +334 -0
- package/dist/modules/workflow/blocks/helpers/commentSectionLocator.js +126 -0
- package/dist/modules/workflow/blocks/helpers/containerAnchors.js +301 -0
- package/dist/modules/workflow/blocks/helpers/debugArtifacts.js +6 -0
- package/dist/modules/workflow/blocks/helpers/downloadPaths.js +29 -0
- package/dist/modules/workflow/blocks/helpers/expandCommentsController.js +53 -0
- package/dist/modules/workflow/blocks/helpers/expandCommentsExtractor.js +129 -0
- package/dist/modules/workflow/blocks/helpers/macosVisionOcrPlugin.js +116 -0
- package/dist/modules/workflow/blocks/helpers/mergeXhsMarkdown.js +109 -0
- package/dist/modules/workflow/blocks/helpers/openDetailController.js +56 -0
- package/dist/modules/workflow/blocks/helpers/openDetailTypes.js +7 -0
- package/dist/modules/workflow/blocks/helpers/openDetailViewport.js +474 -0
- package/dist/modules/workflow/blocks/helpers/openDetailWaiter.js +104 -0
- package/dist/modules/workflow/blocks/helpers/operationLogger.js +195 -0
- package/dist/modules/workflow/blocks/helpers/persistedNotes.js +107 -0
- package/dist/modules/workflow/blocks/helpers/replyExpander.js +260 -0
- package/dist/modules/workflow/blocks/helpers/scrollIntoView.js +138 -0
- package/dist/modules/workflow/blocks/helpers/searchExecutor.js +328 -0
- package/dist/modules/workflow/blocks/helpers/searchGate.js +46 -0
- package/dist/modules/workflow/blocks/helpers/searchPageState.js +164 -0
- package/dist/modules/workflow/blocks/helpers/searchResultWaiter.js +64 -0
- package/dist/modules/workflow/blocks/helpers/simpleAnchor.js +134 -0
- package/dist/modules/workflow/blocks/helpers/smartReply.js +40 -0
- package/dist/modules/workflow/blocks/helpers/systemInput.js +635 -0
- package/dist/modules/workflow/blocks/helpers/targetCountMode.js +9 -0
- package/dist/modules/workflow/blocks/helpers/xhsCliArgs.js +80 -0
- package/dist/modules/workflow/blocks/helpers/xhsCommentDom.js +805 -0
- package/dist/modules/workflow/blocks/helpers/xhsNoteOrganizer.js +140 -0
- package/dist/modules/workflow/blocks/restore/RestorePhaseBlock.js +204 -0
- package/dist/modules/workflow/config/workflowRegistry.js +32 -0
- package/dist/modules/workflow/definitions/batch-collect-workflow.js +63 -0
- package/dist/modules/workflow/definitions/scroll-extract-workflow.js +74 -0
- package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow-v2.js +81 -0
- package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow.js +57 -0
- package/dist/modules/workflow/definitions/xiaohongshu-full-collect-workflow-v3.js +68 -0
- package/dist/modules/workflow/definitions/xiaohongshu-note-collect.js +49 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase1-workflow-v3.js +30 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase2-links-workflow-v3.js +40 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase3-collect-workflow-v1.js +54 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase34-from-links-workflow-v3.js +25 -0
- package/dist/modules/workflow/src/WeiboEventDrivenWorkflowRunner.js +308 -0
- package/dist/modules/workflow/src/context.js +70 -0
- package/dist/modules/workflow/src/index.js +5 -0
- package/dist/modules/workflow/src/orchestrator.js +230 -0
- package/dist/modules/workflow/src/runner.js +55 -0
- package/dist/modules/workflow/src/runtime.js +70 -0
- package/dist/modules/workflow/workflows/WeiboFeedExtractionWorkflow.js +359 -0
- package/dist/modules/workflow/workflows/XiaohongshuLoginWorkflow.js +110 -0
- package/dist/modules/xiaohongshu/app/src/blocks/MatchCommentsBlock.js +139 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1EnsureServicesBlock.js +36 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1MonitorCookieBlock.js +213 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1StartProfileBlock.js +121 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase2CollectLinksBlock.js +1249 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase2SearchBlock.js +703 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseDetailBlock.js +41 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseTabsBlock.js +44 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CollectCommentsBlock.js +150 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ExtractDetailBlock.js +117 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenDetailBlock.js +102 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenTabsBlock.js +109 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34PersistDetailBlock.js +117 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ProcessSingleNoteBlock.js +114 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ValidateLinksBlock.js +90 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase3InteractBlock.js +1009 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase4MultiTabHarvestBlock.js +233 -0
- package/dist/modules/xiaohongshu/app/src/blocks/ReplyInteractBlock.js +291 -0
- package/dist/modules/xiaohongshu/app/src/blocks/XhsDiscoverFallbackBlock.js +240 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatchDsl.js +126 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatcher.js +99 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/evidence.js +27 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/sharding.js +42 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/xhsComments.js +270 -0
- package/dist/modules/xiaohongshu/app/src/index.js +9 -0
- package/dist/modules/xiaohongshu/app/src/utils/checkpoints.js +222 -0
- package/dist/modules/xiaohongshu/app/src/utils/controllerAction.js +43 -0
- package/dist/services/controller/src/controller.js +1476 -0
- package/dist/services/controller/src/index.js +2 -0
- package/dist/services/controller/src/payload-normalizer.js +129 -0
- package/dist/services/shared/heartbeat.js +120 -0
- package/dist/services/shared/lib/errorHandler.js +2 -0
- package/dist/services/shared/serviceProcessLogger.js +139 -0
- package/dist/services/unified-api/RemoteBrowserSession.js +176 -0
- package/dist/services/unified-api/RemoteSessionManager.js +148 -0
- package/dist/services/unified-api/container-operations-handler.js +115 -0
- package/dist/services/unified-api/server.js +652 -0
- package/dist/services/unified-api/state-registry.js +274 -0
- package/dist/services/unified-api/task-persistence.js +66 -0
- package/dist/services/unified-api/task-state.js +130 -0
- package/modules/camo-runtime/src/autoscript/action-providers/xhs/search.mjs +12 -5
- package/modules/xiaohongshu/app/pnpm-lock.yaml +24 -0
- package/package.json +38 -10
- package/.beads/README.md +0 -81
- package/.beads/config.yaml +0 -67
- package/.beads/interactions.jsonl +0 -0
- package/.beads/issues.jsonl +0 -180
- package/.beads/metadata.json +0 -4
- package/.claude/settings.local.json +0 -10
- package/.github/workflows/ci.yml +0 -55
- package/AGENTS.md +0 -253
- package/apps/desktop-console/README.md +0 -27
- package/apps/desktop-console/package-lock.json +0 -897
- package/apps/desktop-console/package.json +0 -20
- package/apps/desktop-console/scripts/build-and-install.mjs +0 -19
- package/apps/desktop-console/scripts/build.mjs +0 -45
- package/apps/desktop-console/scripts/test-preload.mjs +0 -13
- package/apps/desktop-console/src/main/config.mts +0 -26
- package/apps/desktop-console/src/main/core-daemon-manager.mts +0 -131
- package/apps/desktop-console/src/main/desktop-settings.mts +0 -267
- package/apps/desktop-console/src/main/heartbeat-watchdog.mts +0 -50
- package/apps/desktop-console/src/main/heartbeat-watchdog.test.mts +0 -68
- package/apps/desktop-console/src/main/index-streaming.test.mts +0 -20
- package/apps/desktop-console/src/main/index.mts +0 -980
- package/apps/desktop-console/src/main/profile-store.mts +0 -239
- package/apps/desktop-console/src/main/profile-store.test.mts +0 -54
- package/apps/desktop-console/src/main/state-bridge.mts +0 -114
- package/apps/desktop-console/src/main/task-state-types.ts +0 -32
- package/apps/desktop-console/src/renderer/hooks/use-task-state.mts +0 -120
- package/apps/desktop-console/src/renderer/index.mts +0 -133
- package/apps/desktop-console/src/renderer/index.test.mts +0 -34
- package/apps/desktop-console/src/renderer/path-helpers.mts +0 -46
- package/apps/desktop-console/src/renderer/path-helpers.test.mts +0 -14
- package/apps/desktop-console/src/renderer/tabs/debug.mts +0 -48
- package/apps/desktop-console/src/renderer/tabs/debug.test.mts +0 -22
- package/apps/desktop-console/src/renderer/tabs/logs.mts +0 -421
- package/apps/desktop-console/src/renderer/tabs/logs.test.mts +0 -27
- package/apps/desktop-console/src/renderer/tabs/preflight.mts +0 -486
- package/apps/desktop-console/src/renderer/tabs/preflight.test.mts +0 -33
- package/apps/desktop-console/src/renderer/tabs/profile-pool.mts +0 -213
- package/apps/desktop-console/src/renderer/tabs/results.mts +0 -171
- package/apps/desktop-console/src/renderer/tabs/run.test.mts +0 -63
- package/apps/desktop-console/src/renderer/tabs/runtime.mts +0 -151
- package/apps/desktop-console/src/renderer/tabs/settings.mts +0 -146
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/account-flow.mts +0 -486
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/guide-browser-check.mts +0 -56
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/helpers.mts +0 -262
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/layout-block.mts +0 -430
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/live-stats.mts +0 -847
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/run-flow.mts +0 -443
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu-state.mts +0 -425
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu.mts +0 -497
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu.test.mts +0 -291
- package/apps/desktop-console/src/renderer/ui-components.mts +0 -31
- package/docs/README_camoufox_chinese.md +0 -141
- package/docs/USAGE_V3.md +0 -163
- package/docs/arch/OCR_MACOS_PLUGIN.md +0 -39
- package/docs/arch/PORTS.md +0 -40
- package/docs/arch/REGRESSION_CHECKLIST.md +0 -121
- package/docs/arch/SEARCH_GATE.md +0 -224
- package/docs/arch/VIEWPORT_SAFETY.md +0 -182
- package/docs/arch/XIAOHONGSHU_OFFLINE_MOCK_DESIGN.md +0 -267
- package/docs/xiaohongshu-container-driven-summary.md +0 -221
- package/docs/xiaohongshu-full-collect-runbook.md +0 -134
- package/docs/xiaohongshu-next-steps.md +0 -228
- package/docs/xiaohongshu-quickstart.md +0 -73
- package/docs/xiaohongshu-workflow-summary.md +0 -227
- package/modules/container-registry/tests/container-registry.test.ts +0 -16
- package/modules/logging/tests/logging.test.ts +0 -38
- package/modules/operations/tests/operations.test.ts +0 -22
- package/modules/operations/tests/viewport-filter.test.ts +0 -161
- package/modules/operations/tests/visible-only.test.ts +0 -250
- package/modules/session-manager/tests/session-manager.test.ts +0 -23
- package/modules/state/src/atomic-json.test.ts +0 -30
- package/modules/state/src/paths.test.ts +0 -59
- package/modules/state/src/xiaohongshu-collect-state.test.ts +0 -259
- package/modules/workflow/blocks/AnchorVerificationBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/AnchorVerificationBlock.js.map +0 -1
- package/modules/workflow/blocks/DetectPageStateBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/DetectPageStateBlock.js.map +0 -1
- package/modules/workflow/blocks/ErrorRecoveryBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/ErrorRecoveryBlock.js.map +0 -1
- package/modules/workflow/blocks/WaitSearchPermitBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/WaitSearchPermitBlock.js.map +0 -1
- package/modules/workflow/blocks/helpers/containerAnchors.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/containerAnchors.js.map +0 -1
- package/modules/workflow/blocks/helpers/downloadPaths.test.ts +0 -62
- package/modules/workflow/blocks/helpers/mergeXhsMarkdown.test.ts +0 -121
- package/modules/workflow/blocks/helpers/operationLogger.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/operationLogger.js.map +0 -1
- package/modules/workflow/blocks/helpers/persistedNotes.test.ts +0 -268
- package/modules/workflow/blocks/helpers/searchPageState.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/searchPageState.js.map +0 -1
- package/modules/workflow/blocks/helpers/targetCountMode.test.ts +0 -29
- package/modules/workflow/blocks/helpers/xhsCliArgs.test.ts +0 -75
- package/modules/workflow/tests/smartReply.test.ts +0 -32
- package/modules/xiaohongshu/app/src/blocks/Phase3Interact.matcher.test.ts +0 -33
- package/modules/xiaohongshu/app/src/utils/__tests__/checkpoints.test.ts +0 -141
- package/modules/xiaohongshu/app/tests/commentMatchDsl.test.ts +0 -50
- package/modules/xiaohongshu/app/tests/commentMatcher.test.ts +0 -46
- package/modules/xiaohongshu/app/tests/sharding.test.ts +0 -31
- package/package-scripts.json +0 -8
- package/runtime/infra/utils/README.md +0 -13
- package/runtime/infra/utils/scripts/README.md +0 -0
- package/runtime/infra/utils/scripts/development/eval-in-session.mjs +0 -40
- package/runtime/infra/utils/scripts/development/highlight-search-containers.mjs +0 -35
- package/runtime/infra/utils/scripts/service/kill-port.mjs +0 -24
- package/runtime/infra/utils/scripts/service/start-api.mjs +0 -39
- package/runtime/infra/utils/scripts/service/start-browser-service.mjs +0 -106
- package/runtime/infra/utils/scripts/service/stop-api.mjs +0 -18
- package/runtime/infra/utils/scripts/service/stop-browser-service.mjs +0 -104
- package/runtime/infra/utils/scripts/test-services.mjs +0 -94
- package/services/shared/heartbeat.test.ts +0 -102
- package/services/unified-api/__tests__/task-state.test.ts +0 -95
- package/sitecustomize.py +0 -19
- package/tests/README.md +0 -194
- package/tests/e2e/workflows/weibo-feed-extraction.test.ts +0 -171
- package/tests/fixtures/data/container-definitions.json +0 -67
- package/tests/fixtures/pages/simple-page.html +0 -69
- package/tests/integration/01-test-container-match.mjs +0 -188
- package/tests/integration/02-test-dom-branch.mjs +0 -161
- package/tests/integration/03-test-container-operation-system.mjs +0 -91
- package/tests/integration/05-test-container-lifecycle-events.mjs +0 -224
- package/tests/integration/05-test-container-lifecycle-with-events.mjs +0 -250
- package/tests/integration/06-test-container-dom-tree-drawing.mjs +0 -256
- package/tests/integration/07-test-weibo-container-lifecycle.mjs +0 -355
- package/tests/integration/08-test-weibo-feed-workflow.test.mjs +0 -164
- package/tests/integration/10-test-visual-analyzer.mjs +0 -312
- package/tests/integration/11-test-visual-loop.mjs +0 -284
- package/tests/integration/12-test-simple-visual-loop.mjs +0 -242
- package/tests/integration/13-test-visual-robust.mjs +0 -185
- package/tests/integration/14-test-visual-highlight-loop.mjs +0 -271
- package/tests/integration/inspect-page.mjs +0 -50
- package/tests/integration/run-all-tests.mjs +0 -95
- package/tests/patch_verification/CODEX_PATCH_TEST.md +0 -103
- package/tests/patch_verification/PHASE2_ANALYSIS.md +0 -179
- package/tests/patch_verification/PHASE2_OPTIMIZATION_REPORT.md +0 -55
- package/tests/patch_verification/PHASE2_TO_PHASE4_SUMMARY.md +0 -126
- package/tests/patch_verification/QUICK_TEST_SEQUENCE.md +0 -262
- package/tests/patch_verification/README.md +0 -143
- package/tests/patch_verification/RUN_TESTS.md +0 -60
- package/tests/patch_verification/TEST_EXECUTION.md +0 -99
- package/tests/patch_verification/TEST_PLAN.md +0 -328
- package/tests/patch_verification/TEST_RESULTS.md +0 -34
- package/tests/patch_verification/TOOL_TEST_PLAN.md +0 -48
- package/tests/patch_verification/run-tool-test.mjs +0 -121
- package/tests/patch_verification/temp_test_files/test01.txt +0 -1
- package/tests/patch_verification/temp_test_files/test02.txt +0 -3
- package/tests/patch_verification/temp_test_files/test02_gnu.txt +0 -3
- package/tests/patch_verification/temp_test_files/test03.txt +0 -1
- package/tests/patch_verification/temp_test_files/test03_multiline.txt +0 -5
- package/tests/patch_verification/temp_test_files/test04_function.ts +0 -5
- package/tests/patch_verification/temp_test_files/test05_import.ts +0 -4
- package/tests/patch_verification/temp_test_files/test06_special_chars.txt +0 -4
- package/tests/patch_verification/temp_test_files/test07_indentation.ts +0 -5
- package/tests/patch_verification/temp_test_files/test08_mismatch.txt +0 -1
- package/tests/patch_verification/temp_test_files/test_add_02.txt +0 -3
- package/tests/patch_verification/temp_test_files/test_simple.txt +0 -1
- package/tests/runner/TestReporter.mjs +0 -57
- package/tests/runner/TestRunner.mjs +0 -244
- package/tests/unit/commands/profile.test.mjs +0 -10
- package/tests/unit/container/change-notifier.test.mjs +0 -181
- package/tests/unit/lifecycle/session-registry.test.mjs +0 -135
- package/tests/unit/operations/registry.test.ts +0 -73
- package/tests/unit/utils/browser-service.test.mjs +0 -153
- package/tests/unit/utils/config.test.mjs +0 -166
- package/tests/unit/utils/fingerprint.test.mjs +0 -166
- package/tsconfig.json +0 -31
- package/tsconfig.services.json +0 -26
- /package/apps/desktop-console/{src → dist}/renderer/index.html +0 -0
- /package/apps/desktop-console/{src/renderer/tabs → dist/renderer}/run.mts +0 -0
|
@@ -1,250 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 容器生命周期事件跟踪闭环测试
|
|
4
|
-
*
|
|
5
|
-
* 测试流程:
|
|
6
|
-
* 1. 启动 Unified API 和浏览器服务
|
|
7
|
-
* 2. 连接 WebSocket 监听事件
|
|
8
|
-
* 3. 创建浏览器会话
|
|
9
|
-
* 4. 捕获元素(模拟容器发现)
|
|
10
|
-
* 5. 添加新子容器
|
|
11
|
-
* 6. 验证事件流:container:discovered -> container:children_discovered
|
|
12
|
-
* 7. 绘制 DOM tree
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
import { WebSocket } from 'ws';
|
|
16
|
-
import http from 'node:http';
|
|
17
|
-
|
|
18
|
-
const HOST = '127.0.0.1';
|
|
19
|
-
const UNIFIED_API_PORT = 7701;
|
|
20
|
-
const WS_URL = `ws://${HOST}:${UNIFIED_API_PORT}/ws`;
|
|
21
|
-
const API_HOST = `http://${HOST}:${UNIFIED_API_PORT}`;
|
|
22
|
-
|
|
23
|
-
const events = [];
|
|
24
|
-
let ws = null;
|
|
25
|
-
|
|
26
|
-
function log(msg) {
|
|
27
|
-
console.log(`[TEST] ${msg}`);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function httpPost(path, data) {
|
|
31
|
-
return new Promise((resolve, reject) => {
|
|
32
|
-
const payload = JSON.stringify(data || {});
|
|
33
|
-
const req = http.request(
|
|
34
|
-
`${API_HOST}${path}`,
|
|
35
|
-
{
|
|
36
|
-
method: 'POST',
|
|
37
|
-
headers: {
|
|
38
|
-
'Content-Type': 'application/json',
|
|
39
|
-
'Content-Length': Buffer.byteLength(payload)
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
(res) => {
|
|
43
|
-
let body = '';
|
|
44
|
-
res.on('data', (chunk) => body += chunk);
|
|
45
|
-
res.on('end', () => {
|
|
46
|
-
try {
|
|
47
|
-
resolve(JSON.parse(body));
|
|
48
|
-
} catch (err) {
|
|
49
|
-
resolve({ body, statusCode: res.statusCode });
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
req.on('error', reject);
|
|
55
|
-
req.write(payload);
|
|
56
|
-
req.end();
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function httpGet(path) {
|
|
61
|
-
return new Promise((resolve, reject) => {
|
|
62
|
-
http.get(`${API_HOST}${path}`, (res) => {
|
|
63
|
-
let body = '';
|
|
64
|
-
res.on('data', (chunk) => body += chunk);
|
|
65
|
-
res.on('end', () => {
|
|
66
|
-
try {
|
|
67
|
-
resolve(JSON.parse(body));
|
|
68
|
-
} catch (err) {
|
|
69
|
-
resolve({ body, statusCode: res.statusCode });
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}).on('error', reject);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
async function connectWebSocket() {
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
ws = new WebSocket(WS_URL);
|
|
79
|
-
|
|
80
|
-
ws.on('open', () => {
|
|
81
|
-
log('WebSocket 连接成功');
|
|
82
|
-
resolve();
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
ws.on('message', (data) => {
|
|
86
|
-
const msg = JSON.parse(data.toString());
|
|
87
|
-
|
|
88
|
-
// 记录所有事件
|
|
89
|
-
if (msg.type === 'event') {
|
|
90
|
-
events.push(msg);
|
|
91
|
-
log(`收到事件: ${msg.topic}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// 特殊事件日志
|
|
95
|
-
if (msg.topic && msg.topic.includes('container:')) {
|
|
96
|
-
log(` 容器事件详情: ${JSON.stringify(msg.payload).substring(0, 100)}`);
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
ws.on('error', reject);
|
|
101
|
-
|
|
102
|
-
setTimeout(() => reject(new Error('WebSocket 连接超时')), 5000);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
async function checkHealth() {
|
|
107
|
-
log('检查 Unified API 健康状态...');
|
|
108
|
-
const health = await httpGet('/health');
|
|
109
|
-
if (!health.ok) {
|
|
110
|
-
throw new Error('Unified API 不健康');
|
|
111
|
-
}
|
|
112
|
-
log('✓ Unified API 健康');
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
async function getSessionList() {
|
|
116
|
-
log('获取会话列表...');
|
|
117
|
-
const result = await httpPost('/v1/controller/action', {
|
|
118
|
-
action: 'session:list',
|
|
119
|
-
payload: {}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
if (!result.success || !result.data?.sessions) {
|
|
123
|
-
throw new Error('无法获取会话列表');
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
log(`✓ 找到 ${result.data.sessions.length} 个会话`);
|
|
127
|
-
return result.data.sessions;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async function sendAction(action, payload) {
|
|
131
|
-
log(`发送动作: ${action}`);
|
|
132
|
-
const result = await httpPost('/v1/controller/action', {
|
|
133
|
-
action,
|
|
134
|
-
payload
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
if (!result.success) {
|
|
138
|
-
throw new Error(`动作失败: ${action} - ${result.error || '未知错误'}`);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
log(`✓ 动作成功: ${action}`);
|
|
142
|
-
return result;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
async function waitForEvent(topicPattern, timeout = 5000) {
|
|
146
|
-
const startTime = Date.now();
|
|
147
|
-
|
|
148
|
-
while (Date.now() - startTime < timeout) {
|
|
149
|
-
const event = events.find(e => {
|
|
150
|
-
if (typeof topicPattern === 'string') {
|
|
151
|
-
return e.topic === topicPattern;
|
|
152
|
-
} else {
|
|
153
|
-
return topicPattern.test(e.topic);
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
if (event) {
|
|
158
|
-
log(`✓ 找到匹配事件: ${event.topic}`);
|
|
159
|
-
return event;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
throw new Error(`等待事件超时: ${topicPattern}`);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
async function main() {
|
|
169
|
-
try {
|
|
170
|
-
// Step 1: 检查服务健康
|
|
171
|
-
await checkHealth();
|
|
172
|
-
|
|
173
|
-
// Step 2: 连接 WebSocket
|
|
174
|
-
await connectWebSocket();
|
|
175
|
-
|
|
176
|
-
// Step 3: 获取会话列表
|
|
177
|
-
const sessions = await getSessionList();
|
|
178
|
-
|
|
179
|
-
if (sessions.length === 0) {
|
|
180
|
-
log('⚠ 没有活动会话,跳过容器操作测试');
|
|
181
|
-
log('✅ 基础事件系统测试通过');
|
|
182
|
-
ws.close();
|
|
183
|
-
process.exit(0);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const sessionId = sessions[0].session_id;
|
|
187
|
-
log(`使用会话: ${sessionId}`);
|
|
188
|
-
|
|
189
|
-
// Step 4: 订阅容器状态
|
|
190
|
-
log('订阅容器状态变化...');
|
|
191
|
-
const subResult = await httpPost(`/v1/container/test-container/subscribe`, {});
|
|
192
|
-
if (subResult.success) {
|
|
193
|
-
log('✓ 容器订阅成功');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// Step 5: 模拟容器匹配(触发容器发现)
|
|
197
|
-
log('执行容器匹配...');
|
|
198
|
-
const matchResult = await sendAction('containers:match', {
|
|
199
|
-
sessionId,
|
|
200
|
-
url: sessions[0].current_url
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// Step 6: 等待容器发现事件
|
|
204
|
-
log('等待容器发现事件...');
|
|
205
|
-
|
|
206
|
-
// 给事件一些时间传播
|
|
207
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
208
|
-
|
|
209
|
-
// Step 7: 验证收到的事件
|
|
210
|
-
log('\n=== 事件跟踪报告 ===');
|
|
211
|
-
log(`总共收到 ${events.length} 个事件`);
|
|
212
|
-
|
|
213
|
-
events.forEach((event, index) => {
|
|
214
|
-
log(`[${index + 1}] ${event.topic}`);
|
|
215
|
-
if (event.payload) {
|
|
216
|
-
const preview = JSON.stringify(event.payload).substring(0, 80);
|
|
217
|
-
log(` 数据: ${preview}...`);
|
|
218
|
-
}
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
// Step 8: 验证核心事件
|
|
222
|
-
log('\n=== 验证核心事件 ===');
|
|
223
|
-
|
|
224
|
-
const hasContainerEvent = events.some(e => e.topic && e.topic.includes('container'));
|
|
225
|
-
if (hasContainerEvent) {
|
|
226
|
-
log('✓ 检测到容器相关事件');
|
|
227
|
-
} else {
|
|
228
|
-
log('⚠ 未检测到容器事件(可能需要实际容器发现)');
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// Step 9: 总结
|
|
232
|
-
log('\n=== 测试总结 ===');
|
|
233
|
-
log('✅ WebSocket 连接: 通过');
|
|
234
|
-
log('✅ 事件订阅: 通过');
|
|
235
|
-
log('✅ 容器匹配: 通过');
|
|
236
|
-
log(`✅ 事件接收: 通过 (${events.length} 个事件)`);
|
|
237
|
-
log('\n✅ 容器生命周期事件跟踪闭环测试完成!');
|
|
238
|
-
|
|
239
|
-
ws.close();
|
|
240
|
-
process.exit(0);
|
|
241
|
-
|
|
242
|
-
} catch (error) {
|
|
243
|
-
console.error('\n❌ 测试失败:', error.message);
|
|
244
|
-
console.error(error.stack);
|
|
245
|
-
if (ws) ws.close();
|
|
246
|
-
process.exit(1);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
main();
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 容器 DOM Tree 绘制测试 - 简化版
|
|
4
|
-
*
|
|
5
|
-
* 测试流程:
|
|
6
|
-
* 1. 启动 Unified API
|
|
7
|
-
* 2. 连接 WebSocket 监听事件
|
|
8
|
-
* 3. 模拟容器树结构
|
|
9
|
-
* 4. 验证事件流
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import { WebSocket } from 'ws';
|
|
13
|
-
import http from 'node:http';
|
|
14
|
-
|
|
15
|
-
const HOST = '127.0.0.1';
|
|
16
|
-
const UNIFIED_API_PORT = 7701;
|
|
17
|
-
const WS_URL = `ws://${HOST}:${UNIFIED_API_PORT}/ws`;
|
|
18
|
-
const API_HOST = `http://${HOST}:${UNIFIED_API_PORT}`;
|
|
19
|
-
|
|
20
|
-
const events = [];
|
|
21
|
-
let ws = null;
|
|
22
|
-
|
|
23
|
-
function log(msg) {
|
|
24
|
-
console.log(`[DOM-TREE] ${msg}`);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function httpPost(path, data) {
|
|
28
|
-
return new Promise((resolve, reject) => {
|
|
29
|
-
const payload = JSON.stringify(data || {});
|
|
30
|
-
const req = http.request(
|
|
31
|
-
`${API_HOST}${path}`,
|
|
32
|
-
{
|
|
33
|
-
method: 'POST',
|
|
34
|
-
headers: {
|
|
35
|
-
'Content-Type': 'application/json',
|
|
36
|
-
'Content-Length': Buffer.byteLength(payload)
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
(res) => {
|
|
40
|
-
let body = '';
|
|
41
|
-
res.on('data', (chunk) => body += chunk);
|
|
42
|
-
res.on('end', () => {
|
|
43
|
-
try {
|
|
44
|
-
resolve(JSON.parse(body));
|
|
45
|
-
} catch (err) {
|
|
46
|
-
resolve({ body, statusCode: res.statusCode });
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
);
|
|
51
|
-
req.on('error', reject);
|
|
52
|
-
req.write(payload);
|
|
53
|
-
req.end();
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function httpGet(path) {
|
|
58
|
-
return new Promise((resolve, reject) => {
|
|
59
|
-
http.get(`${API_HOST}${path}`, (res) => {
|
|
60
|
-
let body = '';
|
|
61
|
-
res.on('data', (chunk) => body += chunk);
|
|
62
|
-
res.on('end', () => {
|
|
63
|
-
try {
|
|
64
|
-
resolve(JSON.parse(body));
|
|
65
|
-
} catch (err) {
|
|
66
|
-
resolve({ body, statusCode: res.statusCode });
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}).on('error', reject);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
async function connectWebSocket() {
|
|
74
|
-
return new Promise((resolve, reject) => {
|
|
75
|
-
ws = new WebSocket(WS_URL);
|
|
76
|
-
|
|
77
|
-
ws.on('open', () => {
|
|
78
|
-
log('WebSocket 连接成功');
|
|
79
|
-
resolve();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
ws.on('message', (data) => {
|
|
83
|
-
const msg = JSON.parse(data.toString());
|
|
84
|
-
events.push(msg);
|
|
85
|
-
|
|
86
|
-
// 打印容器相关事件
|
|
87
|
-
if (msg.type === 'event' && msg.topic && msg.topic.includes('container')) {
|
|
88
|
-
log(`收到事件: ${msg.topic}`);
|
|
89
|
-
} else if (msg.type === 'ready') {
|
|
90
|
-
log(`收到系统事件: ${msg.type}`);
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
ws.on('error', reject);
|
|
95
|
-
setTimeout(() => reject(new Error('WebSocket 连接超时')), 5000);
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
async function checkHealth() {
|
|
100
|
-
log('检查服务健康...');
|
|
101
|
-
const health = await httpGet('/health');
|
|
102
|
-
if (!health.ok) {
|
|
103
|
-
throw new Error('服务不健康');
|
|
104
|
-
}
|
|
105
|
-
log('✓ 服务健康');
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function printContainerTree(data, indent = 0) {
|
|
109
|
-
const prefix = ' '.repeat(indent);
|
|
110
|
-
|
|
111
|
-
if (data.snapshot) {
|
|
112
|
-
printNode(data.snapshot, indent);
|
|
113
|
-
} else if (data.tree) {
|
|
114
|
-
printNode(data.tree, indent);
|
|
115
|
-
} else if (Array.isArray(data)) {
|
|
116
|
-
data.forEach(node => printNode(node, indent));
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
function printNode(node, indent) {
|
|
121
|
-
const prefix = ' '.repeat(indent);
|
|
122
|
-
const id = node.id || node.containerId || 'unknown';
|
|
123
|
-
const type = node.type || 'container';
|
|
124
|
-
const children = node.children || [];
|
|
125
|
-
const selectors = node.selectors || [];
|
|
126
|
-
|
|
127
|
-
console.log(`${prefix}├─ [${type}] ${id}`);
|
|
128
|
-
|
|
129
|
-
if (selectors.length > 0) {
|
|
130
|
-
console.log(`${prefix}│ selectors: ${selectors.join(', ')}`);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
children.forEach(child => printNode(child, indent + 1));
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
async function drawAsciiTree() {
|
|
137
|
-
log('\n=== DOM Tree (ASCII) ===');
|
|
138
|
-
console.log(`
|
|
139
|
-
┌─ [HTML]
|
|
140
|
-
│ └─ [BODY]
|
|
141
|
-
│ └─ [container] main-container
|
|
142
|
-
│ ├─ [H1] Test Container
|
|
143
|
-
│ └─ [LIST]
|
|
144
|
-
│ ├─ [list-item] Item 1
|
|
145
|
-
│ ├─ [list-item] Item 2
|
|
146
|
-
│ └─ [list-item] Item 3
|
|
147
|
-
`);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
async function simulateContainerDiscovery() {
|
|
151
|
-
log('模拟容器发现流程...');
|
|
152
|
-
|
|
153
|
-
// 模拟容器发现的事件流
|
|
154
|
-
const simulatedEvents = [
|
|
155
|
-
{
|
|
156
|
-
type: 'event',
|
|
157
|
-
topic: 'container:main-container:discovered',
|
|
158
|
-
payload: {
|
|
159
|
-
containerId: 'main-container',
|
|
160
|
-
parentId: 'body',
|
|
161
|
-
bbox: { x: 100, y: 100, width: 800, height: 600 },
|
|
162
|
-
visible: true,
|
|
163
|
-
score: 0.95
|
|
164
|
-
}
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
type: 'event',
|
|
168
|
-
topic: 'container:list-item:discovered',
|
|
169
|
-
payload: {
|
|
170
|
-
containerId: 'list-item-1',
|
|
171
|
-
parentId: 'main-container',
|
|
172
|
-
bbox: { x: 120, y: 150, width: 200, height: 30 },
|
|
173
|
-
visible: true,
|
|
174
|
-
score: 0.85
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
type: 'event',
|
|
179
|
-
topic: 'container:children_discovered',
|
|
180
|
-
payload: {
|
|
181
|
-
containerId: 'main-container',
|
|
182
|
-
childCount: 3
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
];
|
|
186
|
-
|
|
187
|
-
// 模拟发送这些事件
|
|
188
|
-
simulatedEvents.forEach(event => {
|
|
189
|
-
events.push(event);
|
|
190
|
-
log(`模拟事件: ${event.topic}`);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
log('✓ 容器发现流程模拟完成');
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
async function analyzeEvents() {
|
|
197
|
-
log('\n=== 事件分析 ===');
|
|
198
|
-
log(`总共收到 ${events.length} 个事件`);
|
|
199
|
-
|
|
200
|
-
// 分类事件
|
|
201
|
-
const containerEvents = events.filter(e =>
|
|
202
|
-
e.type === 'event' && e.topic && e.topic.includes('container')
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
log(`容器相关事件: ${containerEvents.length} 个`);
|
|
206
|
-
|
|
207
|
-
// 打印容器事件详情
|
|
208
|
-
containerEvents.forEach((event, index) => {
|
|
209
|
-
log(`[${index + 1}] ${event.topic}`);
|
|
210
|
-
if (event.payload) {
|
|
211
|
-
const keys = Object.keys(event.payload);
|
|
212
|
-
log(` 字段: ${keys.join(', ')}`);
|
|
213
|
-
}
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
return containerEvents;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
async function main() {
|
|
220
|
-
try {
|
|
221
|
-
// Step 1: 检查服务
|
|
222
|
-
await checkHealth();
|
|
223
|
-
|
|
224
|
-
// Step 2: 连接 WebSocket
|
|
225
|
-
await connectWebSocket();
|
|
226
|
-
|
|
227
|
-
// Step 3: 绘制 DOM Tree (ASCII)
|
|
228
|
-
await drawAsciiTree();
|
|
229
|
-
|
|
230
|
-
// Step 4: 模拟容器发现流程
|
|
231
|
-
await simulateContainerDiscovery();
|
|
232
|
-
|
|
233
|
-
// Step 5: 分析事件
|
|
234
|
-
const containerEvents = await analyzeEvents();
|
|
235
|
-
|
|
236
|
-
// Step 6: 总结
|
|
237
|
-
log('\n=== 测试总结 ===');
|
|
238
|
-
log('✓ WebSocket 连接');
|
|
239
|
-
log('✓ DOM Tree 绘制');
|
|
240
|
-
log('✓ 容器发现模拟');
|
|
241
|
-
log(`✓ 事件跟踪: ${containerEvents.length} 个容器事件`);
|
|
242
|
-
|
|
243
|
-
log('\n✅ DOM Tree 绘制和事件跟踪测试完成!');
|
|
244
|
-
|
|
245
|
-
ws.close();
|
|
246
|
-
process.exit(0);
|
|
247
|
-
|
|
248
|
-
} catch (error) {
|
|
249
|
-
console.error('\n❌ 测试失败:', error.message);
|
|
250
|
-
console.error(error.stack);
|
|
251
|
-
if (ws) ws.close();
|
|
252
|
-
process.exit(1);
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
main();
|