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,612 @@
|
|
|
1
|
+
# Content Creator - 存储与返回机制说明
|
|
2
|
+
|
|
3
|
+
**更新日期**: 2026-01-20
|
|
4
|
+
**版本**: 1.0
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 📖 目录
|
|
9
|
+
|
|
10
|
+
1. [内容存储机制](#内容存储机制)
|
|
11
|
+
2. [API 返回流程](#api-返回流程)
|
|
12
|
+
3. [图片处理与返回](#图片处理与返回)
|
|
13
|
+
4. [当前实现状态](#当前实现状态)
|
|
14
|
+
5. [未来改进计划](#未来改进计划)
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 📦 内容存储机制
|
|
19
|
+
|
|
20
|
+
### 数据库设计
|
|
21
|
+
|
|
22
|
+
项目使用 PostgreSQL 作为主要存储,设计了完整的表结构:
|
|
23
|
+
|
|
24
|
+
#### 1. **tasks 表** - 任务主表
|
|
25
|
+
|
|
26
|
+
```sql
|
|
27
|
+
CREATE TABLE tasks (
|
|
28
|
+
id SERIAL PRIMARY KEY,
|
|
29
|
+
task_id TEXT UNIQUE NOT NULL,
|
|
30
|
+
user_id TEXT,
|
|
31
|
+
|
|
32
|
+
-- 任务参数
|
|
33
|
+
mode TEXT CHECK (mode IN ('sync', 'async')),
|
|
34
|
+
topic TEXT NOT NULL,
|
|
35
|
+
requirements TEXT NOT NULL,
|
|
36
|
+
|
|
37
|
+
-- 硬性约束(JSON)
|
|
38
|
+
hard_constraints JSONB,
|
|
39
|
+
|
|
40
|
+
-- 状态管理
|
|
41
|
+
status TEXT CHECK (status IN (
|
|
42
|
+
'pending', 'running', 'waiting', 'completed', 'failed', 'cancelled'
|
|
43
|
+
)),
|
|
44
|
+
current_step TEXT,
|
|
45
|
+
worker_id TEXT,
|
|
46
|
+
|
|
47
|
+
-- 重试计数
|
|
48
|
+
text_retry_count INTEGER DEFAULT 0,
|
|
49
|
+
image_retry_count INTEGER DEFAULT 0,
|
|
50
|
+
|
|
51
|
+
-- 乐观锁
|
|
52
|
+
version INTEGER NOT NULL DEFAULT 1,
|
|
53
|
+
|
|
54
|
+
-- 时间戳
|
|
55
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
56
|
+
started_at TIMESTAMP,
|
|
57
|
+
completed_at TIMESTAMP,
|
|
58
|
+
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
59
|
+
|
|
60
|
+
-- 错误和快照
|
|
61
|
+
error_message TEXT,
|
|
62
|
+
state_snapshot JSONB,
|
|
63
|
+
|
|
64
|
+
-- 幂等性
|
|
65
|
+
idempotency_key TEXT UNIQUE
|
|
66
|
+
);
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
**用途**: 存储任务的基本信息和状态
|
|
70
|
+
|
|
71
|
+
#### 2. **results 表** - 生成结果表
|
|
72
|
+
|
|
73
|
+
```sql
|
|
74
|
+
CREATE TABLE results (
|
|
75
|
+
id SERIAL PRIMARY KEY,
|
|
76
|
+
task_id TEXT NOT NULL,
|
|
77
|
+
result_type TEXT CHECK (result_type IN (
|
|
78
|
+
'article', 'image', 'text'
|
|
79
|
+
)),
|
|
80
|
+
|
|
81
|
+
-- 内容存储
|
|
82
|
+
content TEXT, -- 文章内容或图片 URL
|
|
83
|
+
file_path TEXT, -- 本地文件路径(如果下载)
|
|
84
|
+
|
|
85
|
+
-- 元数据(JSON)
|
|
86
|
+
metadata JSONB NOT NULL,
|
|
87
|
+
|
|
88
|
+
-- 时间戳
|
|
89
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
90
|
+
|
|
91
|
+
FOREIGN KEY (task_id) REFERENCES tasks(task_id) ON DELETE CASCADE,
|
|
92
|
+
UNIQUE (task_id, result_type)
|
|
93
|
+
);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**用途**: 存储生成的内容(文章、图片 URL 等)
|
|
97
|
+
|
|
98
|
+
#### 3. **quality_checks 表** - 质量检查表
|
|
99
|
+
|
|
100
|
+
```sql
|
|
101
|
+
CREATE TABLE quality_checks (
|
|
102
|
+
id SERIAL PRIMARY KEY,
|
|
103
|
+
task_id TEXT NOT NULL,
|
|
104
|
+
check_type TEXT CHECK (check_type IN ('text', 'image')),
|
|
105
|
+
|
|
106
|
+
-- 评分
|
|
107
|
+
score NUMERIC(3, 2) CHECK (score >= 1 AND score <= 10),
|
|
108
|
+
passed BOOLEAN NOT NULL,
|
|
109
|
+
hard_constraints_passed BOOLEAN NOT NULL,
|
|
110
|
+
|
|
111
|
+
-- 详情(JSON)
|
|
112
|
+
details JSONB NOT NULL,
|
|
113
|
+
fix_suggestions TEXT[],
|
|
114
|
+
|
|
115
|
+
-- 元数据
|
|
116
|
+
rubric_version TEXT,
|
|
117
|
+
model_name TEXT,
|
|
118
|
+
prompt_hash TEXT,
|
|
119
|
+
|
|
120
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
121
|
+
FOREIGN KEY (task_id) REFERENCES tasks(task_id) ON DELETE CASCADE
|
|
122
|
+
);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**用途**: 存储质量检查结果和改进建议
|
|
126
|
+
|
|
127
|
+
#### 4. **task_steps 表** - 任务步骤表
|
|
128
|
+
|
|
129
|
+
```sql
|
|
130
|
+
CREATE TABLE task_steps (
|
|
131
|
+
id SERIAL PRIMARY KEY,
|
|
132
|
+
task_id TEXT NOT NULL,
|
|
133
|
+
step_name TEXT CHECK (step_name IN (
|
|
134
|
+
'search', 'organize', 'write', 'check_text',
|
|
135
|
+
'generate_image', 'check_image'
|
|
136
|
+
)),
|
|
137
|
+
status TEXT CHECK (status IN (
|
|
138
|
+
'pending', 'running', 'completed', 'failed', 'skipped'
|
|
139
|
+
)),
|
|
140
|
+
|
|
141
|
+
-- 输入输出(JSON)
|
|
142
|
+
input_data JSONB,
|
|
143
|
+
output_data JSONB,
|
|
144
|
+
|
|
145
|
+
-- 性能指标
|
|
146
|
+
started_at TIMESTAMP,
|
|
147
|
+
completed_at TIMESTAMP,
|
|
148
|
+
duration_ms INTEGER,
|
|
149
|
+
|
|
150
|
+
error_message TEXT,
|
|
151
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
152
|
+
|
|
153
|
+
FOREIGN KEY (task_id) REFERENCES tasks(task_id) ON DELETE CASCADE
|
|
154
|
+
);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**用途**: 记录每个工作流步骤的执行情况
|
|
158
|
+
|
|
159
|
+
#### 5. **token_usage 表** - Token 使用统计
|
|
160
|
+
|
|
161
|
+
```sql
|
|
162
|
+
CREATE TABLE token_usage (
|
|
163
|
+
id SERIAL PRIMARY KEY,
|
|
164
|
+
task_id TEXT NOT NULL,
|
|
165
|
+
trace_id TEXT NOT NULL,
|
|
166
|
+
step_name TEXT NOT NULL,
|
|
167
|
+
api_name TEXT NOT NULL,
|
|
168
|
+
model_name TEXT NOT NULL,
|
|
169
|
+
|
|
170
|
+
-- Token 统计
|
|
171
|
+
tokens_in INTEGER NOT NULL,
|
|
172
|
+
tokens_out INTEGER NOT NULL,
|
|
173
|
+
total_tokens INTEGER NOT NULL,
|
|
174
|
+
|
|
175
|
+
-- 成本计算
|
|
176
|
+
cost_per_1k_tokens_in NUMERIC(10, 6) NOT NULL,
|
|
177
|
+
cost_per_1k_tokens_out NUMERIC(10, 6) NOT NULL,
|
|
178
|
+
total_cost NUMERIC(10, 6) NOT NULL,
|
|
179
|
+
|
|
180
|
+
metadata JSONB,
|
|
181
|
+
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
182
|
+
|
|
183
|
+
FOREIGN KEY (task_id) REFERENCES tasks(task_id) ON DELETE CASCADE
|
|
184
|
+
);
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**用途**: 跟踪 Token 使用量和成本
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 🔄 API 返回流程
|
|
192
|
+
|
|
193
|
+
### 当前实现(同步模式)
|
|
194
|
+
|
|
195
|
+
用户通过 CLI 请求后,内容直接**实时返回给用户**:
|
|
196
|
+
|
|
197
|
+
```
|
|
198
|
+
┌────────────────────────────────────────────────────────────┐
|
|
199
|
+
│ 1. 用户创建任务 │
|
|
200
|
+
│ pnpm run cli:create --topic "xxx" --sync │
|
|
201
|
+
├────────────────────────────────────────────────────────────┤
|
|
202
|
+
│ 2. SyncExecutor 执行 │
|
|
203
|
+
│ - 创建任务记录 (tasks 表) │
|
|
204
|
+
│ - 执行工作流 │
|
|
205
|
+
│ - 保存结果到内存 │
|
|
206
|
+
├────────────────────────────────────────────────────────────┤
|
|
207
|
+
│ 3. CLI 直接显示结果给用户 │
|
|
208
|
+
│ - 📝 生成的内容: [文章全文] │
|
|
209
|
+
│ - 🖼️ 生成的配图: [图片 URL] │
|
|
210
|
+
│ - 🔍 文本质检: [质量报告] │
|
|
211
|
+
└────────────────────────────────────────────────────────────┘
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### 返回结果示例
|
|
215
|
+
|
|
216
|
+
```typescript
|
|
217
|
+
interface ExecutionResult {
|
|
218
|
+
taskId: string; // 任务 ID
|
|
219
|
+
status: 'completed' | 'failed'; // 任务状态
|
|
220
|
+
finalState: {
|
|
221
|
+
articleContent: string; // 文章内容(直接返回)
|
|
222
|
+
imageUrl: string; // 图片 URL(直接返回)
|
|
223
|
+
textQualityReport?: { // 质量报告
|
|
224
|
+
score: number;
|
|
225
|
+
passed: boolean;
|
|
226
|
+
reason?: string;
|
|
227
|
+
};
|
|
228
|
+
};
|
|
229
|
+
duration: number; // 执行时长(毫秒)
|
|
230
|
+
metadata: {
|
|
231
|
+
stepsCompleted: string[]; // 完成的步骤
|
|
232
|
+
tokensUsed: number; // 使用 Token 数
|
|
233
|
+
cost: number; // 成本
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### CLI 显示给用户
|
|
239
|
+
|
|
240
|
+
**成功时**:
|
|
241
|
+
```bash
|
|
242
|
+
✅ 任务执行完成!
|
|
243
|
+
|
|
244
|
+
✅ 执行成功
|
|
245
|
+
────────────────────────────────────────
|
|
246
|
+
任务ID: 261e42a2-52fa-4777-b88d-ebc1b13bffe4
|
|
247
|
+
状态: 已完成
|
|
248
|
+
耗时: 51 秒
|
|
249
|
+
步骤: search → organize → write → check_text → generate_image → check_image
|
|
250
|
+
Token: 3,450
|
|
251
|
+
成本: ¥0.1234
|
|
252
|
+
────────────────────────────────────────
|
|
253
|
+
|
|
254
|
+
📝 生成的内容:
|
|
255
|
+
────────────────────────────────────────
|
|
256
|
+
# AI 技术的发展趋势
|
|
257
|
+
|
|
258
|
+
人工智能(AI)技术正在以前所未有的速度发展...
|
|
259
|
+
[完整文章内容]
|
|
260
|
+
────────────────────────────────────────
|
|
261
|
+
|
|
262
|
+
🖼️ 生成的配图:
|
|
263
|
+
────────────────────────────────────────
|
|
264
|
+
https://tos-cn-beijing.ivolces.com/xxxxx.jpg
|
|
265
|
+
────────────────────────────────────────
|
|
266
|
+
|
|
267
|
+
🔍 文本质检:
|
|
268
|
+
────────────────────────────────────────
|
|
269
|
+
状态: 通过
|
|
270
|
+
评分: 8.5/100
|
|
271
|
+
────────────────────────────────────────
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
## 🖼️ 图片处理与返回
|
|
277
|
+
|
|
278
|
+
### 图片生成流程
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
┌────────────────────────────────────────────────────────────┐
|
|
282
|
+
│ 1. GenerateImageNode 执行 │
|
|
283
|
+
│ - 基于 articleContent 生成提示词 │
|
|
284
|
+
│ - 调用 ImageService.generateImage() │
|
|
285
|
+
├────────────────────────────────────────────────────────────┤
|
|
286
|
+
│ 2. ImageService 调用 Doubao API │
|
|
287
|
+
│ POST https://ark.cn-beijing.volces.com/ │
|
|
288
|
+
│ api/v3/images/generations │
|
|
289
|
+
│ { │
|
|
290
|
+
│ model: "doubao-seedream-4-5-251128", │
|
|
291
|
+
│ prompt: "...", │
|
|
292
|
+
│ size: "1920x1920", │
|
|
293
|
+
│ response_format: "url" │
|
|
294
|
+
│ } │
|
|
295
|
+
├────────────────────────────────────────────────────────────┤
|
|
296
|
+
│ 3. Doubao API 返回图片 URL │
|
|
297
|
+
│ { │
|
|
298
|
+
│ data: [{ │
|
|
299
|
+
│ url: "https://tos-xxx.com/xxx.jpg" │
|
|
300
|
+
│ }] │
|
|
301
|
+
│ } │
|
|
302
|
+
├────────────────────────────────────────────────────────────┤
|
|
303
|
+
│ 4. URL 存储到 WorkflowState │
|
|
304
|
+
│ state.imageUrl = "https://tos-xxx.com/xxx.jpg" │
|
|
305
|
+
├────────────────────────────────────────────────────────────┤
|
|
306
|
+
│ 5. URL 直接返回给用户(CLI 显示) │
|
|
307
|
+
│ 🖼️ 生成的配图: https://tos-xxx.com/xxx.jpg │
|
|
308
|
+
└────────────────────────────────────────────────────────────┘
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### 图片 API 响应格式
|
|
312
|
+
|
|
313
|
+
```typescript
|
|
314
|
+
// Doubao API 响应
|
|
315
|
+
{
|
|
316
|
+
"data": [
|
|
317
|
+
{
|
|
318
|
+
"url": "https://tos-cn-beijing.ivolces.com/xxxx/xxxxx.jpg"
|
|
319
|
+
}
|
|
320
|
+
]
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// ImageService 转换后
|
|
324
|
+
interface ImageGenerationResponse {
|
|
325
|
+
imageUrl: string; // 直接的图片 URL
|
|
326
|
+
model: string;
|
|
327
|
+
prompt?: string;
|
|
328
|
+
seed?: number;
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### 图片存储策略
|
|
333
|
+
|
|
334
|
+
**当前实现**:
|
|
335
|
+
- ✅ **云端存储**: Doubao API 生成并托管图片
|
|
336
|
+
- ✅ **URL 返回**: 直接返回云端 URL
|
|
337
|
+
- ✅ **临时访问**: URL 可能有时效限制
|
|
338
|
+
|
|
339
|
+
**特点**:
|
|
340
|
+
- ✅ **无需下载**: 用户直接访问云端 URL
|
|
341
|
+
- ✅ **CDN 加速**: Doubao 使用 COS(对象存储)+ CDN
|
|
342
|
+
- ✅ **自动过期**: Doubao 可能设置访问有效期
|
|
343
|
+
|
|
344
|
+
**缺点**:
|
|
345
|
+
- ⚠️ **无持久化**: 图片不存储到本地数据库
|
|
346
|
+
- ⚠️ **可能过期**: 长期访问可能失败
|
|
347
|
+
- ⚠️ **不可控**: 依赖 Doubao 的存储策略
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## 📊 当前实现状态
|
|
352
|
+
|
|
353
|
+
### ✅ 已实现
|
|
354
|
+
|
|
355
|
+
| 功能 | 状态 | 说明 |
|
|
356
|
+
|------|------|------|
|
|
357
|
+
| 任务状态管理 | ✅ | tasks 表完整记录状态 |
|
|
358
|
+
| 结果存储(设计) | ✅ | results 表已创建 |
|
|
359
|
+
| 内容实时返回 | ✅ | CLI 直接显示结果 |
|
|
360
|
+
| 图片 URL 返回 | ✅ | Doubao API URL 直接返回 |
|
|
361
|
+
| 质量检查记录 | ✅ | quality_checks 表已设计 |
|
|
362
|
+
| Token 统计(设计) | ✅ | token_usage 表已创建 |
|
|
363
|
+
|
|
364
|
+
### ⚠️ 部分实现
|
|
365
|
+
|
|
366
|
+
| 功能 | 状态 | 说明 |
|
|
367
|
+
|------|------|------|
|
|
368
|
+
| 结果持久化 | ⚠️ | 表结构已设计,但 saveResults() 为 TODO |
|
|
369
|
+
| 图片本地存储 | ⚠️ | 当前只返回 URL,未下载到本地 |
|
|
370
|
+
| 质量检查记录 | ⚠️ | 检查功能完整,但未写入数据库 |
|
|
371
|
+
|
|
372
|
+
### ❌ 未实现
|
|
373
|
+
|
|
374
|
+
| 功能 | 状态 | 优先级 |
|
|
375
|
+
|------|------|--------|
|
|
376
|
+
| 结果持久化实现 | ❌ | 高 |
|
|
377
|
+
| 图片本地下载 | ❌ | 中 |
|
|
378
|
+
| Token 使用记录 | ❌ | 中 |
|
|
379
|
+
| 质量报告存储 | ❌ | 中 |
|
|
380
|
+
|
|
381
|
+
---
|
|
382
|
+
|
|
383
|
+
## 🔍 SyncExecutor 的 saveResults() 方法
|
|
384
|
+
|
|
385
|
+
### 当前代码(src/application/workflow/SyncExecutor.ts:226)
|
|
386
|
+
|
|
387
|
+
```typescript
|
|
388
|
+
/**
|
|
389
|
+
* 保存结果
|
|
390
|
+
*/
|
|
391
|
+
private async saveResults(taskId: string, state: WorkflowState): Promise<void> {
|
|
392
|
+
logger.debug('Saving results', {
|
|
393
|
+
taskId,
|
|
394
|
+
hasArticle: !!state.articleContent,
|
|
395
|
+
hasImage: !!state.imageUrl
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
// TODO: 创建Result记录
|
|
399
|
+
// TODO: 创建QualityCheck记录
|
|
400
|
+
// TODO: 更新TokenUsage记录
|
|
401
|
+
|
|
402
|
+
logger.debug('Results saved', { taskId });
|
|
403
|
+
}
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
**状态**: ❌ **未实现**(所有都是 TODO)
|
|
407
|
+
|
|
408
|
+
---
|
|
409
|
+
|
|
410
|
+
## 🎯 用户获取内容的方式
|
|
411
|
+
|
|
412
|
+
### 方式一:CLI 直接返回(当前)
|
|
413
|
+
|
|
414
|
+
**流程**:
|
|
415
|
+
1. 用户运行 `pnpm run cli:create --topic "xxx" --sync`
|
|
416
|
+
2. 系统执行工作流
|
|
417
|
+
3. **CLI 直接显示**生成的内容和图片 URL
|
|
418
|
+
4. 用户从终端复制或查看
|
|
419
|
+
|
|
420
|
+
**优点**:
|
|
421
|
+
- ✅ 即时获取
|
|
422
|
+
- ✅ 无需查询数据库
|
|
423
|
+
- ✅ 适合命令行使用
|
|
424
|
+
|
|
425
|
+
**缺点**:
|
|
426
|
+
- ❌ 内容不持久化
|
|
427
|
+
- ❌ 刷新终端后内容丢失
|
|
428
|
+
- ❌ 无法查询历史
|
|
429
|
+
|
|
430
|
+
### 方式二:数据库查询(待实现)
|
|
431
|
+
|
|
432
|
+
**流程**:
|
|
433
|
+
1. 用户创建任务
|
|
434
|
+
2. 系统保存结果到 results 表
|
|
435
|
+
3. 用户通过 API 或 CLI 查询历史
|
|
436
|
+
4. 系统返回持久化的内容
|
|
437
|
+
|
|
438
|
+
**优点**:
|
|
439
|
+
- ✅ 内容持久化
|
|
440
|
+
- ✅ 可查询历史
|
|
441
|
+
- ✅ 支持多用户
|
|
442
|
+
- ✅ 适合 Web 应用
|
|
443
|
+
|
|
444
|
+
**缺点**:
|
|
445
|
+
- ❌ 需要额外实现
|
|
446
|
+
- ❌ 增加存储成本
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## 🚀 未来改进计划
|
|
451
|
+
|
|
452
|
+
### 优先级:高
|
|
453
|
+
|
|
454
|
+
#### 1. 实现 saveResults() 方法
|
|
455
|
+
|
|
456
|
+
```typescript
|
|
457
|
+
private async saveResults(taskId: string, state: WorkflowState): Promise<void> {
|
|
458
|
+
const resultsRepo = new PostgresResultRepository();
|
|
459
|
+
|
|
460
|
+
// 保存文章结果
|
|
461
|
+
if (state.articleContent) {
|
|
462
|
+
await resultsRepo.create({
|
|
463
|
+
taskId,
|
|
464
|
+
resultType: 'article',
|
|
465
|
+
content: state.articleContent,
|
|
466
|
+
metadata: {
|
|
467
|
+
wordCount: state.articleContent.length,
|
|
468
|
+
generatedAt: new Date().toISOString(),
|
|
469
|
+
},
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
// 保存图片结果
|
|
474
|
+
if (state.imageUrl) {
|
|
475
|
+
await resultsRepo.create({
|
|
476
|
+
taskId,
|
|
477
|
+
resultType: 'image',
|
|
478
|
+
content: state.imageUrl, // URL
|
|
479
|
+
metadata: {
|
|
480
|
+
generatedAt: new Date().toISOString(),
|
|
481
|
+
},
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
#### 2. 下载图片到本地
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
private async saveResults(taskId: string, state: WorkflowState): Promise<void> {
|
|
491
|
+
if (state.imageUrl) {
|
|
492
|
+
// 下载图片
|
|
493
|
+
const response = await axios.get(state.imageUrl, {
|
|
494
|
+
responseType: 'arraybuffer',
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
// 保存到本地
|
|
498
|
+
const filename = `${taskId}_image.jpg`;
|
|
499
|
+
const filePath = path.join(
|
|
500
|
+
config.storage.path,
|
|
501
|
+
filename
|
|
502
|
+
);
|
|
503
|
+
fs.writeFileSync(filePath, response.data);
|
|
504
|
+
|
|
505
|
+
// 存储本地路径
|
|
506
|
+
await resultsRepo.create({
|
|
507
|
+
taskId,
|
|
508
|
+
resultType: 'image',
|
|
509
|
+
content: state.imageUrl, // 保留云 URL
|
|
510
|
+
filePath, // 本地路径
|
|
511
|
+
metadata: { filename, fileSize: response.data.length },
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
### 优先级:中
|
|
518
|
+
|
|
519
|
+
#### 3. 实现 Token 统计
|
|
520
|
+
|
|
521
|
+
```typescript
|
|
522
|
+
private async saveResults(taskId: string, state: WorkflowState): Promise<void> {
|
|
523
|
+
// 保存 Token 使用量
|
|
524
|
+
if (state.totalTokens && state.totalCost) {
|
|
525
|
+
await tokenUsageRepo.create({
|
|
526
|
+
taskId,
|
|
527
|
+
traceId: state.traceId,
|
|
528
|
+
stepName: 'total',
|
|
529
|
+
apiName: 'llm',
|
|
530
|
+
modelName: config.llm.modelName,
|
|
531
|
+
tokensIn: 0,
|
|
532
|
+
tokensOut: state.totalTokens,
|
|
533
|
+
totalTokens: state.totalTokens,
|
|
534
|
+
costPer1kTokensIn: 0,
|
|
535
|
+
costPer1kTokensOut: config.llm.costPer1kTokensOut || 0.0014,
|
|
536
|
+
totalCost: state.totalCost,
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
```
|
|
541
|
+
|
|
542
|
+
#### 4. 实现 HTTP API 查询接口
|
|
543
|
+
|
|
544
|
+
```typescript
|
|
545
|
+
// GET /api/tasks/:taskId/results
|
|
546
|
+
router.get('/tasks/:taskId/results', async (req, res) => {
|
|
547
|
+
const results = await resultsRepo.findByTaskId(req.params.taskId);
|
|
548
|
+
res.json(results);
|
|
549
|
+
});
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
### 优先级:低
|
|
553
|
+
|
|
554
|
+
#### 5. 添加 Web 前端
|
|
555
|
+
|
|
556
|
+
- 提供友好的 Web 界面
|
|
557
|
+
- 支持创建和查询任务
|
|
558
|
+
- 显示历史记录
|
|
559
|
+
- 下载生成的内容
|
|
560
|
+
|
|
561
|
+
---
|
|
562
|
+
|
|
563
|
+
## 📋 总结
|
|
564
|
+
|
|
565
|
+
### 当前状态
|
|
566
|
+
|
|
567
|
+
```
|
|
568
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
569
|
+
当前存储与返回机制
|
|
570
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
571
|
+
|
|
572
|
+
内容存储: ⚠️ 表结构完整,但写入逻辑未实现
|
|
573
|
+
图片存储: ⚠️ 仅返回云端 URL,未本地持久化
|
|
574
|
+
返回方式: ✅ CLI 实时返回(用户可直接查看)
|
|
575
|
+
历史查询: ❌ 未实现
|
|
576
|
+
───────────────────────────────────────────────────────────────────
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
### 用户使用流程
|
|
580
|
+
|
|
581
|
+
```bash
|
|
582
|
+
# 1. 创建任务(同步模式)
|
|
583
|
+
pnpm run cli:create \
|
|
584
|
+
--topic "AI 技术发展" \
|
|
585
|
+
--requirements "写一篇文章" \
|
|
586
|
+
--sync
|
|
587
|
+
|
|
588
|
+
# 2. 等待执行完成(约 50 秒)
|
|
589
|
+
|
|
590
|
+
# 3. 内容直接显示在终端
|
|
591
|
+
✅ 执行成功
|
|
592
|
+
────────────────────────────────────────
|
|
593
|
+
📝 生成的内容:
|
|
594
|
+
# AI 技术的发展趋势
|
|
595
|
+
[完整内容...]
|
|
596
|
+
────────────────────────────────────────
|
|
597
|
+
|
|
598
|
+
🖼️ 生成的配图:
|
|
599
|
+
https://tos-cn-beijing.ivolces.com/xxxxx.jpg
|
|
600
|
+
────────────────────────────────────────
|
|
601
|
+
|
|
602
|
+
# 4. 用户可以:
|
|
603
|
+
# - 复制文章内容
|
|
604
|
+
# - 访问图片 URL
|
|
605
|
+
# - 保存到文件
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
---
|
|
609
|
+
|
|
610
|
+
**文档版本**: 1.0
|
|
611
|
+
**最后更新**: 2026-01-20
|
|
612
|
+
**作者**: Content Creator Team
|