@web-auto/webauto 0.1.1 → 0.1.2
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 +247 -12
- 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 +37 -9
- 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,242 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 简化视觉回环测试 - 验证坐标定位反查 DOM 的可靠性
|
|
4
|
-
*
|
|
5
|
-
* 测试流程:
|
|
6
|
-
* 1. 获取页面上的 body 元素边界框(滚动到顶部后)
|
|
7
|
-
* 2. 通过坐标反查 DOM
|
|
8
|
-
* 3. 验证反查结果
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
import assert from 'node:assert/strict';
|
|
12
|
-
import http from 'node:http';
|
|
13
|
-
|
|
14
|
-
const UNIFIED_API = 'http://127.0.0.1:7701';
|
|
15
|
-
const PROFILE = 'weibo_fresh';
|
|
16
|
-
|
|
17
|
-
function log(msg) {
|
|
18
|
-
console.log(`[simple-visual-test] ${msg}`);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
async function httpPost(path, data) {
|
|
22
|
-
return new Promise((resolve, reject) => {
|
|
23
|
-
const payload = JSON.stringify(data);
|
|
24
|
-
const req = http.request(
|
|
25
|
-
`${UNIFIED_API}${path}`,
|
|
26
|
-
{
|
|
27
|
-
method: 'POST',
|
|
28
|
-
headers: {
|
|
29
|
-
'Content-Type': 'application/json',
|
|
30
|
-
'Content-Length': Buffer.byteLength(payload)
|
|
31
|
-
}
|
|
32
|
-
},
|
|
33
|
-
(res) => {
|
|
34
|
-
let body = '';
|
|
35
|
-
res.on('data', (chunk) => body += chunk);
|
|
36
|
-
res.on('end', () => {
|
|
37
|
-
try {
|
|
38
|
-
resolve(JSON.parse(body));
|
|
39
|
-
} catch (err) {
|
|
40
|
-
resolve({ body, statusCode: res.statusCode });
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
);
|
|
45
|
-
req.on('error', reject);
|
|
46
|
-
req.write(payload);
|
|
47
|
-
req.end();
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function httpGet(path) {
|
|
52
|
-
return new Promise((resolve, reject) => {
|
|
53
|
-
http.get(`${UNIFIED_API}${path}`, (res) => {
|
|
54
|
-
let body = '';
|
|
55
|
-
res.on('data', (chunk) => body += chunk);
|
|
56
|
-
res.on('end', () => {
|
|
57
|
-
try {
|
|
58
|
-
resolve(JSON.parse(body));
|
|
59
|
-
} catch (err) {
|
|
60
|
-
resolve({ body, statusCode: res.statusCode });
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}).on('error', reject);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
async function main() {
|
|
68
|
-
try {
|
|
69
|
-
log('========================================');
|
|
70
|
-
log('简化视觉回环测试');
|
|
71
|
-
log('========================================\n');
|
|
72
|
-
|
|
73
|
-
// 检查服务健康
|
|
74
|
-
log('检查服务健康...');
|
|
75
|
-
const health = await httpGet('/health');
|
|
76
|
-
if (!health.ok) {
|
|
77
|
-
throw new Error('服务不健康,请先启动: node scripts/start-headful.mjs');
|
|
78
|
-
}
|
|
79
|
-
log(' ✓ 服务正常\n');
|
|
80
|
-
|
|
81
|
-
// 获取 body 元素的边界框(确保页面滚动到顶部)
|
|
82
|
-
log('获取 body 元素的边界框...');
|
|
83
|
-
const boundsResult = await httpPost('/v1/controller/action', {
|
|
84
|
-
action: 'browser:execute',
|
|
85
|
-
payload: {
|
|
86
|
-
profile: PROFILE,
|
|
87
|
-
script: `
|
|
88
|
-
(function() {
|
|
89
|
-
// 滚动到页面顶部
|
|
90
|
-
window.scrollTo(0, 0);
|
|
91
|
-
|
|
92
|
-
const body = document.body;
|
|
93
|
-
if (!body) return null;
|
|
94
|
-
|
|
95
|
-
const rect = body.getBoundingClientRect();
|
|
96
|
-
return {
|
|
97
|
-
tagName: body.tagName.toLowerCase(),
|
|
98
|
-
bounds: {
|
|
99
|
-
x: Math.round(rect.x),
|
|
100
|
-
y: Math.round(rect.y),
|
|
101
|
-
width: Math.round(rect.width),
|
|
102
|
-
height: Math.round(rect.height)
|
|
103
|
-
},
|
|
104
|
-
center: {
|
|
105
|
-
x: Math.round(rect.x + rect.width / 2),
|
|
106
|
-
y: Math.round(rect.y + rect.height / 2)
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
})()
|
|
110
|
-
`
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
if (!boundsResult.success) {
|
|
115
|
-
throw new Error('无法获取 body 元素边界框');
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// 检查返回数据结构
|
|
119
|
-
let bounds = boundsResult.data;
|
|
120
|
-
if (bounds && bounds.result) {
|
|
121
|
-
bounds = bounds.result; // 提取实际的数据
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (!bounds || !bounds.center) {
|
|
125
|
-
log(' ✗ 返回数据结构异常');
|
|
126
|
-
log(` 原始数据: ${JSON.stringify(boundsResult.data)}`);
|
|
127
|
-
throw new Error('返回数据结构异常');
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
log(` ✓ body 元素: ${bounds.tagName} @ (${bounds.center.x}, ${bounds.center.y})`);
|
|
131
|
-
log(` bounds: ${bounds.bounds.width}x${bounds.bounds.height}`);
|
|
132
|
-
|
|
133
|
-
// 通过坐标反查 DOM(使用视口内坐标)
|
|
134
|
-
log('\n通过坐标反查 DOM...');
|
|
135
|
-
const reverseResult = await httpPost('/v1/controller/action', {
|
|
136
|
-
action: 'browser:execute',
|
|
137
|
-
payload: {
|
|
138
|
-
profile: PROFILE,
|
|
139
|
-
script: `
|
|
140
|
-
(function() {
|
|
141
|
-
const x = ${bounds.center.x};
|
|
142
|
-
const y = ${bounds.center.y};
|
|
143
|
-
|
|
144
|
-
const element = document.elementFromPoint(x, y);
|
|
145
|
-
if (!element) {
|
|
146
|
-
return {
|
|
147
|
-
tagName: 'NOT_FOUND',
|
|
148
|
-
selector: 'NOT_FOUND',
|
|
149
|
-
className: 'NOT_FOUND',
|
|
150
|
-
id: 'NOT_FOUND',
|
|
151
|
-
textContent: 'Element not found at coordinates (' + x + ', ' + y + ')'
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// 生成选择器
|
|
156
|
-
function getSelector(el) {
|
|
157
|
-
if (el.id) return '#' + el.id;
|
|
158
|
-
|
|
159
|
-
let selector = el.tagName.toLowerCase();
|
|
160
|
-
|
|
161
|
-
if (el.className && typeof el.className === 'string') {
|
|
162
|
-
const classes = el.className.split(' ').filter(c => c && c.length > 0);
|
|
163
|
-
if (classes.length > 0) {
|
|
164
|
-
const stableClass = classes.find(c => !(/[A-Z0-9]{5,}/.test(c)));
|
|
165
|
-
if (stableClass) {
|
|
166
|
-
selector += '.' + stableClass;
|
|
167
|
-
} else {
|
|
168
|
-
const prefix = classes[0].replace(/[_-][A-Z0-9]+$/, '');
|
|
169
|
-
selector += '[class*="' + prefix + '"]';
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return selector;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return {
|
|
178
|
-
tagName: element.tagName.toLowerCase(),
|
|
179
|
-
selector: getSelector(element),
|
|
180
|
-
className: element.className || '',
|
|
181
|
-
id: element.id || '',
|
|
182
|
-
textContent: (element.textContent || '').substring(0, 100)
|
|
183
|
-
};
|
|
184
|
-
})()
|
|
185
|
-
`
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
if (!reverseResult.success || !reverseResult.data) {
|
|
190
|
-
throw new Error('坐标反查 DOM 失败');
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
const found = reverseResult.data;
|
|
194
|
-
|
|
195
|
-
if (found.tagName === 'NOT_FOUND') {
|
|
196
|
-
log(' ✗ 坐标反查失败,未找到元素');
|
|
197
|
-
log(` 位置: (${bounds.center.x}, ${bounds.center.y})`);
|
|
198
|
-
log('❌ 坐标定位反查 DOM 的方式不可靠');
|
|
199
|
-
log('\n========================================');
|
|
200
|
-
log('结论');
|
|
201
|
-
log('========================================');
|
|
202
|
-
log('❌ 测试失败: 坐标定位反查 DOM 方式不可靠');
|
|
203
|
-
process.exit(1);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
log(` ✓ 反查结果: ${found.tagName}`);
|
|
207
|
-
log(` 选择器: ${found.selector}`);
|
|
208
|
-
log(` 类名: ${found.className}`);
|
|
209
|
-
|
|
210
|
-
// 验证结果
|
|
211
|
-
const matched = found.tagName && bounds.tagName &&
|
|
212
|
-
found.tagName.toLowerCase() === bounds.tagName.toLowerCase();
|
|
213
|
-
log(`\n匹配结果: ${matched ? '✓' : '✗'}`);
|
|
214
|
-
|
|
215
|
-
if (matched) {
|
|
216
|
-
log('✅ 坐标定位反查 DOM 的方式可靠');
|
|
217
|
-
log(' 可以用于视觉分析器的 DOM 元素识别');
|
|
218
|
-
} else {
|
|
219
|
-
log('❌ 坐标定位反查 DOM 的方式不可靠');
|
|
220
|
-
log(` 期望: ${bounds.tagName}, 实际: ${found.tagName}`);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
log('\n========================================');
|
|
224
|
-
log('结论');
|
|
225
|
-
log('========================================');
|
|
226
|
-
|
|
227
|
-
if (matched) {
|
|
228
|
-
log('✅ 测试通过: 坐标定位反查 DOM 方式可靠');
|
|
229
|
-
} else {
|
|
230
|
-
log('❌ 测试失败: 坐标定位反查 DOM 方式不可靠');
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
process.exit(matched ? 0 : 1);
|
|
234
|
-
|
|
235
|
-
} catch (error) {
|
|
236
|
-
console.error('\n❌ 测试失败:', error.message);
|
|
237
|
-
if (error.stack) console.error(error.stack);
|
|
238
|
-
process.exit(1);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
main();
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 视觉定位可靠性测试 - 调试版本
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import assert from 'node:assert/strict';
|
|
7
|
-
import http from 'node:http';
|
|
8
|
-
|
|
9
|
-
const UNIFIED_API = 'http://127.0.0.1:7701';
|
|
10
|
-
const PROFILE = 'weibo_fresh';
|
|
11
|
-
|
|
12
|
-
function log(msg) {
|
|
13
|
-
console.log(`[visual-robust] ${msg}`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function httpPost(path, data) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const payload = JSON.stringify(data);
|
|
19
|
-
const req = http.request(
|
|
20
|
-
`${UNIFIED_API}${path}`,
|
|
21
|
-
{
|
|
22
|
-
method: 'POST',
|
|
23
|
-
headers: {
|
|
24
|
-
'Content-Type': 'application/json',
|
|
25
|
-
'Content-Length': Buffer.byteLength(payload)
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
(res) => {
|
|
29
|
-
let body = '';
|
|
30
|
-
res.on('data', (chunk) => body += chunk);
|
|
31
|
-
res.on('end', () => {
|
|
32
|
-
try {
|
|
33
|
-
resolve(JSON.parse(body));
|
|
34
|
-
} catch (err) {
|
|
35
|
-
resolve({ body, statusCode: res.statusCode });
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
req.on('error', reject);
|
|
41
|
-
req.write(payload);
|
|
42
|
-
req.end();
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
async function httpGet(path) {
|
|
47
|
-
return new Promise((resolve, reject) => {
|
|
48
|
-
http.get(`${UNIFIED_API}${path}`, (res) => {
|
|
49
|
-
let body = '';
|
|
50
|
-
res.on('data', (chunk) => body += chunk);
|
|
51
|
-
res.on('end', () => {
|
|
52
|
-
try {
|
|
53
|
-
resolve(JSON.parse(body));
|
|
54
|
-
} catch (err) {
|
|
55
|
-
resolve({ body, statusCode: res.statusCode });
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}).on('error', reject);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
async function main() {
|
|
63
|
-
try {
|
|
64
|
-
log('========================================');
|
|
65
|
-
log('视觉定位可靠性测试');
|
|
66
|
-
log('========================================\n');
|
|
67
|
-
|
|
68
|
-
const health = await httpGet('/health');
|
|
69
|
-
if (!health.ok) {
|
|
70
|
-
throw new Error('服务不健康,请先启动: node scripts/start-headful.mjs');
|
|
71
|
-
}
|
|
72
|
-
log('✓ 服务正常\n');
|
|
73
|
-
|
|
74
|
-
// 一体化测试
|
|
75
|
-
log('执行一体化测试...');
|
|
76
|
-
const result = await httpPost('/v1/controller/action', {
|
|
77
|
-
action: 'browser:execute',
|
|
78
|
-
payload: {
|
|
79
|
-
profile: PROFILE,
|
|
80
|
-
script: `
|
|
81
|
-
(function() {
|
|
82
|
-
window.scrollTo(0, 0);
|
|
83
|
-
const body = document.body;
|
|
84
|
-
if (!body) return { success: false, error: 'body not found' };
|
|
85
|
-
|
|
86
|
-
const rect = body.getBoundingClientRect();
|
|
87
|
-
const x = Math.round(rect.x);
|
|
88
|
-
const y = Math.round(rect.y);
|
|
89
|
-
const width = Math.round(rect.width);
|
|
90
|
-
const height = Math.round(rect.height);
|
|
91
|
-
const centerX = Math.round(x + width / 2);
|
|
92
|
-
const centerY = Math.round(y + height / 2);
|
|
93
|
-
|
|
94
|
-
const element = document.elementFromPoint(centerX, centerY);
|
|
95
|
-
if (!element) {
|
|
96
|
-
return {
|
|
97
|
-
success: false,
|
|
98
|
-
error: 'elementFromPoint returned null',
|
|
99
|
-
original: {
|
|
100
|
-
tagName: body.tagName.toLowerCase(),
|
|
101
|
-
x: centerX,
|
|
102
|
-
y: centerY,
|
|
103
|
-
rect: { x, y, width, height }
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
let selector = element.tagName.toLowerCase();
|
|
109
|
-
if (element.id) {
|
|
110
|
-
selector = '#' + element.id;
|
|
111
|
-
} else if (element.className) {
|
|
112
|
-
const classes = element.className.split(' ').filter(c => c);
|
|
113
|
-
if (classes.length > 0) {
|
|
114
|
-
selector = selector + '.' + classes[0];
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return {
|
|
119
|
-
success: true,
|
|
120
|
-
original: {
|
|
121
|
-
tagName: body.tagName.toLowerCase(),
|
|
122
|
-
x: centerX,
|
|
123
|
-
y: centerY,
|
|
124
|
-
rect: { x, y, width, height }
|
|
125
|
-
},
|
|
126
|
-
found: {
|
|
127
|
-
tagName: element.tagName.toLowerCase(),
|
|
128
|
-
selector,
|
|
129
|
-
id: element.id || '',
|
|
130
|
-
className: element.className || ''
|
|
131
|
-
},
|
|
132
|
-
matched: element.tagName.toLowerCase() === body.tagName.toLowerCase()
|
|
133
|
-
};
|
|
134
|
-
})()
|
|
135
|
-
`
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
log(` success: ${result.success}`);
|
|
140
|
-
log(` data: ${JSON.stringify(result.data).substring(0, 500)}`);
|
|
141
|
-
|
|
142
|
-
if (!result.success) {
|
|
143
|
-
log('✗ 测试失败');
|
|
144
|
-
process.exit(1);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
let data = result.data;
|
|
148
|
-
if (data && data.result) {
|
|
149
|
-
data = data.result;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (!data || !data.original) {
|
|
153
|
-
log('✗ 数据结构异常');
|
|
154
|
-
log(` 完整响应: ${JSON.stringify(result.data)}`);
|
|
155
|
-
process.exit(1);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
log('✓ 测试成功');
|
|
159
|
-
log(` 原始元素: ${data.original.tagName} @ (${data.original.x}, ${data.original.y})`);
|
|
160
|
-
log(` 反查元素: ${data.found.tagName}`);
|
|
161
|
-
log(` 生成选择器: ${data.found.selector}`);
|
|
162
|
-
log(` 匹配结果: ${data.matched ? '✓' : '✗'}`);
|
|
163
|
-
|
|
164
|
-
log('\n========================================');
|
|
165
|
-
log('结论');
|
|
166
|
-
log('========================================');
|
|
167
|
-
|
|
168
|
-
if (data.matched) {
|
|
169
|
-
log('✅ 坐标定位反查 DOM 的方式可靠');
|
|
170
|
-
log(' 可以用于视觉分析器的 DOM 元素识别');
|
|
171
|
-
process.exit(0);
|
|
172
|
-
} else {
|
|
173
|
-
log('❌ 坐标定位反查 DOM 的方式不可靠');
|
|
174
|
-
log(` 期望: ${data.original.tagName}, 实际: ${data.found.tagName}`);
|
|
175
|
-
process.exit(1);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
} catch (error) {
|
|
179
|
-
console.error('\n❌ 测试失败:', error.message);
|
|
180
|
-
if (error.stack) console.error(error.stack);
|
|
181
|
-
process.exit(1);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
main();
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* 视觉高亮回环测试
|
|
4
|
-
* 真正的回环:高亮目标 → 获取坐标 → 反查DOM → 高亮反查结果 → 对比
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import http from 'node:http';
|
|
8
|
-
|
|
9
|
-
const UNIFIED_API = 'http://127.0.0.1:7701';
|
|
10
|
-
const PROFILE = 'weibo_fresh';
|
|
11
|
-
|
|
12
|
-
function log(msg) {
|
|
13
|
-
console.log(`[highlight-loop] ${msg}`);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
async function httpPost(path, data) {
|
|
17
|
-
return new Promise((resolve, reject) => {
|
|
18
|
-
const payload = JSON.stringify(data);
|
|
19
|
-
const req = http.request(
|
|
20
|
-
`${UNIFIED_API}${path}`,
|
|
21
|
-
{ method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(payload) } },
|
|
22
|
-
(res) => {
|
|
23
|
-
let body = '';
|
|
24
|
-
res.on('data', (chunk) => body += chunk);
|
|
25
|
-
res.on('end', () => { try { resolve(JSON.parse(body)); } catch (err) { resolve({ body, statusCode: res.statusCode }); } });
|
|
26
|
-
}
|
|
27
|
-
);
|
|
28
|
-
req.on('error', reject);
|
|
29
|
-
req.write(payload);
|
|
30
|
-
req.end();
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
async function httpGet(path) {
|
|
35
|
-
return new Promise((resolve, reject) => {
|
|
36
|
-
http.get(`${UNIFIED_API}${path}`, (res) => {
|
|
37
|
-
let body = '';
|
|
38
|
-
res.on('data', (chunk) => body += chunk);
|
|
39
|
-
res.on('end', () => { try { resolve(JSON.parse(body)); } catch (err) { resolve({ body, statusCode: res.statusCode }); } });
|
|
40
|
-
}).on('error', reject);
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function main() {
|
|
45
|
-
try {
|
|
46
|
-
log('========================================');
|
|
47
|
-
log('视觉高亮回环测试');
|
|
48
|
-
log('========================================\n');
|
|
49
|
-
|
|
50
|
-
const health = await httpGet('/health');
|
|
51
|
-
if (!health.ok) throw new Error('服务不健康');
|
|
52
|
-
log('✓ 服务正常\n');
|
|
53
|
-
|
|
54
|
-
// Step 1: 找到目标元素并高亮(黄色)
|
|
55
|
-
log('Step 1: 找到目标元素并高亮(黄色)');
|
|
56
|
-
const targetResult = await httpPost('/v1/controller/action', {
|
|
57
|
-
action: 'browser:execute',
|
|
58
|
-
payload: {
|
|
59
|
-
profile: PROFILE,
|
|
60
|
-
script: `
|
|
61
|
-
(function() {
|
|
62
|
-
const links = Array.from(document.querySelectorAll('a'));
|
|
63
|
-
const target = links.find(a => {
|
|
64
|
-
const r = a.getBoundingClientRect();
|
|
65
|
-
return r.width > 10 && r.height > 10 && r.top >= 0 && r.left >= 0 && r.top < window.innerHeight;
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
if (!target) return { success: false, error: 'no visible element found' };
|
|
69
|
-
|
|
70
|
-
const highlight = document.createElement('div');
|
|
71
|
-
highlight.id = 'wa-target-highlight';
|
|
72
|
-
highlight.style.cssText =
|
|
73
|
-
'position: fixed;' +
|
|
74
|
-
'border: 4px solid #FF6B35;' +
|
|
75
|
-
'background: rgba(255,107,53,0.2);' +
|
|
76
|
-
'pointer-events: none;' +
|
|
77
|
-
'z-index: 999999;';
|
|
78
|
-
|
|
79
|
-
const rect = target.getBoundingClientRect();
|
|
80
|
-
highlight.style.left = rect.left + 'px';
|
|
81
|
-
highlight.style.top = rect.top + 'px';
|
|
82
|
-
highlight.style.width = rect.width + 'px';
|
|
83
|
-
highlight.style.height = rect.height + 'px';
|
|
84
|
-
|
|
85
|
-
const label = document.createElement('div');
|
|
86
|
-
label.textContent = 'TARGET (黄色)';
|
|
87
|
-
label.style.cssText =
|
|
88
|
-
'position: absolute;' +
|
|
89
|
-
'top: -28px;' +
|
|
90
|
-
'left: 0;' +
|
|
91
|
-
'background: #FF6B35;' +
|
|
92
|
-
'color: white;' +
|
|
93
|
-
'padding: 4px 8px;' +
|
|
94
|
-
'font-size: 14px;' +
|
|
95
|
-
'font-family: monospace;' +
|
|
96
|
-
'font-weight: bold;';
|
|
97
|
-
highlight.appendChild(label);
|
|
98
|
-
|
|
99
|
-
document.body.appendChild(highlight);
|
|
100
|
-
|
|
101
|
-
return {
|
|
102
|
-
success: true,
|
|
103
|
-
tagName: target.tagName.toLowerCase(),
|
|
104
|
-
className: target.className,
|
|
105
|
-
text: target.textContent.substring(0, 30),
|
|
106
|
-
center: {
|
|
107
|
-
x: Math.round(rect.left + rect.width / 2),
|
|
108
|
-
y: Math.round(rect.top + rect.height / 2)
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
})()
|
|
112
|
-
`
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
let target = targetResult.data;
|
|
117
|
-
if (target && target.result) target = target.result;
|
|
118
|
-
|
|
119
|
-
if (!target || !target.success) {
|
|
120
|
-
throw new Error('无法找到目标元素');
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
log(` ✓ 目标元素: ${target.tagName} (${target.className})`);
|
|
124
|
-
log(` 中心坐标: (${target.center.x}, ${target.center.y})`);
|
|
125
|
-
log(' 黄色高亮框已添加\n');
|
|
126
|
-
|
|
127
|
-
// Step 2: 通过坐标反查 DOM 并高亮(绿色)
|
|
128
|
-
log('Step 2: 通过坐标反查 DOM 并高亮(绿色)');
|
|
129
|
-
const reverseResult = await httpPost('/v1/controller/action', {
|
|
130
|
-
action: 'browser:execute',
|
|
131
|
-
payload: {
|
|
132
|
-
profile: PROFILE,
|
|
133
|
-
script: `
|
|
134
|
-
(function() {
|
|
135
|
-
const x = ${target.center.x};
|
|
136
|
-
const y = ${target.center.y};
|
|
137
|
-
|
|
138
|
-
const element = document.elementFromPoint(x, y);
|
|
139
|
-
if (!element) {
|
|
140
|
-
return {
|
|
141
|
-
success: false,
|
|
142
|
-
error: 'element not found at coordinates',
|
|
143
|
-
x: x,
|
|
144
|
-
y: y
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const reverseHighlight = document.createElement('div');
|
|
149
|
-
reverseHighlight.id = 'wa-reverse-highlight';
|
|
150
|
-
reverseHighlight.style.cssText =
|
|
151
|
-
'position: fixed;' +
|
|
152
|
-
'border: 4px solid #00C853;' +
|
|
153
|
-
'background: rgba(0,200,83,0.2);' +
|
|
154
|
-
'pointer-events: none;' +
|
|
155
|
-
'z-index: 999999;';
|
|
156
|
-
|
|
157
|
-
const rect = element.getBoundingClientRect();
|
|
158
|
-
reverseHighlight.style.left = rect.left + 'px';
|
|
159
|
-
reverseHighlight.style.top = rect.top + 'px';
|
|
160
|
-
reverseHighlight.style.width = rect.width + 'px';
|
|
161
|
-
reverseHighlight.style.height = rect.height + 'px';
|
|
162
|
-
|
|
163
|
-
const label = document.createElement('div');
|
|
164
|
-
label.textContent = 'REVERSE (绿色)';
|
|
165
|
-
label.style.cssText =
|
|
166
|
-
'position: absolute;' +
|
|
167
|
-
'top: -28px;' +
|
|
168
|
-
'left: 0;' +
|
|
169
|
-
'background: #00C853;' +
|
|
170
|
-
'color: white;' +
|
|
171
|
-
'padding: 4px 8px;' +
|
|
172
|
-
'font-size: 14px;' +
|
|
173
|
-
'font-family: monospace;' +
|
|
174
|
-
'font-weight: bold;';
|
|
175
|
-
reverseHighlight.appendChild(label);
|
|
176
|
-
|
|
177
|
-
document.body.appendChild(reverseHighlight);
|
|
178
|
-
|
|
179
|
-
let selector = element.tagName.toLowerCase();
|
|
180
|
-
if (element.id) {
|
|
181
|
-
selector = '#' + element.id;
|
|
182
|
-
} else if (element.className) {
|
|
183
|
-
const classes = element.className.split(' ').filter(c => c);
|
|
184
|
-
if (classes.length > 0) {
|
|
185
|
-
selector += '.' + classes[0];
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
return {
|
|
190
|
-
success: true,
|
|
191
|
-
tagName: element.tagName.toLowerCase(),
|
|
192
|
-
className: element.className,
|
|
193
|
-
selector,
|
|
194
|
-
text: element.textContent.substring(0, 30)
|
|
195
|
-
};
|
|
196
|
-
})()
|
|
197
|
-
`
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
let reverse = reverseResult.data;
|
|
202
|
-
if (reverse && reverse.result) reverse = reverse.result;
|
|
203
|
-
|
|
204
|
-
if (!reverse || !reverse.success) {
|
|
205
|
-
log(` ✗ 反查失败: ${reverse.error || 'unknown'}`);
|
|
206
|
-
log(` 坐标: (${reverse.x}, ${reverse.y})`);
|
|
207
|
-
throw new Error('坐标反查 DOM 失败');
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
log(` ✓ 反查元素: ${reverse.tagName} (${reverse.className})`);
|
|
211
|
-
log(` 生成选择器: ${reverse.selector}\n`);
|
|
212
|
-
|
|
213
|
-
// Step 3: 清理高亮并验证
|
|
214
|
-
log('Step 3: 清理高亮框');
|
|
215
|
-
await httpPost('/v1/controller/action', {
|
|
216
|
-
action: 'browser:execute',
|
|
217
|
-
payload: {
|
|
218
|
-
profile: PROFILE,
|
|
219
|
-
script: `
|
|
220
|
-
(function() {
|
|
221
|
-
const target = document.getElementById('wa-target-highlight');
|
|
222
|
-
const reverse = document.getElementById('wa-reverse-highlight');
|
|
223
|
-
if (target) target.remove();
|
|
224
|
-
if (reverse) reverse.remove();
|
|
225
|
-
return { cleaned: true };
|
|
226
|
-
})()
|
|
227
|
-
`
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
log(' ✓ 高亮框已清理\n');
|
|
232
|
-
|
|
233
|
-
const matched = target.tagName === reverse.tagName;
|
|
234
|
-
const sameClass = target.className === reverse.className;
|
|
235
|
-
|
|
236
|
-
log('========================================');
|
|
237
|
-
log('测试结果');
|
|
238
|
-
log('========================================');
|
|
239
|
-
log(`目标元素: ${target.tagName}`);
|
|
240
|
-
log(`反查元素: ${reverse.tagName}`);
|
|
241
|
-
log(`标签匹配: ${matched ? '✓' : '✗'}`);
|
|
242
|
-
log(`类名匹配: ${sameClass ? '✓' : '✗'}`);
|
|
243
|
-
|
|
244
|
-
if (matched && sameClass) {
|
|
245
|
-
log('\n✅ 坐标定位反查 DOM 的方式可靠');
|
|
246
|
-
log(' 可以用于视觉分析器的 DOM 元素识别');
|
|
247
|
-
} else {
|
|
248
|
-
log('\n⚠️ 标签或类名不匹配');
|
|
249
|
-
log(' 但可以改进选择器生成逻辑(使用 target.closest() 或其他方法)');
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
log('\n========================================');
|
|
253
|
-
log('结论');
|
|
254
|
-
log('========================================');
|
|
255
|
-
|
|
256
|
-
if (matched) {
|
|
257
|
-
log('✅ 测试通过:坐标定位反查 DOM 方式可靠');
|
|
258
|
-
} else {
|
|
259
|
-
log('⚠️ 测试部分通过:需要优化选择器生成逻辑');
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
process.exit(matched ? 0 : 1);
|
|
263
|
-
|
|
264
|
-
} catch (error) {
|
|
265
|
-
console.error('\n❌ 测试失败:', error.message);
|
|
266
|
-
if (error.stack) console.error(error.stack);
|
|
267
|
-
process.exit(1);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
main();
|