@web-auto/webauto 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/desktop-console/default-settings.json +1 -0
- package/apps/desktop-console/dist/main/index.mjs +1618 -0
- package/apps/desktop-console/{src → dist}/main/preload.mjs +10 -0
- package/apps/desktop-console/dist/renderer/index.js +3063 -0
- package/apps/desktop-console/entry/ui-console.mjs +299 -0
- package/apps/webauto/entry/account.mjs +356 -0
- package/apps/webauto/entry/lib/account-detect.mjs +160 -0
- package/apps/webauto/entry/lib/account-store.mjs +587 -0
- package/apps/webauto/entry/lib/profilepool.mjs +1 -1
- package/apps/webauto/entry/xhs-install.mjs +27 -3
- package/apps/webauto/entry/xhs-status.mjs +152 -0
- package/apps/webauto/entry/xhs-unified.mjs +595 -17
- package/bin/webauto.mjs +247 -12
- package/dist/apps/webauto/server.js +66 -0
- package/dist/modules/camo-backend/src/index.js +575 -0
- package/dist/modules/camo-backend/src/internal/BrowserSession.js +817 -0
- package/dist/modules/camo-backend/src/internal/ElementRegistry.js +61 -0
- package/dist/modules/camo-backend/src/internal/ProfileLock.js +85 -0
- package/dist/modules/camo-backend/src/internal/SessionManager.js +172 -0
- package/dist/modules/camo-backend/src/internal/container-matcher.js +852 -0
- package/dist/modules/camo-backend/src/internal/engine-manager.js +258 -0
- package/dist/modules/camo-backend/src/internal/fingerprint.js +203 -0
- package/dist/modules/camo-backend/src/internal/pageRuntime.js +29 -0
- package/dist/modules/camo-backend/src/internal/runtimeInjector.js +30 -0
- package/dist/modules/camo-backend/src/internal/state-bus.js +46 -0
- package/dist/modules/camo-backend/src/internal/storage-paths.js +36 -0
- package/dist/modules/camo-backend/src/internal/ws-server.js +1202 -0
- package/dist/modules/camo-runtime/src/utils/browser-service.mjs +423 -0
- package/dist/modules/camo-runtime/src/utils/config.mjs +77 -0
- package/dist/modules/container-registry/src/index.js +184 -0
- package/dist/modules/logging/src/index.js +92 -0
- package/dist/modules/operations/src/builtin.js +27 -0
- package/dist/modules/operations/src/container-binding.js +75 -0
- package/dist/modules/operations/src/executor.js +146 -0
- package/dist/modules/operations/src/operations/click.js +167 -0
- package/dist/modules/operations/src/operations/extract.js +204 -0
- package/dist/modules/operations/src/operations/find-child.js +17 -0
- package/dist/modules/operations/src/operations/highlight.js +138 -0
- package/dist/modules/operations/src/operations/key.js +61 -0
- package/dist/modules/operations/src/operations/navigate.js +148 -0
- package/dist/modules/operations/src/operations/scroll.js +126 -0
- package/dist/modules/operations/src/operations/type.js +190 -0
- package/dist/modules/operations/src/queue.js +100 -0
- package/dist/modules/operations/src/registry.js +11 -0
- package/dist/modules/operations/src/system/mouse.js +33 -0
- package/dist/modules/state/src/atomic-json.js +33 -0
- package/dist/modules/workflow/blocks/AnchorVerificationBlock.js +71 -0
- package/dist/modules/workflow/blocks/BehaviorRandomizer.js +26 -0
- package/dist/modules/workflow/blocks/CallWorkflowBlock.js +38 -0
- package/dist/modules/workflow/blocks/CloseDetailBlock.js +209 -0
- package/dist/modules/workflow/blocks/CollectBatch.js +137 -0
- package/dist/modules/workflow/blocks/CollectCommentsBlock.js +415 -0
- package/dist/modules/workflow/blocks/CollectSearchListBlock.js +599 -0
- package/dist/modules/workflow/blocks/CollectWeiboPosts.js +229 -0
- package/dist/modules/workflow/blocks/DetectPageStateBlock.js +259 -0
- package/dist/modules/workflow/blocks/EnsureLoginBlock.js +162 -0
- package/dist/modules/workflow/blocks/EnsureSession.js +426 -0
- package/dist/modules/workflow/blocks/ErrorClassifier.js +164 -0
- package/dist/modules/workflow/blocks/ErrorRecoveryBlock.js +319 -0
- package/dist/modules/workflow/blocks/ExpandCommentsBlock.js +1032 -0
- package/dist/modules/workflow/blocks/ExtractDetailBlock.js +310 -0
- package/dist/modules/workflow/blocks/ExtractPostFields.js +88 -0
- package/dist/modules/workflow/blocks/GenerateSmartReplyBlock.js +68 -0
- package/dist/modules/workflow/blocks/GoToSearchBlock.js +497 -0
- package/dist/modules/workflow/blocks/GracefulFallbackBlock.js +104 -0
- package/dist/modules/workflow/blocks/HighlightBlock.js +66 -0
- package/dist/modules/workflow/blocks/InitAutoScroll.js +65 -0
- package/dist/modules/workflow/blocks/LoadContainerDefinition.js +50 -0
- package/dist/modules/workflow/blocks/LoadContainerIndex.js +43 -0
- package/dist/modules/workflow/blocks/LocateAndGuardBlock.js +176 -0
- package/dist/modules/workflow/blocks/LoginRecoveryBlock.js +242 -0
- package/dist/modules/workflow/blocks/MatchContainers.js +64 -0
- package/dist/modules/workflow/blocks/MonitoringBlock.js +190 -0
- package/dist/modules/workflow/blocks/OpenDetailBlock.js +1240 -0
- package/dist/modules/workflow/blocks/OrganizeXhsNotesBlock.js +117 -0
- package/dist/modules/workflow/blocks/PersistXhsNoteBlock.js +270 -0
- package/dist/modules/workflow/blocks/PickSinglePost.js +69 -0
- package/dist/modules/workflow/blocks/ProgressTracker.js +125 -0
- package/dist/modules/workflow/blocks/RecordFixtureBlock.js +44 -0
- package/dist/modules/workflow/blocks/RenderMarkdown.js +48 -0
- package/dist/modules/workflow/blocks/SaveFile.js +54 -0
- package/dist/modules/workflow/blocks/ScrollNextBatch.js +72 -0
- package/dist/modules/workflow/blocks/SessionHealthBlock.js +73 -0
- package/dist/modules/workflow/blocks/StartBrowserService.js +45 -0
- package/dist/modules/workflow/blocks/ValidateContainerDefinition.js +67 -0
- package/dist/modules/workflow/blocks/ValidateExtract.js +35 -0
- package/dist/modules/workflow/blocks/WaitSearchPermitBlock.js +162 -0
- package/dist/modules/workflow/blocks/WaitStable.js +74 -0
- package/dist/modules/workflow/blocks/WarmupCommentsBlock.js +120 -0
- package/dist/modules/workflow/blocks/WorkflowExecutor.js +156 -0
- package/dist/modules/workflow/blocks/XiaohongshuCollectFromLinksBlock.js +1004 -0
- package/dist/modules/workflow/blocks/XiaohongshuCollectLinksBlock.js +1049 -0
- package/dist/modules/workflow/blocks/XiaohongshuFullCollectBlock.js +782 -0
- package/dist/modules/workflow/blocks/helpers/anchorVerify.js +198 -0
- package/dist/modules/workflow/blocks/helpers/asyncWorkQueue.js +53 -0
- package/dist/modules/workflow/blocks/helpers/commentScroller.js +334 -0
- package/dist/modules/workflow/blocks/helpers/commentSectionLocator.js +126 -0
- package/dist/modules/workflow/blocks/helpers/containerAnchors.js +301 -0
- package/dist/modules/workflow/blocks/helpers/debugArtifacts.js +6 -0
- package/dist/modules/workflow/blocks/helpers/downloadPaths.js +29 -0
- package/dist/modules/workflow/blocks/helpers/expandCommentsController.js +53 -0
- package/dist/modules/workflow/blocks/helpers/expandCommentsExtractor.js +129 -0
- package/dist/modules/workflow/blocks/helpers/macosVisionOcrPlugin.js +116 -0
- package/dist/modules/workflow/blocks/helpers/mergeXhsMarkdown.js +109 -0
- package/dist/modules/workflow/blocks/helpers/openDetailController.js +56 -0
- package/dist/modules/workflow/blocks/helpers/openDetailTypes.js +7 -0
- package/dist/modules/workflow/blocks/helpers/openDetailViewport.js +474 -0
- package/dist/modules/workflow/blocks/helpers/openDetailWaiter.js +104 -0
- package/dist/modules/workflow/blocks/helpers/operationLogger.js +195 -0
- package/dist/modules/workflow/blocks/helpers/persistedNotes.js +107 -0
- package/dist/modules/workflow/blocks/helpers/replyExpander.js +260 -0
- package/dist/modules/workflow/blocks/helpers/scrollIntoView.js +138 -0
- package/dist/modules/workflow/blocks/helpers/searchExecutor.js +328 -0
- package/dist/modules/workflow/blocks/helpers/searchGate.js +46 -0
- package/dist/modules/workflow/blocks/helpers/searchPageState.js +164 -0
- package/dist/modules/workflow/blocks/helpers/searchResultWaiter.js +64 -0
- package/dist/modules/workflow/blocks/helpers/simpleAnchor.js +134 -0
- package/dist/modules/workflow/blocks/helpers/smartReply.js +40 -0
- package/dist/modules/workflow/blocks/helpers/systemInput.js +635 -0
- package/dist/modules/workflow/blocks/helpers/targetCountMode.js +9 -0
- package/dist/modules/workflow/blocks/helpers/xhsCliArgs.js +80 -0
- package/dist/modules/workflow/blocks/helpers/xhsCommentDom.js +805 -0
- package/dist/modules/workflow/blocks/helpers/xhsNoteOrganizer.js +140 -0
- package/dist/modules/workflow/blocks/restore/RestorePhaseBlock.js +204 -0
- package/dist/modules/workflow/config/workflowRegistry.js +32 -0
- package/dist/modules/workflow/definitions/batch-collect-workflow.js +63 -0
- package/dist/modules/workflow/definitions/scroll-extract-workflow.js +74 -0
- package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow-v2.js +81 -0
- package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow.js +57 -0
- package/dist/modules/workflow/definitions/xiaohongshu-full-collect-workflow-v3.js +68 -0
- package/dist/modules/workflow/definitions/xiaohongshu-note-collect.js +49 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase1-workflow-v3.js +30 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase2-links-workflow-v3.js +40 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase3-collect-workflow-v1.js +54 -0
- package/dist/modules/workflow/definitions/xiaohongshu-phase34-from-links-workflow-v3.js +25 -0
- package/dist/modules/workflow/src/WeiboEventDrivenWorkflowRunner.js +308 -0
- package/dist/modules/workflow/src/context.js +70 -0
- package/dist/modules/workflow/src/index.js +5 -0
- package/dist/modules/workflow/src/orchestrator.js +230 -0
- package/dist/modules/workflow/src/runner.js +55 -0
- package/dist/modules/workflow/src/runtime.js +70 -0
- package/dist/modules/workflow/workflows/WeiboFeedExtractionWorkflow.js +359 -0
- package/dist/modules/workflow/workflows/XiaohongshuLoginWorkflow.js +110 -0
- package/dist/modules/xiaohongshu/app/src/blocks/MatchCommentsBlock.js +139 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1EnsureServicesBlock.js +36 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1MonitorCookieBlock.js +213 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase1StartProfileBlock.js +121 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase2CollectLinksBlock.js +1249 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase2SearchBlock.js +703 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseDetailBlock.js +41 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseTabsBlock.js +44 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34CollectCommentsBlock.js +150 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ExtractDetailBlock.js +117 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenDetailBlock.js +102 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenTabsBlock.js +109 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34PersistDetailBlock.js +117 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ProcessSingleNoteBlock.js +114 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase34ValidateLinksBlock.js +90 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase3InteractBlock.js +1009 -0
- package/dist/modules/xiaohongshu/app/src/blocks/Phase4MultiTabHarvestBlock.js +233 -0
- package/dist/modules/xiaohongshu/app/src/blocks/ReplyInteractBlock.js +291 -0
- package/dist/modules/xiaohongshu/app/src/blocks/XhsDiscoverFallbackBlock.js +240 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatchDsl.js +126 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatcher.js +99 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/evidence.js +27 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/sharding.js +42 -0
- package/dist/modules/xiaohongshu/app/src/blocks/helpers/xhsComments.js +270 -0
- package/dist/modules/xiaohongshu/app/src/index.js +9 -0
- package/dist/modules/xiaohongshu/app/src/utils/checkpoints.js +222 -0
- package/dist/modules/xiaohongshu/app/src/utils/controllerAction.js +43 -0
- package/dist/services/controller/src/controller.js +1476 -0
- package/dist/services/controller/src/index.js +2 -0
- package/dist/services/controller/src/payload-normalizer.js +129 -0
- package/dist/services/shared/heartbeat.js +120 -0
- package/dist/services/shared/lib/errorHandler.js +2 -0
- package/dist/services/shared/serviceProcessLogger.js +139 -0
- package/dist/services/unified-api/RemoteBrowserSession.js +176 -0
- package/dist/services/unified-api/RemoteSessionManager.js +148 -0
- package/dist/services/unified-api/container-operations-handler.js +115 -0
- package/dist/services/unified-api/server.js +652 -0
- package/dist/services/unified-api/state-registry.js +274 -0
- package/dist/services/unified-api/task-persistence.js +66 -0
- package/dist/services/unified-api/task-state.js +130 -0
- package/modules/camo-runtime/src/autoscript/action-providers/xhs/search.mjs +12 -5
- package/modules/xiaohongshu/app/pnpm-lock.yaml +24 -0
- package/package.json +37 -9
- package/.beads/README.md +0 -81
- package/.beads/config.yaml +0 -67
- package/.beads/interactions.jsonl +0 -0
- package/.beads/issues.jsonl +0 -180
- package/.beads/metadata.json +0 -4
- package/.claude/settings.local.json +0 -10
- package/.github/workflows/ci.yml +0 -55
- package/AGENTS.md +0 -253
- package/apps/desktop-console/README.md +0 -27
- package/apps/desktop-console/package-lock.json +0 -897
- package/apps/desktop-console/package.json +0 -20
- package/apps/desktop-console/scripts/build-and-install.mjs +0 -19
- package/apps/desktop-console/scripts/build.mjs +0 -45
- package/apps/desktop-console/scripts/test-preload.mjs +0 -13
- package/apps/desktop-console/src/main/config.mts +0 -26
- package/apps/desktop-console/src/main/core-daemon-manager.mts +0 -131
- package/apps/desktop-console/src/main/desktop-settings.mts +0 -267
- package/apps/desktop-console/src/main/heartbeat-watchdog.mts +0 -50
- package/apps/desktop-console/src/main/heartbeat-watchdog.test.mts +0 -68
- package/apps/desktop-console/src/main/index-streaming.test.mts +0 -20
- package/apps/desktop-console/src/main/index.mts +0 -980
- package/apps/desktop-console/src/main/profile-store.mts +0 -239
- package/apps/desktop-console/src/main/profile-store.test.mts +0 -54
- package/apps/desktop-console/src/main/state-bridge.mts +0 -114
- package/apps/desktop-console/src/main/task-state-types.ts +0 -32
- package/apps/desktop-console/src/renderer/hooks/use-task-state.mts +0 -120
- package/apps/desktop-console/src/renderer/index.mts +0 -133
- package/apps/desktop-console/src/renderer/index.test.mts +0 -34
- package/apps/desktop-console/src/renderer/path-helpers.mts +0 -46
- package/apps/desktop-console/src/renderer/path-helpers.test.mts +0 -14
- package/apps/desktop-console/src/renderer/tabs/debug.mts +0 -48
- package/apps/desktop-console/src/renderer/tabs/debug.test.mts +0 -22
- package/apps/desktop-console/src/renderer/tabs/logs.mts +0 -421
- package/apps/desktop-console/src/renderer/tabs/logs.test.mts +0 -27
- package/apps/desktop-console/src/renderer/tabs/preflight.mts +0 -486
- package/apps/desktop-console/src/renderer/tabs/preflight.test.mts +0 -33
- package/apps/desktop-console/src/renderer/tabs/profile-pool.mts +0 -213
- package/apps/desktop-console/src/renderer/tabs/results.mts +0 -171
- package/apps/desktop-console/src/renderer/tabs/run.test.mts +0 -63
- package/apps/desktop-console/src/renderer/tabs/runtime.mts +0 -151
- package/apps/desktop-console/src/renderer/tabs/settings.mts +0 -146
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/account-flow.mts +0 -486
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/guide-browser-check.mts +0 -56
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/helpers.mts +0 -262
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/layout-block.mts +0 -430
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/live-stats.mts +0 -847
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu/run-flow.mts +0 -443
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu-state.mts +0 -425
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu.mts +0 -497
- package/apps/desktop-console/src/renderer/tabs/xiaohongshu.test.mts +0 -291
- package/apps/desktop-console/src/renderer/ui-components.mts +0 -31
- package/docs/README_camoufox_chinese.md +0 -141
- package/docs/USAGE_V3.md +0 -163
- package/docs/arch/OCR_MACOS_PLUGIN.md +0 -39
- package/docs/arch/PORTS.md +0 -40
- package/docs/arch/REGRESSION_CHECKLIST.md +0 -121
- package/docs/arch/SEARCH_GATE.md +0 -224
- package/docs/arch/VIEWPORT_SAFETY.md +0 -182
- package/docs/arch/XIAOHONGSHU_OFFLINE_MOCK_DESIGN.md +0 -267
- package/docs/xiaohongshu-container-driven-summary.md +0 -221
- package/docs/xiaohongshu-full-collect-runbook.md +0 -134
- package/docs/xiaohongshu-next-steps.md +0 -228
- package/docs/xiaohongshu-quickstart.md +0 -73
- package/docs/xiaohongshu-workflow-summary.md +0 -227
- package/modules/container-registry/tests/container-registry.test.ts +0 -16
- package/modules/logging/tests/logging.test.ts +0 -38
- package/modules/operations/tests/operations.test.ts +0 -22
- package/modules/operations/tests/viewport-filter.test.ts +0 -161
- package/modules/operations/tests/visible-only.test.ts +0 -250
- package/modules/session-manager/tests/session-manager.test.ts +0 -23
- package/modules/state/src/atomic-json.test.ts +0 -30
- package/modules/state/src/paths.test.ts +0 -59
- package/modules/state/src/xiaohongshu-collect-state.test.ts +0 -259
- package/modules/workflow/blocks/AnchorVerificationBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/AnchorVerificationBlock.js.map +0 -1
- package/modules/workflow/blocks/DetectPageStateBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/DetectPageStateBlock.js.map +0 -1
- package/modules/workflow/blocks/ErrorRecoveryBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/ErrorRecoveryBlock.js.map +0 -1
- package/modules/workflow/blocks/WaitSearchPermitBlock.d.ts.map +0 -1
- package/modules/workflow/blocks/WaitSearchPermitBlock.js.map +0 -1
- package/modules/workflow/blocks/helpers/containerAnchors.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/containerAnchors.js.map +0 -1
- package/modules/workflow/blocks/helpers/downloadPaths.test.ts +0 -62
- package/modules/workflow/blocks/helpers/mergeXhsMarkdown.test.ts +0 -121
- package/modules/workflow/blocks/helpers/operationLogger.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/operationLogger.js.map +0 -1
- package/modules/workflow/blocks/helpers/persistedNotes.test.ts +0 -268
- package/modules/workflow/blocks/helpers/searchPageState.d.ts.map +0 -1
- package/modules/workflow/blocks/helpers/searchPageState.js.map +0 -1
- package/modules/workflow/blocks/helpers/targetCountMode.test.ts +0 -29
- package/modules/workflow/blocks/helpers/xhsCliArgs.test.ts +0 -75
- package/modules/workflow/tests/smartReply.test.ts +0 -32
- package/modules/xiaohongshu/app/src/blocks/Phase3Interact.matcher.test.ts +0 -33
- package/modules/xiaohongshu/app/src/utils/__tests__/checkpoints.test.ts +0 -141
- package/modules/xiaohongshu/app/tests/commentMatchDsl.test.ts +0 -50
- package/modules/xiaohongshu/app/tests/commentMatcher.test.ts +0 -46
- package/modules/xiaohongshu/app/tests/sharding.test.ts +0 -31
- package/package-scripts.json +0 -8
- package/runtime/infra/utils/README.md +0 -13
- package/runtime/infra/utils/scripts/README.md +0 -0
- package/runtime/infra/utils/scripts/development/eval-in-session.mjs +0 -40
- package/runtime/infra/utils/scripts/development/highlight-search-containers.mjs +0 -35
- package/runtime/infra/utils/scripts/service/kill-port.mjs +0 -24
- package/runtime/infra/utils/scripts/service/start-api.mjs +0 -39
- package/runtime/infra/utils/scripts/service/start-browser-service.mjs +0 -106
- package/runtime/infra/utils/scripts/service/stop-api.mjs +0 -18
- package/runtime/infra/utils/scripts/service/stop-browser-service.mjs +0 -104
- package/runtime/infra/utils/scripts/test-services.mjs +0 -94
- package/services/shared/heartbeat.test.ts +0 -102
- package/services/unified-api/__tests__/task-state.test.ts +0 -95
- package/sitecustomize.py +0 -19
- package/tests/README.md +0 -194
- package/tests/e2e/workflows/weibo-feed-extraction.test.ts +0 -171
- package/tests/fixtures/data/container-definitions.json +0 -67
- package/tests/fixtures/pages/simple-page.html +0 -69
- package/tests/integration/01-test-container-match.mjs +0 -188
- package/tests/integration/02-test-dom-branch.mjs +0 -161
- package/tests/integration/03-test-container-operation-system.mjs +0 -91
- package/tests/integration/05-test-container-lifecycle-events.mjs +0 -224
- package/tests/integration/05-test-container-lifecycle-with-events.mjs +0 -250
- package/tests/integration/06-test-container-dom-tree-drawing.mjs +0 -256
- package/tests/integration/07-test-weibo-container-lifecycle.mjs +0 -355
- package/tests/integration/08-test-weibo-feed-workflow.test.mjs +0 -164
- package/tests/integration/10-test-visual-analyzer.mjs +0 -312
- package/tests/integration/11-test-visual-loop.mjs +0 -284
- package/tests/integration/12-test-simple-visual-loop.mjs +0 -242
- package/tests/integration/13-test-visual-robust.mjs +0 -185
- package/tests/integration/14-test-visual-highlight-loop.mjs +0 -271
- package/tests/integration/inspect-page.mjs +0 -50
- package/tests/integration/run-all-tests.mjs +0 -95
- package/tests/patch_verification/CODEX_PATCH_TEST.md +0 -103
- package/tests/patch_verification/PHASE2_ANALYSIS.md +0 -179
- package/tests/patch_verification/PHASE2_OPTIMIZATION_REPORT.md +0 -55
- package/tests/patch_verification/PHASE2_TO_PHASE4_SUMMARY.md +0 -126
- package/tests/patch_verification/QUICK_TEST_SEQUENCE.md +0 -262
- package/tests/patch_verification/README.md +0 -143
- package/tests/patch_verification/RUN_TESTS.md +0 -60
- package/tests/patch_verification/TEST_EXECUTION.md +0 -99
- package/tests/patch_verification/TEST_PLAN.md +0 -328
- package/tests/patch_verification/TEST_RESULTS.md +0 -34
- package/tests/patch_verification/TOOL_TEST_PLAN.md +0 -48
- package/tests/patch_verification/run-tool-test.mjs +0 -121
- package/tests/patch_verification/temp_test_files/test01.txt +0 -1
- package/tests/patch_verification/temp_test_files/test02.txt +0 -3
- package/tests/patch_verification/temp_test_files/test02_gnu.txt +0 -3
- package/tests/patch_verification/temp_test_files/test03.txt +0 -1
- package/tests/patch_verification/temp_test_files/test03_multiline.txt +0 -5
- package/tests/patch_verification/temp_test_files/test04_function.ts +0 -5
- package/tests/patch_verification/temp_test_files/test05_import.ts +0 -4
- package/tests/patch_verification/temp_test_files/test06_special_chars.txt +0 -4
- package/tests/patch_verification/temp_test_files/test07_indentation.ts +0 -5
- package/tests/patch_verification/temp_test_files/test08_mismatch.txt +0 -1
- package/tests/patch_verification/temp_test_files/test_add_02.txt +0 -3
- package/tests/patch_verification/temp_test_files/test_simple.txt +0 -1
- package/tests/runner/TestReporter.mjs +0 -57
- package/tests/runner/TestRunner.mjs +0 -244
- package/tests/unit/commands/profile.test.mjs +0 -10
- package/tests/unit/container/change-notifier.test.mjs +0 -181
- package/tests/unit/lifecycle/session-registry.test.mjs +0 -135
- package/tests/unit/operations/registry.test.ts +0 -73
- package/tests/unit/utils/browser-service.test.mjs +0 -153
- package/tests/unit/utils/config.test.mjs +0 -166
- package/tests/unit/utils/fingerprint.test.mjs +0 -166
- package/tsconfig.json +0 -31
- package/tsconfig.services.json +0 -26
- /package/apps/desktop-console/{src → dist}/renderer/index.html +0 -0
- /package/apps/desktop-console/{src/renderer/tabs → dist/renderer}/run.mts +0 -0
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* State Registry - Unified state management for WebAuto
|
|
3
|
+
*
|
|
4
|
+
* Records and exposes:
|
|
5
|
+
* - Service states (unified-api, browser-service, search-gate)
|
|
6
|
+
* - Session states (active browser sessions)
|
|
7
|
+
* - Environment states (build version, config paths, feature flags)
|
|
8
|
+
*
|
|
9
|
+
* Persistence: ~/.webauto/state/core-state.json
|
|
10
|
+
*/
|
|
11
|
+
import fs from 'node:fs';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
import os from 'node:os';
|
|
14
|
+
// ===== State Registry Class =====
|
|
15
|
+
function resolveStatePaths() {
|
|
16
|
+
const home = os.homedir();
|
|
17
|
+
const stateDir = path.join(home, '.webauto', 'state');
|
|
18
|
+
const logDir = path.join(home, '.webauto', 'logs');
|
|
19
|
+
return {
|
|
20
|
+
home,
|
|
21
|
+
stateDir,
|
|
22
|
+
logDir,
|
|
23
|
+
stateFile: path.join(stateDir, 'core-state.json'),
|
|
24
|
+
logFile: path.join(logDir, 'state.jsonl'),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
class StateRegistry {
|
|
28
|
+
state;
|
|
29
|
+
flushTimer;
|
|
30
|
+
constructor() {
|
|
31
|
+
// Ensure directories exist
|
|
32
|
+
const paths = resolveStatePaths();
|
|
33
|
+
fs.mkdirSync(paths.stateDir, { recursive: true });
|
|
34
|
+
fs.mkdirSync(paths.logDir, { recursive: true });
|
|
35
|
+
// Load or initialize state
|
|
36
|
+
this.state = this.loadState();
|
|
37
|
+
// Auto-flush every 30 seconds
|
|
38
|
+
this.flushTimer = setInterval(() => {
|
|
39
|
+
this.flush();
|
|
40
|
+
}, 30000);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Load state from file or create new
|
|
44
|
+
*/
|
|
45
|
+
loadState() {
|
|
46
|
+
try {
|
|
47
|
+
const { stateFile } = resolveStatePaths();
|
|
48
|
+
if (fs.existsSync(stateFile)) {
|
|
49
|
+
const data = fs.readFileSync(stateFile, 'utf-8');
|
|
50
|
+
const parsed = JSON.parse(data);
|
|
51
|
+
// Validate and migrate if needed
|
|
52
|
+
return this.validateState(parsed);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
console.error('[StateRegistry] Failed to load state:', err);
|
|
57
|
+
}
|
|
58
|
+
// Return initial state
|
|
59
|
+
return {
|
|
60
|
+
services: {},
|
|
61
|
+
sessions: {},
|
|
62
|
+
env: {
|
|
63
|
+
configPaths: {},
|
|
64
|
+
featureFlags: {
|
|
65
|
+
searchGateEnabled: true,
|
|
66
|
+
viewportSafetyEnabled: true,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
timestamp: new Date().toISOString(),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Validate and migrate state
|
|
74
|
+
*/
|
|
75
|
+
validateState(raw) {
|
|
76
|
+
const state = {
|
|
77
|
+
services: raw.services || {},
|
|
78
|
+
sessions: raw.sessions || {},
|
|
79
|
+
env: raw.env || {
|
|
80
|
+
configPaths: {},
|
|
81
|
+
featureFlags: {
|
|
82
|
+
searchGateEnabled: true,
|
|
83
|
+
viewportSafetyEnabled: true,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
timestamp: raw.timestamp || new Date().toISOString(),
|
|
87
|
+
};
|
|
88
|
+
// Ensure env fields exist
|
|
89
|
+
if (!state.env.configPaths) {
|
|
90
|
+
state.env.configPaths = {};
|
|
91
|
+
}
|
|
92
|
+
if (!state.env.featureFlags) {
|
|
93
|
+
state.env.featureFlags = {
|
|
94
|
+
searchGateEnabled: true,
|
|
95
|
+
viewportSafetyEnabled: true,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return state;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Get full state snapshot
|
|
102
|
+
*/
|
|
103
|
+
getState() {
|
|
104
|
+
return {
|
|
105
|
+
...this.state,
|
|
106
|
+
timestamp: new Date().toISOString(),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Update service state
|
|
111
|
+
*/
|
|
112
|
+
updateServiceState(serviceKey, updates) {
|
|
113
|
+
const current = this.state.services[serviceKey] || {
|
|
114
|
+
name: serviceKey,
|
|
115
|
+
port: 0,
|
|
116
|
+
status: 'down',
|
|
117
|
+
healthy: false,
|
|
118
|
+
};
|
|
119
|
+
this.state.services[serviceKey] = {
|
|
120
|
+
...current,
|
|
121
|
+
...updates,
|
|
122
|
+
lastHealthAt: updates.healthy ? new Date().toISOString() : current.lastHealthAt,
|
|
123
|
+
};
|
|
124
|
+
this.state.timestamp = new Date().toISOString();
|
|
125
|
+
this.logChange('service', serviceKey, updates);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Update session state
|
|
129
|
+
*/
|
|
130
|
+
updateSessionState(profileId, updates) {
|
|
131
|
+
const current = this.state.sessions[profileId] || {
|
|
132
|
+
profileId,
|
|
133
|
+
lastActiveAt: new Date().toISOString(),
|
|
134
|
+
createdAt: new Date().toISOString(),
|
|
135
|
+
status: 'running',
|
|
136
|
+
};
|
|
137
|
+
this.state.sessions[profileId] = {
|
|
138
|
+
...current,
|
|
139
|
+
...updates,
|
|
140
|
+
lastActiveAt: new Date().toISOString(),
|
|
141
|
+
};
|
|
142
|
+
this.state.timestamp = new Date().toISOString();
|
|
143
|
+
this.logChange('session', profileId, updates);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Remove session state
|
|
147
|
+
*/
|
|
148
|
+
removeSessionState(profileId) {
|
|
149
|
+
delete this.state.sessions[profileId];
|
|
150
|
+
this.state.timestamp = new Date().toISOString();
|
|
151
|
+
this.logChange('session', profileId, { action: 'removed' });
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Update environment state
|
|
155
|
+
*/
|
|
156
|
+
updateEnvState(updates) {
|
|
157
|
+
this.state.env = {
|
|
158
|
+
...this.state.env,
|
|
159
|
+
...updates,
|
|
160
|
+
};
|
|
161
|
+
if (updates.configPaths) {
|
|
162
|
+
this.state.env.configPaths = {
|
|
163
|
+
...this.state.env.configPaths,
|
|
164
|
+
...updates.configPaths,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
if (updates.featureFlags) {
|
|
168
|
+
this.state.env.featureFlags = {
|
|
169
|
+
...this.state.env.featureFlags,
|
|
170
|
+
...updates.featureFlags,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
this.state.timestamp = new Date().toISOString();
|
|
174
|
+
this.logChange('env', 'global', updates);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Get session state
|
|
178
|
+
*/
|
|
179
|
+
getSessionState(profileId) {
|
|
180
|
+
return this.state.sessions[profileId];
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Get all session states
|
|
184
|
+
*/
|
|
185
|
+
getAllSessionStates() {
|
|
186
|
+
return { ...this.state.sessions };
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get service states
|
|
190
|
+
*/
|
|
191
|
+
getServiceStates() {
|
|
192
|
+
return { ...this.state.services };
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Get environment state
|
|
196
|
+
*/
|
|
197
|
+
getEnvState() {
|
|
198
|
+
return { ...this.state.env };
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Flush state to disk
|
|
202
|
+
*/
|
|
203
|
+
flush() {
|
|
204
|
+
try {
|
|
205
|
+
const { stateFile, stateDir } = resolveStatePaths();
|
|
206
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
207
|
+
fs.writeFileSync(stateFile, JSON.stringify(this.state, null, 2), 'utf-8');
|
|
208
|
+
}
|
|
209
|
+
catch (err) {
|
|
210
|
+
console.error('[StateRegistry] Failed to flush state:', err);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Log state change to jsonl file
|
|
215
|
+
*/
|
|
216
|
+
logChange(type, key, changes) {
|
|
217
|
+
const entry = {
|
|
218
|
+
timestamp: new Date().toISOString(),
|
|
219
|
+
type,
|
|
220
|
+
key,
|
|
221
|
+
changes,
|
|
222
|
+
};
|
|
223
|
+
try {
|
|
224
|
+
const { logFile, logDir } = resolveStatePaths();
|
|
225
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
226
|
+
fs.appendFileSync(logFile, JSON.stringify(entry) + '\n', 'utf-8');
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
console.error('[StateRegistry] Failed to log change:', err);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Cleanup old sessions (inactive for > 24 hours)
|
|
234
|
+
*/
|
|
235
|
+
cleanupOldSessions() {
|
|
236
|
+
const now = Date.now();
|
|
237
|
+
const dayMs = 24 * 60 * 60 * 1000;
|
|
238
|
+
let cleaned = 0;
|
|
239
|
+
for (const [profileId, session] of Object.entries(this.state.sessions)) {
|
|
240
|
+
const lastActive = new Date(session.lastActiveAt).getTime();
|
|
241
|
+
if (now - lastActive > dayMs) {
|
|
242
|
+
delete this.state.sessions[profileId];
|
|
243
|
+
cleaned++;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
if (cleaned > 0) {
|
|
247
|
+
console.log(`[StateRegistry] Cleaned up ${cleaned} old sessions`);
|
|
248
|
+
this.state.timestamp = new Date().toISOString();
|
|
249
|
+
this.flush();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Shutdown and cleanup
|
|
254
|
+
*/
|
|
255
|
+
shutdown() {
|
|
256
|
+
if (this.flushTimer) {
|
|
257
|
+
clearInterval(this.flushTimer);
|
|
258
|
+
}
|
|
259
|
+
this.flush();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
// Singleton instance
|
|
263
|
+
let registryInstance = null;
|
|
264
|
+
let registryHome = null;
|
|
265
|
+
export function getStateRegistry() {
|
|
266
|
+
const currentHome = os.homedir();
|
|
267
|
+
if (!registryInstance || registryHome !== currentHome) {
|
|
268
|
+
registryInstance = new StateRegistry();
|
|
269
|
+
registryHome = currentHome;
|
|
270
|
+
}
|
|
271
|
+
return registryInstance;
|
|
272
|
+
}
|
|
273
|
+
export { StateRegistry };
|
|
274
|
+
//# sourceMappingURL=state-registry.js.map
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// services/unified-api/task-persistence.ts
|
|
2
|
+
// Simple JSONL persistence for task state (webauto-04b)
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
const STATE_DIR = path.join(os.homedir(), '.webauto', 'state');
|
|
7
|
+
export async function ensureStateDir() {
|
|
8
|
+
await fs.mkdir(STATE_DIR, { recursive: true });
|
|
9
|
+
}
|
|
10
|
+
export async function saveTaskSnapshot(task) {
|
|
11
|
+
await ensureStateDir();
|
|
12
|
+
const file = path.join(STATE_DIR, `${task.runId}.json`);
|
|
13
|
+
await fs.writeFile(file, JSON.stringify(task, null, 2), 'utf8');
|
|
14
|
+
}
|
|
15
|
+
export async function loadTaskSnapshot(runId) {
|
|
16
|
+
try {
|
|
17
|
+
const file = path.join(STATE_DIR, `${runId}.json`);
|
|
18
|
+
const raw = await fs.readFile(file, 'utf8');
|
|
19
|
+
return JSON.parse(raw);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function appendEvent(event) {
|
|
26
|
+
await ensureStateDir();
|
|
27
|
+
const file = path.join(STATE_DIR, `${event.runId}.events.jsonl`);
|
|
28
|
+
await fs.appendFile(file, JSON.stringify(event) + '\n', 'utf8');
|
|
29
|
+
}
|
|
30
|
+
export async function loadEvents(runId, since) {
|
|
31
|
+
try {
|
|
32
|
+
const file = path.join(STATE_DIR, `${runId}.events.jsonl`);
|
|
33
|
+
const raw = await fs.readFile(file, 'utf8');
|
|
34
|
+
const lines = raw.trim().split('\n');
|
|
35
|
+
const events = lines.map(line => JSON.parse(line));
|
|
36
|
+
if (!since)
|
|
37
|
+
return events;
|
|
38
|
+
return events.filter(e => e.timestamp > since);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export async function deleteTaskFiles(runId) {
|
|
45
|
+
const snapshotFile = path.join(STATE_DIR, `${runId}.json`);
|
|
46
|
+
const eventsFile = path.join(STATE_DIR, `${runId}.events.jsonl`);
|
|
47
|
+
await Promise.all([
|
|
48
|
+
fs.unlink(snapshotFile).catch(() => { }),
|
|
49
|
+
fs.unlink(eventsFile).catch(() => { }),
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
export async function loadAllTasks() {
|
|
53
|
+
await ensureStateDir();
|
|
54
|
+
const files = await fs.readdir(STATE_DIR);
|
|
55
|
+
const tasks = [];
|
|
56
|
+
for (const file of files) {
|
|
57
|
+
if (!file.endsWith('.json') || file.includes('.events.'))
|
|
58
|
+
continue;
|
|
59
|
+
const runId = file.replace('.json', '');
|
|
60
|
+
const task = await loadTaskSnapshot(runId);
|
|
61
|
+
if (task)
|
|
62
|
+
tasks.push(task);
|
|
63
|
+
}
|
|
64
|
+
return tasks;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=task-persistence.js.map
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
// services/unified-api/task-state.ts
|
|
2
|
+
// Unified task state registry for UI ↔ script data sync (webauto-04b)
|
|
3
|
+
class TaskStateRegistry {
|
|
4
|
+
tasks = new Map();
|
|
5
|
+
events = new Map();
|
|
6
|
+
subscribers = new Set();
|
|
7
|
+
maxEventsPerTask = 100;
|
|
8
|
+
createTask(partial) {
|
|
9
|
+
const now = Date.now();
|
|
10
|
+
const task = {
|
|
11
|
+
runId: partial.runId,
|
|
12
|
+
profileId: partial.profileId,
|
|
13
|
+
keyword: partial.keyword,
|
|
14
|
+
phase: partial.phase || 'unknown',
|
|
15
|
+
status: 'starting',
|
|
16
|
+
progress: { total: 0, processed: 0, failed: 0 },
|
|
17
|
+
stats: {
|
|
18
|
+
notesProcessed: 0,
|
|
19
|
+
commentsCollected: 0,
|
|
20
|
+
likesPerformed: 0,
|
|
21
|
+
repliesGenerated: 0,
|
|
22
|
+
imagesDownloaded: 0,
|
|
23
|
+
ocrProcessed: 0,
|
|
24
|
+
},
|
|
25
|
+
startedAt: now,
|
|
26
|
+
updatedAt: now,
|
|
27
|
+
details: {
|
|
28
|
+
recentEvents: [],
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
this.tasks.set(task.runId, task);
|
|
32
|
+
this.events.set(task.runId, []);
|
|
33
|
+
this.broadcast({ runId: task.runId, type: 'status_change', data: { status: 'starting' }, timestamp: now });
|
|
34
|
+
return task;
|
|
35
|
+
}
|
|
36
|
+
getTask(runId) {
|
|
37
|
+
return this.tasks.get(runId);
|
|
38
|
+
}
|
|
39
|
+
getAllTasks() {
|
|
40
|
+
return Array.from(this.tasks.values());
|
|
41
|
+
}
|
|
42
|
+
updateTask(runId, updates) {
|
|
43
|
+
const task = this.tasks.get(runId);
|
|
44
|
+
if (!task)
|
|
45
|
+
return undefined;
|
|
46
|
+
Object.assign(task, updates, { updatedAt: Date.now() });
|
|
47
|
+
this.tasks.set(runId, task);
|
|
48
|
+
return task;
|
|
49
|
+
}
|
|
50
|
+
updateProgress(runId, progress) {
|
|
51
|
+
const task = this.tasks.get(runId);
|
|
52
|
+
if (!task)
|
|
53
|
+
return;
|
|
54
|
+
Object.assign(task.progress, progress);
|
|
55
|
+
task.updatedAt = Date.now();
|
|
56
|
+
this.broadcast({ runId, type: 'progress', data: task.progress, timestamp: task.updatedAt });
|
|
57
|
+
}
|
|
58
|
+
updateStats(runId, stats) {
|
|
59
|
+
const task = this.tasks.get(runId);
|
|
60
|
+
if (!task)
|
|
61
|
+
return;
|
|
62
|
+
Object.assign(task.stats, stats);
|
|
63
|
+
task.updatedAt = Date.now();
|
|
64
|
+
this.broadcast({ runId, type: 'stats', data: task.stats, timestamp: task.updatedAt });
|
|
65
|
+
}
|
|
66
|
+
pushEvent(runId, eventType, data) {
|
|
67
|
+
const task = this.tasks.get(runId);
|
|
68
|
+
if (!task)
|
|
69
|
+
return;
|
|
70
|
+
const event = { runId, type: eventType, data, timestamp: Date.now() };
|
|
71
|
+
let events = this.events.get(runId) || [];
|
|
72
|
+
events.push(event);
|
|
73
|
+
if (events.length > this.maxEventsPerTask) {
|
|
74
|
+
events = events.slice(-this.maxEventsPerTask);
|
|
75
|
+
}
|
|
76
|
+
this.events.set(runId, events);
|
|
77
|
+
if (task.details) {
|
|
78
|
+
task.details.recentEvents = events.slice(-50);
|
|
79
|
+
}
|
|
80
|
+
this.broadcast({ runId, type: 'event', data: event, timestamp: event.timestamp });
|
|
81
|
+
}
|
|
82
|
+
setStatus(runId, status) {
|
|
83
|
+
const task = this.tasks.get(runId);
|
|
84
|
+
if (!task)
|
|
85
|
+
return;
|
|
86
|
+
task.status = status;
|
|
87
|
+
task.updatedAt = Date.now();
|
|
88
|
+
if (status === 'completed' || status === 'failed' || status === 'aborted') {
|
|
89
|
+
task.completedAt = task.updatedAt;
|
|
90
|
+
}
|
|
91
|
+
this.broadcast({ runId, type: 'status_change', data: { status }, timestamp: task.updatedAt });
|
|
92
|
+
}
|
|
93
|
+
setError(runId, error) {
|
|
94
|
+
const task = this.tasks.get(runId);
|
|
95
|
+
if (!task)
|
|
96
|
+
return;
|
|
97
|
+
task.lastError = error;
|
|
98
|
+
task.updatedAt = Date.now();
|
|
99
|
+
this.broadcast({ runId, type: 'error', data: error, timestamp: task.updatedAt });
|
|
100
|
+
}
|
|
101
|
+
getEvents(runId, since) {
|
|
102
|
+
const events = this.events.get(runId) || [];
|
|
103
|
+
if (!since)
|
|
104
|
+
return events;
|
|
105
|
+
return events.filter(e => e.timestamp > since);
|
|
106
|
+
}
|
|
107
|
+
deleteTask(runId) {
|
|
108
|
+
this.events.delete(runId);
|
|
109
|
+
return this.tasks.delete(runId);
|
|
110
|
+
}
|
|
111
|
+
subscribe(callback) {
|
|
112
|
+
this.subscribers.add(callback);
|
|
113
|
+
return () => {
|
|
114
|
+
this.subscribers.delete(callback);
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
broadcast(update) {
|
|
118
|
+
for (const cb of this.subscribers) {
|
|
119
|
+
try {
|
|
120
|
+
cb(update);
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
console.error('[TaskStateRegistry] subscriber error:', err);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
export const taskStateRegistry = new TaskStateRegistry();
|
|
129
|
+
export default taskStateRegistry;
|
|
130
|
+
//# sourceMappingURL=task-state.js.map
|
|
@@ -88,10 +88,18 @@ export function buildOpenDetailScript(params = {}) {
|
|
|
88
88
|
|
|
89
89
|
const state = loadState();
|
|
90
90
|
if (!Array.isArray(state.visitedNoteIds)) state.visitedNoteIds = [];
|
|
91
|
+
const requestedKeyword = ${JSON.stringify(keyword)};
|
|
92
|
+
const mode = ${JSON.stringify(mode)};
|
|
93
|
+
const previousKeyword = String(state.keyword || '').trim();
|
|
94
|
+
if (mode === 'first') {
|
|
95
|
+
state.visitedNoteIds = [];
|
|
96
|
+
} else if (requestedKeyword && previousKeyword && requestedKeyword !== previousKeyword) {
|
|
97
|
+
state.visitedNoteIds = [];
|
|
98
|
+
}
|
|
91
99
|
state.maxNotes = Number(${maxNotes});
|
|
92
|
-
if (
|
|
100
|
+
if (requestedKeyword) state.keyword = requestedKeyword;
|
|
93
101
|
|
|
94
|
-
if (
|
|
102
|
+
if (mode === 'next' && state.visitedNoteIds.length >= state.maxNotes) {
|
|
95
103
|
throw new Error('AUTOSCRIPT_DONE_MAX_NOTES');
|
|
96
104
|
}
|
|
97
105
|
|
|
@@ -107,7 +115,7 @@ export function buildOpenDetailScript(params = {}) {
|
|
|
107
115
|
if (nodes.length === 0) throw new Error('NO_SEARCH_RESULT_ITEM');
|
|
108
116
|
|
|
109
117
|
let next = null;
|
|
110
|
-
if (
|
|
118
|
+
if (mode === 'next') {
|
|
111
119
|
next = nodes.find((row) => !state.visitedNoteIds.includes(row.noteId));
|
|
112
120
|
if (!next) throw new Error('AUTOSCRIPT_DONE_NO_MORE_NOTES');
|
|
113
121
|
} else {
|
|
@@ -161,7 +169,7 @@ export function buildOpenDetailScript(params = {}) {
|
|
|
161
169
|
saveState(state);
|
|
162
170
|
return {
|
|
163
171
|
opened: true,
|
|
164
|
-
source:
|
|
172
|
+
source: mode === 'next' ? 'open_next_detail' : 'open_first_detail',
|
|
165
173
|
noteId: next.noteId,
|
|
166
174
|
visited: state.visitedNoteIds.length,
|
|
167
175
|
maxNotes: state.maxNotes,
|
|
@@ -171,4 +179,3 @@ export function buildOpenDetailScript(params = {}) {
|
|
|
171
179
|
};
|
|
172
180
|
})()`;
|
|
173
181
|
}
|
|
174
|
-
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
lockfileVersion: '9.0'
|
|
2
|
+
|
|
3
|
+
settings:
|
|
4
|
+
autoInstallPeers: true
|
|
5
|
+
excludeLinksFromLockfile: false
|
|
6
|
+
|
|
7
|
+
importers:
|
|
8
|
+
|
|
9
|
+
.:
|
|
10
|
+
devDependencies:
|
|
11
|
+
typescript:
|
|
12
|
+
specifier: ^5.0.0
|
|
13
|
+
version: 5.9.3
|
|
14
|
+
|
|
15
|
+
packages:
|
|
16
|
+
|
|
17
|
+
typescript@5.9.3:
|
|
18
|
+
resolution: {integrity: sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==}
|
|
19
|
+
engines: {node: '>=14.17'}
|
|
20
|
+
hasBin: true
|
|
21
|
+
|
|
22
|
+
snapshots:
|
|
23
|
+
|
|
24
|
+
typescript@5.9.3: {}
|
package/package.json
CHANGED
|
@@ -1,25 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@web-auto/webauto",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"webauto": "bin/webauto.mjs"
|
|
7
7
|
},
|
|
8
|
+
"files": [
|
|
9
|
+
"bin/",
|
|
10
|
+
"dist/",
|
|
11
|
+
"modules/",
|
|
12
|
+
"scripts/",
|
|
13
|
+
"services/",
|
|
14
|
+
"apps/desktop-console/dist/",
|
|
15
|
+
"apps/desktop-console/default-settings.json",
|
|
16
|
+
"apps/desktop-console/entry/ui-console.mjs",
|
|
17
|
+
"apps/webauto/",
|
|
18
|
+
"!dist/**/*.map",
|
|
19
|
+
"!dist/**/__tests__/**",
|
|
20
|
+
"!dist/**/tests/**",
|
|
21
|
+
"!dist/**/*.test.*",
|
|
22
|
+
"!dist/**/*.spec.*",
|
|
23
|
+
"!modules/**/node_modules/**",
|
|
24
|
+
"!modules/**/__tests__/**",
|
|
25
|
+
"!modules/**/tests/**",
|
|
26
|
+
"!modules/**/*.test.*",
|
|
27
|
+
"!modules/**/*.spec.*",
|
|
28
|
+
"!modules/**/*.map",
|
|
29
|
+
"!services/**/__tests__/**",
|
|
30
|
+
"!services/**/tests/**",
|
|
31
|
+
"!services/**/*.test.*",
|
|
32
|
+
"!services/**/*.spec.*",
|
|
33
|
+
"!services/**/*.map",
|
|
34
|
+
"!apps/desktop-console/dist/**/*.map"
|
|
35
|
+
],
|
|
8
36
|
"dependencies": {
|
|
9
|
-
"@web-auto/camo": "^0.1.
|
|
10
|
-
"ajv": "^8.
|
|
37
|
+
"@web-auto/camo": "^0.1.6",
|
|
38
|
+
"ajv": "^8.18.0",
|
|
11
39
|
"esbuild-register": "^3.6.0",
|
|
12
40
|
"iconv-lite": "^0.6.3",
|
|
13
41
|
"linkedom": "^0.18.12",
|
|
14
42
|
"minimist": "^1.2.8",
|
|
15
43
|
"node-fetch": "^2.7.0",
|
|
16
44
|
"sharp": "^0.33.5",
|
|
17
|
-
"undici": "^7.
|
|
18
|
-
"ws": "^8.
|
|
45
|
+
"undici": "^7.22.0",
|
|
46
|
+
"ws": "^8.19.0"
|
|
19
47
|
},
|
|
20
48
|
"scripts": {
|
|
21
49
|
"start:mcp:browser": "npx @browsermcp/mcp@latest",
|
|
22
|
-
"build": "npm run prebuild && npm run build:services && npm run self-check:post-build && npm run ui:test",
|
|
50
|
+
"build": "npm run prebuild && npm run build:services && npm run self-check:post-build && npm run ui:test && npm --prefix apps/desktop-console run build",
|
|
23
51
|
"build:services": "tsc -p tsconfig.services.json",
|
|
24
52
|
"self-check:post-build": "node scripts/self-check.mjs --quick --post-build",
|
|
25
53
|
"start": "node dist/apps/webauto/server.js",
|
|
@@ -52,15 +80,15 @@
|
|
|
52
80
|
"test:services:unit": "npx tsx --test $(find services -name \"*.test.ts\" -o -name \"*.test.mts\" 2>/dev/null | tr \"\\n\" \" \")"
|
|
53
81
|
},
|
|
54
82
|
"devDependencies": {
|
|
55
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
83
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
56
84
|
"@types/express": "^5.0.6",
|
|
57
85
|
"@types/minimist": "^1.2.5",
|
|
58
|
-
"@types/node": "^24.10.
|
|
86
|
+
"@types/node": "^24.10.13",
|
|
59
87
|
"@types/ws": "^8.18.1",
|
|
60
88
|
"c8": "^10.1.0",
|
|
61
89
|
"camoufox": "^0.1.19",
|
|
62
90
|
"json-schema-to-typescript": "^15.0.4",
|
|
63
|
-
"playwright": "^1.
|
|
91
|
+
"playwright": "^1.58.2",
|
|
64
92
|
"ts-node": "^10.9.2",
|
|
65
93
|
"tsx": "^4.16.5",
|
|
66
94
|
"typescript": "^5.9.3"
|
package/.beads/README.md
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
# Beads - AI-Native Issue Tracking
|
|
2
|
-
|
|
3
|
-
Welcome to Beads! This repository uses **Beads** for issue tracking - a modern, AI-native tool designed to live directly in your codebase alongside your code.
|
|
4
|
-
|
|
5
|
-
## What is Beads?
|
|
6
|
-
|
|
7
|
-
Beads is issue tracking that lives in your repo, making it perfect for AI coding agents and developers who want their issues close to their code. No web UI required - everything works through the CLI and integrates seamlessly with git.
|
|
8
|
-
|
|
9
|
-
**Learn more:** [github.com/steveyegge/beads](https://github.com/steveyegge/beads)
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
### Essential Commands
|
|
14
|
-
|
|
15
|
-
```bash
|
|
16
|
-
# Create new issues
|
|
17
|
-
bd create "Add user authentication"
|
|
18
|
-
|
|
19
|
-
# View all issues
|
|
20
|
-
bd list
|
|
21
|
-
|
|
22
|
-
# View issue details
|
|
23
|
-
bd show <issue-id>
|
|
24
|
-
|
|
25
|
-
# Update issue status
|
|
26
|
-
bd update <issue-id> --status in_progress
|
|
27
|
-
bd update <issue-id> --status done
|
|
28
|
-
|
|
29
|
-
# Sync with git remote
|
|
30
|
-
bd sync
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### Working with Issues
|
|
34
|
-
|
|
35
|
-
Issues in Beads are:
|
|
36
|
-
- **Git-native**: Stored in `.beads/issues.jsonl` and synced like code
|
|
37
|
-
- **AI-friendly**: CLI-first design works perfectly with AI coding agents
|
|
38
|
-
- **Branch-aware**: Issues can follow your branch workflow
|
|
39
|
-
- **Always in sync**: Auto-syncs with your commits
|
|
40
|
-
|
|
41
|
-
## Why Beads?
|
|
42
|
-
|
|
43
|
-
✨ **AI-Native Design**
|
|
44
|
-
- Built specifically for AI-assisted development workflows
|
|
45
|
-
- CLI-first interface works seamlessly with AI coding agents
|
|
46
|
-
- No context switching to web UIs
|
|
47
|
-
|
|
48
|
-
🚀 **Developer Focused**
|
|
49
|
-
- Issues live in your repo, right next to your code
|
|
50
|
-
- Works offline, syncs when you push
|
|
51
|
-
- Fast, lightweight, and stays out of your way
|
|
52
|
-
|
|
53
|
-
🔧 **Git Integration**
|
|
54
|
-
- Automatic sync with git commits
|
|
55
|
-
- Branch-aware issue tracking
|
|
56
|
-
- Intelligent JSONL merge resolution
|
|
57
|
-
|
|
58
|
-
## Get Started with Beads
|
|
59
|
-
|
|
60
|
-
Try Beads in your own projects:
|
|
61
|
-
|
|
62
|
-
```bash
|
|
63
|
-
# Install Beads
|
|
64
|
-
curl -sSL https://raw.githubusercontent.com/steveyegge/beads/main/scripts/install.sh | bash
|
|
65
|
-
|
|
66
|
-
# Initialize in your repo
|
|
67
|
-
bd init
|
|
68
|
-
|
|
69
|
-
# Create your first issue
|
|
70
|
-
bd create "Try out Beads"
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
## Learn More
|
|
74
|
-
|
|
75
|
-
- **Documentation**: [github.com/steveyegge/beads/docs](https://github.com/steveyegge/beads/tree/main/docs)
|
|
76
|
-
- **Quick Start Guide**: Run `bd quickstart`
|
|
77
|
-
- **Examples**: [github.com/steveyegge/beads/examples](https://github.com/steveyegge/beads/tree/main/examples)
|
|
78
|
-
|
|
79
|
-
---
|
|
80
|
-
|
|
81
|
-
*Beads: Issue tracking that moves at the speed of thought* ⚡
|