@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.
Files changed (354) hide show
  1. package/apps/desktop-console/default-settings.json +1 -0
  2. package/apps/desktop-console/dist/main/index.mjs +1618 -0
  3. package/apps/desktop-console/{src → dist}/main/preload.mjs +10 -0
  4. package/apps/desktop-console/dist/renderer/index.js +3063 -0
  5. package/apps/desktop-console/entry/ui-console.mjs +299 -0
  6. package/apps/webauto/entry/account.mjs +356 -0
  7. package/apps/webauto/entry/lib/account-detect.mjs +160 -0
  8. package/apps/webauto/entry/lib/account-store.mjs +587 -0
  9. package/apps/webauto/entry/lib/profilepool.mjs +1 -1
  10. package/apps/webauto/entry/xhs-install.mjs +27 -3
  11. package/apps/webauto/entry/xhs-status.mjs +152 -0
  12. package/apps/webauto/entry/xhs-unified.mjs +595 -17
  13. package/bin/webauto.mjs +247 -12
  14. package/dist/apps/webauto/server.js +66 -0
  15. package/dist/modules/camo-backend/src/index.js +575 -0
  16. package/dist/modules/camo-backend/src/internal/BrowserSession.js +817 -0
  17. package/dist/modules/camo-backend/src/internal/ElementRegistry.js +61 -0
  18. package/dist/modules/camo-backend/src/internal/ProfileLock.js +85 -0
  19. package/dist/modules/camo-backend/src/internal/SessionManager.js +172 -0
  20. package/dist/modules/camo-backend/src/internal/container-matcher.js +852 -0
  21. package/dist/modules/camo-backend/src/internal/engine-manager.js +258 -0
  22. package/dist/modules/camo-backend/src/internal/fingerprint.js +203 -0
  23. package/dist/modules/camo-backend/src/internal/pageRuntime.js +29 -0
  24. package/dist/modules/camo-backend/src/internal/runtimeInjector.js +30 -0
  25. package/dist/modules/camo-backend/src/internal/state-bus.js +46 -0
  26. package/dist/modules/camo-backend/src/internal/storage-paths.js +36 -0
  27. package/dist/modules/camo-backend/src/internal/ws-server.js +1202 -0
  28. package/dist/modules/camo-runtime/src/utils/browser-service.mjs +423 -0
  29. package/dist/modules/camo-runtime/src/utils/config.mjs +77 -0
  30. package/dist/modules/container-registry/src/index.js +184 -0
  31. package/dist/modules/logging/src/index.js +92 -0
  32. package/dist/modules/operations/src/builtin.js +27 -0
  33. package/dist/modules/operations/src/container-binding.js +75 -0
  34. package/dist/modules/operations/src/executor.js +146 -0
  35. package/dist/modules/operations/src/operations/click.js +167 -0
  36. package/dist/modules/operations/src/operations/extract.js +204 -0
  37. package/dist/modules/operations/src/operations/find-child.js +17 -0
  38. package/dist/modules/operations/src/operations/highlight.js +138 -0
  39. package/dist/modules/operations/src/operations/key.js +61 -0
  40. package/dist/modules/operations/src/operations/navigate.js +148 -0
  41. package/dist/modules/operations/src/operations/scroll.js +126 -0
  42. package/dist/modules/operations/src/operations/type.js +190 -0
  43. package/dist/modules/operations/src/queue.js +100 -0
  44. package/dist/modules/operations/src/registry.js +11 -0
  45. package/dist/modules/operations/src/system/mouse.js +33 -0
  46. package/dist/modules/state/src/atomic-json.js +33 -0
  47. package/dist/modules/workflow/blocks/AnchorVerificationBlock.js +71 -0
  48. package/dist/modules/workflow/blocks/BehaviorRandomizer.js +26 -0
  49. package/dist/modules/workflow/blocks/CallWorkflowBlock.js +38 -0
  50. package/dist/modules/workflow/blocks/CloseDetailBlock.js +209 -0
  51. package/dist/modules/workflow/blocks/CollectBatch.js +137 -0
  52. package/dist/modules/workflow/blocks/CollectCommentsBlock.js +415 -0
  53. package/dist/modules/workflow/blocks/CollectSearchListBlock.js +599 -0
  54. package/dist/modules/workflow/blocks/CollectWeiboPosts.js +229 -0
  55. package/dist/modules/workflow/blocks/DetectPageStateBlock.js +259 -0
  56. package/dist/modules/workflow/blocks/EnsureLoginBlock.js +162 -0
  57. package/dist/modules/workflow/blocks/EnsureSession.js +426 -0
  58. package/dist/modules/workflow/blocks/ErrorClassifier.js +164 -0
  59. package/dist/modules/workflow/blocks/ErrorRecoveryBlock.js +319 -0
  60. package/dist/modules/workflow/blocks/ExpandCommentsBlock.js +1032 -0
  61. package/dist/modules/workflow/blocks/ExtractDetailBlock.js +310 -0
  62. package/dist/modules/workflow/blocks/ExtractPostFields.js +88 -0
  63. package/dist/modules/workflow/blocks/GenerateSmartReplyBlock.js +68 -0
  64. package/dist/modules/workflow/blocks/GoToSearchBlock.js +497 -0
  65. package/dist/modules/workflow/blocks/GracefulFallbackBlock.js +104 -0
  66. package/dist/modules/workflow/blocks/HighlightBlock.js +66 -0
  67. package/dist/modules/workflow/blocks/InitAutoScroll.js +65 -0
  68. package/dist/modules/workflow/blocks/LoadContainerDefinition.js +50 -0
  69. package/dist/modules/workflow/blocks/LoadContainerIndex.js +43 -0
  70. package/dist/modules/workflow/blocks/LocateAndGuardBlock.js +176 -0
  71. package/dist/modules/workflow/blocks/LoginRecoveryBlock.js +242 -0
  72. package/dist/modules/workflow/blocks/MatchContainers.js +64 -0
  73. package/dist/modules/workflow/blocks/MonitoringBlock.js +190 -0
  74. package/dist/modules/workflow/blocks/OpenDetailBlock.js +1240 -0
  75. package/dist/modules/workflow/blocks/OrganizeXhsNotesBlock.js +117 -0
  76. package/dist/modules/workflow/blocks/PersistXhsNoteBlock.js +270 -0
  77. package/dist/modules/workflow/blocks/PickSinglePost.js +69 -0
  78. package/dist/modules/workflow/blocks/ProgressTracker.js +125 -0
  79. package/dist/modules/workflow/blocks/RecordFixtureBlock.js +44 -0
  80. package/dist/modules/workflow/blocks/RenderMarkdown.js +48 -0
  81. package/dist/modules/workflow/blocks/SaveFile.js +54 -0
  82. package/dist/modules/workflow/blocks/ScrollNextBatch.js +72 -0
  83. package/dist/modules/workflow/blocks/SessionHealthBlock.js +73 -0
  84. package/dist/modules/workflow/blocks/StartBrowserService.js +45 -0
  85. package/dist/modules/workflow/blocks/ValidateContainerDefinition.js +67 -0
  86. package/dist/modules/workflow/blocks/ValidateExtract.js +35 -0
  87. package/dist/modules/workflow/blocks/WaitSearchPermitBlock.js +162 -0
  88. package/dist/modules/workflow/blocks/WaitStable.js +74 -0
  89. package/dist/modules/workflow/blocks/WarmupCommentsBlock.js +120 -0
  90. package/dist/modules/workflow/blocks/WorkflowExecutor.js +156 -0
  91. package/dist/modules/workflow/blocks/XiaohongshuCollectFromLinksBlock.js +1004 -0
  92. package/dist/modules/workflow/blocks/XiaohongshuCollectLinksBlock.js +1049 -0
  93. package/dist/modules/workflow/blocks/XiaohongshuFullCollectBlock.js +782 -0
  94. package/dist/modules/workflow/blocks/helpers/anchorVerify.js +198 -0
  95. package/dist/modules/workflow/blocks/helpers/asyncWorkQueue.js +53 -0
  96. package/dist/modules/workflow/blocks/helpers/commentScroller.js +334 -0
  97. package/dist/modules/workflow/blocks/helpers/commentSectionLocator.js +126 -0
  98. package/dist/modules/workflow/blocks/helpers/containerAnchors.js +301 -0
  99. package/dist/modules/workflow/blocks/helpers/debugArtifacts.js +6 -0
  100. package/dist/modules/workflow/blocks/helpers/downloadPaths.js +29 -0
  101. package/dist/modules/workflow/blocks/helpers/expandCommentsController.js +53 -0
  102. package/dist/modules/workflow/blocks/helpers/expandCommentsExtractor.js +129 -0
  103. package/dist/modules/workflow/blocks/helpers/macosVisionOcrPlugin.js +116 -0
  104. package/dist/modules/workflow/blocks/helpers/mergeXhsMarkdown.js +109 -0
  105. package/dist/modules/workflow/blocks/helpers/openDetailController.js +56 -0
  106. package/dist/modules/workflow/blocks/helpers/openDetailTypes.js +7 -0
  107. package/dist/modules/workflow/blocks/helpers/openDetailViewport.js +474 -0
  108. package/dist/modules/workflow/blocks/helpers/openDetailWaiter.js +104 -0
  109. package/dist/modules/workflow/blocks/helpers/operationLogger.js +195 -0
  110. package/dist/modules/workflow/blocks/helpers/persistedNotes.js +107 -0
  111. package/dist/modules/workflow/blocks/helpers/replyExpander.js +260 -0
  112. package/dist/modules/workflow/blocks/helpers/scrollIntoView.js +138 -0
  113. package/dist/modules/workflow/blocks/helpers/searchExecutor.js +328 -0
  114. package/dist/modules/workflow/blocks/helpers/searchGate.js +46 -0
  115. package/dist/modules/workflow/blocks/helpers/searchPageState.js +164 -0
  116. package/dist/modules/workflow/blocks/helpers/searchResultWaiter.js +64 -0
  117. package/dist/modules/workflow/blocks/helpers/simpleAnchor.js +134 -0
  118. package/dist/modules/workflow/blocks/helpers/smartReply.js +40 -0
  119. package/dist/modules/workflow/blocks/helpers/systemInput.js +635 -0
  120. package/dist/modules/workflow/blocks/helpers/targetCountMode.js +9 -0
  121. package/dist/modules/workflow/blocks/helpers/xhsCliArgs.js +80 -0
  122. package/dist/modules/workflow/blocks/helpers/xhsCommentDom.js +805 -0
  123. package/dist/modules/workflow/blocks/helpers/xhsNoteOrganizer.js +140 -0
  124. package/dist/modules/workflow/blocks/restore/RestorePhaseBlock.js +204 -0
  125. package/dist/modules/workflow/config/workflowRegistry.js +32 -0
  126. package/dist/modules/workflow/definitions/batch-collect-workflow.js +63 -0
  127. package/dist/modules/workflow/definitions/scroll-extract-workflow.js +74 -0
  128. package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow-v2.js +81 -0
  129. package/dist/modules/workflow/definitions/xiaohongshu-collect-workflow.js +57 -0
  130. package/dist/modules/workflow/definitions/xiaohongshu-full-collect-workflow-v3.js +68 -0
  131. package/dist/modules/workflow/definitions/xiaohongshu-note-collect.js +49 -0
  132. package/dist/modules/workflow/definitions/xiaohongshu-phase1-workflow-v3.js +30 -0
  133. package/dist/modules/workflow/definitions/xiaohongshu-phase2-links-workflow-v3.js +40 -0
  134. package/dist/modules/workflow/definitions/xiaohongshu-phase3-collect-workflow-v1.js +54 -0
  135. package/dist/modules/workflow/definitions/xiaohongshu-phase34-from-links-workflow-v3.js +25 -0
  136. package/dist/modules/workflow/src/WeiboEventDrivenWorkflowRunner.js +308 -0
  137. package/dist/modules/workflow/src/context.js +70 -0
  138. package/dist/modules/workflow/src/index.js +5 -0
  139. package/dist/modules/workflow/src/orchestrator.js +230 -0
  140. package/dist/modules/workflow/src/runner.js +55 -0
  141. package/dist/modules/workflow/src/runtime.js +70 -0
  142. package/dist/modules/workflow/workflows/WeiboFeedExtractionWorkflow.js +359 -0
  143. package/dist/modules/workflow/workflows/XiaohongshuLoginWorkflow.js +110 -0
  144. package/dist/modules/xiaohongshu/app/src/blocks/MatchCommentsBlock.js +139 -0
  145. package/dist/modules/xiaohongshu/app/src/blocks/Phase1EnsureServicesBlock.js +36 -0
  146. package/dist/modules/xiaohongshu/app/src/blocks/Phase1MonitorCookieBlock.js +213 -0
  147. package/dist/modules/xiaohongshu/app/src/blocks/Phase1StartProfileBlock.js +121 -0
  148. package/dist/modules/xiaohongshu/app/src/blocks/Phase2CollectLinksBlock.js +1249 -0
  149. package/dist/modules/xiaohongshu/app/src/blocks/Phase2SearchBlock.js +703 -0
  150. package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseDetailBlock.js +41 -0
  151. package/dist/modules/xiaohongshu/app/src/blocks/Phase34CloseTabsBlock.js +44 -0
  152. package/dist/modules/xiaohongshu/app/src/blocks/Phase34CollectCommentsBlock.js +150 -0
  153. package/dist/modules/xiaohongshu/app/src/blocks/Phase34ExtractDetailBlock.js +117 -0
  154. package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenDetailBlock.js +102 -0
  155. package/dist/modules/xiaohongshu/app/src/blocks/Phase34OpenTabsBlock.js +109 -0
  156. package/dist/modules/xiaohongshu/app/src/blocks/Phase34PersistDetailBlock.js +117 -0
  157. package/dist/modules/xiaohongshu/app/src/blocks/Phase34ProcessSingleNoteBlock.js +114 -0
  158. package/dist/modules/xiaohongshu/app/src/blocks/Phase34ValidateLinksBlock.js +90 -0
  159. package/dist/modules/xiaohongshu/app/src/blocks/Phase3InteractBlock.js +1009 -0
  160. package/dist/modules/xiaohongshu/app/src/blocks/Phase4MultiTabHarvestBlock.js +233 -0
  161. package/dist/modules/xiaohongshu/app/src/blocks/ReplyInteractBlock.js +291 -0
  162. package/dist/modules/xiaohongshu/app/src/blocks/XhsDiscoverFallbackBlock.js +240 -0
  163. package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatchDsl.js +126 -0
  164. package/dist/modules/xiaohongshu/app/src/blocks/helpers/commentMatcher.js +99 -0
  165. package/dist/modules/xiaohongshu/app/src/blocks/helpers/evidence.js +27 -0
  166. package/dist/modules/xiaohongshu/app/src/blocks/helpers/sharding.js +42 -0
  167. package/dist/modules/xiaohongshu/app/src/blocks/helpers/xhsComments.js +270 -0
  168. package/dist/modules/xiaohongshu/app/src/index.js +9 -0
  169. package/dist/modules/xiaohongshu/app/src/utils/checkpoints.js +222 -0
  170. package/dist/modules/xiaohongshu/app/src/utils/controllerAction.js +43 -0
  171. package/dist/services/controller/src/controller.js +1476 -0
  172. package/dist/services/controller/src/index.js +2 -0
  173. package/dist/services/controller/src/payload-normalizer.js +129 -0
  174. package/dist/services/shared/heartbeat.js +120 -0
  175. package/dist/services/shared/lib/errorHandler.js +2 -0
  176. package/dist/services/shared/serviceProcessLogger.js +139 -0
  177. package/dist/services/unified-api/RemoteBrowserSession.js +176 -0
  178. package/dist/services/unified-api/RemoteSessionManager.js +148 -0
  179. package/dist/services/unified-api/container-operations-handler.js +115 -0
  180. package/dist/services/unified-api/server.js +652 -0
  181. package/dist/services/unified-api/state-registry.js +274 -0
  182. package/dist/services/unified-api/task-persistence.js +66 -0
  183. package/dist/services/unified-api/task-state.js +130 -0
  184. package/modules/camo-runtime/src/autoscript/action-providers/xhs/search.mjs +12 -5
  185. package/modules/xiaohongshu/app/pnpm-lock.yaml +24 -0
  186. package/package.json +37 -9
  187. package/.beads/README.md +0 -81
  188. package/.beads/config.yaml +0 -67
  189. package/.beads/interactions.jsonl +0 -0
  190. package/.beads/issues.jsonl +0 -180
  191. package/.beads/metadata.json +0 -4
  192. package/.claude/settings.local.json +0 -10
  193. package/.github/workflows/ci.yml +0 -55
  194. package/AGENTS.md +0 -253
  195. package/apps/desktop-console/README.md +0 -27
  196. package/apps/desktop-console/package-lock.json +0 -897
  197. package/apps/desktop-console/package.json +0 -20
  198. package/apps/desktop-console/scripts/build-and-install.mjs +0 -19
  199. package/apps/desktop-console/scripts/build.mjs +0 -45
  200. package/apps/desktop-console/scripts/test-preload.mjs +0 -13
  201. package/apps/desktop-console/src/main/config.mts +0 -26
  202. package/apps/desktop-console/src/main/core-daemon-manager.mts +0 -131
  203. package/apps/desktop-console/src/main/desktop-settings.mts +0 -267
  204. package/apps/desktop-console/src/main/heartbeat-watchdog.mts +0 -50
  205. package/apps/desktop-console/src/main/heartbeat-watchdog.test.mts +0 -68
  206. package/apps/desktop-console/src/main/index-streaming.test.mts +0 -20
  207. package/apps/desktop-console/src/main/index.mts +0 -980
  208. package/apps/desktop-console/src/main/profile-store.mts +0 -239
  209. package/apps/desktop-console/src/main/profile-store.test.mts +0 -54
  210. package/apps/desktop-console/src/main/state-bridge.mts +0 -114
  211. package/apps/desktop-console/src/main/task-state-types.ts +0 -32
  212. package/apps/desktop-console/src/renderer/hooks/use-task-state.mts +0 -120
  213. package/apps/desktop-console/src/renderer/index.mts +0 -133
  214. package/apps/desktop-console/src/renderer/index.test.mts +0 -34
  215. package/apps/desktop-console/src/renderer/path-helpers.mts +0 -46
  216. package/apps/desktop-console/src/renderer/path-helpers.test.mts +0 -14
  217. package/apps/desktop-console/src/renderer/tabs/debug.mts +0 -48
  218. package/apps/desktop-console/src/renderer/tabs/debug.test.mts +0 -22
  219. package/apps/desktop-console/src/renderer/tabs/logs.mts +0 -421
  220. package/apps/desktop-console/src/renderer/tabs/logs.test.mts +0 -27
  221. package/apps/desktop-console/src/renderer/tabs/preflight.mts +0 -486
  222. package/apps/desktop-console/src/renderer/tabs/preflight.test.mts +0 -33
  223. package/apps/desktop-console/src/renderer/tabs/profile-pool.mts +0 -213
  224. package/apps/desktop-console/src/renderer/tabs/results.mts +0 -171
  225. package/apps/desktop-console/src/renderer/tabs/run.test.mts +0 -63
  226. package/apps/desktop-console/src/renderer/tabs/runtime.mts +0 -151
  227. package/apps/desktop-console/src/renderer/tabs/settings.mts +0 -146
  228. package/apps/desktop-console/src/renderer/tabs/xiaohongshu/account-flow.mts +0 -486
  229. package/apps/desktop-console/src/renderer/tabs/xiaohongshu/guide-browser-check.mts +0 -56
  230. package/apps/desktop-console/src/renderer/tabs/xiaohongshu/helpers.mts +0 -262
  231. package/apps/desktop-console/src/renderer/tabs/xiaohongshu/layout-block.mts +0 -430
  232. package/apps/desktop-console/src/renderer/tabs/xiaohongshu/live-stats.mts +0 -847
  233. package/apps/desktop-console/src/renderer/tabs/xiaohongshu/run-flow.mts +0 -443
  234. package/apps/desktop-console/src/renderer/tabs/xiaohongshu-state.mts +0 -425
  235. package/apps/desktop-console/src/renderer/tabs/xiaohongshu.mts +0 -497
  236. package/apps/desktop-console/src/renderer/tabs/xiaohongshu.test.mts +0 -291
  237. package/apps/desktop-console/src/renderer/ui-components.mts +0 -31
  238. package/docs/README_camoufox_chinese.md +0 -141
  239. package/docs/USAGE_V3.md +0 -163
  240. package/docs/arch/OCR_MACOS_PLUGIN.md +0 -39
  241. package/docs/arch/PORTS.md +0 -40
  242. package/docs/arch/REGRESSION_CHECKLIST.md +0 -121
  243. package/docs/arch/SEARCH_GATE.md +0 -224
  244. package/docs/arch/VIEWPORT_SAFETY.md +0 -182
  245. package/docs/arch/XIAOHONGSHU_OFFLINE_MOCK_DESIGN.md +0 -267
  246. package/docs/xiaohongshu-container-driven-summary.md +0 -221
  247. package/docs/xiaohongshu-full-collect-runbook.md +0 -134
  248. package/docs/xiaohongshu-next-steps.md +0 -228
  249. package/docs/xiaohongshu-quickstart.md +0 -73
  250. package/docs/xiaohongshu-workflow-summary.md +0 -227
  251. package/modules/container-registry/tests/container-registry.test.ts +0 -16
  252. package/modules/logging/tests/logging.test.ts +0 -38
  253. package/modules/operations/tests/operations.test.ts +0 -22
  254. package/modules/operations/tests/viewport-filter.test.ts +0 -161
  255. package/modules/operations/tests/visible-only.test.ts +0 -250
  256. package/modules/session-manager/tests/session-manager.test.ts +0 -23
  257. package/modules/state/src/atomic-json.test.ts +0 -30
  258. package/modules/state/src/paths.test.ts +0 -59
  259. package/modules/state/src/xiaohongshu-collect-state.test.ts +0 -259
  260. package/modules/workflow/blocks/AnchorVerificationBlock.d.ts.map +0 -1
  261. package/modules/workflow/blocks/AnchorVerificationBlock.js.map +0 -1
  262. package/modules/workflow/blocks/DetectPageStateBlock.d.ts.map +0 -1
  263. package/modules/workflow/blocks/DetectPageStateBlock.js.map +0 -1
  264. package/modules/workflow/blocks/ErrorRecoveryBlock.d.ts.map +0 -1
  265. package/modules/workflow/blocks/ErrorRecoveryBlock.js.map +0 -1
  266. package/modules/workflow/blocks/WaitSearchPermitBlock.d.ts.map +0 -1
  267. package/modules/workflow/blocks/WaitSearchPermitBlock.js.map +0 -1
  268. package/modules/workflow/blocks/helpers/containerAnchors.d.ts.map +0 -1
  269. package/modules/workflow/blocks/helpers/containerAnchors.js.map +0 -1
  270. package/modules/workflow/blocks/helpers/downloadPaths.test.ts +0 -62
  271. package/modules/workflow/blocks/helpers/mergeXhsMarkdown.test.ts +0 -121
  272. package/modules/workflow/blocks/helpers/operationLogger.d.ts.map +0 -1
  273. package/modules/workflow/blocks/helpers/operationLogger.js.map +0 -1
  274. package/modules/workflow/blocks/helpers/persistedNotes.test.ts +0 -268
  275. package/modules/workflow/blocks/helpers/searchPageState.d.ts.map +0 -1
  276. package/modules/workflow/blocks/helpers/searchPageState.js.map +0 -1
  277. package/modules/workflow/blocks/helpers/targetCountMode.test.ts +0 -29
  278. package/modules/workflow/blocks/helpers/xhsCliArgs.test.ts +0 -75
  279. package/modules/workflow/tests/smartReply.test.ts +0 -32
  280. package/modules/xiaohongshu/app/src/blocks/Phase3Interact.matcher.test.ts +0 -33
  281. package/modules/xiaohongshu/app/src/utils/__tests__/checkpoints.test.ts +0 -141
  282. package/modules/xiaohongshu/app/tests/commentMatchDsl.test.ts +0 -50
  283. package/modules/xiaohongshu/app/tests/commentMatcher.test.ts +0 -46
  284. package/modules/xiaohongshu/app/tests/sharding.test.ts +0 -31
  285. package/package-scripts.json +0 -8
  286. package/runtime/infra/utils/README.md +0 -13
  287. package/runtime/infra/utils/scripts/README.md +0 -0
  288. package/runtime/infra/utils/scripts/development/eval-in-session.mjs +0 -40
  289. package/runtime/infra/utils/scripts/development/highlight-search-containers.mjs +0 -35
  290. package/runtime/infra/utils/scripts/service/kill-port.mjs +0 -24
  291. package/runtime/infra/utils/scripts/service/start-api.mjs +0 -39
  292. package/runtime/infra/utils/scripts/service/start-browser-service.mjs +0 -106
  293. package/runtime/infra/utils/scripts/service/stop-api.mjs +0 -18
  294. package/runtime/infra/utils/scripts/service/stop-browser-service.mjs +0 -104
  295. package/runtime/infra/utils/scripts/test-services.mjs +0 -94
  296. package/services/shared/heartbeat.test.ts +0 -102
  297. package/services/unified-api/__tests__/task-state.test.ts +0 -95
  298. package/sitecustomize.py +0 -19
  299. package/tests/README.md +0 -194
  300. package/tests/e2e/workflows/weibo-feed-extraction.test.ts +0 -171
  301. package/tests/fixtures/data/container-definitions.json +0 -67
  302. package/tests/fixtures/pages/simple-page.html +0 -69
  303. package/tests/integration/01-test-container-match.mjs +0 -188
  304. package/tests/integration/02-test-dom-branch.mjs +0 -161
  305. package/tests/integration/03-test-container-operation-system.mjs +0 -91
  306. package/tests/integration/05-test-container-lifecycle-events.mjs +0 -224
  307. package/tests/integration/05-test-container-lifecycle-with-events.mjs +0 -250
  308. package/tests/integration/06-test-container-dom-tree-drawing.mjs +0 -256
  309. package/tests/integration/07-test-weibo-container-lifecycle.mjs +0 -355
  310. package/tests/integration/08-test-weibo-feed-workflow.test.mjs +0 -164
  311. package/tests/integration/10-test-visual-analyzer.mjs +0 -312
  312. package/tests/integration/11-test-visual-loop.mjs +0 -284
  313. package/tests/integration/12-test-simple-visual-loop.mjs +0 -242
  314. package/tests/integration/13-test-visual-robust.mjs +0 -185
  315. package/tests/integration/14-test-visual-highlight-loop.mjs +0 -271
  316. package/tests/integration/inspect-page.mjs +0 -50
  317. package/tests/integration/run-all-tests.mjs +0 -95
  318. package/tests/patch_verification/CODEX_PATCH_TEST.md +0 -103
  319. package/tests/patch_verification/PHASE2_ANALYSIS.md +0 -179
  320. package/tests/patch_verification/PHASE2_OPTIMIZATION_REPORT.md +0 -55
  321. package/tests/patch_verification/PHASE2_TO_PHASE4_SUMMARY.md +0 -126
  322. package/tests/patch_verification/QUICK_TEST_SEQUENCE.md +0 -262
  323. package/tests/patch_verification/README.md +0 -143
  324. package/tests/patch_verification/RUN_TESTS.md +0 -60
  325. package/tests/patch_verification/TEST_EXECUTION.md +0 -99
  326. package/tests/patch_verification/TEST_PLAN.md +0 -328
  327. package/tests/patch_verification/TEST_RESULTS.md +0 -34
  328. package/tests/patch_verification/TOOL_TEST_PLAN.md +0 -48
  329. package/tests/patch_verification/run-tool-test.mjs +0 -121
  330. package/tests/patch_verification/temp_test_files/test01.txt +0 -1
  331. package/tests/patch_verification/temp_test_files/test02.txt +0 -3
  332. package/tests/patch_verification/temp_test_files/test02_gnu.txt +0 -3
  333. package/tests/patch_verification/temp_test_files/test03.txt +0 -1
  334. package/tests/patch_verification/temp_test_files/test03_multiline.txt +0 -5
  335. package/tests/patch_verification/temp_test_files/test04_function.ts +0 -5
  336. package/tests/patch_verification/temp_test_files/test05_import.ts +0 -4
  337. package/tests/patch_verification/temp_test_files/test06_special_chars.txt +0 -4
  338. package/tests/patch_verification/temp_test_files/test07_indentation.ts +0 -5
  339. package/tests/patch_verification/temp_test_files/test08_mismatch.txt +0 -1
  340. package/tests/patch_verification/temp_test_files/test_add_02.txt +0 -3
  341. package/tests/patch_verification/temp_test_files/test_simple.txt +0 -1
  342. package/tests/runner/TestReporter.mjs +0 -57
  343. package/tests/runner/TestRunner.mjs +0 -244
  344. package/tests/unit/commands/profile.test.mjs +0 -10
  345. package/tests/unit/container/change-notifier.test.mjs +0 -181
  346. package/tests/unit/lifecycle/session-registry.test.mjs +0 -135
  347. package/tests/unit/operations/registry.test.ts +0 -73
  348. package/tests/unit/utils/browser-service.test.mjs +0 -153
  349. package/tests/unit/utils/config.test.mjs +0 -166
  350. package/tests/unit/utils/fingerprint.test.mjs +0 -166
  351. package/tsconfig.json +0 -31
  352. package/tsconfig.services.json +0 -26
  353. /package/apps/desktop-console/{src → dist}/renderer/index.html +0 -0
  354. /package/apps/desktop-console/{src/renderer/tabs → dist/renderer}/run.mts +0 -0
