@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,34 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { test } from 'node:test';
|
|
4
|
-
import assert from 'node:assert/strict';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const indexPath = path.join(__dirname, 'index.mts');
|
|
9
|
-
|
|
10
|
-
async function getSrc() {
|
|
11
|
-
return readFile(indexPath, 'utf8');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
test('main tabs keep xiaohongshu home and logs before settings', async () => {
|
|
15
|
-
const src = await getSrc();
|
|
16
|
-
assert.match(src, /type TabId = 'xiaohongshu' \| 'preflight' \| 'logs' \| 'settings';/);
|
|
17
|
-
assert.match(src, /\{ id: 'xiaohongshu', label: '[^']+', render: renderXiaohongshuTab \}/);
|
|
18
|
-
assert.match(src, /\{ id: 'preflight', label: '[^']+', render: renderPreflight \}/);
|
|
19
|
-
assert.match(src, /\{ id: 'logs', label: '[^']+', render: renderLogs \}/);
|
|
20
|
-
assert.match(src, /\{ id: 'settings', label: '[^']+', render: renderSettings \}/);
|
|
21
|
-
assert.doesNotMatch(src, /id: 'debug'/);
|
|
22
|
-
assert.doesNotMatch(src, /'runtime'/);
|
|
23
|
-
|
|
24
|
-
const logsIdx = src.indexOf("{ id: 'logs'");
|
|
25
|
-
const settingsIdx = src.indexOf("{ id: 'settings'");
|
|
26
|
-
assert.ok(logsIdx > -1 && settingsIdx > logsIdx, 'logs tab should render before settings tab');
|
|
27
|
-
assert.match(src, /setActiveTab\('xiaohongshu'\);/);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
test('renderer context exposes setActiveTab for cross-tab onboarding navigation', async () => {
|
|
31
|
-
const src = await getSrc();
|
|
32
|
-
assert.match(src, /setActiveTab\(id: TabId\) \{/);
|
|
33
|
-
assert.match(src, /setActiveTab\(id\);/);
|
|
34
|
-
});
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
type PathApi = {
|
|
2
|
-
pathJoin?: (...parts: any[]) => string;
|
|
3
|
-
pathNormalize?: (p: string) => string;
|
|
4
|
-
pathSep?: string;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
function normalizePath(p: string, api?: PathApi) {
|
|
8
|
-
if (!p) return '';
|
|
9
|
-
if (api?.pathNormalize) return String(api.pathNormalize(p));
|
|
10
|
-
return String(p);
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function joinPath(api: PathApi | undefined, ...parts: string[]) {
|
|
14
|
-
if (api?.pathJoin) return String(api.pathJoin(...parts));
|
|
15
|
-
const sep = api?.pathSep || '/';
|
|
16
|
-
return parts.filter(Boolean).join(sep);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function resolveWebautoRoot(downloadRoot: string, api?: PathApi) {
|
|
20
|
-
const raw = String(downloadRoot || '').trim();
|
|
21
|
-
if (!raw) {
|
|
22
|
-
return api?.pathSep === '\\' ? '%USERPROFILE%\\.webauto' : '~/.webauto';
|
|
23
|
-
}
|
|
24
|
-
const normalized = normalizePath(raw, api);
|
|
25
|
-
const sep = api?.pathSep || '/';
|
|
26
|
-
const suffix = `${sep}download`;
|
|
27
|
-
if (normalized.toLowerCase().endsWith(suffix.toLowerCase())) {
|
|
28
|
-
return normalized.slice(0, -suffix.length);
|
|
29
|
-
}
|
|
30
|
-
return normalized;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function resolveConfigPath(downloadRoot: string, api?: PathApi) {
|
|
34
|
-
const root = resolveWebautoRoot(downloadRoot, api);
|
|
35
|
-
return joinPath(api, root, 'config.json');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function resolveProfilesRoot(downloadRoot: string, api?: PathApi) {
|
|
39
|
-
const root = resolveWebautoRoot(downloadRoot, api);
|
|
40
|
-
return joinPath(api, root, 'profiles');
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function resolveFingerprintsRoot(downloadRoot: string, api?: PathApi) {
|
|
44
|
-
const root = resolveWebautoRoot(downloadRoot, api);
|
|
45
|
-
return joinPath(api, root, 'fingerprints');
|
|
46
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { test } from 'node:test';
|
|
2
|
-
import assert from 'node:assert/strict';
|
|
3
|
-
|
|
4
|
-
import { resolveWebautoRoot } from './path-helpers.mts';
|
|
5
|
-
|
|
6
|
-
test('resolveWebautoRoot uses windows-friendly placeholder when download root is empty', () => {
|
|
7
|
-
const root = resolveWebautoRoot('', { pathSep: '\\' });
|
|
8
|
-
assert.equal(root, '%USERPROFILE%\\.webauto');
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
test('resolveWebautoRoot keeps unix placeholder when download root is empty', () => {
|
|
12
|
-
const root = resolveWebautoRoot('', { pathSep: '/' });
|
|
13
|
-
assert.equal(root, '~/.webauto');
|
|
14
|
-
});
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { createEl } from '../ui-components.mts';
|
|
2
|
-
import { renderRun } from './run.mts';
|
|
3
|
-
import { renderResults } from './results.mts';
|
|
4
|
-
|
|
5
|
-
type DebugViewId = 'run' | 'results';
|
|
6
|
-
|
|
7
|
-
let activeDebugView: DebugViewId = 'run';
|
|
8
|
-
|
|
9
|
-
export function renderDebug(root: HTMLElement, ctx: any) {
|
|
10
|
-
root.textContent = '';
|
|
11
|
-
|
|
12
|
-
const title = createEl('div', { style: 'font-weight:700; margin-bottom:8px;' }, ['Debug · 调用与结果']);
|
|
13
|
-
const sub = createEl('div', { className: 'muted', style: 'margin-bottom:10px; font-size:12px;' }, [
|
|
14
|
-
'“调用”和“结果”已整合到 Debug 页;Runtime 已从主导航移除。',
|
|
15
|
-
]);
|
|
16
|
-
|
|
17
|
-
const switcher = createEl('div', { className: 'row', style: 'margin-bottom:8px;' });
|
|
18
|
-
const runBtn = createEl('button', { type: 'button' }, ['调用']) as HTMLButtonElement;
|
|
19
|
-
const resultsBtn = createEl('button', { type: 'button', className: 'secondary' }, ['结果']) as HTMLButtonElement;
|
|
20
|
-
|
|
21
|
-
const panel = createEl('div');
|
|
22
|
-
|
|
23
|
-
const setView = (id: DebugViewId) => {
|
|
24
|
-
activeDebugView = id;
|
|
25
|
-
runBtn.className = id === 'run' ? '' : 'secondary';
|
|
26
|
-
resultsBtn.className = id === 'results' ? '' : 'secondary';
|
|
27
|
-
|
|
28
|
-
panel.textContent = '';
|
|
29
|
-
if (id === 'run') {
|
|
30
|
-
renderRun(panel, ctx);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
renderResults(panel, ctx);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
runBtn.onclick = () => setView('run');
|
|
37
|
-
resultsBtn.onclick = () => setView('results');
|
|
38
|
-
|
|
39
|
-
switcher.appendChild(runBtn);
|
|
40
|
-
switcher.appendChild(resultsBtn);
|
|
41
|
-
|
|
42
|
-
root.appendChild(title);
|
|
43
|
-
root.appendChild(sub);
|
|
44
|
-
root.appendChild(switcher);
|
|
45
|
-
root.appendChild(panel);
|
|
46
|
-
|
|
47
|
-
setView(activeDebugView);
|
|
48
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { test } from 'node:test';
|
|
4
|
-
import assert from 'node:assert/strict';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const debugPath = path.join(__dirname, 'debug.mts');
|
|
9
|
-
|
|
10
|
-
async function getSrc() {
|
|
11
|
-
return readFile(debugPath, 'utf8');
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
test('debug tab aggregates run/results and keeps lightweight switcher', async () => {
|
|
15
|
-
const src = await getSrc();
|
|
16
|
-
assert.match(src, /import \{ renderRun \} from '\.\/run\.mts';/);
|
|
17
|
-
assert.match(src, /import \{ renderResults \} from '\.\/results\.mts';/);
|
|
18
|
-
assert.match(src, /type DebugViewId = 'run' \| 'results';/);
|
|
19
|
-
assert.match(src, /setView\('run'\)/);
|
|
20
|
-
assert.match(src, /setView\('results'\)/);
|
|
21
|
-
assert.match(src, /“调用”和“结果”已整合到 Debug 页;Runtime 已从主导航移除。/);
|
|
22
|
-
});
|
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
import { createEl } from '../ui-components.mts';
|
|
2
|
-
|
|
3
|
-
export function renderLogs(root: HTMLElement, ctx: any) {
|
|
4
|
-
root.textContent = '';
|
|
5
|
-
|
|
6
|
-
const title = createEl('div', { style: 'font-weight:700; margin-bottom:8px;' }, ['日志 · Logs']);
|
|
7
|
-
const sub = createEl('div', { className: 'muted', style: 'margin-bottom:10px; font-size:12px;' }, [
|
|
8
|
-
'命令事件的运行日志(从主壳上下文收集)。',
|
|
9
|
-
]);
|
|
10
|
-
|
|
11
|
-
const toolbar = createEl('div', { className: 'row', style: 'margin-bottom:8px;' });
|
|
12
|
-
const clearBtn = createEl('button', { type: 'button', className: 'secondary' }, ['清空日志']) as HTMLButtonElement;
|
|
13
|
-
const copyGlobalBtn = createEl('button', { type: 'button', className: 'secondary', title: '复制公共日志(Ctrl/Cmd+Shift+1)' }, ['复制公共日志']) as HTMLButtonElement;
|
|
14
|
-
const copyShardBtn = createEl('button', { type: 'button', className: 'secondary', title: '复制分片日志(Ctrl/Cmd+Shift+2)' }, ['复制分片日志']) as HTMLButtonElement;
|
|
15
|
-
const activeOnlyCheckbox = createEl('input', { type: 'checkbox', id: 'logs-active-only' }) as HTMLInputElement;
|
|
16
|
-
activeOnlyCheckbox.checked = true;
|
|
17
|
-
const activeOnlyLabel = createEl('label', { htmlFor: 'logs-active-only', style: 'cursor:pointer; user-select:none;' }, ['仅显示活跃分片']) as HTMLLabelElement;
|
|
18
|
-
const showGlobalCheckbox = createEl('input', { type: 'checkbox', id: 'logs-show-global' }) as HTMLInputElement;
|
|
19
|
-
showGlobalCheckbox.checked = false;
|
|
20
|
-
const showGlobalLabel = createEl('label', { htmlFor: 'logs-show-global', style: 'cursor:pointer; user-select:none;' }, ['显示公共日志']) as HTMLLabelElement;
|
|
21
|
-
toolbar.appendChild(clearBtn);
|
|
22
|
-
toolbar.appendChild(copyGlobalBtn);
|
|
23
|
-
toolbar.appendChild(copyShardBtn);
|
|
24
|
-
toolbar.appendChild(activeOnlyCheckbox);
|
|
25
|
-
toolbar.appendChild(activeOnlyLabel);
|
|
26
|
-
toolbar.appendChild(showGlobalCheckbox);
|
|
27
|
-
toolbar.appendChild(showGlobalLabel);
|
|
28
|
-
|
|
29
|
-
const globalContainer = createEl('div', {
|
|
30
|
-
style: 'display:flex; flex-direction:column; gap:10px; margin-bottom:10px;',
|
|
31
|
-
}) as HTMLDivElement;
|
|
32
|
-
|
|
33
|
-
const shardContainer = createEl('div', {
|
|
34
|
-
style: 'display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; align-items:start; font-family:"Cascadia Mono", Consolas, ui-monospace, SFMono-Regular, Menlo, monospace; font-size:12px;',
|
|
35
|
-
}) as HTMLDivElement;
|
|
36
|
-
|
|
37
|
-
const sectionMap = new Map<string, HTMLDivElement>();
|
|
38
|
-
const sectionCardMap = new Map<string, HTMLDivElement>();
|
|
39
|
-
const sectionRunIds = new Map<string, Set<string>>();
|
|
40
|
-
const sectionHeaderMap = new Map<string, HTMLDivElement>();
|
|
41
|
-
const sectionTypeMap = new Map<string, 'global' | 'shard'>();
|
|
42
|
-
const logActiveRunIds = new Set<string>();
|
|
43
|
-
const parentRunIds = new Set<string>();
|
|
44
|
-
const runIdToSection = new Map<string, string>();
|
|
45
|
-
const parentRunCurrentSection = new Map<string, string>();
|
|
46
|
-
const shardRunIds = new Set<string>();
|
|
47
|
-
let selectedSectionKey = 'global';
|
|
48
|
-
let shardProfileQueue: string[] = [];
|
|
49
|
-
|
|
50
|
-
const parseShardHint = (line: string): string[] => {
|
|
51
|
-
const text = String(line || '');
|
|
52
|
-
const hinted = text.match(/\[shard-hint\]\s*profiles=([A-Za-z0-9_,-]+)/i);
|
|
53
|
-
const orchestrate = text.match(/\[orchestrate\][^\n]*\bprofiles=([A-Za-z0-9_,-]+)/i);
|
|
54
|
-
const raw = hinted?.[1] || orchestrate?.[1] || '';
|
|
55
|
-
if (!raw) return [];
|
|
56
|
-
return String(raw)
|
|
57
|
-
.split(',')
|
|
58
|
-
.map((x) => x.trim())
|
|
59
|
-
.filter(Boolean);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const isShardSection = (sectionKey: string) => String(sectionKey || '').startsWith('shard:');
|
|
63
|
-
|
|
64
|
-
const extractRunId = (line: string) => {
|
|
65
|
-
const text = String(line || '');
|
|
66
|
-
const byRunTag = text.match(/^\[(?:run:|rid:)([A-Za-z0-9_-]+)\]\s*(.*)$/);
|
|
67
|
-
const prefixedRunId = byRunTag?.[1] ? String(byRunTag[1]) : '';
|
|
68
|
-
const tailText = byRunTag?.[2] ? String(byRunTag[2]) : text;
|
|
69
|
-
|
|
70
|
-
// 优先使用日志正文里的 runId(例如 [Logger] runId=...),避免被外层 [rid:parent] 覆盖
|
|
71
|
-
const byRunIdField = tailText.match(/runId=([A-Za-z0-9_-]+)/);
|
|
72
|
-
if (byRunIdField?.[1]) return String(byRunIdField[1]);
|
|
73
|
-
const byRunIdTag = tailText.match(/\[runId:([A-Za-z0-9_-]+)\]/);
|
|
74
|
-
if (byRunIdTag?.[1]) return String(byRunIdTag[1]);
|
|
75
|
-
|
|
76
|
-
if (prefixedRunId) return prefixedRunId;
|
|
77
|
-
|
|
78
|
-
const byRunTagAnyPos = text.match(/\[(?:run:|rid:)([A-Za-z0-9_-]+)\]/);
|
|
79
|
-
if (byRunTagAnyPos?.[1]) return String(byRunTagAnyPos[1]);
|
|
80
|
-
return 'global';
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const extractPrefixedRunId = (line: string) => {
|
|
84
|
-
const text = String(line || '');
|
|
85
|
-
const byRunTag = text.match(/^\[(?:run:|rid:)([A-Za-z0-9_-]+)\]/);
|
|
86
|
-
return byRunTag?.[1] ? String(byRunTag[1]) : '';
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const ensureSection = (sectionKey: string, headerLabel?: string) => {
|
|
90
|
-
const normalized = String(sectionKey || 'global').trim() || 'global';
|
|
91
|
-
const existing = sectionMap.get(normalized);
|
|
92
|
-
if (existing) {
|
|
93
|
-
if (headerLabel && sectionHeaderMap.has(normalized)) {
|
|
94
|
-
sectionHeaderMap.get(normalized)!.textContent = headerLabel;
|
|
95
|
-
}
|
|
96
|
-
return existing;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const card = createEl('div', {
|
|
100
|
-
style: 'border:1px solid #23262f; background:#0b0d12; border-radius:10px; overflow:hidden; min-width:0;',
|
|
101
|
-
}) as HTMLDivElement;
|
|
102
|
-
const head = createEl('div', {
|
|
103
|
-
style: 'padding:8px 12px; border-bottom:1px solid #23262f; background:#121622; font-weight:600; color:#9aa4bd;',
|
|
104
|
-
}, [headerLabel || (normalized === 'global' ? '公共日志' : `runId: ${normalized}`)]) as HTMLDivElement;
|
|
105
|
-
const body = createEl('div', {
|
|
106
|
-
style: 'padding:10px 12px; white-space:pre-wrap; word-break:break-all; line-height:1.5; height:calc(100vh - 220px); overflow:auto;',
|
|
107
|
-
}) as HTMLDivElement;
|
|
108
|
-
card.tabIndex = 0;
|
|
109
|
-
|
|
110
|
-
card.appendChild(head);
|
|
111
|
-
card.appendChild(body);
|
|
112
|
-
if (normalized === 'global' || !isShardSection(normalized)) {
|
|
113
|
-
globalContainer.appendChild(card);
|
|
114
|
-
sectionTypeMap.set(normalized, 'global');
|
|
115
|
-
} else {
|
|
116
|
-
shardContainer.appendChild(card);
|
|
117
|
-
sectionTypeMap.set(normalized, 'shard');
|
|
118
|
-
}
|
|
119
|
-
sectionMap.set(normalized, body);
|
|
120
|
-
sectionCardMap.set(normalized, card);
|
|
121
|
-
sectionRunIds.set(normalized, new Set<string>());
|
|
122
|
-
sectionHeaderMap.set(normalized, head);
|
|
123
|
-
const activateCard = () => {
|
|
124
|
-
selectedSectionKey = normalized;
|
|
125
|
-
sectionCardMap.forEach((item, key) => {
|
|
126
|
-
const isSelected = key === selectedSectionKey;
|
|
127
|
-
item.style.outline = isSelected ? '2px solid #4f86ff' : 'none';
|
|
128
|
-
item.style.outlineOffset = isSelected ? '-2px' : '0';
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
card.addEventListener('click', activateCard);
|
|
132
|
-
card.addEventListener('focus', activateCard);
|
|
133
|
-
return body;
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
const getSectionText = (sectionKey: string) => {
|
|
137
|
-
const body = sectionMap.get(sectionKey);
|
|
138
|
-
if (!body) return '';
|
|
139
|
-
return Array.from(body.children)
|
|
140
|
-
.map((el) => String((el as HTMLElement).innerText || (el as HTMLElement).textContent || '').trim())
|
|
141
|
-
.filter(Boolean)
|
|
142
|
-
.join('\n');
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
const collectSectionText = (type: 'global' | 'shard') => {
|
|
146
|
-
return Array.from(sectionMap.keys())
|
|
147
|
-
.filter((sectionKey) => sectionTypeMap.get(sectionKey) === type)
|
|
148
|
-
.filter((sectionKey) => {
|
|
149
|
-
const card = sectionCardMap.get(sectionKey);
|
|
150
|
-
if (!card) return false;
|
|
151
|
-
return card.style.display !== 'none';
|
|
152
|
-
})
|
|
153
|
-
.map((sectionKey) => getSectionText(sectionKey))
|
|
154
|
-
.filter(Boolean)
|
|
155
|
-
.join('\n');
|
|
156
|
-
};
|
|
157
|
-
|
|
158
|
-
const writeClipboard = async (text: string) => {
|
|
159
|
-
if (!text) return { ok: false, error: 'empty' };
|
|
160
|
-
if (typeof window.api?.clipboardWriteText === 'function') {
|
|
161
|
-
return window.api.clipboardWriteText(text);
|
|
162
|
-
}
|
|
163
|
-
if (typeof navigator?.clipboard?.writeText === 'function') {
|
|
164
|
-
await navigator.clipboard.writeText(text);
|
|
165
|
-
return { ok: true };
|
|
166
|
-
}
|
|
167
|
-
return { ok: false, error: 'clipboard_unavailable' };
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const copyByType = async (type: 'global' | 'shard') => {
|
|
171
|
-
const text = collectSectionText(type);
|
|
172
|
-
if (!text) {
|
|
173
|
-
ctx.setStatus?.(`日志复制失败:${type === 'global' ? '公共日志为空' : '分片日志为空'}`);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
const ret = await writeClipboard(text);
|
|
177
|
-
ctx.setStatus?.(ret?.ok ? `已复制${type === 'global' ? '公共日志' : '分片日志'}(${text.split('\n').length}行)` : `日志复制失败:${ret?.error || 'unknown'}`);
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
const copySelected = async () => {
|
|
181
|
-
const sectionType = sectionTypeMap.get(selectedSectionKey) || 'global';
|
|
182
|
-
const text = selectedSectionKey ? getSectionText(selectedSectionKey) : '';
|
|
183
|
-
if (text) {
|
|
184
|
-
const ret = await writeClipboard(text);
|
|
185
|
-
ctx.setStatus?.(
|
|
186
|
-
ret?.ok
|
|
187
|
-
? `已复制当前日志卡片(${selectedSectionKey})`
|
|
188
|
-
: `日志复制失败:${ret?.error || 'unknown'}`,
|
|
189
|
-
);
|
|
190
|
-
return;
|
|
191
|
-
}
|
|
192
|
-
await copyByType(sectionType);
|
|
193
|
-
};
|
|
194
|
-
|
|
195
|
-
const resolveSectionKey = (text: string, rawRunId: string, prefixedRunId: string) => {
|
|
196
|
-
if (rawRunId === 'global') return 'global';
|
|
197
|
-
|
|
198
|
-
if (text.includes('[started]') && text.includes('xiaohongshu orchestrate')) {
|
|
199
|
-
parentRunIds.add(rawRunId);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const mapped = runIdToSection.get(rawRunId);
|
|
203
|
-
if (mapped) return mapped;
|
|
204
|
-
|
|
205
|
-
// 同一父rid下,优先沿用“当前分片上下文”
|
|
206
|
-
if (prefixedRunId && rawRunId === prefixedRunId) {
|
|
207
|
-
const currentSection = parentRunCurrentSection.get(prefixedRunId);
|
|
208
|
-
if (currentSection) return currentSection;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
if (!parentRunIds.has(rawRunId) && shardProfileQueue.length > 0) {
|
|
212
|
-
const profile = String(shardProfileQueue.shift() || '').trim();
|
|
213
|
-
if (profile) {
|
|
214
|
-
const sectionKey = `shard:${profile}`;
|
|
215
|
-
runIdToSection.set(rawRunId, sectionKey);
|
|
216
|
-
shardRunIds.add(rawRunId);
|
|
217
|
-
ensureSection(sectionKey, `分片: ${profile}`);
|
|
218
|
-
return sectionKey;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return rawRunId;
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
const updateSectionVisibility = () => {
|
|
226
|
-
const activeOnly = activeOnlyCheckbox.checked;
|
|
227
|
-
const showGlobal = showGlobalCheckbox.checked;
|
|
228
|
-
const activeRunIds: Set<string> = (ctx as any)._activeRunIds instanceof Set ? (ctx as any)._activeRunIds : new Set<string>();
|
|
229
|
-
const effectiveActiveRunIds = new Set<string>([...activeRunIds, ...logActiveRunIds]);
|
|
230
|
-
sectionCardMap.forEach((card, sectionKey) => {
|
|
231
|
-
if (sectionKey === 'global') {
|
|
232
|
-
card.style.display = showGlobal ? '' : 'none';
|
|
233
|
-
return;
|
|
234
|
-
}
|
|
235
|
-
if (!isShardSection(sectionKey)) {
|
|
236
|
-
card.style.display = showGlobal ? '' : 'none';
|
|
237
|
-
return;
|
|
238
|
-
}
|
|
239
|
-
if (!activeOnly) {
|
|
240
|
-
card.style.display = '';
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
const relatedRunIds = sectionRunIds.get(sectionKey) || new Set<string>();
|
|
244
|
-
const visible =
|
|
245
|
-
effectiveActiveRunIds.has(sectionKey) ||
|
|
246
|
-
shardRunIds.has(sectionKey) ||
|
|
247
|
-
Array.from(relatedRunIds).some((runId) => effectiveActiveRunIds.has(runId));
|
|
248
|
-
card.style.display = visible ? '' : 'none';
|
|
249
|
-
});
|
|
250
|
-
};
|
|
251
|
-
|
|
252
|
-
const appendLine = (line: string) => {
|
|
253
|
-
const text = String(line || '').trim();
|
|
254
|
-
if (!text) return;
|
|
255
|
-
|
|
256
|
-
const prefixedRunId = extractPrefixedRunId(text);
|
|
257
|
-
const rawRunId = extractRunId(text);
|
|
258
|
-
|
|
259
|
-
const hintedProfiles = parseShardHint(text);
|
|
260
|
-
if (hintedProfiles.length > 0) {
|
|
261
|
-
shardProfileQueue = hintedProfiles.slice();
|
|
262
|
-
hintedProfiles.forEach((profile) => {
|
|
263
|
-
const sectionKey = `shard:${profile}`;
|
|
264
|
-
ensureSection(sectionKey, `分片: ${profile}`);
|
|
265
|
-
if (prefixedRunId && rawRunId !== 'global') {
|
|
266
|
-
parentRunCurrentSection.set(prefixedRunId, sectionKey);
|
|
267
|
-
runIdToSection.set(rawRunId, sectionKey);
|
|
268
|
-
shardRunIds.add(rawRunId);
|
|
269
|
-
if (!sectionRunIds.has(sectionKey)) {
|
|
270
|
-
sectionRunIds.set(sectionKey, new Set<string>());
|
|
271
|
-
}
|
|
272
|
-
sectionRunIds.get(sectionKey)!.add(rawRunId);
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// 识别日志中的 Profile 行,切换父rid当前分片上下文
|
|
278
|
-
const profileMatch = text.match(/\b[Pp]rofile\s*[::]\s*([A-Za-z0-9_-]+)/);
|
|
279
|
-
const profileEqMatch = text.match(/\bprofile=([A-Za-z0-9_-]+)/);
|
|
280
|
-
const resolvedProfile = String(profileMatch?.[1] || profileEqMatch?.[1] || '').trim();
|
|
281
|
-
if (resolvedProfile) {
|
|
282
|
-
const profileId = resolvedProfile;
|
|
283
|
-
if (profileId) {
|
|
284
|
-
const sectionKey = `shard:${profileId}`;
|
|
285
|
-
ensureSection(sectionKey, `分片: ${profileId}`);
|
|
286
|
-
if (prefixedRunId && rawRunId && rawRunId !== prefixedRunId) {
|
|
287
|
-
runIdToSection.set(rawRunId, sectionKey);
|
|
288
|
-
if (!sectionRunIds.has(sectionKey)) {
|
|
289
|
-
sectionRunIds.set(sectionKey, new Set<string>());
|
|
290
|
-
}
|
|
291
|
-
sectionRunIds.get(sectionKey)!.add(rawRunId);
|
|
292
|
-
}
|
|
293
|
-
if (prefixedRunId) {
|
|
294
|
-
parentRunCurrentSection.set(prefixedRunId, sectionKey);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
const loggerChildRunId = text.match(/\[Logger\]\s+runId=([A-Za-z0-9_-]+)/);
|
|
300
|
-
if (loggerChildRunId?.[1] && prefixedRunId) {
|
|
301
|
-
const childRunId = String(loggerChildRunId[1]).trim();
|
|
302
|
-
const parentSection = parentRunCurrentSection.get(prefixedRunId);
|
|
303
|
-
if (parentSection) {
|
|
304
|
-
shardRunIds.add(childRunId);
|
|
305
|
-
runIdToSection.set(childRunId, parentSection);
|
|
306
|
-
if (!sectionRunIds.has(parentSection)) {
|
|
307
|
-
sectionRunIds.set(parentSection, new Set<string>());
|
|
308
|
-
}
|
|
309
|
-
sectionRunIds.get(parentSection)!.add(childRunId);
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if (rawRunId !== 'global') {
|
|
314
|
-
logActiveRunIds.add(rawRunId);
|
|
315
|
-
if (text.includes('[exit]')) {
|
|
316
|
-
logActiveRunIds.delete(rawRunId);
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
const sectionKey = resolveSectionKey(text, rawRunId, prefixedRunId);
|
|
321
|
-
const body = ensureSection(sectionKey);
|
|
322
|
-
if (isShardSection(sectionKey) && rawRunId !== 'global') {
|
|
323
|
-
shardRunIds.add(rawRunId);
|
|
324
|
-
}
|
|
325
|
-
if (rawRunId !== 'global') {
|
|
326
|
-
if (!sectionRunIds.has(sectionKey)) {
|
|
327
|
-
sectionRunIds.set(sectionKey, new Set<string>());
|
|
328
|
-
}
|
|
329
|
-
sectionRunIds.get(sectionKey)?.add(rawRunId);
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
const div = createEl('div', { className: 'muted' }, [text]);
|
|
333
|
-
body.appendChild(div);
|
|
334
|
-
};
|
|
335
|
-
|
|
336
|
-
clearBtn.onclick = () => {
|
|
337
|
-
ctx.clearLog();
|
|
338
|
-
sectionMap.clear();
|
|
339
|
-
sectionCardMap.clear();
|
|
340
|
-
sectionRunIds.clear();
|
|
341
|
-
sectionHeaderMap.clear();
|
|
342
|
-
sectionTypeMap.clear();
|
|
343
|
-
logActiveRunIds.clear();
|
|
344
|
-
parentRunIds.clear();
|
|
345
|
-
runIdToSection.clear();
|
|
346
|
-
parentRunCurrentSection.clear();
|
|
347
|
-
shardRunIds.clear();
|
|
348
|
-
shardProfileQueue = [];
|
|
349
|
-
selectedSectionKey = 'global';
|
|
350
|
-
|
|
351
|
-
globalContainer.textContent = '';
|
|
352
|
-
shardContainer.textContent = '';
|
|
353
|
-
};
|
|
354
|
-
copyGlobalBtn.onclick = () => { void copyByType('global'); };
|
|
355
|
-
copyShardBtn.onclick = () => { void copyByType('shard'); };
|
|
356
|
-
|
|
357
|
-
activeOnlyCheckbox.onchange = () => {
|
|
358
|
-
updateSectionVisibility();
|
|
359
|
-
};
|
|
360
|
-
showGlobalCheckbox.onchange = () => {
|
|
361
|
-
updateSectionVisibility();
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
// 初始渲染现有日志
|
|
365
|
-
const existingLines = (ctx as any)._logLines || [];
|
|
366
|
-
if (Array.isArray(existingLines)) {
|
|
367
|
-
existingLines.forEach((line: string) => {
|
|
368
|
-
appendLine(line);
|
|
369
|
-
});
|
|
370
|
-
updateSectionVisibility();
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// 监听后续日志追加
|
|
374
|
-
const originalAppendLog = typeof ctx._appendLogBase === 'function' ? ctx._appendLogBase : ctx.appendLog;
|
|
375
|
-
ctx._appendLogBase = originalAppendLog;
|
|
376
|
-
ctx.appendLog = (line: string) => {
|
|
377
|
-
appendLine(line);
|
|
378
|
-
updateSectionVisibility();
|
|
379
|
-
// 同时保留原有行为(如果其他地方需要)
|
|
380
|
-
if (typeof originalAppendLog === 'function') originalAppendLog.call(ctx, line);
|
|
381
|
-
};
|
|
382
|
-
|
|
383
|
-
const unsubscribeActiveRuns = typeof ctx.onActiveRunsChanged === 'function'
|
|
384
|
-
? ctx.onActiveRunsChanged(() => updateSectionVisibility())
|
|
385
|
-
: null;
|
|
386
|
-
|
|
387
|
-
updateSectionVisibility();
|
|
388
|
-
|
|
389
|
-
root.appendChild(title);
|
|
390
|
-
root.appendChild(sub);
|
|
391
|
-
root.appendChild(toolbar);
|
|
392
|
-
root.appendChild(globalContainer);
|
|
393
|
-
root.appendChild(shardContainer);
|
|
394
|
-
|
|
395
|
-
const onKeydown = (evt: KeyboardEvent) => {
|
|
396
|
-
if (!(evt.ctrlKey || evt.metaKey) || !evt.shiftKey) return;
|
|
397
|
-
const key = String(evt.key || '').toLowerCase();
|
|
398
|
-
const code = String(evt.code || '');
|
|
399
|
-
if (code === 'Digit1' || key === '1') {
|
|
400
|
-
evt.preventDefault();
|
|
401
|
-
void copyByType('global');
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
if (code === 'Digit2' || key === '2') {
|
|
405
|
-
evt.preventDefault();
|
|
406
|
-
void copyByType('shard');
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
if (code === 'KeyC' || key === 'c') {
|
|
410
|
-
evt.preventDefault();
|
|
411
|
-
void copySelected();
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
root.addEventListener('keydown', onKeydown);
|
|
415
|
-
ensureSection('global', '公共日志');
|
|
416
|
-
|
|
417
|
-
root.addEventListener('DOMNodeRemoved', () => {
|
|
418
|
-
if (typeof unsubscribeActiveRuns === 'function') unsubscribeActiveRuns();
|
|
419
|
-
root.removeEventListener('keydown', onKeydown);
|
|
420
|
-
}, { once: true });
|
|
421
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { test } from 'node:test';
|
|
4
|
-
import assert from 'node:assert/strict';
|
|
5
|
-
import { fileURLToPath } from 'node:url';
|
|
6
|
-
|
|
7
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
8
|
-
const logsPath = path.join(__dirname, 'logs.mts');
|
|
9
|
-
|
|
10
|
-
test('logs tab supports separate copy actions for global/shard areas', async () => {
|
|
11
|
-
const src = await readFile(logsPath, 'utf8');
|
|
12
|
-
assert.match(src, /复制公共日志/);
|
|
13
|
-
assert.match(src, /复制分片日志/);
|
|
14
|
-
assert.match(src, /copyByType\('global'\)/);
|
|
15
|
-
assert.match(src, /copyByType\('shard'\)/);
|
|
16
|
-
assert.match(src, /clipboardWriteText/);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
test('logs tab supports keyboard shortcuts for copy', async () => {
|
|
20
|
-
const src = await readFile(logsPath, 'utf8');
|
|
21
|
-
assert.match(src, /evt\.ctrlKey \|\| evt\.metaKey/);
|
|
22
|
-
assert.match(src, /evt\.shiftKey/);
|
|
23
|
-
assert.match(src, /code === 'Digit1' \|\| key === '1'/);
|
|
24
|
-
assert.match(src, /code === 'Digit2' \|\| key === '2'/);
|
|
25
|
-
assert.match(src, /code === 'KeyC' \|\| key === 'c'/);
|
|
26
|
-
assert.match(src, /copySelected/);
|
|
27
|
-
});
|