@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,497 +0,0 @@
|
|
|
1
|
-
import { createEl } from '../ui-components.mjs';
|
|
2
|
-
import {
|
|
3
|
-
LikeRuleDraft,
|
|
4
|
-
LikeRuleKind,
|
|
5
|
-
XHS_DEFAULT_BATCH_KEY,
|
|
6
|
-
attachTooltip,
|
|
7
|
-
bindInputHistory,
|
|
8
|
-
bindSectionToggle,
|
|
9
|
-
likeRuleGuide,
|
|
10
|
-
makeCheckbox,
|
|
11
|
-
makeNumberInput,
|
|
12
|
-
makeTextInput,
|
|
13
|
-
parseLikeRulesCsv,
|
|
14
|
-
readLastConfig,
|
|
15
|
-
stringifyLikeRule,
|
|
16
|
-
writeLastConfig,
|
|
17
|
-
} from './xiaohongshu/helpers.mjs';
|
|
18
|
-
import { createLiveStatsController } from './xiaohongshu/live-stats.mjs';
|
|
19
|
-
import { createAccountFlowController } from './xiaohongshu/account-flow.mjs';
|
|
20
|
-
import { createRunFlowController } from './xiaohongshu/run-flow.mjs';
|
|
21
|
-
import { buildXhsLayout } from './xiaohongshu/layout-block.mjs';
|
|
22
|
-
import { consumeNavTarget, runGuideBrowserCheck } from './xiaohongshu/guide-browser-check.mjs';
|
|
23
|
-
let xhsCmdUnsubscribe: (() => void) | null = null, xhsSettingsUnsubscribe: (() => void) | null = null;
|
|
24
|
-
let startupBrowserChecked = false;
|
|
25
|
-
let startupBrowserCheckDone = false;
|
|
26
|
-
export function renderXiaohongshuTab(root: HTMLElement, api: any) {
|
|
27
|
-
if (xhsCmdUnsubscribe) {
|
|
28
|
-
xhsCmdUnsubscribe();
|
|
29
|
-
xhsCmdUnsubscribe = null;
|
|
30
|
-
}
|
|
31
|
-
if (xhsSettingsUnsubscribe) {
|
|
32
|
-
xhsSettingsUnsubscribe();
|
|
33
|
-
xhsSettingsUnsubscribe = null;
|
|
34
|
-
}
|
|
35
|
-
root.innerHTML = '';
|
|
36
|
-
const card = createEl('div', { className: 'card', style: 'padding:12px;' });
|
|
37
|
-
const onboardingCard = createEl('div', {
|
|
38
|
-
style: 'margin-bottom:0; border:1px dashed #2b67ff; border-radius:10px; padding:10px; background:#0d1a33;',
|
|
39
|
-
}) as HTMLDivElement;
|
|
40
|
-
const onboardingTitle = createEl('div', { style: 'font-weight:600; margin-bottom:4px; color:#dbeafe;' }, ['首次引导:先配置账号']);
|
|
41
|
-
const onboardingSummary = createEl('div', { className: 'muted', style: 'font-size:12px; margin-bottom:4px;' }, ['正在加载 profile...']) as HTMLDivElement;
|
|
42
|
-
const onboardingTips = createEl('div', { className: 'muted', style: 'font-size:12px; margin-bottom:8px;' }, [
|
|
43
|
-
'请先在预处理页创建 profile,并设置账号名(alias),这里会按“账号名 (profileId)”显示。',
|
|
44
|
-
]) as HTMLDivElement;
|
|
45
|
-
const onboardingGotoPreflightBtn = createEl('button', { type: 'button', className: 'secondary' }, ['去预处理设置账号']) as HTMLButtonElement;
|
|
46
|
-
onboardingGotoPreflightBtn.onclick = () => { if (typeof api?.setActiveTab === 'function') api.setActiveTab('preflight'); };
|
|
47
|
-
onboardingCard.appendChild(onboardingTitle);
|
|
48
|
-
onboardingCard.appendChild(onboardingSummary);
|
|
49
|
-
onboardingCard.appendChild(onboardingTips);
|
|
50
|
-
onboardingCard.appendChild(createEl('div', { className: 'row', style: 'margin-bottom:0;' }, [onboardingGotoPreflightBtn]));
|
|
51
|
-
const navStepHint = createEl('div', { className: 'muted', style: 'font-size:12px;' }, ['导航模式:先账号检查,再点赞设置,最后回到运行看板。']) as HTMLDivElement;
|
|
52
|
-
const GUIDE_STATE_KEY = 'webauto.xhs.guideState.v1';
|
|
53
|
-
const readGuideState = () => { try { const raw = window.localStorage.getItem(GUIDE_STATE_KEY); return raw ? JSON.parse(raw) : { browserReady: false, accountReady: false, keywordSet: false }; } catch { return { browserReady: false, accountReady: false, keywordSet: false }; } };
|
|
54
|
-
const saveGuideState = (s: any) => { try { window.localStorage.setItem(GUIDE_STATE_KEY, JSON.stringify(s)); } catch {} };
|
|
55
|
-
let guideState = readGuideState();
|
|
56
|
-
let runBtn: HTMLButtonElement | null = null;
|
|
57
|
-
let browserCheckAttempted = false;
|
|
58
|
-
const guideCard = createEl('div', { style: 'border:1px solid #26437a; background:#0c1830; border-radius:10px; padding:10px; margin-bottom:10px;' }) as HTMLDivElement;
|
|
59
|
-
const guideTitle = createEl('div', { style: 'font-weight:600; margin-bottom:8px; color:#dbeafe;' }, ['🧭 新用户引导']) as HTMLDivElement, guideProgress = createEl('div', { style: 'font-size:12px; color:#8b93a6; margin-bottom:8px;' }, ['检查进度...']) as HTMLDivElement;
|
|
60
|
-
guideCard.appendChild(guideTitle); guideCard.appendChild(guideProgress);
|
|
61
|
-
const guideStepsGrid = createEl('div', { className: 'xhs-guide-grid' }) as HTMLDivElement;
|
|
62
|
-
const browserStep = createEl('div', { className: 'xhs-guide-step' }) as HTMLDivElement;
|
|
63
|
-
browserStep.appendChild(createEl('span', {}, ['1. ']));
|
|
64
|
-
const browserStatus = createEl('span', { style: 'color:#f59e0b;' }, ['⏳ 检查浏览器']) as HTMLSpanElement;
|
|
65
|
-
browserStep.appendChild(browserStatus);
|
|
66
|
-
guideStepsGrid.appendChild(browserStep);
|
|
67
|
-
const accountStep = createEl('div', { className: 'xhs-guide-step' }) as HTMLDivElement;
|
|
68
|
-
accountStep.appendChild(createEl('span', {}, ['2. ']));
|
|
69
|
-
const accountStatus = createEl('span', { style: 'color:#f59e0b;' }, ['⏳ 配置账号']) as HTMLSpanElement;
|
|
70
|
-
accountStatus.style.cursor = 'pointer';
|
|
71
|
-
accountStatus.title = '点击开始账号检查与交互配置';
|
|
72
|
-
accountStatus.addEventListener('click', () => runInteractiveAccountCheck());
|
|
73
|
-
accountStep.appendChild(accountStatus);
|
|
74
|
-
guideStepsGrid.appendChild(accountStep);
|
|
75
|
-
const keywordStep = createEl('div', { className: 'xhs-guide-step' }) as HTMLDivElement;
|
|
76
|
-
keywordStep.appendChild(createEl('span', {}, ['3. ']));
|
|
77
|
-
const keywordStatus = createEl('span', { style: 'color:#f59e0b;' }, ['⏳ 配置关键词']) as HTMLSpanElement;
|
|
78
|
-
keywordStep.appendChild(keywordStatus); guideStepsGrid.appendChild(keywordStep);
|
|
79
|
-
const completeStep = createEl('div', { className: 'xhs-guide-step xhs-guide-step--full', style: 'display:none;' }) as HTMLDivElement;
|
|
80
|
-
completeStep.appendChild(createEl('span', {}, ['✅ ']));
|
|
81
|
-
completeStep.appendChild(createEl('span', { style: 'color:#22c55e;' }, ['准备就绪,可以开始运行']));
|
|
82
|
-
guideStepsGrid.appendChild(completeStep);
|
|
83
|
-
guideCard.appendChild(guideStepsGrid);
|
|
84
|
-
const startRunBtn = createEl('button', { type: 'button', style: 'display:none; margin-top:8px; width:100%;' }, ['开始运行']) as HTMLButtonElement;
|
|
85
|
-
guideCard.appendChild(startRunBtn);
|
|
86
|
-
const tileLane = createEl('div', { className: 'xhs-tile-lane' }) as HTMLDivElement;
|
|
87
|
-
const tileRegistry = new Map<string, HTMLDivElement>();
|
|
88
|
-
let activeTileId = 'board';
|
|
89
|
-
const setActiveTile = (id: string) => {
|
|
90
|
-
activeTileId = id;
|
|
91
|
-
tileRegistry.forEach((tileEl, tileId) => {
|
|
92
|
-
tileEl.classList.toggle('active', tileId === id);
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
const isInteractiveTarget = (target: EventTarget | null) => {
|
|
96
|
-
if (!(target instanceof Element)) return false;
|
|
97
|
-
return Boolean(target.closest('button, input, select, textarea, label, a'));
|
|
98
|
-
};
|
|
99
|
-
const createTile = (id: string, titleText: string) => {
|
|
100
|
-
const tile = createEl('section', { className: `xhs-tile xhs-tile--${id}`, 'data-xhs-tile': id }) as HTMLDivElement;
|
|
101
|
-
const head = createEl('div', { className: 'xhs-tile-head' }, [titleText]);
|
|
102
|
-
const body = createEl('div', { className: 'xhs-tile-body' }) as HTMLDivElement;
|
|
103
|
-
tile.addEventListener('pointerdown', (evt) => {
|
|
104
|
-
if (isInteractiveTarget(evt.target)) return;
|
|
105
|
-
setActiveTile(id);
|
|
106
|
-
}, { capture: true });
|
|
107
|
-
tile.onclick = () => setActiveTile(id);
|
|
108
|
-
tile.appendChild(head);
|
|
109
|
-
tile.appendChild(body);
|
|
110
|
-
tileRegistry.set(id, tile);
|
|
111
|
-
return { tile, body };
|
|
112
|
-
};
|
|
113
|
-
const focusTile = (id: string) => {
|
|
114
|
-
const tile = tileRegistry.get(id);
|
|
115
|
-
if (!tile) return;
|
|
116
|
-
setActiveTile(id);
|
|
117
|
-
tile.scrollIntoView({ behavior: 'smooth', inline: 'start', block: 'nearest' });
|
|
118
|
-
};
|
|
119
|
-
const resolveTileIdFromEvent = (target: EventTarget | null) => {
|
|
120
|
-
if (!(target instanceof Element)) return '';
|
|
121
|
-
const tileEl = target.closest('[data-xhs-tile]') as HTMLElement | null;
|
|
122
|
-
return String(tileEl?.dataset?.xhsTile || '').trim();
|
|
123
|
-
};
|
|
124
|
-
tileLane.addEventListener(
|
|
125
|
-
'wheel',
|
|
126
|
-
(evt) => {
|
|
127
|
-
const sourceTileId = tileLane.scrollWidth <= tileLane.clientWidth + 4 ? '' : resolveTileIdFromEvent(evt.target);
|
|
128
|
-
if (!sourceTileId || sourceTileId !== activeTileId) return;
|
|
129
|
-
const baseDelta = Math.abs(evt.deltaY) >= Math.abs(evt.deltaX) ? evt.deltaY : evt.deltaX;
|
|
130
|
-
if (!Number.isFinite(baseDelta) || baseDelta === 0) return;
|
|
131
|
-
const deltaFactor = evt.deltaMode === 1
|
|
132
|
-
? 18
|
|
133
|
-
: evt.deltaMode === 2
|
|
134
|
-
? Math.max(240, tileLane.clientWidth * 0.85)
|
|
135
|
-
: 1;
|
|
136
|
-
evt.preventDefault();
|
|
137
|
-
tileLane.scrollLeft += baseDelta * deltaFactor;
|
|
138
|
-
},
|
|
139
|
-
{ passive: false, capture: true },
|
|
140
|
-
);
|
|
141
|
-
const guideLockMask = createEl('div', {
|
|
142
|
-
style: 'position:absolute; inset:0; background:rgba(10,14,24,0.72); border:1px dashed #26437a; border-radius:10px; display:none; align-items:center; justify-content:center; z-index:5; color:#c7d2fe; text-align:center; padding:12px; font-size:12px; pointer-events:none;',
|
|
143
|
-
}, ['请先完成引导:浏览器检查、账号登录、关键词配置']) as HTMLDivElement;
|
|
144
|
-
const isKeywordReady = () => String(keywordInput.value || '').trim().length > 0;
|
|
145
|
-
const runQuickBrowserCheck = async () => {
|
|
146
|
-
if (browserCheckAttempted || startupBrowserCheckDone || guideState.browserReady) return;
|
|
147
|
-
browserCheckAttempted = true;
|
|
148
|
-
startupBrowserCheckDone = true;
|
|
149
|
-
await runGuideBrowserCheck(api, guideState, browserStatus, saveGuideState);
|
|
150
|
-
};
|
|
151
|
-
const applyGuideLock = () => {
|
|
152
|
-
const accountReady = guideState.accountReady;
|
|
153
|
-
const keywordReady = isKeywordReady();
|
|
154
|
-
guideState.keywordSet = keywordReady;
|
|
155
|
-
keywordInput.style.borderColor = keywordReady ? '' : '#ef4444';
|
|
156
|
-
keywordInput.style.backgroundColor = keywordReady ? '' : '#2a1515';
|
|
157
|
-
accountStatus.textContent = accountReady ? '✅ 已有可用账号' : '⏳ 至少登录1个账号';
|
|
158
|
-
accountStatus.style.color = accountReady ? '#22c55e' : '#f59e0b';
|
|
159
|
-
keywordStatus.textContent = keywordReady ? '✅ 关键词已配置' : '⏳ 请先配置关键词';
|
|
160
|
-
keywordStatus.style.color = keywordReady ? '#22c55e' : '#f59e0b';
|
|
161
|
-
const allReady = Boolean(guideState.browserReady && accountReady && keywordReady);
|
|
162
|
-
guideProgress.textContent = allReady
|
|
163
|
-
? '引导完成,可查看全部配置并运行。'
|
|
164
|
-
: `引导未完成:browser=${guideState.browserReady ? 'ok' : 'pending'} account=${accountReady ? 'ok' : 'pending'} keyword=${keywordReady ? 'ok' : 'pending'}`;
|
|
165
|
-
completeStep.style.display = allReady ? '' : 'none';
|
|
166
|
-
startRunBtn.style.display = allReady ? 'none' : '';
|
|
167
|
-
startRunBtn.textContent = '仍然开始运行';
|
|
168
|
-
guideCard.style.display = allReady ? 'none' : '';
|
|
169
|
-
tileLane.style.pointerEvents = '';
|
|
170
|
-
tileLane.style.filter = '';
|
|
171
|
-
guideLockMask.style.display = allReady ? 'none' : 'flex';
|
|
172
|
-
if (runBtn) {
|
|
173
|
-
if (!runBtn.disabled) {
|
|
174
|
-
runBtn.title = allReady ? '' : '引导未完成,仍可直接运行';
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
if (!allReady) {
|
|
178
|
-
setActiveTile('account');
|
|
179
|
-
const accountTile = tileRegistry.get('account');
|
|
180
|
-
if (accountTile) accountTile.scrollIntoView({ behavior: 'smooth', inline: 'start', block: 'nearest' });
|
|
181
|
-
}
|
|
182
|
-
saveGuideState(guideState);
|
|
183
|
-
};
|
|
184
|
-
const runBrowserStatusCheck = async (profileId: string, reason = 'account-check') => {
|
|
185
|
-
if (typeof window.api?.cmdSpawn !== 'function') return false;
|
|
186
|
-
const args = [
|
|
187
|
-
window.api.pathJoin('apps', 'webauto', 'entry', 'browser-status.mjs'),
|
|
188
|
-
profileId,
|
|
189
|
-
'--site',
|
|
190
|
-
'xiaohongshu',
|
|
191
|
-
];
|
|
192
|
-
api?.appendLog?.(`[ui] browser-status (${reason}) profile=${profileId}`);
|
|
193
|
-
await window.api.cmdSpawn({
|
|
194
|
-
title: `browser-status ${profileId}`,
|
|
195
|
-
cwd: '',
|
|
196
|
-
args,
|
|
197
|
-
groupKey: 'xiaohongshu',
|
|
198
|
-
});
|
|
199
|
-
return true;
|
|
200
|
-
};
|
|
201
|
-
const runInteractiveAccountCheck = async () => {
|
|
202
|
-
const selectedProfile = String(profilePickSel.value || '').trim();
|
|
203
|
-
if (!selectedProfile) {
|
|
204
|
-
guideState.accountReady = false;
|
|
205
|
-
applyGuideLock();
|
|
206
|
-
setActiveTile('account');
|
|
207
|
-
if (typeof api?.setActiveTab === 'function') api.setActiveTab('preflight');
|
|
208
|
-
navStepHint.textContent = '请先新增账号并完成登录,再进行账号检查。';
|
|
209
|
-
alert('请先新增账号并完成登录,再进行账号检查。');
|
|
210
|
-
return;
|
|
211
|
-
}
|
|
212
|
-
const ok = await runBrowserStatusCheck(selectedProfile, 'guide-step');
|
|
213
|
-
if (!ok) {
|
|
214
|
-
setActiveTile('account');
|
|
215
|
-
if (typeof api?.setActiveTab === 'function') api.setActiveTab('preflight');
|
|
216
|
-
navStepHint.textContent = '账号检查失败,请在账号区重新触发登录。';
|
|
217
|
-
alert('账号检查失败:cmdSpawn 不可用,请查看日志');
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
void refreshProfileChoices(selectedProfile);
|
|
221
|
-
};
|
|
222
|
-
card.appendChild(guideCard);
|
|
223
|
-
const persistedConfig = readLastConfig();
|
|
224
|
-
const layout = buildXhsLayout({
|
|
225
|
-
createTile,
|
|
226
|
-
card,
|
|
227
|
-
tileLane,
|
|
228
|
-
guideLockMask,
|
|
229
|
-
onboardingCard,
|
|
230
|
-
persistedConfig,
|
|
231
|
-
});
|
|
232
|
-
const {
|
|
233
|
-
orchestrateModeSelect, keywordInput, envInput, accountModeSelect, profilePickSel, profileRefreshBtn,
|
|
234
|
-
shardProfilesBox, shardProfilesHint, shardResolvedHint, maxNotesInput, dryRunCheckbox, protocolModeCheckbox,
|
|
235
|
-
headlessCheckbox, modeHint, singleProfileRow, singleProfileHint, shardProfilesSection, accountAuditSummary,
|
|
236
|
-
accountAuditList, accountRefreshBtn, accountLiveProbeBtn, addAccountCountInput, addBatchNameInput,
|
|
237
|
-
accountAddBtn, accountNextLikeBtn, batchKeyValue, batchNextBtn, homepageToggle, imagesToggle, commentsToggle, maxCommentsInput,
|
|
238
|
-
commentRoundsInput, gateToggle, matchKeywordsInput, matchModeSelect, matchMinHitsInput, likesToggle,
|
|
239
|
-
maxLikesInput, likeRuleTypeSelect, likeRuleAInput, likeRuleBInput, addLikeRuleBtn, likeRulePreview,
|
|
240
|
-
replyToggle, replyTextInput, ocrToggle, ocrCommandInput, opOrderInput, opOrderRow, homeSection,
|
|
241
|
-
commentsSection, gateSection, likesSection, replySection, ocrSection, likeNextBoardBtn, linksStat,
|
|
242
|
-
postsStat, commentsStat, likesStat, likesSkipStat, repliesStat, streamStat, shardStatsList, likedList, repliedList,
|
|
243
|
-
persistedSingleProfile, persistedShardProfiles, bindLikeRulePersistence,
|
|
244
|
-
} = layout;
|
|
245
|
-
accountNextLikeBtn.onclick = () => focusTile('like');
|
|
246
|
-
likeNextBoardBtn.onclick = () => focusTile('board');
|
|
247
|
-
browserStep.onclick = () => { focusTile('account'); void runQuickBrowserCheck(); };
|
|
248
|
-
accountStep.onclick = () => { focusTile('account'); void runInteractiveAccountCheck(); };
|
|
249
|
-
keywordStep.onclick = () => { focusTile('board'); keywordInput.focus(); };
|
|
250
|
-
keywordInput.addEventListener('input', applyGuideLock);
|
|
251
|
-
keywordInput.addEventListener('change', applyGuideLock);
|
|
252
|
-
queueMicrotask(() => {
|
|
253
|
-
const finalizeGuide = () => { navStepHint.textContent = 'Step 1: complete account check/login, then configure keyword.'; applyGuideLock(); };
|
|
254
|
-
if (startupBrowserChecked) return void finalizeGuide();
|
|
255
|
-
startupBrowserChecked = true;
|
|
256
|
-
runQuickBrowserCheck().finally(finalizeGuide);
|
|
257
|
-
});
|
|
258
|
-
const liveStatsController = createLiveStatsController({
|
|
259
|
-
maxCommentsInput,
|
|
260
|
-
linksStat,
|
|
261
|
-
postsStat,
|
|
262
|
-
commentsStat,
|
|
263
|
-
likesStat,
|
|
264
|
-
likesSkipStat,
|
|
265
|
-
repliesStat,
|
|
266
|
-
streamStat,
|
|
267
|
-
shardStatsList,
|
|
268
|
-
likedList,
|
|
269
|
-
repliedList,
|
|
270
|
-
});
|
|
271
|
-
const accountFlow = createAccountFlowController({
|
|
272
|
-
api,
|
|
273
|
-
profilePickSel,
|
|
274
|
-
accountModeSelect,
|
|
275
|
-
singleProfileHint,
|
|
276
|
-
shardProfilesBox,
|
|
277
|
-
shardProfilesHint,
|
|
278
|
-
shardResolvedHint,
|
|
279
|
-
accountAuditSummary,
|
|
280
|
-
accountAuditList,
|
|
281
|
-
accountRefreshBtn,
|
|
282
|
-
accountLiveProbeBtn,
|
|
283
|
-
addAccountCountInput,
|
|
284
|
-
addBatchNameInput,
|
|
285
|
-
accountAddBtn,
|
|
286
|
-
batchKeyValue,
|
|
287
|
-
batchNextBtn,
|
|
288
|
-
onboardingSummary,
|
|
289
|
-
onboardingCard,
|
|
290
|
-
onboardingTips,
|
|
291
|
-
persistedSingleProfile,
|
|
292
|
-
persistedShardProfiles,
|
|
293
|
-
setActiveTile,
|
|
294
|
-
saveGuideState,
|
|
295
|
-
applyGuideLock,
|
|
296
|
-
getGuideState: () => guideState,
|
|
297
|
-
setNavHint: (text: string) => {
|
|
298
|
-
navStepHint.textContent = text;
|
|
299
|
-
},
|
|
300
|
-
runBrowserStatusCheck,
|
|
301
|
-
});
|
|
302
|
-
const {
|
|
303
|
-
refreshProfileChoices,
|
|
304
|
-
startAccountAutoRefresh,
|
|
305
|
-
stopAccountAutoRefresh,
|
|
306
|
-
getSelectedShardProfiles,
|
|
307
|
-
renderSingleProfileHint,
|
|
308
|
-
renderShardHints,
|
|
309
|
-
syncAddBatchPlaceholder,
|
|
310
|
-
} = accountFlow;
|
|
311
|
-
const persistHistoryFns: Array<() => void> = [];
|
|
312
|
-
const registerHistoryInput = (input: HTMLInputElement, key: string) => {
|
|
313
|
-
const persist = bindInputHistory(input, key, api);
|
|
314
|
-
persistHistoryFns.push(persist);
|
|
315
|
-
return persist;
|
|
316
|
-
};
|
|
317
|
-
registerHistoryInput(keywordInput, 'keyword');
|
|
318
|
-
registerHistoryInput(envInput, 'env');
|
|
319
|
-
registerHistoryInput(maxNotesInput, 'target');
|
|
320
|
-
registerHistoryInput(maxCommentsInput, 'maxComments');
|
|
321
|
-
registerHistoryInput(commentRoundsInput, 'commentRounds');
|
|
322
|
-
registerHistoryInput(matchKeywordsInput, 'matchKeywords');
|
|
323
|
-
registerHistoryInput(matchMinHitsInput, 'matchMinHits');
|
|
324
|
-
registerHistoryInput(maxLikesInput, 'maxLikes');
|
|
325
|
-
const persistLikeRuleAHistory = registerHistoryInput(likeRuleAInput, 'likeRuleA');
|
|
326
|
-
const persistLikeRuleBHistory = registerHistoryInput(likeRuleBInput, 'likeRuleB');
|
|
327
|
-
registerHistoryInput(replyTextInput, 'replyText');
|
|
328
|
-
registerHistoryInput(ocrCommandInput, 'ocrCommand');
|
|
329
|
-
registerHistoryInput(opOrderInput, 'opOrder');
|
|
330
|
-
const getEffectiveHomepageFlags = () => ({
|
|
331
|
-
doHomepage: Boolean(homepageToggle.checked),
|
|
332
|
-
doImages: Boolean(homepageToggle.checked && imagesToggle.checked),
|
|
333
|
-
});
|
|
334
|
-
const persistLastConfig = () => {
|
|
335
|
-
writeLastConfig({
|
|
336
|
-
orchestrateMode: orchestrateModeSelect.value,
|
|
337
|
-
keyword: keywordInput.value,
|
|
338
|
-
env: envInput.value,
|
|
339
|
-
accountMode: accountModeSelect.value,
|
|
340
|
-
singleProfile: profilePickSel.value,
|
|
341
|
-
shardProfiles: getSelectedShardProfiles(),
|
|
342
|
-
maxNotes: maxNotesInput.value,
|
|
343
|
-
dryRun: dryRunCheckbox.checked,
|
|
344
|
-
protocolMode: protocolModeCheckbox.checked,
|
|
345
|
-
headless: headlessCheckbox.checked,
|
|
346
|
-
doHomepage: getEffectiveHomepageFlags().doHomepage,
|
|
347
|
-
doImages: getEffectiveHomepageFlags().doImages,
|
|
348
|
-
doComments: commentsToggle.checked,
|
|
349
|
-
maxComments: maxCommentsInput.value,
|
|
350
|
-
commentRounds: commentRoundsInput.value,
|
|
351
|
-
doGate: gateToggle.checked,
|
|
352
|
-
matchKeywords: matchKeywordsInput.value,
|
|
353
|
-
matchMode: matchModeSelect.value,
|
|
354
|
-
matchMinHits: matchMinHitsInput.value,
|
|
355
|
-
doLikes: likesToggle.checked,
|
|
356
|
-
maxLikes: maxLikesInput.value,
|
|
357
|
-
likeRules: likeRulePreview.value,
|
|
358
|
-
doReply: replyToggle.checked,
|
|
359
|
-
replyText: replyTextInput.value,
|
|
360
|
-
doOcr: ocrToggle.checked,
|
|
361
|
-
ocrCommand: ocrCommandInput.value,
|
|
362
|
-
opOrder: opOrderInput.value,
|
|
363
|
-
});
|
|
364
|
-
};
|
|
365
|
-
bindLikeRulePersistence({
|
|
366
|
-
persistLastConfig,
|
|
367
|
-
persistLikeRuleAHistory,
|
|
368
|
-
persistLikeRuleBHistory,
|
|
369
|
-
});
|
|
370
|
-
const bindPersistControl = (el: HTMLElement, evt = 'change') => {
|
|
371
|
-
el.addEventListener(evt, persistLastConfig);
|
|
372
|
-
};
|
|
373
|
-
[
|
|
374
|
-
orchestrateModeSelect,
|
|
375
|
-
accountModeSelect,
|
|
376
|
-
profilePickSel,
|
|
377
|
-
keywordInput,
|
|
378
|
-
envInput,
|
|
379
|
-
maxNotesInput,
|
|
380
|
-
maxCommentsInput,
|
|
381
|
-
commentRoundsInput,
|
|
382
|
-
matchKeywordsInput,
|
|
383
|
-
matchModeSelect,
|
|
384
|
-
matchMinHitsInput,
|
|
385
|
-
maxLikesInput,
|
|
386
|
-
replyTextInput,
|
|
387
|
-
ocrCommandInput,
|
|
388
|
-
opOrderInput,
|
|
389
|
-
dryRunCheckbox,
|
|
390
|
-
protocolModeCheckbox,
|
|
391
|
-
headlessCheckbox,
|
|
392
|
-
homepageToggle,
|
|
393
|
-
imagesToggle,
|
|
394
|
-
commentsToggle,
|
|
395
|
-
gateToggle,
|
|
396
|
-
likesToggle,
|
|
397
|
-
replyToggle,
|
|
398
|
-
ocrToggle,
|
|
399
|
-
].forEach((el) => bindPersistControl(el));
|
|
400
|
-
likeRuleTypeSelect.addEventListener('change', persistLastConfig);
|
|
401
|
-
addLikeRuleBtn.addEventListener('click', persistLastConfig);
|
|
402
|
-
const refreshOrchestrationLayout = () => {
|
|
403
|
-
const mode = String(orchestrateModeSelect.value || 'phase1-phase2-unified').trim();
|
|
404
|
-
const unifiedEnabled = mode === 'phase1-phase2-unified' || mode === 'unified-only';
|
|
405
|
-
const accountMode = String(accountModeSelect.value || 'single').trim();
|
|
406
|
-
const isSingleMode = accountMode !== 'shards';
|
|
407
|
-
singleProfileRow.style.display = isSingleMode ? '' : 'none';
|
|
408
|
-
singleProfileHint.style.display = isSingleMode ? '' : 'none';
|
|
409
|
-
shardProfilesSection.style.display = isSingleMode ? 'none' : '';
|
|
410
|
-
if (isSingleMode) renderSingleProfileHint();
|
|
411
|
-
else renderShardHints();
|
|
412
|
-
const featureDisplay = unifiedEnabled ? '' : 'none';
|
|
413
|
-
homeSection.style.display = featureDisplay;
|
|
414
|
-
commentsSection.style.display = featureDisplay;
|
|
415
|
-
gateSection.style.display = featureDisplay;
|
|
416
|
-
likesSection.style.display = featureDisplay;
|
|
417
|
-
replySection.style.display = featureDisplay;
|
|
418
|
-
ocrSection.style.display = featureDisplay;
|
|
419
|
-
opOrderRow.style.display = featureDisplay;
|
|
420
|
-
if (mode === 'phase1-only') {
|
|
421
|
-
modeHint.textContent = '仅执行 Phase1:启动/恢复浏览器会话,不做搜索采集与互动。';
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
if (mode === 'phase1-phase2') {
|
|
425
|
-
modeHint.textContent = '执行 Phase1 + Phase2:启动会话并采集链接,不执行评论/点赞。';
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
if (mode === 'unified-only') {
|
|
429
|
-
modeHint.textContent = '仅执行 Unified:使用已有 phase2-links.jsonl 执行评论采集/点赞/回复。';
|
|
430
|
-
return;
|
|
431
|
-
}
|
|
432
|
-
modeHint.textContent = '完整编排:先 Phase1 启动,再 Phase2 采集链接,最后 Unified 采集评论/点赞。';
|
|
433
|
-
};
|
|
434
|
-
profilePickSel.addEventListener('change', () => { renderSingleProfileHint(); syncAddBatchPlaceholder(); });
|
|
435
|
-
orchestrateModeSelect.addEventListener('change', refreshOrchestrationLayout);
|
|
436
|
-
accountModeSelect.addEventListener('change', refreshOrchestrationLayout);
|
|
437
|
-
refreshOrchestrationLayout();
|
|
438
|
-
consumeNavTarget(focusTile);
|
|
439
|
-
void refreshProfileChoices();
|
|
440
|
-
startAccountAutoRefresh('tab-enter');
|
|
441
|
-
xhsSettingsUnsubscribe = window.api.onSettingsChanged((next: any) => {
|
|
442
|
-
api.settings = next;
|
|
443
|
-
void refreshProfileChoices();
|
|
444
|
-
});
|
|
445
|
-
const runFlow = createRunFlowController({
|
|
446
|
-
card,
|
|
447
|
-
api,
|
|
448
|
-
startRunBtn,
|
|
449
|
-
orchestrateModeSelect,
|
|
450
|
-
accountModeSelect,
|
|
451
|
-
profilePickSel,
|
|
452
|
-
keywordInput,
|
|
453
|
-
envInput,
|
|
454
|
-
protocolModeCheckbox,
|
|
455
|
-
headlessCheckbox,
|
|
456
|
-
dryRunCheckbox,
|
|
457
|
-
maxNotesInput,
|
|
458
|
-
maxCommentsInput,
|
|
459
|
-
commentRoundsInput,
|
|
460
|
-
gateToggle,
|
|
461
|
-
matchKeywordsInput,
|
|
462
|
-
matchModeSelect,
|
|
463
|
-
matchMinHitsInput,
|
|
464
|
-
likesToggle,
|
|
465
|
-
maxLikesInput,
|
|
466
|
-
likeRulePreview,
|
|
467
|
-
replyToggle,
|
|
468
|
-
replyTextInput,
|
|
469
|
-
ocrToggle,
|
|
470
|
-
ocrCommandInput,
|
|
471
|
-
opOrderInput,
|
|
472
|
-
commentsToggle,
|
|
473
|
-
persistHistoryFns,
|
|
474
|
-
persistLastConfig,
|
|
475
|
-
getSelectedShardProfiles,
|
|
476
|
-
getEffectiveHomepageFlags,
|
|
477
|
-
focusAccountSetup: () => {
|
|
478
|
-
focusTile('account');
|
|
479
|
-
queueMicrotask(() => {
|
|
480
|
-
if (String(accountModeSelect.value || 'single').trim() === 'shards') {
|
|
481
|
-
const firstShard = shardProfilesBox.querySelector('input[type=checkbox]') as HTMLInputElement | null;
|
|
482
|
-
if (firstShard) firstShard.focus();
|
|
483
|
-
return;
|
|
484
|
-
}
|
|
485
|
-
profilePickSel.focus();
|
|
486
|
-
});
|
|
487
|
-
},
|
|
488
|
-
focusKeywordSetup: () => {
|
|
489
|
-
focusTile('board');
|
|
490
|
-
queueMicrotask(() => keywordInput.focus());
|
|
491
|
-
},
|
|
492
|
-
liveStats: liveStatsController,
|
|
493
|
-
});
|
|
494
|
-
runBtn = runFlow.runBtn;
|
|
495
|
-
xhsCmdUnsubscribe = runFlow.dispose;
|
|
496
|
-
root.appendChild(card);
|
|
497
|
-
}
|