@@ -1,430 +0,0 @@
1
- import { createEl } from '../../ui-components.mjs';
2
- import { LikeRuleDraft, LikeRuleKind, XhsLastConfig, attachTooltip, bindSectionToggle, likeRuleGuide, makeCheckbox, makeNumberInput, makeTextInput, parseLikeRulesCsv, stringifyLikeRule } from './helpers.mjs';
3
- type BuildLayoutOptions = { createTile: (id: string, titleText: string) => { tile: HTMLDivElement; body: HTMLDivElement }; card: HTMLDivElement; tileLane: HTMLDivElement; guideLockMask: HTMLDivElement; onboardingCard: HTMLDivElement; persistedConfig: XhsLastConfig };
4
- export function buildXhsLayout(opts: BuildLayoutOptions) {
5
- const { createTile, card, tileLane, guideLockMask, onboardingCard, persistedConfig } = opts;
6
- let persistLastConfigHook = () => {};
7
- let persistLikeRuleAHistoryHook = () => {};
8
- let persistLikeRuleBHistoryHook = () => {};
9
- const orchestrateModeSelect = createEl('select', { style: 'width:280px;' }) as HTMLSelectElement;
10
- orchestrateModeSelect.appendChild(createEl('option', { value: 'phase1-phase2-unified', selected: true }, ['完整编排:Phase1 + Phase2 + Unified']));
11
- orchestrateModeSelect.appendChild(createEl('option', { value: 'phase1-phase2' }, ['仅预处理:Phase1 + Phase2']));
12
- orchestrateModeSelect.appendChild(createEl('option', { value: 'phase1-only' }, ['仅启动浏览器:Phase1']));
13
- orchestrateModeSelect.appendChild(createEl('option', { value: 'unified-only' }, ['仅执行 Unified(使用已有 links)']));
14
- const keywordInput = makeTextInput('黄金走势', '关键词');
15
- const envInput = makeTextInput('debug', 'env');
16
- const accountModeSelect = createEl('select', { style: 'width:220px;' }) as HTMLSelectElement;
17
- accountModeSelect.appendChild(createEl('option', { value: 'single', selected: true }, ['单账号(一个 profile)']));
18
- accountModeSelect.appendChild(createEl('option', { value: 'shards' }, ['分片并发(多个 profiles)']));
19
- const profilePickSel = createEl('select', { style: 'min-width:360px; max-width:580px;' }) as HTMLSelectElement;
20
- profilePickSel.appendChild(createEl('option', { value: '' }, ['(请选择账号:alias / profile)']));
21
- const profileRefreshBtn = createEl('button', { type: 'button', className: 'secondary' }, ['刷新 profiles']) as HTMLButtonElement;
22
- const shardProfilesBox = createEl('div', {
23
- className: 'list',
24
- style: 'width:100%; max-height:156px; overflow:auto; border:1px solid #1f2937; border-radius:6px; padding:6px;',
25
- });
26
- const shardProfilesHint = createEl('div', { className: 'muted', style: 'font-size:12px; margin-top:6px;' }, ['selected=0']) as HTMLDivElement;
27
- const shardResolvedHint = createEl('div', { className: 'muted', style: 'font-size:12px; margin-top:4px;' }, ['']) as HTMLDivElement;
28
- const maxNotesInput = makeNumberInput('100', '1');
29
- const dryRunCheckbox = makeCheckbox(true, 'xh-dry-run');
30
- const protocolModeCheckbox = makeCheckbox(true, 'xh-protocol-mode');
31
- const headlessCheckbox = makeCheckbox(true, 'xh-headless');
32
- const modeHint = createEl('div', { style: 'margin-bottom:8px; color:#64748b; font-size:12px;' }, [
33
- '完整编排推荐:先 Phase1 启动,再 Phase2 采集链接,最后 Unified 采集评论/点赞。',
34
- ]);
35
- const baseParamsTile = createEl('div', { style: 'display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin-bottom:10px;' });
36
- const tileBase1 = createEl('div', { className: 'xhs-bento-card' });
37
- tileBase1.appendChild(createEl('div', { style: 'font-weight:600; margin-bottom:8px; font-size:13px; color:#2b67ff;' }, ['📋 编排设置']));
38
- tileBase1.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:6px;' }, [
39
- createEl('label', { style: 'font-size:12px;' }, ['模式']), orchestrateModeSelect,
40
- ]));
41
- tileBase1.appendChild(createEl('div', { className: 'row', style: 'gap:6px;' }, [
42
- createEl('label', { style: 'font-size:12px;' }, ['关键词']), keywordInput,
43
- ]));
44
- baseParamsTile.appendChild(tileBase1);
45
- const tileBase2 = createEl('div', { className: 'xhs-bento-card' });
46
- tileBase2.appendChild(createEl('div', { style: 'font-weight:600; margin-bottom:8px; font-size:13px; color:#2b67ff;' }, ['🔧 环境账号']));
47
- tileBase2.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:6px;' }, [
48
- createEl('label', { style: 'font-size:12px;' }, ['环境']), envInput,
49
- ]));
50
- tileBase2.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:6px;' }, [
51
- createEl('label', { style: 'font-size:12px;' }, ['账号模式']), accountModeSelect,
52
- ]));
53
- const singleProfileRow = createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:6px;' }, [
54
- createEl('label', { style: 'font-size:12px;' }, ['单账号(账号名 / profile)']), profilePickSel, profileRefreshBtn,
55
- ]) as HTMLDivElement;
56
- const singleProfileHint = createEl('div', { className: 'muted', style: 'font-size:12px; margin:-2px 0 6px 0;' }, [
57
- '当前实际使用:(未选择账号)',
58
- ]) as HTMLDivElement;
59
- const shardProfilesSection = createEl('div', { style: 'margin-top:6px;' }) as HTMLDivElement;
60
- shardProfilesSection.appendChild(createEl('div', { className: 'muted', style: 'font-size:12px; margin-bottom:4px;' }, ['分片 profiles(仅分片模式生效)']));
61
- shardProfilesSection.appendChild(shardProfilesBox);
62
- shardProfilesSection.appendChild(shardProfilesHint);
63
- shardProfilesSection.appendChild(shardResolvedHint);
64
- tileBase2.appendChild(singleProfileRow);
65
- tileBase2.appendChild(singleProfileHint);
66
- tileBase2.appendChild(shardProfilesSection);
67
- shardProfilesBox.style.marginTop = '0';
68
- const accountAuditSummary = createEl('div', { className: 'muted', style: 'font-size:12px;' }, ['账号检查:待刷新']) as HTMLDivElement;
69
- const accountAuditList = createEl('div', { className: 'xhs-account-list' }) as HTMLDivElement;
70
- const accountRefreshBtn = createEl('button', { type: 'button', className: 'secondary' }, ['检查账号状态']) as HTMLButtonElement;
71
- const accountLiveProbeBtn = createEl('button', { type: 'button', className: 'secondary' }, ['实时探测登录']) as HTMLButtonElement;
72
- const addAccountCountInput = makeNumberInput('1', '1', '64px');
73
- const addBatchNameInput = makeTextInput('', '账号名前缀(默认当前 batch / xiaohongshu)', '220px');
74
- const accountAddBtn = createEl('button', { type: 'button' }, ['新增账号(headful/camoufox)']) as HTMLButtonElement;
75
- const accountNextLikeBtn = createEl('button', { type: 'button', className: 'secondary' }, ['下一步:点赞设置']) as HTMLButtonElement;
76
- const batchKeyValue = createEl('div', { className: 'muted', style: 'font-size:12px; min-width:160px;' }, ['xiaohongshu']) as HTMLDivElement;
77
- const batchNextBtn = createEl('button', { type: 'button', className: 'secondary' }, ['新建批次']) as HTMLButtonElement;
78
- const accountAuditCard = createEl('div', { className: 'xhs-compact-card xhs-bento-card' });
79
- accountAuditCard.appendChild(createEl('div', { style: 'font-weight:600; margin-bottom:6px; color:#dbeafe;' }, ['账号检查与新增']));
80
- accountAuditCard.appendChild(accountAuditSummary);
81
- accountAuditCard.appendChild(accountAuditList);
82
- accountAuditCard.appendChild(createEl('div', { className: 'row', style: 'margin-top:8px; margin-bottom:6px;' }, [
83
- accountRefreshBtn,
84
- accountLiveProbeBtn,
85
- createEl('label', { style: 'font-size:12px; color:#8b93a6;' }, ['新增账号数']),
86
- addAccountCountInput,
87
- createEl('label', { style: 'font-size:12px; color:#8b93a6;' }, ['账号名前缀']),
88
- addBatchNameInput,
89
- accountAddBtn,
90
- ]));
91
- accountAuditCard.appendChild(createEl('div', { className: 'row', style: 'margin-top:4px; margin-bottom:6px;' }, [
92
- createEl('label', { style: 'font-size:12px; color:#8b93a6;' }, ['当前批次']),
93
- batchKeyValue,
94
- batchNextBtn,
95
- ]));
96
- accountAuditCard.appendChild(createEl('div', { className: 'row', style: 'margin-bottom:0;' }, [accountNextLikeBtn]));
97
- // accountAuditCard is placed as an independent card in account bento grid
98
- baseParamsTile.appendChild(tileBase2);
99
- const tileBase3 = createEl('div', { className: 'xhs-bento-card' });
100
- tileBase3.appendChild(createEl('div', { style: 'font-weight:600; margin-bottom:8px; font-size:13px; color:#2b67ff;' }, ['⚙️ 运行选项']));
101
- tileBase3.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:6px;' }, [
102
- createEl('label', { style: 'font-size:12px;' }, ['目标帖子']), maxNotesInput,
103
- ]));
104
- tileBase3.appendChild(createEl('div', { className: 'row', style: 'gap:8px; margin-bottom:6px;' }, [
105
- dryRunCheckbox,
106
- createEl('label', { htmlFor: 'xh-dry-run', style: 'font-size:12px; color:#a87b00; cursor:pointer;' }, ['Dry Run']),
107
- ]));
108
- tileBase3.appendChild(createEl('div', { className: 'row', style: 'gap:8px; margin-bottom:6px;' }, [
109
- headlessCheckbox,
110
- createEl('label', { htmlFor: 'xh-headless', style: 'font-size:12px; color:#2b67ff; cursor:pointer;' }, ['无头模式']),
111
- ]));
112
- tileBase3.appendChild(createEl('div', { className: 'row', style: 'gap:8px;' }, [
113
- protocolModeCheckbox,
114
- createEl('label', { htmlFor: 'xh-protocol-mode', style: 'font-size:12px; color:#14532d; cursor:pointer;' }, ['协议级操作']),
115
- ]));
116
- baseParamsTile.appendChild(tileBase3);
117
- const featureTiles = createEl('div', { style: 'display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:10px; margin-bottom:10px; align-items:start; grid-auto-rows:min-content;' });
118
- const homepageToggle = makeCheckbox(false, 'xh-do-homepage');
119
- const imagesToggle = makeCheckbox(false, 'xh-do-images');
120
- const homeSection = createEl('div', { className: 'xhs-bento-card' });
121
- homeSection.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:8px;' }, [
122
- homepageToggle,
123
- createEl('label', { htmlFor: 'xh-do-homepage', style: 'cursor:pointer; font-weight:600;' }, ['主页内容采集(正文/作者/链接)']),
124
- ]));
125
- const homeBody = createEl('div', { style: 'padding-left:24px;' });
126
- homeBody.appendChild(createEl('div', { className: 'row', style: 'gap:6px;' }, [
127
- imagesToggle,
128
- createEl('label', { htmlFor: 'xh-do-images', style: 'cursor:pointer;' }, ['同时下载图片']),
129
- ]));
130
- homeSection.appendChild(homeBody);
131
- attachTooltip(homeSection, '主页采集:抓取帖子正文、作者和主贴链接;若勾选图片下载,会额外下载图片。');
132
- bindSectionToggle(homepageToggle, homeBody);
133
- homepageToggle.addEventListener('change', () => { if (!homepageToggle.checked) imagesToggle.checked = false; });
134
- featureTiles.appendChild(homeSection);
135
- const commentsToggle = makeCheckbox(true, 'xh-do-comments');
136
- const maxCommentsInput = makeNumberInput('0', '0');
137
- const commentRoundsInput = makeNumberInput('0', '0');
138
- const commentsSection = createEl('div', { className: 'xhs-bento-card' });
139
- commentsSection.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:8px;' }, [
140
- commentsToggle,
141
- createEl('label', { htmlFor: 'xh-do-comments', style: 'cursor:pointer; font-weight:600;' }, ['评论采集']),
142
- ]));
143
- const commentsBody = createEl('div', { style: 'padding-left:24px;' });
144
- commentsBody.appendChild(createEl('div', { className: 'row', style: 'gap:8px; margin-bottom:6px;' }, [
145
- createEl('label', { style: 'width:86px;' }, ['每帖上限(0=不限)']), maxCommentsInput,
146
- ]));
147
- commentsBody.appendChild(createEl('div', { className: 'row', style: 'gap:8px;' }, [
148
- createEl('label', { style: 'width:86px;' }, ['滚屏轮次(0=不限)']), commentRoundsInput,
149
- ]));
150
- commentsSection.appendChild(commentsBody);
151
- attachTooltip(commentsSection, '评论采集:抓取评论区内容;可配置每帖最大评论数与滚屏轮次。');
152
- bindSectionToggle(commentsToggle, commentsBody);
153
- featureTiles.appendChild(commentsSection);
154
- const gateToggle = makeCheckbox(false, 'xh-do-gate');
155
- const gateSection = createEl('div', { className: 'xhs-bento-card' });
156
- gateSection.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:8px;' }, [
157
- gateToggle,
158
- createEl('label', { htmlFor: 'xh-do-gate', style: 'cursor:pointer; font-weight:600;' }, ['评论命中规则(用于回复/兜底匹配)']),
159
- ]));
160
- const matchKeywordsInput = makeTextInput('操底,上链接', '逗号分隔关键词');
161
- const matchModeSelect = createEl('select', { style: 'width:120px;' }) as HTMLSelectElement;
162
- matchModeSelect.appendChild(createEl('option', { value: 'any', selected: true }, ['任一命中']));
163
- matchModeSelect.appendChild(createEl('option', { value: 'atLeast' }, ['至少N个']));
164
- matchModeSelect.appendChild(createEl('option', { value: 'all' }, ['全部命中']));
165
- const matchMinHitsInput = makeNumberInput('2', '1', '74px');
166
- const gateBody = createEl('div', { style: 'padding-left:24px;' });
167
- gateBody.appendChild(createEl('div', { className: 'row', style: 'gap:8px; margin-bottom:6px;' }, [
168
- createEl('label', { style: 'width:86px;' }, ['关键词']), matchKeywordsInput,
169
- ]));
170
- gateBody.appendChild(createEl('div', { className: 'row', style: 'gap:8px;' }, [
171
- createEl('label', { style: 'width:86px;' }, ['匹配模式']), matchModeSelect,
172
- createEl('label', { style: 'width:62px; margin-left:8px;' }, ['最少命中']), matchMinHitsInput,
173
- ]));
174
- gateSection.appendChild(gateBody);
175
- attachTooltip(gateSection, '命中规则:根据关键词筛选评论;通常与自动回复联动使用。');
176
- bindSectionToggle(gateToggle, gateBody);
177
- featureTiles.appendChild(gateSection);
178
- const likesToggle = makeCheckbox(false, 'xh-do-likes');
179
- const maxLikesInput = makeNumberInput('2', '1');
180
- const likesSection = createEl('div', { className: 'xhs-bento-card' });
181
- likesSection.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:8px;' }, [
182
- likesToggle,
183
- createEl('label', { htmlFor: 'xh-do-likes', style: 'cursor:pointer; font-weight:600;' }, ['评论点赞']),
184
- ]));
185
- const likesBody = createEl('div', { className: 'xhs-bento-grid xhs-bento-grid--tight' });
186
- const tile1 = createEl('div', { className: 'xhs-compact-card', style: 'display:flex; flex-direction:column;' });
187
- tile1.appendChild(createEl('div', { style: 'font-weight:600; margin-bottom:8px; font-size:13px; color:#2b67ff;' }, ['📊 数量限制']));
188
- tile1.appendChild(createEl('div', { className: 'row', style: 'gap:6px; flex-wrap:nowrap;' }, [
189
- createEl('label', { style: 'font-size:12px; white-space:nowrap; color:#8b93a6;' }, ['每轮滚动点赞上限']),
190
- maxLikesInput,
191
- ]));
192
- likesBody.appendChild(tile1);
193
- const likeRuleTypeSelect = createEl('select', { style: 'width:100%; font-size:12px;' }) as HTMLSelectElement;
194
- likeRuleTypeSelect.appendChild(createEl('option', { value: 'contains' }, ['单关键词']));
195
- likeRuleTypeSelect.appendChild(createEl('option', { value: 'and' }, ['同时包含 {A+B}']));
196
- likeRuleTypeSelect.appendChild(createEl('option', { value: 'include_without' }, ['包含排除 {A-B}']));
197
- const tile2 = createEl('div', { className: 'xhs-compact-card', style: 'display:flex; flex-direction:column;' });
198
- tile2.appendChild(createEl('div', { style: 'font-weight:600; margin-bottom:8px; font-size:13px; color:#2b67ff;' }, ['🎯 匹配模式']));
199
- tile2.appendChild(likeRuleTypeSelect);
200
- const likeRuleHelp = createEl('div', { style: 'color:#8b93a6; font-size:10px; margin-top:6px; line-height:1.4;' });
201
- tile2.appendChild(likeRuleHelp);
202
- likesBody.appendChild(tile2);
203
- const likeRuleAInput = makeTextInput('', '词A', '100%');
204
- const likeRuleBInput = makeTextInput('', '词B (可选)', '100%');
205
- const addLikeRuleBtn = createEl('button', { type: 'button', style: 'width:100%; font-size:12px;' }, ['+ 添加规则']) as HTMLButtonElement;
206
- const tile3 = createEl('div', { className: 'xhs-compact-card', style: 'display:flex; flex-direction:column;' });
207
- tile3.appendChild(createEl('div', { style: 'font-weight:600; margin-bottom:8px; font-size:13px; color:#2b67ff;' }, ['➕ 添加规则']));
208
- tile3.appendChild(createEl('div', { style: 'margin-bottom:6px;' }, [likeRuleAInput]));
209
- tile3.appendChild(createEl('div', { style: 'margin-bottom:6px;' }, [likeRuleBInput]));
210
- tile3.appendChild(addLikeRuleBtn);
211
- likesBody.appendChild(tile3);
212
- const likeRules: LikeRuleDraft[] = [
213
- { kind: 'contains', a: '操底' },
214
- { kind: 'contains', a: '上链接' },
215
- ];
216
- const likeRuleList = createEl('div', { style: 'display:flex; flex-wrap:wrap; gap:6px;' });
217
- const likeRulePreview = createEl('input', { type: 'hidden', readOnly: true }) as HTMLInputElement;
218
- const refreshLikeGuide = () => {
219
- const kind = (likeRuleTypeSelect.value || 'contains') as LikeRuleKind;
220
- const g = likeRuleGuide(kind);
221
- likeRuleHelp.textContent = `${g.title}:${g.desc}`;
222
- likeRuleBInput.disabled = kind === 'contains';
223
- likeRuleBInput.style.opacity = kind === 'contains' ? '0.5' : '1';
224
- likeRuleBInput.placeholder = kind === 'contains' ? '(单关键词无需词B)' : '词B';
225
- if (kind === 'contains') likeRuleBInput.value = '';
226
- };
227
- const refreshLikeRuleList = () => {
228
- likeRuleList.innerHTML = '';
229
- if (likeRules.length === 0) {
230
- likeRuleList.appendChild(createEl('span', { style: 'color:#666; font-size:11px;' }, ['暂无规则']));
231
- }
232
- likeRules.forEach((rule, idx) => {
233
- const chip = createEl('div', {
234
- style: 'display:inline-flex; align-items:center; gap:4px; background:#1b2233; border:1px solid #2b67ff; border-radius:6px; padding:4px 8px; font-size:12px;',
235
- });
236
- chip.appendChild(createEl('span', {}, [stringifyLikeRule(rule)]));
237
- const rmBtn = createEl('span', { style: 'cursor:pointer; color:#ff6b6b; margin-left:4px; font-weight:bold;' }, ['×']) as HTMLSpanElement;
238
- rmBtn.onclick = () => {
239
- likeRules.splice(idx, 1);
240
- refreshLikeRuleList();
241
- persistLastConfigHook();
242
- };
243
- chip.appendChild(rmBtn);
244
- likeRuleList.appendChild(chip);
245
- });
246
- likeRulePreview.value = likeRules.map((rule) => stringifyLikeRule(rule)).join(',');
247
- };
248
- addLikeRuleBtn.onclick = () => {
249
- const kind = (likeRuleTypeSelect.value || 'contains') as LikeRuleKind;
250
- const a = String(likeRuleAInput.value || '').trim();
251
- const b = String(likeRuleBInput.value || '').trim();
252
- if (!a) {
253
- alert('请先填写词A');
254
- return;
255
- }
256
- if (kind !== 'contains' && !b) {
257
- alert('当前规则需要词B');
258
- return;
259
- }
260
- likeRules.push({ kind, a, b: kind === 'contains' ? '' : b });
261
- persistLikeRuleAHistoryHook();
262
- persistLikeRuleBHistoryHook();
263
- likeRuleAInput.value = '';
264
- likeRuleBInput.value = '';
265
- refreshLikeRuleList();
266
- persistLastConfigHook();
267
- };
268
- likeRuleTypeSelect.onchange = refreshLikeGuide;
269
- const persistedLikeRules = parseLikeRulesCsv(String(persistedConfig.likeRules || ''));
270
- if (persistedLikeRules.length > 0) {
271
- likeRules.splice(0, likeRules.length, ...persistedLikeRules);
272
- }
273
- refreshLikeGuide();
274
- refreshLikeRuleList();
275
- const ruleListRow = createEl('div', { style: 'grid-column:1 / -1; margin-top:4px; border:1px solid #23262f; border-radius:8px; padding:8px; background:#0b1220;' });
276
- ruleListRow.appendChild(createEl('div', { style: 'font-size:11px; color:#8b93a6; margin-bottom:6px;' }, ['已添加规则(点击 × 删除):']));
277
- ruleListRow.appendChild(likeRuleList);
278
- likesBody.appendChild(ruleListRow);
279
- likesSection.appendChild(likesBody);
280
- attachTooltip(likesSection, '评论点赞:按规则对评论点赞;需配置关键词规则和点赞上限。');
281
- const likeNextBoardBtn = createEl('button', { type: 'button', className: 'secondary' }, ['点赞设置完成:回看板']) as HTMLButtonElement;
282
- likesSection.appendChild(createEl('div', { className: 'row', style: 'margin-top:8px; margin-bottom:0;' }, [likeNextBoardBtn]));
283
- bindSectionToggle(likesToggle, likesBody);
284
- featureTiles.appendChild(likesSection);
285
- const replyToggle = makeCheckbox(false, 'xh-do-reply');
286
- const replyTextInput = makeTextInput('感谢分享,已关注', '回复内容');
287
- const replySection = createEl('div', { className: 'xhs-bento-card' });
288
- replySection.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:8px;' }, [
289
- replyToggle,
290
- createEl('label', { htmlFor: 'xh-do-reply', style: 'cursor:pointer; font-weight:600;' }, ['自动回复(开发态,不发送)']),
291
- ]));
292
- const replyBody = createEl('div', { style: 'padding-left:24px;' });
293
- replyBody.appendChild(createEl('div', { className: 'row', style: 'gap:8px;' }, [
294
- createEl('label', { style: 'width:86px;' }, ['回复文本']), replyTextInput,
295
- ]));
296
- replySection.appendChild(replyBody);
297
- attachTooltip(replySection, '自动回复:对命中规则的评论执行回复;必须配合“评论命中规则”开启。');
298
- bindSectionToggle(replyToggle, replyBody);
299
- featureTiles.appendChild(replySection);
300
- const ocrToggle = makeCheckbox(false, 'xh-do-ocr');
301
- const ocrSection = createEl('div', { className: 'xhs-bento-card' });
302
- ocrSection.appendChild(createEl('div', { className: 'row', style: 'gap:6px; margin-bottom:8px;' }, [
303
- ocrToggle,
304
- createEl('label', { htmlFor: 'xh-do-ocr', style: 'cursor:pointer; font-weight:600;' }, ['图片 OCR(DeepSeek OCR)']),
305
- ]));
306
- const ocrCommandInput = makeTextInput('', 'OCR命令(留空自动: deepseek-ocr 或 dsocr)');
307
- const ocrBody = createEl('div', { style: 'padding-left:24px;' });
308
- ocrBody.appendChild(createEl('div', { className: 'row', style: 'gap:8px;' }, [
309
- createEl('label', { style: 'width:86px;' }, ['OCR命令']), ocrCommandInput,
310
- ]));
311
- ocrSection.appendChild(ocrBody);
312
- bindSectionToggle(ocrToggle, ocrBody);
313
- featureTiles.appendChild(ocrSection);
314
- const opOrderInput = makeTextInput('', '执行顺序列表(留空使用默认编排)');
315
- const opOrderRow = createEl('div', { className: 'row', style: 'gap:8px; margin-bottom:12px;' }, [
316
- createEl('label', { style: 'width:86px;' }, ['执行顺序']), opOrderInput,
317
- ]);
318
- const applyPersistedValue = (input: HTMLInputElement | HTMLSelectElement, value: unknown) => {
319
- if (value === undefined || value === null) return;
320
- const textValue = String(value).trim();
321
- if (!textValue) return;
322
- input.value = textValue;
323
- };
324
- applyPersistedValue(orchestrateModeSelect, persistedConfig.orchestrateMode);
325
- applyPersistedValue(keywordInput, persistedConfig.keyword);
326
- applyPersistedValue(envInput, persistedConfig.env);
327
- applyPersistedValue(accountModeSelect, persistedConfig.accountMode);
328
- applyPersistedValue(maxNotesInput, persistedConfig.maxNotes);
329
- applyPersistedValue(maxCommentsInput, persistedConfig.maxComments);
330
- applyPersistedValue(commentRoundsInput, persistedConfig.commentRounds);
331
- applyPersistedValue(matchKeywordsInput, persistedConfig.matchKeywords);
332
- applyPersistedValue(matchModeSelect, persistedConfig.matchMode);
333
- applyPersistedValue(matchMinHitsInput, persistedConfig.matchMinHits);
334
- applyPersistedValue(maxLikesInput, persistedConfig.maxLikes);
335
- applyPersistedValue(replyTextInput, persistedConfig.replyText);
336
- applyPersistedValue(ocrCommandInput, persistedConfig.ocrCommand);
337
- applyPersistedValue(opOrderInput, persistedConfig.opOrder);
338
- if (typeof persistedConfig.dryRun === 'boolean') dryRunCheckbox.checked = persistedConfig.dryRun;
339
- if (typeof persistedConfig.protocolMode === 'boolean') protocolModeCheckbox.checked = persistedConfig.protocolMode;
340
- if (typeof persistedConfig.headless === 'boolean') headlessCheckbox.checked = persistedConfig.headless;
341
- if (typeof persistedConfig.doHomepage === 'boolean') homepageToggle.checked = persistedConfig.doHomepage;
342
- if (typeof persistedConfig.doImages === 'boolean') imagesToggle.checked = persistedConfig.doImages;
343
- if (!homepageToggle.checked) imagesToggle.checked = false;
344
- if (typeof persistedConfig.doComments === 'boolean') commentsToggle.checked = persistedConfig.doComments;
345
- if (typeof persistedConfig.doGate === 'boolean') gateToggle.checked = persistedConfig.doGate;
346
- if (typeof persistedConfig.doLikes === 'boolean') likesToggle.checked = persistedConfig.doLikes;
347
- if (typeof persistedConfig.doReply === 'boolean') replyToggle.checked = persistedConfig.doReply;
348
- if (typeof persistedConfig.doOcr === 'boolean') ocrToggle.checked = persistedConfig.doOcr;
349
- const persistedSingleProfile = String(persistedConfig.singleProfile || '').trim();
350
- const persistedShardProfiles = new Set(
351
- Array.isArray(persistedConfig.shardProfiles)
352
- ? persistedConfig.shardProfiles.map((x) => String(x || '').trim()).filter(Boolean)
353
- : [],
354
- );
355
- const statsSection = createEl('div', { className: 'xhs-bento-card', style: 'margin-bottom:0;' });
356
- const statsRow = createEl('div', {
357
- className: 'row',
358
- style: 'flex-wrap: nowrap; gap: 16px; margin-bottom: 8px; font-size: 12px; overflow-x: auto;',
359
- });
360
- const linksStat = createEl('span', { className: 'muted' }, ['链接:0/0']) as HTMLSpanElement;
361
- const postsStat = createEl('span', { className: 'muted' }, ['帖子:0']) as HTMLSpanElement;
362
- const commentsStat = createEl('span', { className: 'muted' }, ['评论:0/不限']) as HTMLSpanElement;
363
- const likesStat = createEl('span', { className: 'muted' }, ['点赞:0']) as HTMLSpanElement;
364
- const likesSkipStat = createEl('span', { className: 'muted' }, ['点赞跳过:0']) as HTMLSpanElement;
365
- const repliesStat = createEl('span', { className: 'muted' }, ['回复:0']) as HTMLSpanElement;
366
- const streamStat = createEl('span', { className: 'muted', style: 'font-size:11px;' }, ['事件流:未绑定']) as HTMLSpanElement;
367
- [linksStat, postsStat, commentsStat, likesStat, likesSkipStat, repliesStat, streamStat].forEach(el => statsRow.appendChild(el));
368
- statsSection.appendChild(statsRow);
369
- const shardStatsTitle = createEl('div', { style: 'margin-top:6px; font-weight:600;' }, ['分片进度(合并 + 明细)']) as HTMLDivElement;
370
- const shardStatsList = createEl('div', { style: 'display:flex; flex-direction:column; gap:6px; margin-top:6px;' }) as HTMLDivElement;
371
- statsSection.appendChild(shardStatsTitle);
372
- statsSection.appendChild(shardStatsList);
373
- const likedTitle = createEl('div', { style: 'margin-top:8px; font-weight:600;' }, ['已点赞帖子']) as HTMLDivElement;
374
- const likedList = createEl('div', { style: 'display:flex; flex-direction:column; gap:6px; margin-top:6px;' }) as HTMLDivElement;
375
- const repliedTitle = createEl('div', { style: 'margin-top:10px; font-weight:600;' }, ['已回复帖子']) as HTMLDivElement;
376
- const repliedList = createEl('div', { style: 'display:flex; flex-direction:column; gap:6px; margin-top:6px;' }) as HTMLDivElement;
377
- statsSection.appendChild(likedTitle);
378
- statsSection.appendChild(likedList);
379
- statsSection.appendChild(repliedTitle);
380
- statsSection.appendChild(repliedList);
381
- const boardTile = createTile('board', '运行看板');
382
- boardTile.body.appendChild(statsSection);
383
- const likeTile = createTile('like', '点赞设置');
384
- const likeBento = createEl('div', { className: 'xhs-bento-grid xhs-bento-grid--tight' });
385
- likeBento.appendChild(likesSection);
386
- likeTile.body.appendChild(likeBento);
387
- const accountTile = createTile('account', '账号检查与登录引导');
388
- const accountBento = createEl('div', { className: 'xhs-bento-grid' });
389
- accountBento.appendChild(onboardingCard);
390
- accountBento.appendChild(tileBase2);
391
- accountBento.appendChild(accountAuditCard);
392
- accountTile.body.appendChild(accountBento);
393
- const runTile = createTile('run', '编排与运行参数');
394
- const runBento = createEl('div', { className: 'xhs-bento-grid' });
395
- runBento.appendChild(tileBase1);
396
- runBento.appendChild(tileBase3);
397
- runBento.appendChild(createEl('div', { className: 'xhs-compact-card xhs-bento-card' }, [modeHint]));
398
- runBento.appendChild(createEl('div', { className: 'xhs-compact-card xhs-bento-card' }, [opOrderRow]));
399
- runTile.body.appendChild(runBento);
400
- const commentTile = createTile('comment', '评论与回复设置');
401
- const commentBento = createEl('div', { className: 'xhs-bento-grid xhs-bento-grid--tight' });
402
- commentBento.appendChild(commentsSection);
403
- commentBento.appendChild(gateSection);
404
- commentBento.appendChild(replySection);
405
- commentTile.body.appendChild(commentBento);
406
- const collectTile = createTile('collect', '主页采集与OCR');
407
- const collectBento = createEl('div', { className: 'xhs-bento-grid xhs-bento-grid--tight' });
408
- collectBento.appendChild(homeSection);
409
- collectBento.appendChild(ocrSection);
410
- collectTile.body.appendChild(collectBento);
411
- [boardTile.tile, likeTile.tile, runTile.tile, accountTile.tile, commentTile.tile, collectTile.tile].forEach((tile) => tileLane.appendChild(tile));
412
- tileLane.style.position = 'relative';
413
- tileLane.appendChild(guideLockMask);
414
- card.appendChild(tileLane);
415
- const bindLikeRulePersistence = (hooks: { persistLastConfig: () => void; persistLikeRuleAHistory: () => void; persistLikeRuleBHistory: () => void }) => {
416
- persistLastConfigHook = hooks.persistLastConfig;
417
- persistLikeRuleAHistoryHook = hooks.persistLikeRuleAHistory;
418
- persistLikeRuleBHistoryHook = hooks.persistLikeRuleBHistory;
419
- };
420
- return {
421
- orchestrateModeSelect, keywordInput, envInput, accountModeSelect, profilePickSel, profileRefreshBtn, shardProfilesBox, shardProfilesHint, shardResolvedHint,
422
- maxNotesInput, dryRunCheckbox, protocolModeCheckbox, headlessCheckbox, modeHint, singleProfileRow, singleProfileHint, shardProfilesSection,
423
- accountAuditSummary, accountAuditList, accountRefreshBtn, accountLiveProbeBtn, addAccountCountInput, addBatchNameInput, accountAddBtn,
424
- accountNextLikeBtn, batchKeyValue, batchNextBtn, homepageToggle, imagesToggle, commentsToggle, maxCommentsInput, commentRoundsInput, gateToggle, matchKeywordsInput,
425
- matchModeSelect, matchMinHitsInput, likesToggle, maxLikesInput, likeRuleTypeSelect, likeRuleAInput, likeRuleBInput, addLikeRuleBtn,
426
- likeRulePreview, replyToggle, replyTextInput, ocrToggle, ocrCommandInput, opOrderInput, opOrderRow, homeSection, commentsSection, gateSection,
427
- likesSection, replySection, ocrSection, likeNextBoardBtn, linksStat, postsStat, commentsStat, likesStat, likesSkipStat, repliesStat, streamStat, shardStatsList, likedList,
428
- repliedList, persistedSingleProfile, persistedShardProfiles, bindLikeRulePersistence,
429
- };
430
- }