llm-content-creator 0.1.0

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 (438) hide show
  1. package/README.md +309 -0
  2. package/dist/application/workflow/SyncExecutor.d.ts +75 -0
  3. package/dist/application/workflow/SyncExecutor.d.ts.map +1 -0
  4. package/dist/application/workflow/SyncExecutor.js +370 -0
  5. package/dist/application/workflow/SyncExecutor.js.map +1 -0
  6. package/dist/application/workflow/types.d.ts +46 -0
  7. package/dist/application/workflow/types.d.ts.map +1 -0
  8. package/dist/application/workflow/types.js +7 -0
  9. package/dist/application/workflow/types.js.map +1 -0
  10. package/dist/config/index.d.ts +173 -0
  11. package/dist/config/index.d.ts.map +1 -0
  12. package/dist/config/index.js +288 -0
  13. package/dist/config/index.js.map +1 -0
  14. package/dist/domain/entities/QualityCheck.d.ts +181 -0
  15. package/dist/domain/entities/QualityCheck.d.ts.map +1 -0
  16. package/dist/domain/entities/QualityCheck.js +39 -0
  17. package/dist/domain/entities/QualityCheck.js.map +1 -0
  18. package/dist/domain/entities/Result.d.ts +103 -0
  19. package/dist/domain/entities/Result.d.ts.map +1 -0
  20. package/dist/domain/entities/Result.js +15 -0
  21. package/dist/domain/entities/Result.js.map +1 -0
  22. package/dist/domain/entities/Task.d.ts +130 -0
  23. package/dist/domain/entities/Task.d.ts.map +1 -0
  24. package/dist/domain/entities/Task.js +64 -0
  25. package/dist/domain/entities/Task.js.map +1 -0
  26. package/dist/domain/entities/TaskStep.d.ts +160 -0
  27. package/dist/domain/entities/TaskStep.d.ts.map +1 -0
  28. package/dist/domain/entities/TaskStep.js +30 -0
  29. package/dist/domain/entities/TaskStep.js.map +1 -0
  30. package/dist/domain/entities/TokenUsage.d.ts +70 -0
  31. package/dist/domain/entities/TokenUsage.d.ts.map +1 -0
  32. package/dist/domain/entities/TokenUsage.js +42 -0
  33. package/dist/domain/entities/TokenUsage.js.map +1 -0
  34. package/dist/domain/entities/index.d.ts +11 -0
  35. package/dist/domain/entities/index.d.ts.map +1 -0
  36. package/dist/domain/entities/index.js +16 -0
  37. package/dist/domain/entities/index.js.map +1 -0
  38. package/dist/domain/repositories/QualityCheckRepository.d.ts +49 -0
  39. package/dist/domain/repositories/QualityCheckRepository.d.ts.map +1 -0
  40. package/dist/domain/repositories/QualityCheckRepository.js +5 -0
  41. package/dist/domain/repositories/QualityCheckRepository.js.map +1 -0
  42. package/dist/domain/repositories/ResultRepository.d.ts +43 -0
  43. package/dist/domain/repositories/ResultRepository.d.ts.map +1 -0
  44. package/dist/domain/repositories/ResultRepository.js +5 -0
  45. package/dist/domain/repositories/ResultRepository.js.map +1 -0
  46. package/dist/domain/repositories/TaskRepository.d.ts +240 -0
  47. package/dist/domain/repositories/TaskRepository.d.ts.map +1 -0
  48. package/dist/domain/repositories/TaskRepository.js +7 -0
  49. package/dist/domain/repositories/TaskRepository.js.map +1 -0
  50. package/dist/domain/workflow/CheckpointManager.d.ts +94 -0
  51. package/dist/domain/workflow/CheckpointManager.d.ts.map +1 -0
  52. package/dist/domain/workflow/CheckpointManager.js +224 -0
  53. package/dist/domain/workflow/CheckpointManager.js.map +1 -0
  54. package/dist/domain/workflow/ContentCreatorGraph.d.ts +17 -0
  55. package/dist/domain/workflow/ContentCreatorGraph.d.ts.map +1 -0
  56. package/dist/domain/workflow/ContentCreatorGraph.js +381 -0
  57. package/dist/domain/workflow/ContentCreatorGraph.js.map +1 -0
  58. package/dist/domain/workflow/State.d.ts +172 -0
  59. package/dist/domain/workflow/State.d.ts.map +1 -0
  60. package/dist/domain/workflow/State.js +184 -0
  61. package/dist/domain/workflow/State.js.map +1 -0
  62. package/dist/domain/workflow/index.d.ts +11 -0
  63. package/dist/domain/workflow/index.d.ts.map +1 -0
  64. package/dist/domain/workflow/index.js +15 -0
  65. package/dist/domain/workflow/index.js.map +1 -0
  66. package/dist/domain/workflow/nodes/BaseNode.d.ts +134 -0
  67. package/dist/domain/workflow/nodes/BaseNode.d.ts.map +1 -0
  68. package/dist/domain/workflow/nodes/BaseNode.js +253 -0
  69. package/dist/domain/workflow/nodes/BaseNode.js.map +1 -0
  70. package/dist/domain/workflow/nodes/CheckImageNode.d.ts +43 -0
  71. package/dist/domain/workflow/nodes/CheckImageNode.d.ts.map +1 -0
  72. package/dist/domain/workflow/nodes/CheckImageNode.js +254 -0
  73. package/dist/domain/workflow/nodes/CheckImageNode.js.map +1 -0
  74. package/dist/domain/workflow/nodes/CheckTextNode.d.ts +66 -0
  75. package/dist/domain/workflow/nodes/CheckTextNode.d.ts.map +1 -0
  76. package/dist/domain/workflow/nodes/CheckTextNode.js +530 -0
  77. package/dist/domain/workflow/nodes/CheckTextNode.js.map +1 -0
  78. package/dist/domain/workflow/nodes/GenerateImageNode.d.ts +44 -0
  79. package/dist/domain/workflow/nodes/GenerateImageNode.d.ts.map +1 -0
  80. package/dist/domain/workflow/nodes/GenerateImageNode.js +272 -0
  81. package/dist/domain/workflow/nodes/GenerateImageNode.js.map +1 -0
  82. package/dist/domain/workflow/nodes/OrganizeNode.d.ts +49 -0
  83. package/dist/domain/workflow/nodes/OrganizeNode.d.ts.map +1 -0
  84. package/dist/domain/workflow/nodes/OrganizeNode.js +241 -0
  85. package/dist/domain/workflow/nodes/OrganizeNode.js.map +1 -0
  86. package/dist/domain/workflow/nodes/SearchNode.d.ts +48 -0
  87. package/dist/domain/workflow/nodes/SearchNode.d.ts.map +1 -0
  88. package/dist/domain/workflow/nodes/SearchNode.js +151 -0
  89. package/dist/domain/workflow/nodes/SearchNode.js.map +1 -0
  90. package/dist/domain/workflow/nodes/WriteNode.d.ts +68 -0
  91. package/dist/domain/workflow/nodes/WriteNode.d.ts.map +1 -0
  92. package/dist/domain/workflow/nodes/WriteNode.js +431 -0
  93. package/dist/domain/workflow/nodes/WriteNode.js.map +1 -0
  94. package/dist/domain/workflow/nodes/config/index.js +287 -0
  95. package/dist/domain/workflow/nodes/domain/entities/Task.js +68 -0
  96. package/dist/domain/workflow/nodes/domain/workflow/State.js +200 -0
  97. package/dist/domain/workflow/nodes/domain/workflow/nodes/BaseNode.js +328 -0
  98. package/dist/domain/workflow/nodes/domain/workflow/nodes/CheckTextNode.js +500 -0
  99. package/dist/domain/workflow/nodes/index.d.ts +13 -0
  100. package/dist/domain/workflow/nodes/index.d.ts.map +1 -0
  101. package/dist/domain/workflow/nodes/index.js +13 -0
  102. package/dist/domain/workflow/nodes/index.js.map +1 -0
  103. package/dist/domain/workflow/nodes/infrastructure/logging/logger.js +275 -0
  104. package/dist/domain/workflow/nodes/services/llm/EnhancedLLMService.js +559 -0
  105. package/dist/index.d.ts +24 -0
  106. package/dist/index.d.ts.map +1 -0
  107. package/dist/index.js +34 -0
  108. package/dist/index.js.map +1 -0
  109. package/dist/infrastructure/cache/CacheService.d.ts +139 -0
  110. package/dist/infrastructure/cache/CacheService.d.ts.map +1 -0
  111. package/dist/infrastructure/cache/CacheService.js +419 -0
  112. package/dist/infrastructure/cache/CacheService.js.map +1 -0
  113. package/dist/infrastructure/cache/index.d.ts +5 -0
  114. package/dist/infrastructure/cache/index.d.ts.map +1 -0
  115. package/dist/infrastructure/cache/index.js +6 -0
  116. package/dist/infrastructure/cache/index.js.map +1 -0
  117. package/dist/infrastructure/database/BaseRepository.d.ts +98 -0
  118. package/dist/infrastructure/database/BaseRepository.d.ts.map +1 -0
  119. package/dist/infrastructure/database/BaseRepository.js +178 -0
  120. package/dist/infrastructure/database/BaseRepository.js.map +1 -0
  121. package/dist/infrastructure/database/MemoryTaskRepository.d.ts +77 -0
  122. package/dist/infrastructure/database/MemoryTaskRepository.d.ts.map +1 -0
  123. package/dist/infrastructure/database/MemoryTaskRepository.js +309 -0
  124. package/dist/infrastructure/database/MemoryTaskRepository.js.map +1 -0
  125. package/dist/infrastructure/database/PostgresQualityCheckRepository.d.ts +36 -0
  126. package/dist/infrastructure/database/PostgresQualityCheckRepository.d.ts.map +1 -0
  127. package/dist/infrastructure/database/PostgresQualityCheckRepository.js +89 -0
  128. package/dist/infrastructure/database/PostgresQualityCheckRepository.js.map +1 -0
  129. package/dist/infrastructure/database/PostgresTaskRepository.d.ts +94 -0
  130. package/dist/infrastructure/database/PostgresTaskRepository.d.ts.map +1 -0
  131. package/dist/infrastructure/database/PostgresTaskRepository.js +364 -0
  132. package/dist/infrastructure/database/PostgresTaskRepository.js.map +1 -0
  133. package/dist/infrastructure/database/ResultRepository.d.ts +41 -0
  134. package/dist/infrastructure/database/ResultRepository.d.ts.map +1 -0
  135. package/dist/infrastructure/database/ResultRepository.js +86 -0
  136. package/dist/infrastructure/database/ResultRepository.js.map +1 -0
  137. package/dist/infrastructure/database/SQLiteTaskRepository.d.ts +101 -0
  138. package/dist/infrastructure/database/SQLiteTaskRepository.d.ts.map +1 -0
  139. package/dist/infrastructure/database/SQLiteTaskRepository.js +548 -0
  140. package/dist/infrastructure/database/SQLiteTaskRepository.js.map +1 -0
  141. package/dist/infrastructure/database/index.d.ts +32 -0
  142. package/dist/infrastructure/database/index.d.ts.map +1 -0
  143. package/dist/infrastructure/database/index.js +72 -0
  144. package/dist/infrastructure/database/index.js.map +1 -0
  145. package/dist/infrastructure/logging/logger.d.ts +69 -0
  146. package/dist/infrastructure/logging/logger.d.ts.map +1 -0
  147. package/dist/infrastructure/logging/logger.js +169 -0
  148. package/dist/infrastructure/logging/logger.js.map +1 -0
  149. package/dist/infrastructure/monitoring/LoggingService.d.ts +109 -0
  150. package/dist/infrastructure/monitoring/LoggingService.d.ts.map +1 -0
  151. package/dist/infrastructure/monitoring/LoggingService.js +198 -0
  152. package/dist/infrastructure/monitoring/LoggingService.js.map +1 -0
  153. package/dist/infrastructure/monitoring/MetricsService.d.ts +112 -0
  154. package/dist/infrastructure/monitoring/MetricsService.d.ts.map +1 -0
  155. package/dist/infrastructure/monitoring/MetricsService.js +362 -0
  156. package/dist/infrastructure/monitoring/MetricsService.js.map +1 -0
  157. package/dist/infrastructure/monitoring/SentryService.d.ts +108 -0
  158. package/dist/infrastructure/monitoring/SentryService.d.ts.map +1 -0
  159. package/dist/infrastructure/monitoring/SentryService.js +282 -0
  160. package/dist/infrastructure/monitoring/SentryService.js.map +1 -0
  161. package/dist/infrastructure/monitoring/index.d.ts +7 -0
  162. package/dist/infrastructure/monitoring/index.d.ts.map +1 -0
  163. package/dist/infrastructure/monitoring/index.js +10 -0
  164. package/dist/infrastructure/monitoring/index.js.map +1 -0
  165. package/dist/infrastructure/queue/TaskQueue.d.ts +110 -0
  166. package/dist/infrastructure/queue/TaskQueue.d.ts.map +1 -0
  167. package/dist/infrastructure/queue/TaskQueue.js +363 -0
  168. package/dist/infrastructure/queue/TaskQueue.js.map +1 -0
  169. package/dist/infrastructure/queue/index.d.ts +5 -0
  170. package/dist/infrastructure/queue/index.d.ts.map +1 -0
  171. package/dist/infrastructure/queue/index.js +5 -0
  172. package/dist/infrastructure/queue/index.js.map +1 -0
  173. package/dist/infrastructure/redis/connection.d.ts +61 -0
  174. package/dist/infrastructure/redis/connection.d.ts.map +1 -0
  175. package/dist/infrastructure/redis/connection.js +184 -0
  176. package/dist/infrastructure/redis/connection.js.map +1 -0
  177. package/dist/infrastructure/redis/index.d.ts +5 -0
  178. package/dist/infrastructure/redis/index.d.ts.map +1 -0
  179. package/dist/infrastructure/redis/index.js +5 -0
  180. package/dist/infrastructure/redis/index.js.map +1 -0
  181. package/dist/infrastructure/security/ApiKeyService.d.ts +103 -0
  182. package/dist/infrastructure/security/ApiKeyService.d.ts.map +1 -0
  183. package/dist/infrastructure/security/ApiKeyService.js +250 -0
  184. package/dist/infrastructure/security/ApiKeyService.js.map +1 -0
  185. package/dist/infrastructure/security/QuotaService.d.ts +87 -0
  186. package/dist/infrastructure/security/QuotaService.d.ts.map +1 -0
  187. package/dist/infrastructure/security/QuotaService.js +303 -0
  188. package/dist/infrastructure/security/QuotaService.js.map +1 -0
  189. package/dist/infrastructure/security/RateLimiter.d.ts +104 -0
  190. package/dist/infrastructure/security/RateLimiter.d.ts.map +1 -0
  191. package/dist/infrastructure/security/RateLimiter.js +331 -0
  192. package/dist/infrastructure/security/RateLimiter.js.map +1 -0
  193. package/dist/infrastructure/security/index.d.ts +7 -0
  194. package/dist/infrastructure/security/index.d.ts.map +1 -0
  195. package/dist/infrastructure/security/index.js +10 -0
  196. package/dist/infrastructure/security/index.js.map +1 -0
  197. package/dist/monitoring/index.d.ts +5 -0
  198. package/dist/monitoring/index.d.ts.map +1 -0
  199. package/dist/monitoring/index.js +5 -0
  200. package/dist/monitoring/index.js.map +1 -0
  201. package/dist/monitoring/server.d.ts +14 -0
  202. package/dist/monitoring/server.d.ts.map +1 -0
  203. package/dist/monitoring/server.js +99 -0
  204. package/dist/monitoring/server.js.map +1 -0
  205. package/dist/presentation/cli/commands/cancel.d.ts +8 -0
  206. package/dist/presentation/cli/commands/cancel.d.ts.map +1 -0
  207. package/dist/presentation/cli/commands/cancel.js +57 -0
  208. package/dist/presentation/cli/commands/cancel.js.map +1 -0
  209. package/dist/presentation/cli/commands/create.d.ts +8 -0
  210. package/dist/presentation/cli/commands/create.d.ts.map +1 -0
  211. package/dist/presentation/cli/commands/create.js +368 -0
  212. package/dist/presentation/cli/commands/create.js.map +1 -0
  213. package/dist/presentation/cli/commands/result.d.ts +8 -0
  214. package/dist/presentation/cli/commands/result.d.ts.map +1 -0
  215. package/dist/presentation/cli/commands/result.js +121 -0
  216. package/dist/presentation/cli/commands/result.js.map +1 -0
  217. package/dist/presentation/cli/commands/status.d.ts +8 -0
  218. package/dist/presentation/cli/commands/status.d.ts.map +1 -0
  219. package/dist/presentation/cli/commands/status.js +92 -0
  220. package/dist/presentation/cli/commands/status.js.map +1 -0
  221. package/dist/presentation/cli/index.d.ts +8 -0
  222. package/dist/presentation/cli/index.d.ts.map +1 -0
  223. package/dist/presentation/cli/index.js +32 -0
  224. package/dist/presentation/cli/index.js.map +1 -0
  225. package/dist/presentation/cli/utils/cleanup.d.ts +14 -0
  226. package/dist/presentation/cli/utils/cleanup.d.ts.map +1 -0
  227. package/dist/presentation/cli/utils/cleanup.js +62 -0
  228. package/dist/presentation/cli/utils/cleanup.js.map +1 -0
  229. package/dist/presentation/cli/utils/formatter.d.ts +28 -0
  230. package/dist/presentation/cli/utils/formatter.d.ts.map +1 -0
  231. package/dist/presentation/cli/utils/formatter.js +68 -0
  232. package/dist/presentation/cli/utils/formatter.js.map +1 -0
  233. package/dist/presentation/cli.d.ts +7 -0
  234. package/dist/presentation/cli.d.ts.map +1 -0
  235. package/dist/presentation/cli.js +8 -0
  236. package/dist/presentation/cli.js.map +1 -0
  237. package/dist/presentation/monitor-cli.d.ts +8 -0
  238. package/dist/presentation/monitor-cli.d.ts.map +1 -0
  239. package/dist/presentation/monitor-cli.js +44 -0
  240. package/dist/presentation/monitor-cli.js.map +1 -0
  241. package/dist/presentation/worker-cli.d.ts +8 -0
  242. package/dist/presentation/worker-cli.d.ts.map +1 -0
  243. package/dist/presentation/worker-cli.js +51 -0
  244. package/dist/presentation/worker-cli.js.map +1 -0
  245. package/dist/schedulers/TaskScheduler.d.ts +99 -0
  246. package/dist/schedulers/TaskScheduler.d.ts.map +1 -0
  247. package/dist/schedulers/TaskScheduler.js +233 -0
  248. package/dist/schedulers/TaskScheduler.js.map +1 -0
  249. package/dist/schedulers/index.d.ts +5 -0
  250. package/dist/schedulers/index.d.ts.map +1 -0
  251. package/dist/schedulers/index.js +5 -0
  252. package/dist/schedulers/index.js.map +1 -0
  253. package/dist/services/image/ImageService.d.ts +68 -0
  254. package/dist/services/image/ImageService.d.ts.map +1 -0
  255. package/dist/services/image/ImageService.js +166 -0
  256. package/dist/services/image/ImageService.js.map +1 -0
  257. package/dist/services/index.d.ts +8 -0
  258. package/dist/services/index.d.ts.map +1 -0
  259. package/dist/services/index.js +12 -0
  260. package/dist/services/index.js.map +1 -0
  261. package/dist/services/llm/EnhancedLLMService.d.ts +148 -0
  262. package/dist/services/llm/EnhancedLLMService.d.ts.map +1 -0
  263. package/dist/services/llm/EnhancedLLMService.js +425 -0
  264. package/dist/services/llm/EnhancedLLMService.js.map +1 -0
  265. package/dist/services/llm/LLMService.d.ts +103 -0
  266. package/dist/services/llm/LLMService.d.ts.map +1 -0
  267. package/dist/services/llm/LLMService.js +212 -0
  268. package/dist/services/llm/LLMService.js.map +1 -0
  269. package/dist/services/quality/HardRuleChecker.d.ts +143 -0
  270. package/dist/services/quality/HardRuleChecker.d.ts.map +1 -0
  271. package/dist/services/quality/HardRuleChecker.js +353 -0
  272. package/dist/services/quality/HardRuleChecker.js.map +1 -0
  273. package/dist/services/quality/LLMEvaluator.d.ts +105 -0
  274. package/dist/services/quality/LLMEvaluator.d.ts.map +1 -0
  275. package/dist/services/quality/LLMEvaluator.js +312 -0
  276. package/dist/services/quality/LLMEvaluator.js.map +1 -0
  277. package/dist/services/quality/QualityCheckService.d.ts +112 -0
  278. package/dist/services/quality/QualityCheckService.d.ts.map +1 -0
  279. package/dist/services/quality/QualityCheckService.js +342 -0
  280. package/dist/services/quality/QualityCheckService.js.map +1 -0
  281. package/dist/services/quality/QualityService.d.ts +75 -0
  282. package/dist/services/quality/QualityService.d.ts.map +1 -0
  283. package/dist/services/quality/QualityService.js +360 -0
  284. package/dist/services/quality/QualityService.js.map +1 -0
  285. package/dist/services/quality/index.d.ts +7 -0
  286. package/dist/services/quality/index.d.ts.map +1 -0
  287. package/dist/services/quality/index.js +10 -0
  288. package/dist/services/quality/index.js.map +1 -0
  289. package/dist/services/search/SearchService.d.ts +79 -0
  290. package/dist/services/search/SearchService.d.ts.map +1 -0
  291. package/dist/services/search/SearchService.js +193 -0
  292. package/dist/services/search/SearchService.js.map +1 -0
  293. package/dist/workers/TaskWorker.d.ts +61 -0
  294. package/dist/workers/TaskWorker.d.ts.map +1 -0
  295. package/dist/workers/TaskWorker.js +256 -0
  296. package/dist/workers/TaskWorker.js.map +1 -0
  297. package/dist/workers/index.d.ts +5 -0
  298. package/dist/workers/index.d.ts.map +1 -0
  299. package/dist/workers/index.js +5 -0
  300. package/dist/workers/index.js.map +1 -0
  301. package/docs/DOCUMENTATION-ANALYSIS.md +190 -0
  302. package/docs/README.md +145 -0
  303. package/docs/SOURCE-CODE-ANALYSIS.md +1107 -0
  304. package/docs/architecture-complete.md +5524 -0
  305. package/docs/archive/implementation/implementation-analysis/README.md +244 -0
  306. package/docs/archive/implementation/implementation-analysis/implementation-analysis-context.md +483 -0
  307. package/docs/archive/implementation/implementation-analysis/implementation-analysis-plan.md +1242 -0
  308. package/docs/archive/implementation/implementation-analysis/implementation-analysis-tasks.md +777 -0
  309. package/docs/archive/phases/phase-1/phase-1-completion-summary.md +284 -0
  310. package/docs/archive/phases/phase-1/phase-1-implementation-guide.md +1380 -0
  311. package/docs/archive/phases/phase-2/phase-2a/phase-2a-completion-summary.md +443 -0
  312. package/docs/archive/phases/phase-2/phase-2b/phase-2b-completion-report.md +430 -0
  313. package/docs/archive/phases/phase-2/phase-2b/phase-2b-completion-summary.md +592 -0
  314. package/docs/archive/phases/phase-2/phase-2b/phase-2b-final-summary.md +371 -0
  315. package/docs/archive/phases/phase-2/phase-2b/phase-2b-preparation-complete.md +343 -0
  316. package/docs/archive/phases/phase-2/phase-2b/phase-2b-preparation.md +945 -0
  317. package/docs/archive/phases/phase-2/phase-2b/phase-2b-progress-update.md +366 -0
  318. package/docs/archive/phases/phase-3/phase-3-completion-summary.md +354 -0
  319. package/docs/archive/phases/phase-3/phase-3-development-plan.md +878 -0
  320. package/docs/archive/phases/phase-3/phase-3-quick-start.md +324 -0
  321. package/docs/archive/phases/phase-4/phase-4-completion-summary.md +708 -0
  322. package/docs/archive/phases/phase-4/phase-4-development-plan.md +740 -0
  323. package/docs/archive/phases/phase-4/phase-4-quick-start.md +632 -0
  324. package/docs/archive/phases/phase-4/phase-4-session-3-security-testing.md +484 -0
  325. package/docs/archive/phases/phase-4/phase-4-session-4-unit-tests.md +550 -0
  326. package/docs/archive/phases/phase-4/phase-4-session-5-security-tests.md +564 -0
  327. package/docs/archive/phases/phase-4/phase-4-session-6-cache-integration.md +456 -0
  328. package/docs/archive/phases/phase-4/phase-4-session-7-test-fixes.md +348 -0
  329. package/docs/archive/phases/phase-4/phase-4-session-8-taskqueue-fixes.md +323 -0
  330. package/docs/archive/phases/phase-4/phase-4-session-summary-continued.md +373 -0
  331. package/docs/archive/phases/phase-4/phase-4-session-summary.md +595 -0
  332. package/docs/archive/reports/progress-reports/PHASE_0_PROGRESS.md +242 -0
  333. package/docs/archive/reports/progress-reports/PHASE_0_SUMMARY.md +262 -0
  334. package/docs/archive/reports/progress-reports/PHASE_1_2_ISSUES.md +399 -0
  335. package/docs/archive/reports/progress-reports/PHASE_1_PROGRESS.md +388 -0
  336. package/docs/archive/reports/progress-reports/PHASE_3_PREPARATION.md +574 -0
  337. package/docs/archive/reports/progress-reports/current-progress-update.md +294 -0
  338. package/docs/archive/reports/progress-reports/final-summary.md +215 -0
  339. package/docs/archive/reports/progress-reports/implementation-summary.md +287 -0
  340. package/docs/archive/reports/progress-reports/project-progress-report.md +440 -0
  341. package/docs/archive/reports/progress-reports/project-progress.md +386 -0
  342. package/docs/archive/reports/test-reports/TEST-COVERAGE-REPORT.md +441 -0
  343. package/docs/archive/reports/test-reports/e2e-test-report.md +293 -0
  344. package/docs/archive/reports/test-reports/final-test-report.md +367 -0
  345. package/docs/archive/reports/test-reports/real-env-test-report.md +391 -0
  346. package/docs/archive/reports/test-reports/test-completion-summary.md +356 -0
  347. package/docs/archive/reports/test-reports/test-report.md +371 -0
  348. package/docs/archive/sessions/session-2-summary.md +429 -0
  349. package/docs/archive/sessions/session-3-summary.md +395 -0
  350. package/docs/archive/sessions/session-summary.md +370 -0
  351. package/docs/config-system-update.md +239 -0
  352. package/docs/database-refactoring-PLAN.md +199 -0
  353. package/docs/database-refactoring-SUMMARY.md +384 -0
  354. package/docs/quality-check-architecture.md +1030 -0
  355. package/docs/quick-start.md +388 -0
  356. package/docs/references/bullmq-quick-reference.md +525 -0
  357. package/docs/references/monitoring-optimization-guide.md +871 -0
  358. package/docs/references/performance-optimization-guide.md +933 -0
  359. package/docs/storage-guide.md +612 -0
  360. package/docs/test-implementation-PLAN.md +223 -0
  361. package/docs/test-implementation-SUMMARY.md +194 -0
  362. package/docs/user-guide.md +719 -0
  363. package/docs/workflow-architecture.md +549 -0
  364. package/package.json +126 -0
  365. package/src/application/workflow/SyncExecutor.ts +444 -0
  366. package/src/application/workflow/types.ts +57 -0
  367. package/src/config/index.ts +352 -0
  368. package/src/domain/entities/QualityCheck.ts +202 -0
  369. package/src/domain/entities/Result.ts +130 -0
  370. package/src/domain/entities/Task.ts +178 -0
  371. package/src/domain/entities/TaskStep.ts +188 -0
  372. package/src/domain/entities/TokenUsage.ts +119 -0
  373. package/src/domain/entities/index.ts +20 -0
  374. package/src/domain/repositories/QualityCheckRepository.ts +52 -0
  375. package/src/domain/repositories/ResultRepository.ts +47 -0
  376. package/src/domain/repositories/TaskRepository.ts +271 -0
  377. package/src/domain/workflow/CheckpointManager.ts +283 -0
  378. package/src/domain/workflow/ContentCreatorGraph.ts +446 -0
  379. package/src/domain/workflow/State.ts +321 -0
  380. package/src/domain/workflow/index.ts +18 -0
  381. package/src/domain/workflow/nodes/BaseNode.ts +325 -0
  382. package/src/domain/workflow/nodes/CheckImageNode.ts +325 -0
  383. package/src/domain/workflow/nodes/CheckTextNode.ts +709 -0
  384. package/src/domain/workflow/nodes/GenerateImageNode.ts +342 -0
  385. package/src/domain/workflow/nodes/OrganizeNode.ts +304 -0
  386. package/src/domain/workflow/nodes/SearchNode.ts +192 -0
  387. package/src/domain/workflow/nodes/WriteNode.ts +505 -0
  388. package/src/domain/workflow/nodes/index.ts +13 -0
  389. package/src/index.ts +43 -0
  390. package/src/infrastructure/cache/CacheService.ts +483 -0
  391. package/src/infrastructure/cache/index.ts +6 -0
  392. package/src/infrastructure/database/BaseRepository.ts +214 -0
  393. package/src/infrastructure/database/MemoryTaskRepository.ts +377 -0
  394. package/src/infrastructure/database/PostgresQualityCheckRepository.ts +115 -0
  395. package/src/infrastructure/database/PostgresTaskRepository.ts +424 -0
  396. package/src/infrastructure/database/ResultRepository.ts +113 -0
  397. package/src/infrastructure/database/SQLiteTaskRepository.ts +651 -0
  398. package/src/infrastructure/database/index.ts +83 -0
  399. package/src/infrastructure/logging/logger.ts +231 -0
  400. package/src/infrastructure/monitoring/LoggingService.ts +292 -0
  401. package/src/infrastructure/monitoring/MetricsService.ts +468 -0
  402. package/src/infrastructure/monitoring/SentryService.ts +345 -0
  403. package/src/infrastructure/monitoring/index.ts +12 -0
  404. package/src/infrastructure/queue/TaskQueue.ts +429 -0
  405. package/src/infrastructure/queue/index.ts +5 -0
  406. package/src/infrastructure/redis/connection.ts +215 -0
  407. package/src/infrastructure/redis/index.ts +5 -0
  408. package/src/infrastructure/security/ApiKeyService.ts +340 -0
  409. package/src/infrastructure/security/QuotaService.ts +411 -0
  410. package/src/infrastructure/security/RateLimiter.ts +417 -0
  411. package/src/infrastructure/security/index.ts +12 -0
  412. package/src/monitoring/index.ts +5 -0
  413. package/src/monitoring/server.ts +109 -0
  414. package/src/presentation/cli/commands/cancel.ts +64 -0
  415. package/src/presentation/cli/commands/create.ts +400 -0
  416. package/src/presentation/cli/commands/result.ts +136 -0
  417. package/src/presentation/cli/commands/status.ts +102 -0
  418. package/src/presentation/cli/index.ts +39 -0
  419. package/src/presentation/cli/utils/cleanup.ts +65 -0
  420. package/src/presentation/cli/utils/formatter.ts +74 -0
  421. package/src/presentation/cli.ts +8 -0
  422. package/src/presentation/monitor-cli.ts +52 -0
  423. package/src/presentation/worker-cli.ts +62 -0
  424. package/src/schedulers/TaskScheduler.ts +314 -0
  425. package/src/schedulers/index.ts +11 -0
  426. package/src/services/image/ImageService.ts +221 -0
  427. package/src/services/index.ts +15 -0
  428. package/src/services/llm/EnhancedLLMService.ts +596 -0
  429. package/src/services/llm/LLMService.ts +310 -0
  430. package/src/services/quality/HardRuleChecker.ts +509 -0
  431. package/src/services/quality/LLMEvaluator.ts +400 -0
  432. package/src/services/quality/QualityCheckService.ts +473 -0
  433. package/src/services/quality/QualityService.ts +445 -0
  434. package/src/services/quality/index.ts +12 -0
  435. package/src/services/search/SearchService.ts +266 -0
  436. package/src/types/global.d.ts +17 -0
  437. package/src/workers/TaskWorker.ts +320 -0
  438. package/src/workers/index.ts +5 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MemoryTaskRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/database/MemoryTaskRepository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAQtE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,MAAM,MAAM,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAErD;;GAEG;AACH,MAAM,OAAO,oBAAoB;IACvB,KAAK,GAAsB,IAAI,GAAG,EAAE,CAAC;IACrC,SAAS,GAAqB,IAAI,GAAG,EAAE,CAAC;IAEhD;QACE,MAAM,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAC;IAChE,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,MAAwB;QACnC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QAEvB,MAAM,IAAI,GAAS;YACjB,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,MAAM,EAAE,MAAM,CAAC,EAAE;YACjB,IAAI,EAAE,MAAM,CAAC,IAAW;YACxB,IAAI,EAAE,MAAM,CAAC,IAAW;YACxB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,MAAM,EAAE,UAAU,CAAC,OAAO;YAC1B,QAAQ,EAAE,CAAC,EAAE,SAAS;YACtB,OAAO,EAAE,CAAC;YACV,cAAc,EAAE,CAAC;YACjB,eAAe,EAAE,CAAC;YAClB,cAAc,EAAE,SAAS;YACzB,SAAS,EAAE,GAAG;YACd,SAAS,EAAE,GAAG;SACf,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,GAAG,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;QACf,CAAC;QAED,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,MAAM,WAAW,GAAS;YACxB,GAAG,IAAI;YACP,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,YAAY;YACZ,WAAW,EAAE,GAAG;YAChB,OAAO,EAAE,OAAO,GAAG,CAAC;YACpB,SAAS,EAAE,GAAG;SACf,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACpC,MAAM,CAAC,IAAI,CAAC,gCAAgC,EAAE,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI;YAC3B,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI;YAC9B,QAAQ,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;gBAC7D,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;gBAC/C,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAA4B,CAAC;SACjC,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Quality Check Repository
