@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
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Workflow Block: ErrorRecoveryBlock
|
|
3
|
+
*
|
|
4
|
+
* 职责:
|
|
5
|
+
* - 提供阶段错误后的恢复策略
|
|
6
|
+
* - 统一恢复到安全起点(搜索页或主页)
|
|
7
|
+
* - 验证恢复是否成功(锚点回环)
|
|
8
|
+
* - 支持ESC恢复模式(用于Phase3/4详情页恢复)
|
|
9
|
+
* - 支持多种恢复路径(home/search/detail)
|
|
10
|
+
*/
|
|
11
|
+
import { logControllerActionError, logControllerActionResult, logControllerActionStart, } from './helpers/operationLogger.js';
|
|
12
|
+
export async function execute(input) {
|
|
13
|
+
const { sessionId, fromStage, targetStage, serviceUrl = 'http://127.0.0.1:7701', maxRetries = 2, recoveryMode = 'navigate' } = input;
|
|
14
|
+
// 开发阶段策略:只允许系统级 ESC 恢复;禁止 navigate/JS click/dispatchEvent 等兜底
|
|
15
|
+
if (recoveryMode !== 'esc') {
|
|
16
|
+
return {
|
|
17
|
+
success: false,
|
|
18
|
+
recovered: false,
|
|
19
|
+
finalStage: 'unknown',
|
|
20
|
+
error: 'ErrorRecoveryBlock: only esc recovery is allowed (navigate disabled)',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const controllerUrl = `${serviceUrl}/v1/controller/action`;
|
|
24
|
+
async function controllerAction(action, payload = {}) {
|
|
25
|
+
const opId = logControllerActionStart(action, payload, { source: 'ErrorRecoveryBlock' });
|
|
26
|
+
try {
|
|
27
|
+
const res = await fetch(controllerUrl, {
|
|
28
|
+
method: 'POST',
|
|
29
|
+
headers: { 'Content-Type': 'application/json' },
|
|
30
|
+
body: JSON.stringify({ action, payload }),
|
|
31
|
+
signal: AbortSignal.timeout ? AbortSignal.timeout(10000) : undefined
|
|
32
|
+
});
|
|
33
|
+
if (!res.ok) {
|
|
34
|
+
throw new Error(`HTTP ${res.status}: ${await res.text()}`);
|
|
35
|
+
}
|
|
36
|
+
const data = await res.json();
|
|
37
|
+
const result = data.data || data;
|
|
38
|
+
logControllerActionResult(opId, action, result, { source: 'ErrorRecoveryBlock' });
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
logControllerActionError(opId, action, error, payload, { source: 'ErrorRecoveryBlock' });
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async function getCurrentUrl() {
|
|
47
|
+
const data = await controllerAction('browser:execute', {
|
|
48
|
+
profile: sessionId,
|
|
49
|
+
script: 'location.href'
|
|
50
|
+
});
|
|
51
|
+
return data?.result || data?.data?.result || '';
|
|
52
|
+
}
|
|
53
|
+
async function verifyStage(stage) {
|
|
54
|
+
try {
|
|
55
|
+
const { verifyAnchorByContainerId } = await import('./helpers/containerAnchors.js');
|
|
56
|
+
const targetContainerId = stage === 'search'
|
|
57
|
+
? 'xiaohongshu_search.search_result_list'
|
|
58
|
+
: 'xiaohongshu_home';
|
|
59
|
+
const anchor = await verifyAnchorByContainerId(targetContainerId, sessionId, serviceUrl, '2px solid #4caf50', 1200);
|
|
60
|
+
if (!anchor.found || !anchor.rect) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
const rectOk = anchor.rect.width > 0 && anchor.rect.height > 0;
|
|
64
|
+
if (!rectOk) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
// 额外约束:确认“可见的”详情 overlay 已完全消失,避免在仍有详情 overlay 时误判为 search/home
|
|
68
|
+
try {
|
|
69
|
+
const domState = await controllerAction('browser:execute', {
|
|
70
|
+
profile: sessionId,
|
|
71
|
+
script: `(() => {
|
|
72
|
+
const selectors = [
|
|
73
|
+
'.note-detail-mask',
|
|
74
|
+
'.note-detail-page',
|
|
75
|
+
'.note-detail-dialog',
|
|
76
|
+
'.note-detail',
|
|
77
|
+
'.detail-container',
|
|
78
|
+
'.media-container'
|
|
79
|
+
];
|
|
80
|
+
const isVisible = (el) => {
|
|
81
|
+
if (!el) return false;
|
|
82
|
+
const style = window.getComputedStyle(el);
|
|
83
|
+
if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') return false;
|
|
84
|
+
const r = el.getBoundingClientRect();
|
|
85
|
+
if (!r.width || !r.height) return false;
|
|
86
|
+
if (r.bottom <= 0 || r.top >= window.innerHeight) return false;
|
|
87
|
+
return true;
|
|
88
|
+
};
|
|
89
|
+
let visibleOverlay = null;
|
|
90
|
+
for (const sel of selectors) {
|
|
91
|
+
const el = document.querySelector(sel);
|
|
92
|
+
if (el && isVisible(el)) {
|
|
93
|
+
visibleOverlay = el;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { hasDetailOverlayVisible: !!visibleOverlay };
|
|
98
|
+
})()`,
|
|
99
|
+
});
|
|
100
|
+
const payload = domState.result || domState.data?.result || domState;
|
|
101
|
+
if (payload?.hasDetailOverlayVisible) {
|
|
102
|
+
console.warn('[ErrorRecovery] verifyStage: visible detail overlay still present, stage not stable');
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
console.warn('[ErrorRecovery] verifyStage DOM check error:', e.message);
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
console.warn('[ErrorRecovery] verifyStage 锚点验证异常:', error.message);
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async function recoverWithEsc() {
|
|
117
|
+
console.log('[ErrorRecovery] 使用ESC模式恢复...');
|
|
118
|
+
// 0. 入口锚点:先确认当前确实处于“详情态”(存在“可见的” detail overlay),避免在错误页面上盲动。
|
|
119
|
+
let hasDetailOverlay = false;
|
|
120
|
+
try {
|
|
121
|
+
const domState = await controllerAction('browser:execute', {
|
|
122
|
+
profile: sessionId,
|
|
123
|
+
script: `(() => {
|
|
124
|
+
const selectors = [
|
|
125
|
+
'.note-detail-mask',
|
|
126
|
+
'.note-detail-page',
|
|
127
|
+
'.note-detail-dialog',
|
|
128
|
+
'.note-detail',
|
|
129
|
+
'.detail-container',
|
|
130
|
+
'.media-container'
|
|
131
|
+
];
|
|
132
|
+
const isVisible = (el) => {
|
|
133
|
+
if (!el) return false;
|
|
134
|
+
const style = window.getComputedStyle(el);
|
|
135
|
+
if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') return false;
|
|
136
|
+
const r = el.getBoundingClientRect();
|
|
137
|
+
if (!r.width || !r.height) return false;
|
|
138
|
+
if (r.bottom <= 0 || r.top >= window.innerHeight) return false;
|
|
139
|
+
return true;
|
|
140
|
+
};
|
|
141
|
+
let visibleOverlay = null;
|
|
142
|
+
for (const sel of selectors) {
|
|
143
|
+
const el = document.querySelector(sel);
|
|
144
|
+
if (el && isVisible(el)) {
|
|
145
|
+
visibleOverlay = el;
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return { hasDetailOverlayVisible: !!visibleOverlay };
|
|
150
|
+
})()`,
|
|
151
|
+
});
|
|
152
|
+
const payload = domState.result || domState.data?.result || domState;
|
|
153
|
+
hasDetailOverlay = Boolean(payload?.hasDetailOverlayVisible);
|
|
154
|
+
}
|
|
155
|
+
catch (e) {
|
|
156
|
+
console.warn(`[ErrorRecovery] detail-overlay DOM probe failed before ESC recovery: ${e.message}`);
|
|
157
|
+
}
|
|
158
|
+
if (!hasDetailOverlay) {
|
|
159
|
+
console.warn('[ErrorRecovery] detail overlay not detected before ESC recovery, continue ESC path based on stage hint');
|
|
160
|
+
// 这里不再直接返回失败:
|
|
161
|
+
// - 来到 ErrorRecoveryBlock 且 fromStage=detail 时,调用方已经认为当前处于详情态
|
|
162
|
+
// - DOM 预探测只是辅助信号,可能因为样式/结构变化导致误判
|
|
163
|
+
// 因此即便未检测到 overlay,也继续尝试容器关闭与 ESC 按键,由后续 verifyStage 严格确认结果
|
|
164
|
+
}
|
|
165
|
+
// 0.1 次级锚点(非强制):尝试命中详情 modal 容器,用于高亮确认;失败不再视为致命,仅记录日志。
|
|
166
|
+
try {
|
|
167
|
+
const { verifyAnchorByContainerId } = await import('./helpers/containerAnchors.js');
|
|
168
|
+
const detailAnchor = await verifyAnchorByContainerId('xiaohongshu_detail.modal_shell', sessionId, serviceUrl, '2px solid #ff4444', 1200);
|
|
169
|
+
if (!detailAnchor.found || !detailAnchor.rect) {
|
|
170
|
+
console.warn('[ErrorRecovery] detail modal anchor not found, continue ESC recovery based on DOM overlay only');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (e) {
|
|
174
|
+
console.warn(`[ErrorRecovery] verify detail anchor failed before ESC recovery: ${e.message}`);
|
|
175
|
+
// 容器锚点只是次级信号,这里不再直接失败,后续依赖 DOM + search_result_list 锚点确认恢复效果
|
|
176
|
+
}
|
|
177
|
+
// 1) 优先通过容器运行时 + 系统点击关闭详情 modal(点击右上角关闭按钮)
|
|
178
|
+
try {
|
|
179
|
+
const clickResult = await controllerAction('container:operation', {
|
|
180
|
+
containerId: 'xiaohongshu_detail.modal_shell',
|
|
181
|
+
operationId: 'click',
|
|
182
|
+
config: {
|
|
183
|
+
selector: '.note-detail-mask .close-box, .note-detail-mask .close-circle',
|
|
184
|
+
useSystemMouse: true,
|
|
185
|
+
retries: 1,
|
|
186
|
+
},
|
|
187
|
+
sessionId
|
|
188
|
+
});
|
|
189
|
+
console.log('[ErrorRecovery] container-close click result:', JSON.stringify(clickResult));
|
|
190
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
191
|
+
// 1.1 关闭后通过搜索结果列表锚点 + DOM overlay 检查判断是否已回到安全阶段
|
|
192
|
+
try {
|
|
193
|
+
const { verifyAnchorByContainerId } = await import('./helpers/containerAnchors.js');
|
|
194
|
+
const anchor = await verifyAnchorByContainerId('xiaohongshu_search.search_result_list', sessionId, serviceUrl, '2px solid #4caf50', 1000);
|
|
195
|
+
const anchorOk = anchor.found && anchor.rect && anchor.rect.width > 0 && anchor.rect.height > 0;
|
|
196
|
+
let overlayGone = true;
|
|
197
|
+
try {
|
|
198
|
+
const domState = await controllerAction('browser:execute', {
|
|
199
|
+
profile: sessionId,
|
|
200
|
+
script: `(() => {
|
|
201
|
+
const selectors = [
|
|
202
|
+
'.note-detail-mask',
|
|
203
|
+
'.note-detail-page',
|
|
204
|
+
'.note-detail-dialog',
|
|
205
|
+
'.note-detail',
|
|
206
|
+
'.detail-container',
|
|
207
|
+
'.media-container'
|
|
208
|
+
];
|
|
209
|
+
const isVisible = (el) => {
|
|
210
|
+
if (!el) return false;
|
|
211
|
+
const style = window.getComputedStyle(el);
|
|
212
|
+
if (style.display === 'none' || style.visibility === 'hidden' || style.opacity === '0') return false;
|
|
213
|
+
const r = el.getBoundingClientRect();
|
|
214
|
+
if (!r.width || !r.height) return false;
|
|
215
|
+
if (r.bottom <= 0 || r.top >= window.innerHeight) return false;
|
|
216
|
+
return true;
|
|
217
|
+
};
|
|
218
|
+
let visibleOverlay = null;
|
|
219
|
+
for (const sel of selectors) {
|
|
220
|
+
const el = document.querySelector(sel);
|
|
221
|
+
if (el && isVisible(el)) {
|
|
222
|
+
visibleOverlay = el;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return { hasDetailOverlayVisible: !!visibleOverlay };
|
|
227
|
+
})()`,
|
|
228
|
+
});
|
|
229
|
+
const payload = domState.result || domState.data?.result || domState;
|
|
230
|
+
overlayGone = !Boolean(payload?.hasDetailOverlayVisible);
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
console.warn(`[ErrorRecovery] overlay DOM check after container-close failed: ${e.message}`);
|
|
234
|
+
}
|
|
235
|
+
if (anchorOk && overlayGone) {
|
|
236
|
+
console.log('[ErrorRecovery] ✅ detail closed via container operation (anchor matched, overlay gone)');
|
|
237
|
+
return { success: true, method: 'container-close' };
|
|
238
|
+
}
|
|
239
|
+
if (anchorOk && !overlayGone) {
|
|
240
|
+
console.warn('[ErrorRecovery] search_result_list visible but detail overlay still present after container-close, will fallback to ESC key');
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
catch (err) {
|
|
244
|
+
console.warn(`[ErrorRecovery] verify search_result_list after close failed: ${err?.message || err}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (err) {
|
|
248
|
+
console.warn(`[ErrorRecovery] container close failed, fallback to ESC key: ${err?.message || String(err)}`);
|
|
249
|
+
}
|
|
250
|
+
// 2) 兜底:再次发送 ESC 键关闭详情页
|
|
251
|
+
try {
|
|
252
|
+
await controllerAction('keyboard:press', { profileId: sessionId, key: 'Escape' });
|
|
253
|
+
await new Promise((resolve) => setTimeout(resolve, 1500));
|
|
254
|
+
const { verifyAnchorByContainerId } = await import('./helpers/containerAnchors.js');
|
|
255
|
+
const anchor = await verifyAnchorByContainerId('xiaohongshu_search.search_result_list', sessionId, serviceUrl, '2px solid #4caf50', 1000);
|
|
256
|
+
const ok = Boolean(anchor.found && anchor.rect && anchor.rect.width > 0 && anchor.rect.height > 0);
|
|
257
|
+
return { success: ok, method: 'esc-key-double' };
|
|
258
|
+
}
|
|
259
|
+
catch (err) {
|
|
260
|
+
console.warn(`[ErrorRecovery] second ESC fallback failed: ${err?.message || err}`);
|
|
261
|
+
return { success: false, method: 'esc-key-double-error' };
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
console.log(`[ErrorRecovery] 从 ${fromStage} 恢复到 ${targetStage}...`);
|
|
265
|
+
try {
|
|
266
|
+
const currentUrl = await getCurrentUrl();
|
|
267
|
+
const atSearch = await verifyStage('search');
|
|
268
|
+
const atHome = await verifyStage('home');
|
|
269
|
+
if ((targetStage === 'search' && atSearch) || (targetStage === 'home' && atHome)) {
|
|
270
|
+
console.log(`[ErrorRecovery] ✅ 已在目标阶段 ${targetStage}(anchor verified)`);
|
|
271
|
+
return {
|
|
272
|
+
success: true,
|
|
273
|
+
recovered: false,
|
|
274
|
+
finalStage: targetStage,
|
|
275
|
+
currentUrl,
|
|
276
|
+
method: 'already-at-target',
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
if (fromStage === 'detail' && targetStage === 'search') {
|
|
280
|
+
const escResult = await recoverWithEsc();
|
|
281
|
+
if (escResult.success) {
|
|
282
|
+
const verified = await verifyStage('search');
|
|
283
|
+
if (verified) {
|
|
284
|
+
return {
|
|
285
|
+
success: true,
|
|
286
|
+
recovered: true,
|
|
287
|
+
finalStage: 'search',
|
|
288
|
+
currentUrl: await getCurrentUrl(),
|
|
289
|
+
method: escResult.method,
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
success: false,
|
|
295
|
+
recovered: false,
|
|
296
|
+
finalStage: 'unknown',
|
|
297
|
+
currentUrl: await getCurrentUrl(),
|
|
298
|
+
error: 'esc_recovery_failed',
|
|
299
|
+
method: 'esc_recovery_failed',
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
success: false,
|
|
304
|
+
recovered: false,
|
|
305
|
+
finalStage: 'unknown',
|
|
306
|
+
currentUrl,
|
|
307
|
+
error: `unsupported_recovery_path: from=${fromStage} target=${targetStage} (esc only)`,
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
catch (err) {
|
|
311
|
+
return {
|
|
312
|
+
success: false,
|
|
313
|
+
recovered: false,
|
|
314
|
+
finalStage: 'unknown',
|
|
315
|
+
error: `恢复异常: ${err.message}`
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
//# sourceMappingURL=ErrorRecoveryBlock.js.map
|