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.
- package/README.md +309 -0
- package/dist/application/workflow/SyncExecutor.d.ts +75 -0
- package/dist/application/workflow/SyncExecutor.d.ts.map +1 -0
- package/dist/application/workflow/SyncExecutor.js +370 -0
- package/dist/application/workflow/SyncExecutor.js.map +1 -0
- package/dist/application/workflow/types.d.ts +46 -0
- package/dist/application/workflow/types.d.ts.map +1 -0
- package/dist/application/workflow/types.js +7 -0
- package/dist/application/workflow/types.js.map +1 -0
- package/dist/config/index.d.ts +173 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +288 -0
- package/dist/config/index.js.map +1 -0
- package/dist/domain/entities/QualityCheck.d.ts +181 -0
- package/dist/domain/entities/QualityCheck.d.ts.map +1 -0
- package/dist/domain/entities/QualityCheck.js +39 -0
- package/dist/domain/entities/QualityCheck.js.map +1 -0
- package/dist/domain/entities/Result.d.ts +103 -0
- package/dist/domain/entities/Result.d.ts.map +1 -0
- package/dist/domain/entities/Result.js +15 -0
- package/dist/domain/entities/Result.js.map +1 -0
- package/dist/domain/entities/Task.d.ts +130 -0
- package/dist/domain/entities/Task.d.ts.map +1 -0
- package/dist/domain/entities/Task.js +64 -0
- package/dist/domain/entities/Task.js.map +1 -0
- package/dist/domain/entities/TaskStep.d.ts +160 -0
- package/dist/domain/entities/TaskStep.d.ts.map +1 -0
- package/dist/domain/entities/TaskStep.js +30 -0
- package/dist/domain/entities/TaskStep.js.map +1 -0
- package/dist/domain/entities/TokenUsage.d.ts +70 -0
- package/dist/domain/entities/TokenUsage.d.ts.map +1 -0
- package/dist/domain/entities/TokenUsage.js +42 -0
- package/dist/domain/entities/TokenUsage.js.map +1 -0
- package/dist/domain/entities/index.d.ts +11 -0
- package/dist/domain/entities/index.d.ts.map +1 -0
- package/dist/domain/entities/index.js +16 -0
- package/dist/domain/entities/index.js.map +1 -0
- package/dist/domain/repositories/QualityCheckRepository.d.ts +49 -0
- package/dist/domain/repositories/QualityCheckRepository.d.ts.map +1 -0
- package/dist/domain/repositories/QualityCheckRepository.js +5 -0
- package/dist/domain/repositories/QualityCheckRepository.js.map +1 -0
- package/dist/domain/repositories/ResultRepository.d.ts +43 -0
- package/dist/domain/repositories/ResultRepository.d.ts.map +1 -0
- package/dist/domain/repositories/ResultRepository.js +5 -0
- package/dist/domain/repositories/ResultRepository.js.map +1 -0
- package/dist/domain/repositories/TaskRepository.d.ts +240 -0
- package/dist/domain/repositories/TaskRepository.d.ts.map +1 -0
- package/dist/domain/repositories/TaskRepository.js +7 -0
- package/dist/domain/repositories/TaskRepository.js.map +1 -0
- package/dist/domain/workflow/CheckpointManager.d.ts +94 -0
- package/dist/domain/workflow/CheckpointManager.d.ts.map +1 -0
- package/dist/domain/workflow/CheckpointManager.js +224 -0
- package/dist/domain/workflow/CheckpointManager.js.map +1 -0
- package/dist/domain/workflow/ContentCreatorGraph.d.ts +17 -0
- package/dist/domain/workflow/ContentCreatorGraph.d.ts.map +1 -0
- package/dist/domain/workflow/ContentCreatorGraph.js +381 -0
- package/dist/domain/workflow/ContentCreatorGraph.js.map +1 -0
- package/dist/domain/workflow/State.d.ts +172 -0
- package/dist/domain/workflow/State.d.ts.map +1 -0
- package/dist/domain/workflow/State.js +184 -0
- package/dist/domain/workflow/State.js.map +1 -0
- package/dist/domain/workflow/index.d.ts +11 -0
- package/dist/domain/workflow/index.d.ts.map +1 -0
- package/dist/domain/workflow/index.js +15 -0
- package/dist/domain/workflow/index.js.map +1 -0
- package/dist/domain/workflow/nodes/BaseNode.d.ts +134 -0
- package/dist/domain/workflow/nodes/BaseNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/BaseNode.js +253 -0
- package/dist/domain/workflow/nodes/BaseNode.js.map +1 -0
- package/dist/domain/workflow/nodes/CheckImageNode.d.ts +43 -0
- package/dist/domain/workflow/nodes/CheckImageNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/CheckImageNode.js +254 -0
- package/dist/domain/workflow/nodes/CheckImageNode.js.map +1 -0
- package/dist/domain/workflow/nodes/CheckTextNode.d.ts +66 -0
- package/dist/domain/workflow/nodes/CheckTextNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/CheckTextNode.js +530 -0
- package/dist/domain/workflow/nodes/CheckTextNode.js.map +1 -0
- package/dist/domain/workflow/nodes/GenerateImageNode.d.ts +44 -0
- package/dist/domain/workflow/nodes/GenerateImageNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/GenerateImageNode.js +272 -0
- package/dist/domain/workflow/nodes/GenerateImageNode.js.map +1 -0
- package/dist/domain/workflow/nodes/OrganizeNode.d.ts +49 -0
- package/dist/domain/workflow/nodes/OrganizeNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/OrganizeNode.js +241 -0
- package/dist/domain/workflow/nodes/OrganizeNode.js.map +1 -0
- package/dist/domain/workflow/nodes/SearchNode.d.ts +48 -0
- package/dist/domain/workflow/nodes/SearchNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/SearchNode.js +151 -0
- package/dist/domain/workflow/nodes/SearchNode.js.map +1 -0
- package/dist/domain/workflow/nodes/WriteNode.d.ts +68 -0
- package/dist/domain/workflow/nodes/WriteNode.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/WriteNode.js +431 -0
- package/dist/domain/workflow/nodes/WriteNode.js.map +1 -0
- package/dist/domain/workflow/nodes/config/index.js +287 -0
- package/dist/domain/workflow/nodes/domain/entities/Task.js +68 -0
- package/dist/domain/workflow/nodes/domain/workflow/State.js +200 -0
- package/dist/domain/workflow/nodes/domain/workflow/nodes/BaseNode.js +328 -0
- package/dist/domain/workflow/nodes/domain/workflow/nodes/CheckTextNode.js +500 -0
- package/dist/domain/workflow/nodes/index.d.ts +13 -0
- package/dist/domain/workflow/nodes/index.d.ts.map +1 -0
- package/dist/domain/workflow/nodes/index.js +13 -0
- package/dist/domain/workflow/nodes/index.js.map +1 -0
- package/dist/domain/workflow/nodes/infrastructure/logging/logger.js +275 -0
- package/dist/domain/workflow/nodes/services/llm/EnhancedLLMService.js +559 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/cache/CacheService.d.ts +139 -0
- package/dist/infrastructure/cache/CacheService.d.ts.map +1 -0
- package/dist/infrastructure/cache/CacheService.js +419 -0
- package/dist/infrastructure/cache/CacheService.js.map +1 -0
- package/dist/infrastructure/cache/index.d.ts +5 -0
- package/dist/infrastructure/cache/index.d.ts.map +1 -0
- package/dist/infrastructure/cache/index.js +6 -0
- package/dist/infrastructure/cache/index.js.map +1 -0
- package/dist/infrastructure/database/BaseRepository.d.ts +98 -0
- package/dist/infrastructure/database/BaseRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/BaseRepository.js +178 -0
- package/dist/infrastructure/database/BaseRepository.js.map +1 -0
- package/dist/infrastructure/database/MemoryTaskRepository.d.ts +77 -0
- package/dist/infrastructure/database/MemoryTaskRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/MemoryTaskRepository.js +309 -0
- package/dist/infrastructure/database/MemoryTaskRepository.js.map +1 -0
- package/dist/infrastructure/database/PostgresQualityCheckRepository.d.ts +36 -0
- package/dist/infrastructure/database/PostgresQualityCheckRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/PostgresQualityCheckRepository.js +89 -0
- package/dist/infrastructure/database/PostgresQualityCheckRepository.js.map +1 -0
- package/dist/infrastructure/database/PostgresTaskRepository.d.ts +94 -0
- package/dist/infrastructure/database/PostgresTaskRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/PostgresTaskRepository.js +364 -0
- package/dist/infrastructure/database/PostgresTaskRepository.js.map +1 -0
- package/dist/infrastructure/database/ResultRepository.d.ts +41 -0
- package/dist/infrastructure/database/ResultRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/ResultRepository.js +86 -0
- package/dist/infrastructure/database/ResultRepository.js.map +1 -0
- package/dist/infrastructure/database/SQLiteTaskRepository.d.ts +101 -0
- package/dist/infrastructure/database/SQLiteTaskRepository.d.ts.map +1 -0
- package/dist/infrastructure/database/SQLiteTaskRepository.js +548 -0
- package/dist/infrastructure/database/SQLiteTaskRepository.js.map +1 -0
- package/dist/infrastructure/database/index.d.ts +32 -0
- package/dist/infrastructure/database/index.d.ts.map +1 -0
- package/dist/infrastructure/database/index.js +72 -0
- package/dist/infrastructure/database/index.js.map +1 -0
- package/dist/infrastructure/logging/logger.d.ts +69 -0
- package/dist/infrastructure/logging/logger.d.ts.map +1 -0
- package/dist/infrastructure/logging/logger.js +169 -0
- package/dist/infrastructure/logging/logger.js.map +1 -0
- package/dist/infrastructure/monitoring/LoggingService.d.ts +109 -0
- package/dist/infrastructure/monitoring/LoggingService.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/LoggingService.js +198 -0
- package/dist/infrastructure/monitoring/LoggingService.js.map +1 -0
- package/dist/infrastructure/monitoring/MetricsService.d.ts +112 -0
- package/dist/infrastructure/monitoring/MetricsService.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/MetricsService.js +362 -0
- package/dist/infrastructure/monitoring/MetricsService.js.map +1 -0
- package/dist/infrastructure/monitoring/SentryService.d.ts +108 -0
- package/dist/infrastructure/monitoring/SentryService.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/SentryService.js +282 -0
- package/dist/infrastructure/monitoring/SentryService.js.map +1 -0
- package/dist/infrastructure/monitoring/index.d.ts +7 -0
- package/dist/infrastructure/monitoring/index.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/index.js +10 -0
- package/dist/infrastructure/monitoring/index.js.map +1 -0
- package/dist/infrastructure/queue/TaskQueue.d.ts +110 -0
- package/dist/infrastructure/queue/TaskQueue.d.ts.map +1 -0
- package/dist/infrastructure/queue/TaskQueue.js +363 -0
- package/dist/infrastructure/queue/TaskQueue.js.map +1 -0
- package/dist/infrastructure/queue/index.d.ts +5 -0
- package/dist/infrastructure/queue/index.d.ts.map +1 -0
- package/dist/infrastructure/queue/index.js +5 -0
- package/dist/infrastructure/queue/index.js.map +1 -0
- package/dist/infrastructure/redis/connection.d.ts +61 -0
- package/dist/infrastructure/redis/connection.d.ts.map +1 -0
- package/dist/infrastructure/redis/connection.js +184 -0
- package/dist/infrastructure/redis/connection.js.map +1 -0
- package/dist/infrastructure/redis/index.d.ts +5 -0
- package/dist/infrastructure/redis/index.d.ts.map +1 -0
- package/dist/infrastructure/redis/index.js +5 -0
- package/dist/infrastructure/redis/index.js.map +1 -0
- package/dist/infrastructure/security/ApiKeyService.d.ts +103 -0
- package/dist/infrastructure/security/ApiKeyService.d.ts.map +1 -0
- package/dist/infrastructure/security/ApiKeyService.js +250 -0
- package/dist/infrastructure/security/ApiKeyService.js.map +1 -0
- package/dist/infrastructure/security/QuotaService.d.ts +87 -0
- package/dist/infrastructure/security/QuotaService.d.ts.map +1 -0
- package/dist/infrastructure/security/QuotaService.js +303 -0
- package/dist/infrastructure/security/QuotaService.js.map +1 -0
- package/dist/infrastructure/security/RateLimiter.d.ts +104 -0
- package/dist/infrastructure/security/RateLimiter.d.ts.map +1 -0
- package/dist/infrastructure/security/RateLimiter.js +331 -0
- package/dist/infrastructure/security/RateLimiter.js.map +1 -0
- package/dist/infrastructure/security/index.d.ts +7 -0
- package/dist/infrastructure/security/index.d.ts.map +1 -0
- package/dist/infrastructure/security/index.js +10 -0
- package/dist/infrastructure/security/index.js.map +1 -0
- package/dist/monitoring/index.d.ts +5 -0
- package/dist/monitoring/index.d.ts.map +1 -0
- package/dist/monitoring/index.js +5 -0
- package/dist/monitoring/index.js.map +1 -0
- package/dist/monitoring/server.d.ts +14 -0
- package/dist/monitoring/server.d.ts.map +1 -0
- package/dist/monitoring/server.js +99 -0
- package/dist/monitoring/server.js.map +1 -0
- package/dist/presentation/cli/commands/cancel.d.ts +8 -0
- package/dist/presentation/cli/commands/cancel.d.ts.map +1 -0
- package/dist/presentation/cli/commands/cancel.js +57 -0
- package/dist/presentation/cli/commands/cancel.js.map +1 -0
- package/dist/presentation/cli/commands/create.d.ts +8 -0
- package/dist/presentation/cli/commands/create.d.ts.map +1 -0
- package/dist/presentation/cli/commands/create.js +368 -0
- package/dist/presentation/cli/commands/create.js.map +1 -0
- package/dist/presentation/cli/commands/result.d.ts +8 -0
- package/dist/presentation/cli/commands/result.d.ts.map +1 -0
- package/dist/presentation/cli/commands/result.js +121 -0
- package/dist/presentation/cli/commands/result.js.map +1 -0
- package/dist/presentation/cli/commands/status.d.ts +8 -0
- package/dist/presentation/cli/commands/status.d.ts.map +1 -0
- package/dist/presentation/cli/commands/status.js +92 -0
- package/dist/presentation/cli/commands/status.js.map +1 -0
- package/dist/presentation/cli/index.d.ts +8 -0
- package/dist/presentation/cli/index.d.ts.map +1 -0
- package/dist/presentation/cli/index.js +32 -0
- package/dist/presentation/cli/index.js.map +1 -0
- package/dist/presentation/cli/utils/cleanup.d.ts +14 -0
- package/dist/presentation/cli/utils/cleanup.d.ts.map +1 -0
- package/dist/presentation/cli/utils/cleanup.js +62 -0
- package/dist/presentation/cli/utils/cleanup.js.map +1 -0
- package/dist/presentation/cli/utils/formatter.d.ts +28 -0
- package/dist/presentation/cli/utils/formatter.d.ts.map +1 -0
- package/dist/presentation/cli/utils/formatter.js +68 -0
- package/dist/presentation/cli/utils/formatter.js.map +1 -0
- package/dist/presentation/cli.d.ts +7 -0
- package/dist/presentation/cli.d.ts.map +1 -0
- package/dist/presentation/cli.js +8 -0
- package/dist/presentation/cli.js.map +1 -0
- package/dist/presentation/monitor-cli.d.ts +8 -0
- package/dist/presentation/monitor-cli.d.ts.map +1 -0
- package/dist/presentation/monitor-cli.js +44 -0
- package/dist/presentation/monitor-cli.js.map +1 -0
- package/dist/presentation/worker-cli.d.ts +8 -0
- package/dist/presentation/worker-cli.d.ts.map +1 -0
- package/dist/presentation/worker-cli.js +51 -0
- package/dist/presentation/worker-cli.js.map +1 -0
- package/dist/schedulers/TaskScheduler.d.ts +99 -0
- package/dist/schedulers/TaskScheduler.d.ts.map +1 -0
- package/dist/schedulers/TaskScheduler.js +233 -0
- package/dist/schedulers/TaskScheduler.js.map +1 -0
- package/dist/schedulers/index.d.ts +5 -0
- package/dist/schedulers/index.d.ts.map +1 -0
- package/dist/schedulers/index.js +5 -0
- package/dist/schedulers/index.js.map +1 -0
- package/dist/services/image/ImageService.d.ts +68 -0
- package/dist/services/image/ImageService.d.ts.map +1 -0
- package/dist/services/image/ImageService.js +166 -0
- package/dist/services/image/ImageService.js.map +1 -0
- package/dist/services/index.d.ts +8 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/index.js +12 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/llm/EnhancedLLMService.d.ts +148 -0
- package/dist/services/llm/EnhancedLLMService.d.ts.map +1 -0
- package/dist/services/llm/EnhancedLLMService.js +425 -0
- package/dist/services/llm/EnhancedLLMService.js.map +1 -0
- package/dist/services/llm/LLMService.d.ts +103 -0
- package/dist/services/llm/LLMService.d.ts.map +1 -0
- package/dist/services/llm/LLMService.js +212 -0
- package/dist/services/llm/LLMService.js.map +1 -0
- package/dist/services/quality/HardRuleChecker.d.ts +143 -0
- package/dist/services/quality/HardRuleChecker.d.ts.map +1 -0
- package/dist/services/quality/HardRuleChecker.js +353 -0
- package/dist/services/quality/HardRuleChecker.js.map +1 -0
- package/dist/services/quality/LLMEvaluator.d.ts +105 -0
- package/dist/services/quality/LLMEvaluator.d.ts.map +1 -0
- package/dist/services/quality/LLMEvaluator.js +312 -0
- package/dist/services/quality/LLMEvaluator.js.map +1 -0
- package/dist/services/quality/QualityCheckService.d.ts +112 -0
- package/dist/services/quality/QualityCheckService.d.ts.map +1 -0
- package/dist/services/quality/QualityCheckService.js +342 -0
- package/dist/services/quality/QualityCheckService.js.map +1 -0
- package/dist/services/quality/QualityService.d.ts +75 -0
- package/dist/services/quality/QualityService.d.ts.map +1 -0
- package/dist/services/quality/QualityService.js +360 -0
- package/dist/services/quality/QualityService.js.map +1 -0
- package/dist/services/quality/index.d.ts +7 -0
- package/dist/services/quality/index.d.ts.map +1 -0
- package/dist/services/quality/index.js +10 -0
- package/dist/services/quality/index.js.map +1 -0
- package/dist/services/search/SearchService.d.ts +79 -0
- package/dist/services/search/SearchService.d.ts.map +1 -0
- package/dist/services/search/SearchService.js +193 -0
- package/dist/services/search/SearchService.js.map +1 -0
- package/dist/workers/TaskWorker.d.ts +61 -0
- package/dist/workers/TaskWorker.d.ts.map +1 -0
- package/dist/workers/TaskWorker.js +256 -0
- package/dist/workers/TaskWorker.js.map +1 -0
- package/dist/workers/index.d.ts +5 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +5 -0
- package/dist/workers/index.js.map +1 -0
- package/docs/DOCUMENTATION-ANALYSIS.md +190 -0
- package/docs/README.md +145 -0
- package/docs/SOURCE-CODE-ANALYSIS.md +1107 -0
- package/docs/architecture-complete.md +5524 -0
- package/docs/archive/implementation/implementation-analysis/README.md +244 -0
- package/docs/archive/implementation/implementation-analysis/implementation-analysis-context.md +483 -0
- package/docs/archive/implementation/implementation-analysis/implementation-analysis-plan.md +1242 -0
- package/docs/archive/implementation/implementation-analysis/implementation-analysis-tasks.md +777 -0
- package/docs/archive/phases/phase-1/phase-1-completion-summary.md +284 -0
- package/docs/archive/phases/phase-1/phase-1-implementation-guide.md +1380 -0
- package/docs/archive/phases/phase-2/phase-2a/phase-2a-completion-summary.md +443 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-completion-report.md +430 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-completion-summary.md +592 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-final-summary.md +371 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-preparation-complete.md +343 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-preparation.md +945 -0
- package/docs/archive/phases/phase-2/phase-2b/phase-2b-progress-update.md +366 -0
- package/docs/archive/phases/phase-3/phase-3-completion-summary.md +354 -0
- package/docs/archive/phases/phase-3/phase-3-development-plan.md +878 -0
- package/docs/archive/phases/phase-3/phase-3-quick-start.md +324 -0
- package/docs/archive/phases/phase-4/phase-4-completion-summary.md +708 -0
- package/docs/archive/phases/phase-4/phase-4-development-plan.md +740 -0
- package/docs/archive/phases/phase-4/phase-4-quick-start.md +632 -0
- package/docs/archive/phases/phase-4/phase-4-session-3-security-testing.md +484 -0
- package/docs/archive/phases/phase-4/phase-4-session-4-unit-tests.md +550 -0
- package/docs/archive/phases/phase-4/phase-4-session-5-security-tests.md +564 -0
- package/docs/archive/phases/phase-4/phase-4-session-6-cache-integration.md +456 -0
- package/docs/archive/phases/phase-4/phase-4-session-7-test-fixes.md +348 -0
- package/docs/archive/phases/phase-4/phase-4-session-8-taskqueue-fixes.md +323 -0
- package/docs/archive/phases/phase-4/phase-4-session-summary-continued.md +373 -0
- package/docs/archive/phases/phase-4/phase-4-session-summary.md +595 -0
- package/docs/archive/reports/progress-reports/PHASE_0_PROGRESS.md +242 -0
- package/docs/archive/reports/progress-reports/PHASE_0_SUMMARY.md +262 -0
- package/docs/archive/reports/progress-reports/PHASE_1_2_ISSUES.md +399 -0
- package/docs/archive/reports/progress-reports/PHASE_1_PROGRESS.md +388 -0
- package/docs/archive/reports/progress-reports/PHASE_3_PREPARATION.md +574 -0
- package/docs/archive/reports/progress-reports/current-progress-update.md +294 -0
- package/docs/archive/reports/progress-reports/final-summary.md +215 -0
- package/docs/archive/reports/progress-reports/implementation-summary.md +287 -0
- package/docs/archive/reports/progress-reports/project-progress-report.md +440 -0
- package/docs/archive/reports/progress-reports/project-progress.md +386 -0
- package/docs/archive/reports/test-reports/TEST-COVERAGE-REPORT.md +441 -0
- package/docs/archive/reports/test-reports/e2e-test-report.md +293 -0
- package/docs/archive/reports/test-reports/final-test-report.md +367 -0
- package/docs/archive/reports/test-reports/real-env-test-report.md +391 -0
- package/docs/archive/reports/test-reports/test-completion-summary.md +356 -0
- package/docs/archive/reports/test-reports/test-report.md +371 -0
- package/docs/archive/sessions/session-2-summary.md +429 -0
- package/docs/archive/sessions/session-3-summary.md +395 -0
- package/docs/archive/sessions/session-summary.md +370 -0
- package/docs/config-system-update.md +239 -0
- package/docs/database-refactoring-PLAN.md +199 -0
- package/docs/database-refactoring-SUMMARY.md +384 -0
- package/docs/quality-check-architecture.md +1030 -0
- package/docs/quick-start.md +388 -0
- package/docs/references/bullmq-quick-reference.md +525 -0
- package/docs/references/monitoring-optimization-guide.md +871 -0
- package/docs/references/performance-optimization-guide.md +933 -0
- package/docs/storage-guide.md +612 -0
- package/docs/test-implementation-PLAN.md +223 -0
- package/docs/test-implementation-SUMMARY.md +194 -0
- package/docs/user-guide.md +719 -0
- package/docs/workflow-architecture.md +549 -0
- package/package.json +126 -0
- package/src/application/workflow/SyncExecutor.ts +444 -0
- package/src/application/workflow/types.ts +57 -0
- package/src/config/index.ts +352 -0
- package/src/domain/entities/QualityCheck.ts +202 -0
- package/src/domain/entities/Result.ts +130 -0
- package/src/domain/entities/Task.ts +178 -0
- package/src/domain/entities/TaskStep.ts +188 -0
- package/src/domain/entities/TokenUsage.ts +119 -0
- package/src/domain/entities/index.ts +20 -0
- package/src/domain/repositories/QualityCheckRepository.ts +52 -0
- package/src/domain/repositories/ResultRepository.ts +47 -0
- package/src/domain/repositories/TaskRepository.ts +271 -0
- package/src/domain/workflow/CheckpointManager.ts +283 -0
- package/src/domain/workflow/ContentCreatorGraph.ts +446 -0
- package/src/domain/workflow/State.ts +321 -0
- package/src/domain/workflow/index.ts +18 -0
- package/src/domain/workflow/nodes/BaseNode.ts +325 -0
- package/src/domain/workflow/nodes/CheckImageNode.ts +325 -0
- package/src/domain/workflow/nodes/CheckTextNode.ts +709 -0
- package/src/domain/workflow/nodes/GenerateImageNode.ts +342 -0
- package/src/domain/workflow/nodes/OrganizeNode.ts +304 -0
- package/src/domain/workflow/nodes/SearchNode.ts +192 -0
- package/src/domain/workflow/nodes/WriteNode.ts +505 -0
- package/src/domain/workflow/nodes/index.ts +13 -0
- package/src/index.ts +43 -0
- package/src/infrastructure/cache/CacheService.ts +483 -0
- package/src/infrastructure/cache/index.ts +6 -0
- package/src/infrastructure/database/BaseRepository.ts +214 -0
- package/src/infrastructure/database/MemoryTaskRepository.ts +377 -0
- package/src/infrastructure/database/PostgresQualityCheckRepository.ts +115 -0
- package/src/infrastructure/database/PostgresTaskRepository.ts +424 -0
- package/src/infrastructure/database/ResultRepository.ts +113 -0
- package/src/infrastructure/database/SQLiteTaskRepository.ts +651 -0
- package/src/infrastructure/database/index.ts +83 -0
- package/src/infrastructure/logging/logger.ts +231 -0
- package/src/infrastructure/monitoring/LoggingService.ts +292 -0
- package/src/infrastructure/monitoring/MetricsService.ts +468 -0
- package/src/infrastructure/monitoring/SentryService.ts +345 -0
- package/src/infrastructure/monitoring/index.ts +12 -0
- package/src/infrastructure/queue/TaskQueue.ts +429 -0
- package/src/infrastructure/queue/index.ts +5 -0
- package/src/infrastructure/redis/connection.ts +215 -0
- package/src/infrastructure/redis/index.ts +5 -0
- package/src/infrastructure/security/ApiKeyService.ts +340 -0
- package/src/infrastructure/security/QuotaService.ts +411 -0
- package/src/infrastructure/security/RateLimiter.ts +417 -0
- package/src/infrastructure/security/index.ts +12 -0
- package/src/monitoring/index.ts +5 -0
- package/src/monitoring/server.ts +109 -0
- package/src/presentation/cli/commands/cancel.ts +64 -0
- package/src/presentation/cli/commands/create.ts +400 -0
- package/src/presentation/cli/commands/result.ts +136 -0
- package/src/presentation/cli/commands/status.ts +102 -0
- package/src/presentation/cli/index.ts +39 -0
- package/src/presentation/cli/utils/cleanup.ts +65 -0
- package/src/presentation/cli/utils/formatter.ts +74 -0
- package/src/presentation/cli.ts +8 -0
- package/src/presentation/monitor-cli.ts +52 -0
- package/src/presentation/worker-cli.ts +62 -0
- package/src/schedulers/TaskScheduler.ts +314 -0
- package/src/schedulers/index.ts +11 -0
- package/src/services/image/ImageService.ts +221 -0
- package/src/services/index.ts +15 -0
- package/src/services/llm/EnhancedLLMService.ts +596 -0
- package/src/services/llm/LLMService.ts +310 -0
- package/src/services/quality/HardRuleChecker.ts +509 -0
- package/src/services/quality/LLMEvaluator.ts +400 -0
- package/src/services/quality/QualityCheckService.ts +473 -0
- package/src/services/quality/QualityService.ts +445 -0
- package/src/services/quality/index.ts +12 -0
- package/src/services/search/SearchService.ts +266 -0
- package/src/types/global.d.ts +17 -0
- package/src/workers/TaskWorker.ts +320 -0
- package/src/workers/index.ts +5 -0
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI create命令
|
|
3
|
+
*
|
|
4
|
+
* 创建内容创作任务
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import ora from 'ora';
|
|
9
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
10
|
+
import { createSyncExecutor } from '../../../application/workflow/SyncExecutor.js';
|
|
11
|
+
import { MemoryTaskRepository } from '../../../infrastructure/database/MemoryTaskRepository.js';
|
|
12
|
+
import { PostgresTaskRepository } from '../../../infrastructure/database/PostgresTaskRepository.js';
|
|
13
|
+
import { PostgresResultRepository } from '../../../infrastructure/database/ResultRepository.js';
|
|
14
|
+
import { PostgresQualityCheckRepository } from '../../../infrastructure/database/PostgresQualityCheckRepository.js';
|
|
15
|
+
import { ExecutionMode, TaskPriority } from '../../../domain/entities/Task.js';
|
|
16
|
+
import { createLogger } from '../../../infrastructure/logging/logger.js';
|
|
17
|
+
import { closeLogger } from '../../../infrastructure/logging/logger.js';
|
|
18
|
+
import { printSeparator, formatDuration, formatTokens, formatCost } from '../utils/formatter.js';
|
|
19
|
+
import { config } from '../../../config/index.js';
|
|
20
|
+
const logger = createLogger('CLI:Create');
|
|
21
|
+
export const createCommand = new Command('create')
|
|
22
|
+
.description('创建内容创作任务')
|
|
23
|
+
.option('-t, --topic <topic>', '文章主题')
|
|
24
|
+
.option('-r, --requirements <requirements>', '创作要求')
|
|
25
|
+
.option('-a, --audience <audience>', '目标受众', '普通读者')
|
|
26
|
+
.option('--keywords <keywords>', '关键词(逗号分隔)', '')
|
|
27
|
+
.option('--tone <tone>', '语气风格', '专业')
|
|
28
|
+
.option('--min-words <number>', '最小字数', '500')
|
|
29
|
+
.option('--max-words <number>', '最大字数', '2000')
|
|
30
|
+
.option('--mode <mode>', '执行模式 (sync|async)', 'sync')
|
|
31
|
+
.option('--priority <priority>', '优先级 (low|normal|high|urgent)', 'normal')
|
|
32
|
+
.option('--sync', '同步执行(等待结果)', false)
|
|
33
|
+
.action(async (options) => {
|
|
34
|
+
// ==================== 第一阶段:参数验证(不需要任何服务) ====================
|
|
35
|
+
try {
|
|
36
|
+
// 验证输入
|
|
37
|
+
if (!options.topic) {
|
|
38
|
+
console.error(chalk.red('❌ 错误: 必须提供文章主题 (-t, --topic)'));
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
if (!options.requirements) {
|
|
42
|
+
console.error(chalk.red('❌ 错误: 必须提供创作要求 (-r, --requirements)'));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
// 显示任务信息
|
|
46
|
+
console.log(chalk.blue.bold('\n🚀 创建内容创作任务'));
|
|
47
|
+
printSeparator();
|
|
48
|
+
console.log(chalk.white(`主题: ${options.topic}`));
|
|
49
|
+
console.log(chalk.white(`要求: ${options.requirements}`));
|
|
50
|
+
console.log(chalk.white(`受众: ${options.audience}`));
|
|
51
|
+
console.log(chalk.white(`语气: ${options.tone}`));
|
|
52
|
+
if (options.keywords) {
|
|
53
|
+
console.log(chalk.white(`关键词: ${options.keywords}`));
|
|
54
|
+
}
|
|
55
|
+
console.log(chalk.white(`执行模式: ${options.mode}`));
|
|
56
|
+
console.log(chalk.white(`优先级: ${options.priority}`));
|
|
57
|
+
printSeparator();
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error(chalk.red(`\n❌ 参数验证失败: ${error instanceof Error ? error.message : String(error)}`));
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
// 解析关键词(在两个 try 块之外的共享作用域)
|
|
64
|
+
const keywords = options.keywords
|
|
65
|
+
? options.keywords.split(',').map((k) => k.trim())
|
|
66
|
+
: undefined;
|
|
67
|
+
// ==================== 第二阶段:服务初始化(仅在验证通过后) ====================
|
|
68
|
+
// 延迟导入服务,避免参数验证失败时不必要的初始化
|
|
69
|
+
const { redisClient } = await import('../../../infrastructure/redis/connection.js');
|
|
70
|
+
const { metricsService } = await import('../../../infrastructure/monitoring/MetricsService.js');
|
|
71
|
+
// 资源管理变量
|
|
72
|
+
const resources = {
|
|
73
|
+
pool: null,
|
|
74
|
+
servicesInitialized: true,
|
|
75
|
+
};
|
|
76
|
+
try {
|
|
77
|
+
// 创建执行器
|
|
78
|
+
// 根据配置选择使用 PostgreSQL 或内存数据库
|
|
79
|
+
let taskRepo;
|
|
80
|
+
let resultRepo = null;
|
|
81
|
+
let qualityCheckRepo = null;
|
|
82
|
+
if (config.database.type === 'postgres') {
|
|
83
|
+
const { Pool } = await import('pg');
|
|
84
|
+
resources.pool = new Pool({
|
|
85
|
+
host: config.postgres.host,
|
|
86
|
+
port: config.postgres.port,
|
|
87
|
+
database: config.postgres.database,
|
|
88
|
+
user: config.postgres.user,
|
|
89
|
+
password: config.postgres.password,
|
|
90
|
+
});
|
|
91
|
+
// 使用 PostgreSQL Task Repository,确保任务持久化
|
|
92
|
+
taskRepo = new PostgresTaskRepository(resources.pool);
|
|
93
|
+
resultRepo = new PostgresResultRepository(resources.pool);
|
|
94
|
+
qualityCheckRepo = new PostgresQualityCheckRepository(resources.pool);
|
|
95
|
+
console.log('✅ 使用 PostgreSQL 持久化存储');
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
// 使用内存数据库(仅用于测试)
|
|
99
|
+
taskRepo = new MemoryTaskRepository();
|
|
100
|
+
console.log('⚠️ 使用内存存储(数据不会持久化)');
|
|
101
|
+
}
|
|
102
|
+
// ==================== 第三阶段:执行任务 ====================
|
|
103
|
+
const isAsyncMode = options.mode === 'async';
|
|
104
|
+
if (isAsyncMode) {
|
|
105
|
+
// ==================== 异步模式:使用 TaskScheduler ====================
|
|
106
|
+
const { TaskScheduler } = await import('../../../schedulers/TaskScheduler.js');
|
|
107
|
+
const scheduler = new TaskScheduler();
|
|
108
|
+
// 初始化调度器
|
|
109
|
+
await scheduler.initialize();
|
|
110
|
+
// 创建进度spinner
|
|
111
|
+
const spinner = ora('添加任务到队列...').start();
|
|
112
|
+
// 添加任务到队列
|
|
113
|
+
const taskId = await scheduler.scheduleTask({
|
|
114
|
+
mode: 'async',
|
|
115
|
+
topic: options.topic,
|
|
116
|
+
requirements: options.requirements,
|
|
117
|
+
hardConstraints: {
|
|
118
|
+
minWords: parseInt(options.minWords) || undefined,
|
|
119
|
+
maxWords: parseInt(options.maxWords) || undefined,
|
|
120
|
+
keywords,
|
|
121
|
+
},
|
|
122
|
+
priority: parsePriorityToNumber(options.priority),
|
|
123
|
+
});
|
|
124
|
+
spinner.succeed('任务已添加到队列!');
|
|
125
|
+
// 显示任务信息
|
|
126
|
+
console.log(chalk.green.bold('\n✅ 任务已成功创建'));
|
|
127
|
+
printSeparator();
|
|
128
|
+
console.log(chalk.white(`任务ID: ${taskId}`));
|
|
129
|
+
console.log(chalk.white(`模式: 异步(队列)`));
|
|
130
|
+
console.log(chalk.white(`状态: 等待 Worker 处理`));
|
|
131
|
+
printSeparator();
|
|
132
|
+
console.log(chalk.yellow.bold('\n💡 后续操作:'));
|
|
133
|
+
console.log(chalk.white('1. 查询任务状态:'));
|
|
134
|
+
console.log(chalk.gray(` pnpm cli result --task-id ${taskId}`));
|
|
135
|
+
console.log(chalk.white('\n2. 确保 Worker 正在运行:'));
|
|
136
|
+
console.log(chalk.gray(' pnpm run worker'));
|
|
137
|
+
console.log(chalk.white('\n3. 查看队列状态:'));
|
|
138
|
+
console.log(chalk.gray(' pnpm cli worker:status'));
|
|
139
|
+
printSeparator();
|
|
140
|
+
logger.info('Task created via async mode', {
|
|
141
|
+
taskId,
|
|
142
|
+
mode: 'async',
|
|
143
|
+
topic: options.topic,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
// ==================== 同步模式:使用 SyncExecutor ====================
|
|
148
|
+
const executor = createSyncExecutor(taskRepo, {
|
|
149
|
+
databaseType: config.database.type,
|
|
150
|
+
enableLogging: true,
|
|
151
|
+
logLevel: 'info',
|
|
152
|
+
});
|
|
153
|
+
// 设置结果仓储(如果可用)
|
|
154
|
+
if (resultRepo) {
|
|
155
|
+
executor.setResultRepository(resultRepo);
|
|
156
|
+
}
|
|
157
|
+
if (qualityCheckRepo) {
|
|
158
|
+
executor.setQualityCheckRepository(qualityCheckRepo);
|
|
159
|
+
}
|
|
160
|
+
// 创建进度spinner
|
|
161
|
+
const spinner = ora('初始化中...').start();
|
|
162
|
+
// 添加进度回调
|
|
163
|
+
const taskId = uuidv4();
|
|
164
|
+
executor.onProgress(taskId, (progress) => {
|
|
165
|
+
spinner.text = `${progress.message} (${progress.percentage}%)`;
|
|
166
|
+
});
|
|
167
|
+
// 执行任务
|
|
168
|
+
spinner.text = '执行任务中...';
|
|
169
|
+
const result = await executor.execute({
|
|
170
|
+
mode: ExecutionMode.SYNC,
|
|
171
|
+
topic: options.topic,
|
|
172
|
+
requirements: options.requirements,
|
|
173
|
+
targetAudience: options.audience,
|
|
174
|
+
keywords,
|
|
175
|
+
tone: options.tone,
|
|
176
|
+
hardConstraints: {
|
|
177
|
+
minWords: parseInt(options.minWords) || undefined,
|
|
178
|
+
maxWords: parseInt(options.maxWords) || undefined,
|
|
179
|
+
},
|
|
180
|
+
priority: parsePriority(options.priority),
|
|
181
|
+
idempotencyKey: taskId,
|
|
182
|
+
});
|
|
183
|
+
spinner.succeed('任务执行完成!');
|
|
184
|
+
// 显示结果
|
|
185
|
+
console.log(chalk.green.bold('\n✅ 执行成功'));
|
|
186
|
+
printSeparator();
|
|
187
|
+
console.log(chalk.white(`任务ID: ${result.taskId}`));
|
|
188
|
+
console.log(chalk.white(`状态: ${getStatusDisplay(result.status)}`));
|
|
189
|
+
console.log(chalk.white(`耗时: ${formatDuration(result.duration)}`));
|
|
190
|
+
console.log(chalk.white(`步骤: ${result.metadata.stepsCompleted.join(' → ')}`));
|
|
191
|
+
console.log(chalk.white(`Token: ${formatTokens(result.metadata.tokensUsed)}`));
|
|
192
|
+
console.log(chalk.white(`成本: ${formatCost(result.metadata.cost)}`));
|
|
193
|
+
printSeparator();
|
|
194
|
+
// 显示生成的内容
|
|
195
|
+
if (result.finalState.articleContent) {
|
|
196
|
+
console.log(chalk.white.bold('\n📝 生成的内容:'));
|
|
197
|
+
printSeparator();
|
|
198
|
+
console.log(result.finalState.articleContent);
|
|
199
|
+
printSeparator();
|
|
200
|
+
}
|
|
201
|
+
// 显示生成的图片
|
|
202
|
+
if (result.finalState.images && result.finalState.images.length > 0) {
|
|
203
|
+
console.log(chalk.white.bold('\n🖼️ 生成的配图:'));
|
|
204
|
+
printSeparator();
|
|
205
|
+
result.finalState.images.forEach((img) => {
|
|
206
|
+
console.log(chalk.cyan(img.url));
|
|
207
|
+
});
|
|
208
|
+
printSeparator();
|
|
209
|
+
}
|
|
210
|
+
// 显示质检结果
|
|
211
|
+
if (result.finalState.textQualityReport) {
|
|
212
|
+
const qr = result.finalState.textQualityReport;
|
|
213
|
+
console.log(chalk.white.bold('\n🔍 文本质检:'));
|
|
214
|
+
printSeparator();
|
|
215
|
+
console.log(chalk.white(`状态: ${qr.passed ? chalk.green('通过') : chalk.red('未通过')}`));
|
|
216
|
+
if (qr.score !== undefined) {
|
|
217
|
+
console.log(chalk.white(`评分: ${qr.score}/100`));
|
|
218
|
+
}
|
|
219
|
+
if (qr.fixSuggestions && qr.fixSuggestions.length > 0) {
|
|
220
|
+
console.log(chalk.gray(`建议: ${qr.fixSuggestions.join(', ')}`));
|
|
221
|
+
}
|
|
222
|
+
printSeparator();
|
|
223
|
+
// 🔧 保存质检报告到数据库(变通方案)
|
|
224
|
+
if (qualityCheckRepo) {
|
|
225
|
+
try {
|
|
226
|
+
await qualityCheckRepo.create({
|
|
227
|
+
taskId: result.taskId,
|
|
228
|
+
checkType: 'text',
|
|
229
|
+
score: qr.score || 0,
|
|
230
|
+
passed: qr.passed,
|
|
231
|
+
hardConstraintsPassed: qr.hardConstraintsPassed || false,
|
|
232
|
+
details: qr.details || {},
|
|
233
|
+
fixSuggestions: qr.fixSuggestions || [],
|
|
234
|
+
rubricVersion: '1.0',
|
|
235
|
+
modelName: qr.modelName,
|
|
236
|
+
});
|
|
237
|
+
logger.info('Text quality check saved to database (workaround)', {
|
|
238
|
+
taskId: result.taskId,
|
|
239
|
+
score: qr.score,
|
|
240
|
+
passed: qr.passed,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
logger.error('Failed to save text quality check (workaround)', {
|
|
245
|
+
taskId: result.taskId,
|
|
246
|
+
error: error instanceof Error ? error.message : String(error),
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
// 🔧 同样保存图片质检报告(变通方案)
|
|
252
|
+
if (result.finalState.imageQualityReport && qualityCheckRepo) {
|
|
253
|
+
try {
|
|
254
|
+
const qr = result.finalState.imageQualityReport;
|
|
255
|
+
await qualityCheckRepo.create({
|
|
256
|
+
taskId: result.taskId,
|
|
257
|
+
checkType: 'image',
|
|
258
|
+
score: qr.score || 0,
|
|
259
|
+
passed: qr.passed,
|
|
260
|
+
hardConstraintsPassed: qr.hardConstraintsPassed || false,
|
|
261
|
+
details: qr.details || {},
|
|
262
|
+
fixSuggestions: qr.fixSuggestions || [],
|
|
263
|
+
rubricVersion: '1.0',
|
|
264
|
+
modelName: qr.modelName,
|
|
265
|
+
});
|
|
266
|
+
logger.info('Image quality check saved to database (workaround)', {
|
|
267
|
+
taskId: result.taskId,
|
|
268
|
+
score: qr.score,
|
|
269
|
+
passed: qr.passed,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
logger.error('Failed to save image quality check (workaround)', {
|
|
274
|
+
taskId: result.taskId,
|
|
275
|
+
error: error instanceof Error ? error.message : String(error),
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
logger.info('Task completed via CLI', {
|
|
280
|
+
taskId: result.taskId,
|
|
281
|
+
status: result.status,
|
|
282
|
+
duration: result.duration
|
|
283
|
+
});
|
|
284
|
+
} // 结束同步模式的 else 块
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
logger.error('Create command failed', error);
|
|
288
|
+
console.error(chalk.red(`\n❌ 错误: ${error instanceof Error ? error.message : String(error)}`));
|
|
289
|
+
if (error instanceof Error && error.stack) {
|
|
290
|
+
console.error(chalk.gray('\n堆栈信息:'));
|
|
291
|
+
console.error(chalk.gray(error.stack));
|
|
292
|
+
}
|
|
293
|
+
process.exit(1);
|
|
294
|
+
}
|
|
295
|
+
finally {
|
|
296
|
+
// ==================== 第四阶段:资源清理 ====================
|
|
297
|
+
// 仅在服务已初始化的情况下清理
|
|
298
|
+
if (resources.servicesInitialized) {
|
|
299
|
+
logger.debug('Starting resource cleanup...');
|
|
300
|
+
// 1. 关闭 Logger(必须在最后)
|
|
301
|
+
try {
|
|
302
|
+
await closeLogger();
|
|
303
|
+
logger.debug('Logger closed');
|
|
304
|
+
}
|
|
305
|
+
catch (error) {
|
|
306
|
+
console.log('Error closing logger (ignored):', error);
|
|
307
|
+
}
|
|
308
|
+
// 2. 停止 Metrics 服务定时器
|
|
309
|
+
try {
|
|
310
|
+
metricsService.stop();
|
|
311
|
+
console.log('Metrics service stopped');
|
|
312
|
+
}
|
|
313
|
+
catch (error) {
|
|
314
|
+
console.log('Error stopping metrics service (ignored):', error);
|
|
315
|
+
}
|
|
316
|
+
// 3. 关闭 Redis 客户端连接
|
|
317
|
+
try {
|
|
318
|
+
await redisClient.disconnect();
|
|
319
|
+
console.log('Redis client disconnected');
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
console.log('Error disconnecting Redis (ignored):', error);
|
|
323
|
+
}
|
|
324
|
+
// 4. 关闭 PostgreSQL 连接池
|
|
325
|
+
try {
|
|
326
|
+
if (resources.pool) {
|
|
327
|
+
await resources.pool.end();
|
|
328
|
+
console.log('PostgreSQL connection pool closed');
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
console.log('Error closing PostgreSQL pool (ignored):', error);
|
|
333
|
+
}
|
|
334
|
+
console.log('Resource cleanup completed');
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
function parsePriority(priority) {
|
|
339
|
+
const priorityMap = {
|
|
340
|
+
'low': TaskPriority.LOW,
|
|
341
|
+
'normal': TaskPriority.NORMAL,
|
|
342
|
+
'high': TaskPriority.HIGH,
|
|
343
|
+
'urgent': TaskPriority.URGENT,
|
|
344
|
+
};
|
|
345
|
+
return priorityMap[priority] || TaskPriority.NORMAL;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* 将优先级字符串转换为数字(用于 TaskScheduler)
|
|
349
|
+
* TaskScheduler 使用数字优先级(1-10,数字越小优先级越高)
|
|
350
|
+
*/
|
|
351
|
+
function parsePriorityToNumber(priority) {
|
|
352
|
+
const priorityMap = {
|
|
353
|
+
'low': 5, // 低优先级
|
|
354
|
+
'normal': 7, // 普通优先级(默认)
|
|
355
|
+
'high': 3, // 高优先级
|
|
356
|
+
'urgent': 1, // 紧急优先级
|
|
357
|
+
};
|
|
358
|
+
return priorityMap[priority] || 7; // 默认为 normal (7)
|
|
359
|
+
}
|
|
360
|
+
function getStatusDisplay(status) {
|
|
361
|
+
const statusMap = {
|
|
362
|
+
'completed': chalk.green('已完成'),
|
|
363
|
+
'failed': chalk.red('失败'),
|
|
364
|
+
'cancelled': chalk.gray('已取消'),
|
|
365
|
+
};
|
|
366
|
+
return statusMap[status] || status;
|
|
367
|
+
}
|
|
368
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/create.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,EAAE,oBAAoB,EAAE,MAAM,0DAA0D,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,MAAM,4DAA4D,CAAC;AACpG,OAAO,EAAE,wBAAwB,EAAE,MAAM,sDAAsD,CAAC;AAChG,OAAO,EAAE,8BAA8B,EAAE,MAAM,oEAAoE,CAAC;AACpH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,2CAA2C,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACjG,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,MAAM,MAAM,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;AAE1C,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,UAAU,CAAC;KACvB,MAAM,CAAC,qBAAqB,EAAE,MAAM,CAAC;KACrC,MAAM,CAAC,mCAAmC,EAAE,MAAM,CAAC;KACnD,MAAM,CAAC,2BAA2B,EAAE,MAAM,EAAE,MAAM,CAAC;KACnD,MAAM,CAAC,uBAAuB,EAAE,W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2
|
+
* CLI result命令
|
|
3
|
+
*
|
|
4
|
+
* 获取任务结果
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { createTaskRepository } from '../../../infrastructure/database/index.js';
|
|
9
|
+
import { PostgresResultRepository } from '../../../infrastructure/database/ResultRepository.js';
|
|
10
|
+
import { getStatusText, printSeparator } from '../utils/formatter.js';
|
|
11
|
+
import { cleanupResources } from '../utils/cleanup.js';
|
|
12
|
+
import { config } from '../../../config/index.js';
|
|
13
|
+
export const resultCommand = new Command('result')
|
|
14
|
+
.description('获取任务结果')
|
|
15
|
+
.requiredOption('-t, --task-id <taskId>', '任务ID')
|
|
16
|
+
.option('--format <format>', '输出格式 (text|json)', 'text')
|
|
17
|
+
.action(async (options) => {
|
|
18
|
+
// 使用工厂函数创建 Repository(支持 memory 和 postgres)
|
|
19
|
+
const taskRepo = createTaskRepository();
|
|
20
|
+
let resultRepo = null;
|
|
21
|
+
let pool = null;
|
|
22
|
+
try {
|
|
23
|
+
const task = await taskRepo.findById(options.taskId);
|
|
24
|
+
if (!task) {
|
|
25
|
+
console.error(chalk.red(`❌ 错误: 未找到任务 ${options.taskId}`));
|
|
26
|
+
// 如果是内存模式,显示额外提示
|
|
27
|
+
if (config.database.type === 'memory') {
|
|
28
|
+
console.log(chalk.yellow('\n💡 提示: 当前使用内存模式'));
|
|
29
|
+
console.log(chalk.gray(' - 内存模式下的任务数据不会持久化'));
|
|
30
|
+
console.log(chalk.gray(' - 任务完成后结果会直接显示在终端'));
|
|
31
|
+
console.log(chalk.gray(' - 如果需要查询历史任务,请使用 PostgreSQL 模式'));
|
|
32
|
+
}
|
|
33
|
+
await cleanupResources(taskRepo, resultRepo);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
// 如果任务未完成,显示状态
|
|
37
|
+
if (task.status !== 'completed') {
|
|
38
|
+
console.log(chalk.yellow(`⚠️ 任务尚未完成,当前状态: ${getStatusText(task.status)}`));
|
|
39
|
+
await cleanupResources(taskRepo, resultRepo);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// JSON格式输出
|
|
43
|
+
if (options.format === 'json') {
|
|
44
|
+
console.log(JSON.stringify(task, null, 2));
|
|
45
|
+
await cleanupResources(taskRepo, resultRepo);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
// 文本格式输出
|
|
49
|
+
console.log(chalk.blue.bold('\n📄 任务结果'));
|
|
50
|
+
printSeparator();
|
|
51
|
+
console.log(chalk.white(`任务ID: ${task.taskId}`));
|
|
52
|
+
console.log(chalk.white(`状态: ${getStatusText(task.status)}`));
|
|
53
|
+
printSeparator();
|
|
54
|
+
// 从数据库查询结果(仅 PostgreSQL)
|
|
55
|
+
if (config.database.type === 'postgres') {
|
|
56
|
+
const { Pool } = await import('pg');
|
|
57
|
+
pool = new Pool({
|
|
58
|
+
host: config.postgres.host,
|
|
59
|
+
port: config.postgres.port,
|
|
60
|
+
database: config.postgres.database,
|
|
61
|
+
user: config.postgres.user,
|
|
62
|
+
password: config.postgres.password,
|
|
63
|
+
});
|
|
64
|
+
resultRepo = new PostgresResultRepository(pool);
|
|
65
|
+
const results = await resultRepo.findByTaskId(options.taskId);
|
|
66
|
+
if (results.length === 0) {
|
|
67
|
+
console.log(chalk.yellow('提示: 该任务未生成结果'));
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
console.log(chalk.blue.bold('\n📋 生成结果'));
|
|
71
|
+
printSeparator();
|
|
72
|
+
results.forEach((result, index) => {
|
|
73
|
+
console.log(chalk.white.bold(`${index + 1}. ${result.resultType.toUpperCase()}`));
|
|
74
|
+
printSeparator();
|
|
75
|
+
if (result.resultType === 'article') {
|
|
76
|
+
console.log(chalk.white('内容:'));
|
|
77
|
+
console.log(chalk.gray(result.content || '(无内容)'));
|
|
78
|
+
if (result.metadata?.wordCount) {
|
|
79
|
+
console.log(chalk.gray(`字数: ${result.metadata.wordCount}`));
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
else if (result.resultType === 'image') {
|
|
83
|
+
console.log(chalk.white('图片 URL:'));
|
|
84
|
+
console.log(chalk.cyan(result.content || '(无 URL)'));
|
|
85
|
+
}
|
|
86
|
+
printSeparator();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
// 关闭结果查询的连接池
|
|
90
|
+
await pool.end();
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
// Memory 模式:提示结果仅实时返回
|
|
94
|
+
console.log(chalk.yellow('\n💡 提示: 当前使用 Memory 模式'));
|
|
95
|
+
console.log(chalk.gray(' - 任务结果仅在执行时实时返回到终端'));
|
|
96
|
+
console.log(chalk.gray(' - 任务完成后数据不会保存到数据库'));
|
|
97
|
+
console.log(chalk.gray(' - 如需保存结果,请使用 PostgreSQL 模式或 sync 模式查看实时输出'));
|
|
98
|
+
}
|
|
99
|
+
// 清理所有资源
|
|
100
|
+
await cleanupResources(taskRepo, resultRepo);
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
console.error(chalk.red(`❌ 错误: ${error instanceof Error ? error.message : String(error)}`));
|
|
104
|
+
// 如果是内存模式,显示额外提示
|
|
105
|
+
if (config.database.type === 'memory') {
|
|
106
|
+
console.log(chalk.yellow('\n💡 提示: Memory 模式下任务数据不持久化'));
|
|
107
|
+
}
|
|
108
|
+
await cleanupResources(taskRepo, resultRepo);
|
|
109
|
+
// 清理 PostgreSQL 连接池
|
|
110
|
+
if (pool) {
|
|
111
|
+
try {
|
|
112
|
+
await pool.end();
|
|
113
|
+
}
|
|
114
|
+
catch (e) {
|
|
115
|
+
// 忽略关闭错误
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
//# sourceMappingURL=result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"result.js","sourceRoot":"","sources":["../../../../src/presentation/c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CAAC,GAAG,CAAC,SAAS,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;QAE5F,iBAAiB;QACjB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,6BAA6B,CAAC,CAAC,CAAC;QAC3D,CAAC;QAED,MAAM,gBAAgB,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QAE7C,oBAAoB;QACpB,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;YACnB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,SAAS;YACX,CAAC;QACH,CAAC;QAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../../src/presentation/cli/commands/status.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMpC,eAAO,MAAM,aAAa,SAmEtB,CAAC"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI status命令
|
|
3
|
+
*
|
|
4
|
+
* 查询任务状态
|
|
5
|
+
*/
|
|
6
|
+
import { Command } from 'commander';
|
|
7
|
+
import chalk from 'chalk';
|
|
8
|
+
import { PostgresTaskRepository } from '../../../infrastructure/database/PostgresTaskRepository.js';
|
|
9
|
+
import { getStatusText, formatDate, formatDuration, printSeparator } from '../utils/formatter.js';
|
|
10
|
+
import { cleanupResources } from '../utils/cleanup.js';
|
|
11
|
+
export const statusCommand = new Command('status')
|
|
12
|
+
.description('查询任务状态')
|
|
13
|
+
.requiredOption('-t, --task-id <taskId>', '任务ID')
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
const taskRepo = new PostgresTaskRepository();
|
|
16
|
+
try {
|
|
17
|
+
const task = await taskRepo.findById(options.taskId);
|
|
18
|
+
if (!task) {
|
|
19
|
+
console.error(chalk.red(`❌ 错误: 未找到任务 ${options.taskId}`));
|
|
20
|
+
await cleanupResources(taskRepo);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
console.log(chalk.blue.bold('\n📊 任务状态'));
|
|
24
|
+
printSeparator();
|
|
25
|
+
console.log(chalk.white(`任务ID: ${task.taskId}`));
|
|
26
|
+
console.log(chalk.white(`状态: ${getStatusText(task.status)}`));
|
|
27
|
+
console.log(chalk.white(`当前步骤: ${task.currentStep ? getStepDisplayName(task.currentStep) : '无'}`));
|
|
28
|
+
console.log(chalk.white(`执行模式: ${task.mode === 'sync' ? '同步' : '异步'}`));
|
|
29
|
+
console.log(chalk.white(`优先级: ${getPriorityText(task.priority)}`));
|
|
30
|
+
printSeparator();
|
|
31
|
+
console.log(chalk.white(`创建时间: ${formatDate(task.createdAt)}`));
|
|
32
|
+
if (task.startedAt) {
|
|
33
|
+
console.log(chalk.white(`开始时间: ${formatDate(task.startedAt)}`));
|
|
34
|
+
}
|
|
35
|
+
if (task.completedAt) {
|
|
36
|
+
const duration = task.completedAt.getTime() - task.createdAt.getTime();
|
|
37
|
+
console.log(chalk.white(`完成时间: ${formatDate(task.completedAt)}`));
|
|
38
|
+
console.log(chalk.white(`总耗时: ${formatDuration(duration)}`));
|
|
39
|
+
}
|
|
40
|
+
printSeparator();
|
|
41
|
+
// 显示重试信息
|
|
42
|
+
if (task.textRetryCount > 0 || task.imageRetryCount > 0) {
|
|
43
|
+
console.log(chalk.white.bold('重试统计:'));
|
|
44
|
+
if (task.textRetryCount > 0) {
|
|
45
|
+
console.log(chalk.white(` 文本质检: ${task.textRetryCount} 次`));
|
|
46
|
+
}
|
|
47
|
+
if (task.imageRetryCount > 0) {
|
|
48
|
+
console.log(chalk.white(` 配图质检: ${task.imageRetryCount} 次`));
|
|
49
|
+
}
|
|
50
|
+
printSeparator();
|
|
51
|
+
}
|
|
52
|
+
// 显示错误信息
|
|
53
|
+
if (task.errorMessage) {
|
|
54
|
+
console.log(chalk.red.bold('错误信息:'));
|
|
55
|
+
console.log(chalk.red(task.errorMessage));
|
|
56
|
+
printSeparator();
|
|
57
|
+
}
|
|
58
|
+
// 显示Worker信息
|
|
59
|
+
if (task.workerId) {
|
|
60
|
+
console.log(chalk.white(`Worker ID: ${task.workerId}`));
|
|
61
|
+
printSeparator();
|
|
62
|
+
}
|
|
63
|
+
// 清理资源并正常退出
|
|
64
|
+
await cleanupResources(taskRepo);
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
console.error(chalk.red(`❌ 错误: ${error instanceof Error ? error.message : String(error)}`));
|
|
68
|
+
await cleanupResources(taskRepo);
|
|
69
|
+
process.exit(1);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
function getStepDisplayName(step) {
|
|
73
|
+
const displayNames = {
|
|
74
|
+
'search': '🔍 搜索资料',
|
|
75
|
+
'organize': '📋 整理大纲',
|
|
76
|
+
'write': '✍️ 撰写内容',
|
|
77
|
+
'check_text': '🔍 文本质检',
|
|
78
|
+
'generate_image': '🎨 生成配图',
|
|
79
|
+
'check_image': '🔍 配图质检',
|
|
80
|
+
};
|
|
81
|
+
return displayNames[step] || step;
|
|
82
|
+
}
|
|
83
|
+
function getPriorityText(priority) {
|
|
84
|
+
const priorityMap = {
|
|
85
|
+
1: '低',
|
|
86
|
+
2: '普通',
|
|
87
|
+
3: '高',
|
|
88
|
+
4: '紧急',
|
|
89
|
+
};
|
|
90
|
+
return priorityMap[priority] || '普通';
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.js","sourceRo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