3
+ *
4
+ * 负责质量检查结果的数据库操作
5
+ */
6
+ import { Pool } from 'pg';
7
+ import type { IQualityCheckRepository, CreateQualityCheckParams } from '../../domain/repositories/QualityCheckRepository.js';
8
+ /**
9
+ * PostgreSQL Quality Check Repository 实现
10
+ */
11
+ export declare class PostgresQualityCheckRepository implements IQualityCheckRepository {
12
+ private pool;
13
+ constructor(pool: Pool);
14
+ /**
15
+ * 创建质量检查记录
16
+ */
17
+ create(params: CreateQualityCheckParams): Promise<void>;
18
+ /**
19
+ * 根据任务 ID 查询质量检查
20
+ */
21
+ findByTaskId(taskId: string): Promise<Array<{
22
+ id: number;
23
+ taskId: string;
24
+ checkType: string;
25
+ score: number;
26
+ passed: boolean;
27
+ hardConstraintsPassed: boolean;
28
+ details: any;
29
+ fixSuggestions: string[] | null;
30
+ rubricVersion: string | null;
31
+ modelName: string | null;
32
+ promptHash: string | null;
33
+ createdAt: Date;
34
+ }>>;
35
+ }
36
+ //# sourceMappingURL=PostgresQualityCheckRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostgresQualityCheckRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/database/PostgresQualityCheckRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAE1B,OAAO,KAAK,EACV,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,qDAAqD,CAAC;AAI7D;;GAEG;AACH,qBAAa,8BAA+B,YAAW,uBAAuB;IAC5E,OAAO,CAAC,IAAI,CAAO;gBAEP,IAAI,EAAE,IAAI;IAItB;;OAEG;IACG,MAAM,CAAC,MAAM,EAAE,wBAAwB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoC7D;;OAEG;IAEG,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAChD,EAAE,EAAE,MAAM,CAAC;QACX,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,OAAO,CAAC;QAChB,qBAAqB,EAAE,OAAO,CAAC;QAC/B,OAAO,EAAE,GAAG,CAAC;QACb,cAAc,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAChC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,SAAS,EAAE,IAAI,CAAC;KACjB,CAAC,CAAC;CAiCJ"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Quality Check Repository
3
+ *
4
+ * 负责质量检查结果的数据库操作
5
+ */
6
+ import { Pool } from 'pg';
7
+ import { createLogger } from '../logging/logger.js';
8
+ const logger = createLogger('QualityCheckRepository');
9
+ /**
10
+ * PostgreSQL Quality Check Repository 实现
11
+ */
12
+ export class PostgresQualityCheckRepository {
13
+ pool;
14
+ constructor(pool) {
15
+ this.pool = pool;
16
+ }
17
+ /**
18
+ * 创建质量检查记录
19
+ */
20
+ async create(params) {
21
+ const client = await this.pool.connect();
22
+ try {
23
+ await client.query(`INSERT INTO quality_checks
24
+ (task_id, check_type, score, passed, hard_constraints_passed,
25
+ details, fix_suggestions, rubric_version, model_name, prompt_hash)
26
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)`, [
27
+ params.taskId,
28
+ params.checkType,
29
+ params.score,
30
+ params.passed,
31
+ params.hardConstraintsPassed,
32
+ JSON.stringify(params.details || {}),
33
+ params.fixSuggestions || null,
34
+ params.rubricVersion || null,
35
+ params.modelName || null,
36
+ params.promptHash || null,
37
+ ]);
38
+ logger.info('Quality check created', {
39
+ taskId: params.taskId,
40
+ checkType: params.checkType,
41
+ score: params.score,
42
+ passed: params.passed,
43
+ });
44
+ }
45
+ catch (error) {
46
+ logger.error('Failed to create quality check', error);
47
+ throw error;
48
+ }
49
+ finally {
50
+ client.release();
51
+ }
52
+ }
53
+ /**
54
+ * 根据任务 ID 查询质量检查
55
+ */
56
+ // @ts-ignore - Database returns string for checkType, interface expects union type
57
+ async findByTaskId(taskId) {
58
+ const client = await this.pool.connect();
59
+ try {
60
+ const result = await client.query(`SELECT id, task_id, check_type, score, passed, hard_constraints_passed,
61
+ details, fix_suggestions, rubric_version, model_name, prompt_hash, created_at
62
+ FROM quality_checks
63
+ WHERE task_id = $1
64
+ ORDER BY created_at DESC`, [taskId]);
65
+ return result.rows.map((row) => ({
66
+ id: row.id,
67
+ taskId: row.task_id,
68
+ checkType: row.check_type,
69
+ score: row.score,
70
+ passed: row.passed,
71
+ hardConstraintsPassed: row.hard_constraints_passed,
72
+ details: row.details ? JSON.parse(row.details) : null,
73
+ fixSuggestions: row.fix_suggestions,
74
+ rubricVersion: row.rubric_version,
75
+ modelName: row.model_name,
76
+ promptHash: row.prompt_hash,
77
+ createdAt: row.created_at,
78
+ }));
79
+ }
80
+ catch (error) {
81
+ logger.error('Failed to query quality checks', error);
82
+ throw error;
83
+ }
84
+ finally {
85
+ client.release();
86
+ }
87
+ }
88
+ }
89
+ //# sourceMappingURL=PostgresQualityCheckRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostgresQualityCheckRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/database/PostgresQualityCheckRepository.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAMpD,MAAM,MAAM,GAAG,YAAY,CAAC,wBAAwB,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,OAAO,8BAA8B;IACjC,IAAI,CAAO;IAEnB,YAAY,IAAU;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,MAAgC;QAC3C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;QACzC,IAAI,CAAC;YACH,MAAM,MAAM,CAAC,KAAK,CAChB;;;0DAGkD,EAClD;gBACE,MAAM,CAAC,MAAM;gBACb,MAAM,CAAC,SAAS;gBAChB,MAAM,CAAC,KAAK;gBACZ,MAAM,CAAC,MAAM;gBACb,MAAM,CAAC,qBAAqB;gBAC5B,IAAI,CAAC,S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CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI;gBACrD,cAAc,EAAE,GAAG,CAAC,eAAe;gBACnC,aAAa,EAAE,GAAG,CAAC,cAAc;gBACjC,SAAS,EAAE,GAAG,CAAC,UAAU;gBACzB,UAAU,EAAE,GAAG,CAAC,WAAW;gBAC3B,SAAS,EAAE,GAAG,CAAC,UAAU;aAC1B,CAAC,CAAQ,CAAC;QACb,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,KAAc,CAAC,CAAC;YAC/D,MAAM,KAAK,CAAC;QACd,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,94 @@
1
+ /**
2
+ * PostgresTaskRepository - 任务数据访问实现
3
+ *
4
+ * 使用 PostgreSQL 实现任务数据持久化
5
+ * 支持乐观锁并发控制和 Worker 抢占机制
6
+ */
7
+ import { BaseRepository } from './BaseRepository.js';
8
+ import type { ITaskRepository, CreateTaskInput, TaskFilter, Pagination } from '../../domain/repositories/TaskRepository.js';
9
+ import type { Task } from '../../domain/entities/Task.js';
10
+ import { TaskStatus } from '../../domain/entities/Task.js';
11
+ /**
12
+ * PostgreSQL 任务仓储实现
13
+ */
14
+ export declare class PostgresTaskRepository extends BaseRepository implements ITaskRepository {
15
+ /**
16
+ * 创建任务
17
+ */
18
+ create(input: CreateTaskInput): Promise<Task>;
19
+ /**
20
+ * 根据 taskId 查询任务
21
+ */
22
+ findById(taskId: string): Promise<Task | null>;
23
+ /**
24
+ * 根据 idempotencyKey 查询任务
25
+ */
26
+ findByIdempotencyKey(idempotencyKey: string): Promise<Task | null>;
27
+ /**
28
+ * 根据 userId 查询任务列表
29
+ */
30
+ findByUserId(userId: string, pagination?: Pagination): Promise<Task[]>;
31
+ /**
32
+ * 查询任务列表(支持过滤和分页)
33
+ */
34
+ findMany(filter?: TaskFilter, pagination?: Pagination): Promise<Task[]>;
35
+ /**
36
+ * 统计任务数量
37
+ */
38
+ count(filter?: TaskFilter): Promise<number>;
39
+ /**
40
+ * 更新任务状态(带乐观锁)
41
+ */
42
+ updateStatus(taskId: string, status: TaskStatus, version: number): Promise<boolean>;
43
+ /**
44
+ * 更新当前步骤(带乐观锁)
45
+ */
46
+ updateCurrentStep(taskId: string, step: string, version: number): Promise<boolean>;
47
+ /**
48
+ * Worker 抢占任务(乐观锁)
49
+ *
50
+ * 只有状态为 pending 且版本号匹配的任务才能被抢占
51
+ */
52
+ claimTask(taskId: string, workerId: string, version: number): Promise<boolean>;
53
+ /**
54
+ * 增加重试计数(带乐观锁)
55
+ */
56
+ incrementRetryCount(taskId: string, type: 'text' | 'image', version: number): Promise<boolean>;
57
+ /**
58
+ * 保存 State 快照(带乐观锁)
59
+ */
60
+ saveStateSnapshot(taskId: string, snapshot: object, version: number): Promise<boolean>;
61
+ /**
62
+ * 标记任务完成(带乐观锁)
63
+ */
64
+ markAsCompleted(taskId: string, version: number): Promise<boolean>;
65
+ /**
66
+ * 标记任务失败(带乐观锁)
67
+ */
68
+ markAsFailed(taskId: string, errorMessage: string, version: number): Promise<boolean>;
69
+ /**
70
+ * 释放 Worker 占用(用于任务崩溃时)
71
+ */
72
+ releaseWorker(taskId: string, workerId: string, version: number): Promise<boolean>;
73
+ /**
74
+ * 软删除任务
75
+ */
76
+ softDelete(taskId: string): Promise<boolean>;
77
+ /**
78
+ * 永久删除任务
79
+ */
80
+ delete(taskId: string): Promise<boolean>;
81
+ /**
82
+ * 获取待处理任务队列(用于 Worker 获取任务)
83
+ */
84
+ getPendingTasks(limit?: number): Promise<Task[]>;
85
+ /**
86
+ * 获取 Worker 的活跃任务
87
+ */
88
+ getActiveTasksByWorker(workerId: string): Promise<Task[]>;
89
+ /**
90
+ * 映射数据库行到 Task 实体
91
+ */
92
+ private mapToTask;
93
+ }
94
+ //# sourceMappingURL=PostgresTaskRepository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostgresTaskRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/database/PostgresTaskRepository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAC5H,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAiB,MAAM,+BAA+B,CAAC;AAG1E;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,cAAe,YAAW,eAAe;IAEnF;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAiCnD;;OAEG;IACG,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAWpD;;OAEG;IACG,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC;IAWxE;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IAchF;;OAEG;IACG,QAAQ,CAAC,MAAM,GAAE,UAAe,EAAE,UAAU,GAAE,UAAe,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;IA6CrF;;OAEG;IAEG,KAAK,CAAC,MAAM,GAAE,UAAe,GAAG,OAAO,CAAC,MAAM,CAAC;IA2BrD;;OAEG;IACG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAczF;;OAEG;IACG,iBAAiB,CAAC,MAAM,EAAE,MAA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,0 +1,364 @@
1
+ /**
2
+ * PostgresTaskRepository - 任务数据访问实现
3
+ *
4
+ * 使用 PostgreSQL 实现任务数据持久化
5
+ * 支持乐观锁并发控制和 Worker 抢占机制
6
+ */
7
+ import { BaseRepository } from './BaseRepository.js';
8
+ import { TaskStatus, ExecutionMode } from '../../domain/entities/Task.js';
9
+ import { v4 as uuidv4 } from 'uuid';
10
+ /**
11
+ * PostgreSQL 任务仓储实现
12
+ */
13
+ export class PostgresTaskRepository extends BaseRepository {
14
+ /**
15
+ * 创建任务
16
+ */
17
+ async create(input) {
18
+ // 使用幂等键作为 taskId,或者生成新的 UUID
19
+ const taskId = input.idempotencyKey || uuidv4();
20
+ const query = `
21
+ INSERT INTO tasks (
22
+ task_id, user_id, mode, topic, requirements,
23
+ hard_constraints, idempotency_key
24
+ ) VALUES ($1, $2, $3, $4, $5, $6, $7)
25
+ ON CONFLICT (task_id) DO UPDATE SET
26
+ user_id = EXCLUDED.user_id,
27
+ mode = EXCLUDED.mode,
28
+ topic = EXCLUDED.topic,
29
+ requirements = EXCLUDED.requirements,
30
+ hard_constraints = EXCLUDED.hard_constraints,
31
+ updated_at = CURRENT_TIMESTAMP
32
+ RETURNING *
33
+ `;
34
+ const values = [
35
+ taskId,
36
+ input.userId || null,
37
+ input.mode,
38
+ input.topic,
39
+ input.requirements,
40
+ JSON.stringify(input.hardConstraints || {}),
41
+ input.idempotencyKey || null,
42
+ ];
43
+ const result = await this.query(query, values);
44
+ return this.mapToTask(result.rows[0]);
45
+ }
46
+ /**
47
+ * 根据 taskId 查询任务
48
+ */
49
+ async findById(taskId) {
50
+ const query = 'SELECT * FROM tasks WHERE task_id = $1 AND deleted_at IS NULL';
51
+ const result = await this.query(query, [taskId]);
52
+ if (result.rows.length === 0) {
53
+ return null;
54
+ }
55
+ return this.mapToTask(result.rows[0]);
56
+ }
57
+ /**
58
+ * 根据 idempotencyKey 查询任务
59
+ */
60
+ async findByIdempotencyKey(idempotencyKey) {
61
+ const query = 'SELECT * FROM tasks WHERE idempotency_key = $1 AND deleted_at IS NULL';
62
+ const result = await this.query(query, [idempotencyKey]);
63
+ if (result.rows.length === 0) {
64
+ return null;
65
+ }
66
+ return this.mapToTask(result.rows[0]);
67
+ }
68
+ /**
69
+ * 根据 userId 查询任务列表
70
+ */
71
+ async findByUserId(userId, pagination = {}) {
72
+ const { limit = 10, offset = 0 } = pagination;
73
+ const query = `
74
+ SELECT * FROM tasks
75
+ WHERE user_id = $1 AND deleted_at IS NULL
76
+ ORDER BY created_at DESC
77
+ LIMIT $2 OFFSET $3
78
+ `;
79
+ const result = await this.query(query, [userId, limit, offset]);
80
+ return result.rows.map(row => this.mapToTask(row));
81
+ }
82
+ /**
83
+ * 查询任务列表(支持过滤和分页)
84
+ */
85
+ async findMany(filter = {}, pagination = {}) {
86
+ const { limit = 10, offset = 0 } = pagination;
87
+ const conditions = ['deleted_at IS NULL'];
88
+ const params = [];
89
+ let paramIndex = 1;
90
+ if (filter.userId) {
91
+ conditions.push(`user_id = $${paramIndex++}`);
92
+ params.push(filter.userId);
93
+ }
94
+ if (filter.status) {
95
+ conditions.push(`status = $${paramIndex++}`);
96
+ params.push(filter.status);
97
+ }
98
+ if (filter.mode) {
99
+ conditions.push(`mode = $${paramIndex++}`);
100
+ params.push(filter.mode);
101
+ }
102
+ if (filter.startDate) {
103
+ conditions.push(`created_at >= $${paramIndex++}`);
104
+ params.push(filter.startDate);
105
+ }
106
+ if (filter.endDate) {
107
+ conditions.push(`created_at <= $${paramIndex++}`);
108
+ params.push(filter.endDate);
109
+ }
110
+ const whereClause = conditions.join(' AND ');
111
+ const query = `
112
+ SELECT * FROM tasks
113
+ WHERE ${whereClause}
114
+ ORDER BY created_at DESC
115
+ LIMIT $${paramIndex++} OFFSET $${paramIndex++}
116
+ `;
117
+ params.push(limit, offset);
118
+ const result = await this.query(query, params);
119
+ return result.rows.map(row => this.mapToTask(row));
120
+ }
121
+ /**
122
+ * 统计任务数量
123
+ */
124
+ // @ts-ignore - Method signature differs from base class
125
+ async count(filter = {}) {
126
+ const conditions = ['deleted_at IS NULL'];
127
+ const params = [];
128
+ let paramIndex = 1;
129
+ if (filter.userId) {
130
+ conditions.push(`user_id = $${paramIndex++}`);
131
+ params.push(filter.userId);
132
+ }
133
+ if (filter.status) {
134
+ conditions.push(`status = $${paramIndex++}`);
135
+ params.push(filter.status);
136
+ }
137
+ if (filter.mode) {
138
+ conditions.push(`mode = $${paramIndex++}`);
139
+ params.push(filter.mode);
140
+ }
141
+ const whereClause = conditions.join(' AND ');
142
+ const query = `SELECT COUNT(*) as count FROM tasks WHERE ${whereClause}`;
143
+ const result = await this.query(query, params);
144
+ return parseInt(result.rows[0]?.count ?? '0', 10);
145
+ }
146
+ /**
147
+ * 更新任务状态(带乐观锁)
148
+ */
149
+ async updateStatus(taskId, status, version) {
150
+ const query = `
151
+ UPDATE tasks
152
+ SET status = $1,
153
+ version = version + 1,
154
+ updated_at = CURRENT_TIMESTAMP
155
+ WHERE task_id = $2 AND version = $3 AND deleted_at IS NULL
156
+ RETURNING version
157
+ `;
158
+ const result = await this.query(query, [status, taskId, version]);
159
+ return result.rowCount === 1;
160
+ }
161
+ /**
162
+ * 更新当前步骤(带乐观锁)
163
+ */
164
+ async updateCurrentStep(taskId, step, version) {
165
+ const query = `
166
+ UPDATE tasks
167
+ SET current_step = $1,
168
+ version = version + 1,
169
+ updated_at = CURRENT_TIMESTAMP
170
+ WHERE task_id = $2 AND version = $3 AND deleted_at IS NULL
171
+ RETURNING version
172
+ `;
173
+ const result = await this.query(query, [step, taskId, version]);
174
+ return result.rowCount === 1;
175
+ }
176
+ /**
177
+ * Worker 抢占任务(乐观锁)
178
+ *
179
+ * 只有状态为 pending 且版本号匹配的任务才能被抢占
180
+ */
181
+ async claimTask(taskId, workerId, version) {
182
+ const query = `
183
+ UPDATE tasks
184
+ SET worker_id = $1,
185
+ status = 'running',
186
+ started_at = CURRENT_TIMESTAMP,
187
+ current_step = 'claimed',
188
+ version = version + 1,
189
+ updated_at = CURRENT_TIMESTAMP
190
+ WHERE task_id = $2
191
+ AND version = $3
192
+ AND status = 'pending'
193
+ AND deleted_at IS NULL
194
+ RETURNING version
195
+ `;
196
+ const result = await this.query(query, [workerId, taskId, version]);
197
+ return result.rowCount === 1;
198
+ }
199
+ /**
200
+ * 增加重试计数(带乐观锁)
201
+ */
202
+ async incrementRetryCount(taskId, type, version) {
203
+ const column = type === 'text' ? 'text_retry_count' : 'image_retry_count';
204
+ const query = `
205
+ UPDATE tasks
206
+ SET ${column} = ${column} + 1,
207
+ version = version + 1,
208
+ updated_at = CURRENT_TIMESTAMP
209
+ WHERE task_id = $1 AND version = $2 AND deleted_at IS NULL
210
+ RETURNING version
211
+ `;
212
+ const result = await this.query(query, [taskId, version]);
213
+ return result.rowCount === 1;
214
+ }
215
+ /**
216
+ * 保存 State 快照(带乐观锁)
217
+ */
218
+ async saveStateSnapshot(taskId, snapshot, version) {
219
+ const query = `
220
+ UPDATE tasks
221
+ SET state_snapshot = $1,
222
+ version = version + 1,
223
+ updated_at = CURRENT_TIMESTAMP
224
+ WHERE task_id = $2 AND version = $3 AND deleted_at IS NULL
225
+ RETURNING version
226
+ `;
227
+ const result = await this.query(query, [JSON.stringify(snapshot), taskId, version]);
228
+ return result.rowCount === 1;
229
+ }
230
+ /**
231
+ * 标记任务完成(带乐观锁)
232
+ */
233
+ async markAsCompleted(taskId, version) {
234
+ const query = `
235
+ UPDATE tasks
236
+ SET status = 'completed',
237
+ completed_at = CURRENT_TIMESTAMP,
238
+ version = version + 1,
239
+ updated_at = CURRENT_TIMESTAMP
240
+ WHERE task_id = $1 AND version = $2 AND deleted_at IS NULL
241
+ RETURNING version
242
+ `;
243
+ const result = await this.query(query, [taskId, version]);
244
+ return result.rowCount === 1;
245
+ }
246
+ /**
247
+ * 标记任务失败(带乐观锁)
248
+ */
249
+ async markAsFailed(taskId, errorMessage, version) {
250
+ const query = `
251
+ UPDATE tasks
252
+ SET status = 'failed',
253
+ error_message = $1,
254
+ completed_at = CURRENT_TIMESTAMP,
255
+ version = version + 1,
256
+ updated_at = CURRENT_TIMESTAMP
257
+ WHERE task_id = $2 AND version = $3 AND deleted_at IS NULL
258
+ RETURNING version
259
+ `;
260
+ const result = await this.query(query, [errorMessage, taskId, version]);
261
+ return result.rowCount === 1;
262
+ }
263
+ /**
264
+ * 释放 Worker 占用(用于任务崩溃时)
265
+ */
266
+ async releaseWorker(taskId, workerId, version) {
267
+ const query = `
268
+ UPDATE tasks
269
+ SET worker_id = NULL,
270
+ status = 'pending',
271
+ version = version + 1,
272
+ updated_at = CURRENT_TIMESTAMP
273
+ WHERE task_id = $1
274
+ AND worker_id = $2
275
+ AND version = $3
276
+ AND deleted_at IS NULL
277
+ RETURNING version
278
+ `;
279
+ const result = await this.query(query, [taskId, workerId, version]);
280
+ return result.rowCount === 1;
281
+ }
282
+ /**
283
+ * 软删除任务
284
+ */
285
+ async softDelete(taskId) {
286
+ const query = `
287
+ UPDATE tasks
288
+ SET deleted_at = CURRENT_TIMESTAMP,
289
+ updated_at = CURRENT_TIMESTAMP
290
+ WHERE task_id = $1 AND deleted_at IS NULL
291
+ RETURNING task_id
292
+ `;
293
+ const result = await this.query(query, [taskId]);
294
+ return result.rowCount === 1;
295
+ }
296
+ /**
297
+ * 永久删除任务
298
+ */
299
+ async delete(taskId) {
300
+ const query = 'DELETE FROM tasks WHERE task_id = $1 RETURNING task_id';
301
+ const result = await this.query(query, [taskId]);
302
+ return result.rowCount === 1;
303
+ }
304
+ /**
305
+ * 获取待处理任务队列(用于 Worker 获取任务)
306
+ */
307
+ async getPendingTasks(limit = 10) {
308
+ const query = `
309
+ SELECT * FROM tasks
310
+ WHERE status = 'pending' AND deleted_at IS NULL
311
+ ORDER BY priority DESC, created_at ASC
312
+ LIMIT $1
313
+ `;
314
+ const result = await this.query(query, [limit]);
315
+ return result.rows.map(row => this.mapToTask(row));
316
+ }
317
+ /**
318
+ * 获取 Worker 的活跃任务
319
+ */
320
+ async getActiveTasksByWorker(workerId) {
321
+ const query = `
322
+ SELECT * FROM tasks
323
+ WHERE worker_id = $1
324
+ AND status = 'running'
325
+ AND deleted_at IS NULL
326
+ ORDER BY started_at DESC
327
+ `;
328
+ const result = await this.query(query, [workerId]);
329
+ return result.rows.map(row => this.mapToTask(row));
330
+ }
331
+ /**
332
+ * 映射数据库行到 Task 实体
333
+ */
334
+ mapToTask(row) {
335
+ return {
336
+ taskId: row.task_id,
337
+ id: row.task_id, // 别名
338
+ userId: row.user_id || undefined,
339
+ mode: row.mode,
340
+ topic: row.topic,
341
+ requirements: row.requirements,
342
+ targetAudience: '', // 默认值,向后兼容
343
+ hardConstraints: row.hard_constraints || {},
344
+ status: row.status,
345
+ currentStep: row.current_step || undefined,
346
+ workerId: row.worker_id || undefined,
347
+ assignedWorkerId: row.worker_id || undefined, // 别名
348
+ textRetryCount: row.text_retry_count || 0,
349
+ imageRetryCount: row.image_retry_count || 0,
350
+ version: row.version,
351
+ createdAt: new Date(row.created_at),
352
+ startedAt: row.started_at ? new Date(row.started_at) : undefined,
353
+ completedAt: row.completed_at ? new Date(row.completed_at) : undefined,
354
+ updatedAt: new Date(row.updated_at),
355
+ deletedAt: row.deleted_at ? new Date(row.deleted_at) : undefined,
356
+ claimedAt: row.started_at ? new Date(row.started_at) : undefined, // 别名
357
+ errorMessage: row.error_message || undefined,
358
+ stateSnapshot: row.state_snapshot || undefined,
359
+ idempotencyKey: row.idempotency_key || undefined,
360
+ priority: 2, // 默认 NORMAL
361
+ };
362
+ }
363
+ }
364
+ //# sourceMappingURL=PostgresTaskRepository.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostgresTaskRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/database/PostgresTaskRepository.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE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