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 @@
|
|
|
1
|
+
{"version":3,"file":"MetricsService.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/monitoring/MetricsService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH;;GAEG;AACH,MAAM,WAAW,YAAY;IAE3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAGhB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC5C;AAED;;GAEG;AACH,qBAAa,cAAc;IAEzB,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,YAAY,CAAoB;IACxC,OAAO,CAAC,YAAY,CAAgB;IAGpC,OAAO,CAAC,qBAAqB,CAA+B;IAG5D,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,kBAAkB,CAAoB;IAC9C,OAAO,CAAC,aAAa,CAAkB;IACvC,OAAO,CAAC,QAAQ,CAAkB;IAClC,OAAO,CAAC,SAAS,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,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAI1C,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IAMtD,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAIxC,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAInC;;OAEG;IACH,OAAO,CAAC,4BAA4B;IAkBpC;;OAEG;IACH,IAAI,IAAI,IAAI;IAQZ;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC;IAInC;;OAEG;IACH,cAAc,IAAI,MAAM;IAIxB;;OAEG;IACH,YAAY,IAAI,IAAI;IAKpB;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC;CAYtC;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,gBAAuB,CAAC"}
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prometheus 指标服务
|
|
3
|
+
*
|
|
4
|
+
* 基于 prom-client 的指标采集服务
|
|
5
|
+
* 收集任务、LLM、队列、系统等关键指标
|
|
6
|
+
*/
|
|
7
|
+
import { register, Counter, Histogram, Gauge } from 'prom-client';
|
|
8
|
+
import { createLogger } from '../logging/logger.js';
|
|
9
|
+
const logger = createLogger('Metrics');
|
|
10
|
+
/**
|
|
11
|
+
* Prometheus 指标服务类
|
|
12
|
+
*/
|
|
13
|
+
export class MetricsService {
|
|
14
|
+
// 任务相关指标
|
|
15
|
+
taskCreated;
|
|
16
|
+
taskCompleted;
|
|
17
|
+
taskFailed;
|
|
18
|
+
taskCancelled;
|
|
19
|
+
taskDuration;
|
|
20
|
+
taskProgress;
|
|
21
|
+
// 系统指标收集定时器
|
|
22
|
+
systemMetricsInterval = null;
|
|
23
|
+
// LLM 相关指标
|
|
24
|
+
llmRequests;
|
|
25
|
+
llmRequestDuration;
|
|
26
|
+
llmTokenUsage;
|
|
27
|
+
llmRetry;
|
|
28
|
+
llmErrors;
|
|
29
|
+
// 队列相关指标
|
|
30
|
+
queueJobsWaiting;
|
|
31
|
+
queueJobsActive;
|
|
32
|
+
queueJobsCompleted;
|
|
33
|
+
queueJobsFailed;
|
|
34
|
+
queueJobDuration;
|
|
35
|
+
// 质量检查相关指标
|
|
36
|
+
qualityChecks;
|
|
37
|
+
qualityCheckDuration;
|
|
38
|
+
qualityCheckPassed;
|
|
39
|
+
qualityCheckFailed;
|
|
40
|
+
qualityCheckScore;
|
|
41
|
+
// 缓存相关指标
|
|
42
|
+
cacheHits;
|
|
43
|
+
cacheMisses;
|
|
44
|
+
cacheSet;
|
|
45
|
+
cacheDelete;
|
|
46
|
+
cacheSize;
|
|
47
|
+
// 系统相关指标
|
|
48
|
+
memoryUsage;
|
|
49
|
+
activeWorkers;
|
|
50
|
+
uptime;
|
|
51
|
+
constructor() {
|
|
52
|
+
// 初始化任务指标
|
|
53
|
+
this.taskCreated = new Counter({
|
|
54
|
+
name: 'task_created_total',
|
|
55
|
+
help: 'Total number of tasks created',
|
|
56
|
+
labelNames: ['workerId', 'mode'],
|
|
57
|
+
});
|
|
58
|
+
this.taskCompleted = new Counter({
|
|
59
|
+
name: 'task_completed_total',
|
|
60
|
+
help: 'Total number of tasks completed',
|
|
61
|
+
labelNames: ['workerId', 'mode'],
|
|
62
|
+
});
|
|
63
|
+
this.taskFailed = new Counter({
|
|
64
|
+
name: 'task_failed_total',
|
|
65
|
+
help: 'Total number of tasks failed',
|
|
66
|
+
labelNames: ['workerId', 'mode', 'error'],
|
|
67
|
+
});
|
|
68
|
+
this.taskCancelled = new Counter({
|
|
69
|
+
name: 'task_cancelled_total',
|
|
70
|
+
help: 'Total number of tasks cancelled',
|
|
71
|
+
labelNames: ['workerId'],
|
|
72
|
+
});
|
|
73
|
+
this.taskDuration = new Histogram({
|
|
74
|
+
name: 'task_duration_seconds',
|
|
75
|
+
help: 'Task execution duration in seconds',
|
|
76
|
+
labelNames: ['workerId', 'mode'],
|
|
77
|
+
buckets: [10, 30, 60, 120, 300, 600, 1800, 3600], // 10s 到 1h
|
|
78
|
+
});
|
|
79
|
+
this.taskProgress = new Gauge({
|
|
80
|
+
name: 'task_progress_percentage',
|
|
81
|
+
help: 'Current task progress percentage',
|
|
82
|
+
labelNames: ['workerId', 'taskId'],
|
|
83
|
+
});
|
|
84
|
+
// 初始化 LLM 指标
|
|
85
|
+
this.llmRequests = new Counter({
|
|
86
|
+
name: 'llm_request_total',
|
|
87
|
+
help: 'Total number of LLM requests',
|
|
88
|
+
labelNames: ['model', 'operation'],
|
|
89
|
+
});
|
|
90
|
+
this.llmRequestDuration = new Histogram({
|
|
91
|
+
name: 'llm_request_duration_seconds',
|
|
92
|
+
help: 'LLM request duration in seconds',
|
|
93
|
+
labelNames: ['model', 'operation'],
|
|
94
|
+
buckets: [1, 5, 10, 20, 30, 60, 120], // 1s 到 2min
|
|
95
|
+
});
|
|
96
|
+
this.llmTokenUsage = new Counter({
|
|
97
|
+
name: 'llm_token_usage_total',
|
|
98
|
+
help: 'Total number of tokens used',
|
|
99
|
+
labelNames: ['model', 'type'], // type: prompt, completion
|
|
100
|
+
});
|
|
101
|
+
this.llmRetry = new Counter({
|
|
102
|
+
name: 'llm_retry_total',
|
|
103
|
+
help: 'Total number of LLM request retries',
|
|
104
|
+
labelNames: ['model', 'operation'],
|
|
105
|
+
});
|
|
106
|
+
this.llmErrors = new Counter({
|
|
107
|
+
name: 'llm_error_total',
|
|
108
|
+
help: 'Total number of LLM errors',
|
|
109
|
+
labelNames: ['model', 'operation', 'error'],
|
|
110
|
+
});
|
|
111
|
+
// 初始化队列指标
|
|
112
|
+
this.queueJobsWaiting = new Gauge({
|
|
113
|
+
name: 'queue_jobs_waiting',
|
|
114
|
+
help: 'Number of jobs waiting in queue',
|
|
115
|
+
labelNames: ['queueName'],
|
|
116
|
+
});
|
|
117
|
+
this.queueJobsActive = new Gauge({
|
|
118
|
+
name: 'queue_jobs_active',
|
|
119
|
+
help: 'Number of active jobs being processed',
|
|
120
|
+
labelNames: ['queueName'],
|
|
121
|
+
});
|
|
122
|
+
this.queueJobsCompleted = new Counter({
|
|
123
|
+
name: 'queue_jobs_completed_total',
|
|
124
|
+
help: 'Total number of jobs completed',
|
|
125
|
+
labelNames: ['queueName'],
|
|
126
|
+
});
|
|
127
|
+
this.queueJobsFailed = new Counter({
|
|
128
|
+
name: 'queue_jobs_failed_total',
|
|
129
|
+
help: 'Total number of jobs failed',
|
|
130
|
+
labelNames: ['queueName', 'error'],
|
|
131
|
+
});
|
|
132
|
+
this.queueJobDuration = new Histogram({
|
|
133
|
+
name: 'queue_job_duration_seconds',
|
|
134
|
+
help: 'Queue job duration in seconds',
|
|
135
|
+
labelNames: ['queueName'],
|
|
136
|
+
buckets: [1, 5, 10, 30, 60, 300, 600],
|
|
137
|
+
});
|
|
138
|
+
// 初始化质量检查指标
|
|
139
|
+
this.qualityChecks = new Counter({
|
|
140
|
+
name: 'quality_check_total',
|
|
141
|
+
help: 'Total number of quality checks',
|
|
142
|
+
labelNames: ['type'], // type: hard, soft, full
|
|
143
|
+
});
|
|
144
|
+
this.qualityCheckDuration = new Histogram({
|
|
145
|
+
name: 'quality_check_duration_seconds',
|
|
146
|
+
help: 'Quality check duration in seconds',
|
|
147
|
+
labelNames: ['type'],
|
|
148
|
+
buckets: [1, 5, 10, 20, 30],
|
|
149
|
+
});
|
|
150
|
+
this.qualityCheckPassed = new Counter({
|
|
151
|
+
name: 'quality_check_passed_total',
|
|
152
|
+
help: 'Total number of quality checks passed',
|
|
153
|
+
labelNames: ['type'],
|
|
154
|
+
});
|
|
155
|
+
this.qualityCheckFailed = new Counter({
|
|
156
|
+
name: 'quality_check_failed_total',
|
|
157
|
+
help: 'Total number of quality checks failed',
|
|
158
|
+
labelNames: ['type', 'reason'],
|
|
159
|
+
});
|
|
160
|
+
this.qualityCheckScore = new Histogram({
|
|
161
|
+
name: 'quality_check_score',
|
|
162
|
+
help: 'Quality check score distribution',
|
|
163
|
+
labelNames: ['type'],
|
|
164
|
+
buckets: [2, 4, 6, 7, 8, 9, 10], // 对应评分等级
|
|
165
|
+
});
|
|
166
|
+
// 初始化缓存指标
|
|
167
|
+
this.cacheHits = new Counter({
|
|
168
|
+
name: 'cache_hits_total',
|
|
169
|
+
help: 'Total number of cache hits',
|
|
170
|
+
labelNames: ['cacheName'],
|
|
171
|
+
});
|
|
172
|
+
this.cacheMisses = new Counter({
|
|
173
|
+
name: 'cache_misses_total',
|
|
174
|
+
help: 'Total number of cache misses',
|
|
175
|
+
labelNames: ['cacheName'],
|
|
176
|
+
});
|
|
177
|
+
this.cacheSet = new Counter({
|
|
178
|
+
name: 'cache_set_total',
|
|
179
|
+
help: 'Total number of cache sets',
|
|
180
|
+
labelNames: ['cacheName'],
|
|
181
|
+
});
|
|
182
|
+
this.cacheDelete = new Counter({
|
|
183
|
+
name: 'cache_delete_total',
|
|
184
|
+
help: 'Total number of cache deletes',
|
|
185
|
+
labelNames: ['cacheName'],
|
|
186
|
+
});
|
|
187
|
+
this.cacheSize = new Gauge({
|
|
188
|
+
name: 'cache_size',
|
|
189
|
+
help: 'Current cache size',
|
|
190
|
+
labelNames: ['cacheName'],
|
|
191
|
+
});
|
|
192
|
+
// 初始化系统指标
|
|
193
|
+
this.memoryUsage = new Gauge({
|
|
194
|
+
name: 'memory_usage_bytes',
|
|
195
|
+
help: 'Memory usage in bytes',
|
|
196
|
+
labelNames: ['type'], // type: heap, rss, external
|
|
197
|
+
});
|
|
198
|
+
this.activeWorkers = new Gauge({
|
|
199
|
+
name: 'active_workers_total',
|
|
200
|
+
help: 'Number of active workers',
|
|
201
|
+
});
|
|
202
|
+
this.uptime = new Gauge({
|
|
203
|
+
name: 'uptime_seconds',
|
|
204
|
+
help: 'Service uptime in seconds',
|
|
205
|
+
});
|
|
206
|
+
// 启动系统指标收集
|
|
207
|
+
this.startSystemMetricsCollection();
|
|
208
|
+
logger.info('Metrics service initialized');
|
|
209
|
+
}
|
|
210
|
+
// ==================== 任务相关方法 ====================
|
|
211
|
+
recordTaskCreated(workerId, mode) {
|
|
212
|
+
this.taskCreated.inc({ workerId, mode });
|
|
213
|
+
}
|
|
214
|
+
recordTaskCompleted(workerId, mode, duration) {
|
|
215
|
+
this.taskCompleted.inc({ workerId, mode });
|
|
216
|
+
this.taskDuration.observe({ workerId, mode }, duration / 1000);
|
|
217
|
+
}
|
|
218
|
+
recordTaskFailed(workerId, mode, error) {
|
|
219
|
+
this.taskFailed.inc({ workerId, mode, error });
|
|
220
|
+
}
|
|
221
|
+
recordTaskCancelled(workerId) {
|
|
222
|
+
this.taskCancelled.inc({ workerId });
|
|
223
|
+
}
|
|
224
|
+
recordTaskProgress(workerId, taskId, progress) {
|
|
225
|
+
this.taskProgress.set({ workerId, taskId }, progress);
|
|
226
|
+
}
|
|
227
|
+
// ==================== LLM 相关方法 ====================
|
|
228
|
+
recordLLMRequest(model, operation) {
|
|
229
|
+
this.llmRequests.inc({ model, operation });
|
|
230
|
+
}
|
|
231
|
+
recordLLMRequestDuration(model, operation, duration) {
|
|
232
|
+
this.llmRequestDuration.observe({ model, operation }, duration / 1000);
|
|
233
|
+
}
|
|
234
|
+
recordLLMTokenUsage(model, type, count) {
|
|
235
|
+
this.llmTokenUsage.inc({ model, type }, count);
|
|
236
|
+
}
|
|
237
|
+
recordLLMRetry(model, operation) {
|
|
238
|
+
this.llmRetry.inc({ model, operation });
|
|
239
|
+
}
|
|
240
|
+
recordLLMError(model, operation, error) {
|
|
241
|
+
this.llmErrors.inc({ model, operation, error });
|
|
242
|
+
}
|
|
243
|
+
// ==================== 队列相关方法 ====================
|
|
244
|
+
recordQueueJobsWaiting(queueName, count) {
|
|
245
|
+
this.queueJobsWaiting.set({ queueName }, count);
|
|
246
|
+
}
|
|
247
|
+
recordQueueJobsActive(queueName, count) {
|
|
248
|
+
this.queueJobsActive.set({ queueName }, count);
|
|
249
|
+
}
|
|
250
|
+
recordQueueJobCompleted(queueName) {
|
|
251
|
+
this.queueJobsCompleted.inc({ queueName });
|
|
252
|
+
}
|
|
253
|
+
recordQueueJobFailed(queueName, error) {
|
|
254
|
+
this.queueJobsFailed.inc({ queueName, error });
|
|
255
|
+
}
|
|
256
|
+
recordQueueJobDuration(queueName, duration) {
|
|
257
|
+
this.queueJobDuration.observe({ queueName }, duration / 1000);
|
|
258
|
+
}
|
|
259
|
+
// ==================== 质量检查相关方法 ====================
|
|
260
|
+
recordQualityCheck(type) {
|
|
261
|
+
this.qualityChecks.inc({ type });
|
|
262
|
+
}
|
|
263
|
+
recordQualityCheckDuration(type, duration) {
|
|
264
|
+
this.qualityCheckDuration.observe({ type }, duration / 1000);
|
|
265
|
+
}
|
|
266
|
+
recordQualityCheckPassed(type) {
|
|
267
|
+
this.qualityCheckPassed.inc({ type });
|
|
268
|
+
}
|
|
269
|
+
recordQualityCheckFailed(type, reason) {
|
|
270
|
+
this.qualityCheckFailed.inc({ type, reason });
|
|
271
|
+
}
|
|
272
|
+
recordQualityCheckScore(type, score) {
|
|
273
|
+
this.qualityCheckScore.observe({ type }, score);
|
|
274
|
+
}
|
|
275
|
+
// ==================== 缓存相关方法 ====================
|
|
276
|
+
recordCacheHit(cacheName) {
|
|
277
|
+
this.cacheHits.inc({ cacheName });
|
|
278
|
+
}
|
|
279
|
+
recordCacheMiss(cacheName) {
|
|
280
|
+
this.cacheMisses.inc({ cacheName });
|
|
281
|
+
}
|
|
282
|
+
recordCacheSet(cacheName) {
|
|
283
|
+
this.cacheSet.inc({ cacheName });
|
|
284
|
+
}
|
|
285
|
+
recordCacheDelete(cacheName) {
|
|
286
|
+
this.cacheDelete.inc({ cacheName });
|
|
287
|
+
}
|
|
288
|
+
recordCacheSize(cacheName, size) {
|
|
289
|
+
this.cacheSize.set({ cacheName }, size);
|
|
290
|
+
}
|
|
291
|
+
// ==================== 系统相关方法 ====================
|
|
292
|
+
recordActiveWorkers(count) {
|
|
293
|
+
this.activeWorkers.set(count);
|
|
294
|
+
}
|
|
295
|
+
recordUptime(seconds) {
|
|
296
|
+
this.uptime.set(seconds);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* 启动系统指标收集
|
|
300
|
+
*/
|
|
301
|
+
startSystemMetricsCollection() {
|
|
302
|
+
const startTime = Date.now();
|
|
303
|
+
// 每 5 秒收集一次系统指标
|
|
304
|
+
this.systemMetricsInterval = setInterval(() => {
|
|
305
|
+
const memUsage = process.memoryUsage();
|
|
306
|
+
this.memoryUsage.set({ type: 'rss' }, memUsage.rss);
|
|
307
|
+
this.memoryUsage.set({ type: 'heapTotal' }, memUsage.heapTotal);
|
|
308
|
+
this.memoryUsage.set({ type: 'heapUsed' }, memUsage.heapUsed);
|
|
309
|
+
this.memoryUsage.set({ type: 'external' }, memUsage.external);
|
|
310
|
+
this.uptime.set((Date.now() - startTime) / 1000);
|
|
311
|
+
}, 5000);
|
|
312
|
+
logger.info('System metrics collection started');
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
315
|
+
* 停止系统指标收集
|
|
316
|
+
*/
|
|
317
|
+
stop() {
|
|
318
|
+
if (this.systemMetricsInterval) {
|
|
319
|
+
clearInterval(this.systemMetricsInterval);
|
|
320
|
+
this.systemMetricsInterval = null;
|
|
321
|
+
logger.info('System metrics collection stopped');
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* 获取 Prometheus 指标
|
|
326
|
+
*/
|
|
327
|
+
async getMetrics() {
|
|
328
|
+
return await register.metrics();
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 获取内容类型
|
|
332
|
+
*/
|
|
333
|
+
getContentType() {
|
|
334
|
+
return register.contentType;
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* 清空所有指标
|
|
338
|
+
*/
|
|
339
|
+
resetMetrics() {
|
|
340
|
+
register.clear();
|
|
341
|
+
logger.info('Metrics reset');
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* 获取指标统计
|
|
345
|
+
*/
|
|
346
|
+
async getMetricsStats() {
|
|
347
|
+
const metrics = await register.getMetricsAsJSON();
|
|
348
|
+
return {
|
|
349
|
+
totalMetrics: metrics.length,
|
|
350
|
+
metrics: metrics.map(m => ({
|
|
351
|
+
name: m.name,
|
|
352
|
+
type: m.type,
|
|
353
|
+
help: m.help,
|
|
354
|
+
})),
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Metrics 服务单例
|
|
360
|
+
*/
|
|
361
|
+
export const metricsService = new MetricsService();
|
|
362
|
+
//# sourceMappingURL=MetricsService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetricsService.js","sourceRoot":"","sources":["../../../src/infrastructure/monitoring/MetricsService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC;AAwBvC;;GAEG;AACH,MAAM,OAAO,cAAc;IACzB,SAAS;IACD,WAAW,CAAkB;IAC7B,aAAa,CAAkB;IAC/B,UAAU,CAAkB;IAC5B,aAAa,CAAkB;IAC/B,YAAY,CAAoB;IAChC,YAAY,CAAgB;IAEpC,YAAY;IACJ,qBAAqB,GAA0B,IAAI,CAAC;IAE5D,WAAW;IACH,WAAW,CAAkB;IAC7B,kBAAkB,CAAoB;IACtC,aAAa,CAAkB;IAC/B,QAAQ,CAAkB;IAC1B,SAAS,CAAkB;IAEnC,SAAS;IACD,gBAAgB,CAAgB;IAChC,eAAe,CAAgB;IAC/B,kBAAkB,CAAkB;IACpC,eAAe,CAAkB;IACjC,gBAAgB,CAAoB;IAE5C,WAAW;IACH,aAAa,CAAkB;IAC/B,oBAAoB,CAAoB;IACxC,kBAAkB,CAAkB;IACpC,kBAAkB,CAAkB;IACpC,iBAAiB,CAAoB;IAE7C,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I;gBACZ,IAAI,EAAE,CAAC,CAAC,IAAI;gBACZ,IAAI,EAAE,CAAC,CAAC,IAAI;aACb,CAAC,CAAC;SACJ,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sentry 错误追踪服务
|
|
3
|
+
*
|
|
4
|
+
* 基于 Sentry v8 的错误追踪和性能监控
|
|
5
|
+
* 提供错误捕获、性能监控、用户反馈等功能
|
|
6
|
+
*/
|
|
7
|
+
import * as Sentry from '@sentry/node';
|
|
8
|
+
/**
|
|
9
|
+
* Sentry 配置选项
|
|
10
|
+
*/
|
|
11
|
+
export interface SentryOptions {
|
|
12
|
+
dsn: string;
|
|
13
|
+
environment?: string;
|
|
14
|
+
release?: string;
|
|
15
|
+
tracesSampleRate?: number;
|
|
16
|
+
profilesSampleRate?: number;
|
|
17
|
+
beforeSend?: (event: Sentry.Event, hint?: Sentry.EventHint) => Sentry.Event | null;
|
|
18
|
+
beforeBreadcrumb?: (breadcrumb: Sentry.Breadcrumb, hint?: Sentry.BreadcrumbHint) => Sentry.Breadcrumb | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 用户信息
|
|
22
|
+
*/
|
|
23
|
+
export interface User {
|
|
24
|
+
id: string;
|
|
25
|
+
email?: string;
|
|
26
|
+
username?: string;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* 事务上下文
|
|
31
|
+
*/
|
|
32
|
+
export interface TransactionContext {
|
|
33
|
+
op: string;
|
|
34
|
+
name: string;
|
|
35
|
+
data?: Record<string, any>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Sentry 服务类
|
|
39
|
+
*/
|
|
40
|
+
export declare class SentryService {
|
|
41
|
+
private initialized;
|
|
42
|
+
constructor(_options?: SentryOptions);
|
|
43
|
+
/**
|
|
44
|
+
* 初始化 Sentry
|
|
45
|
+
*/
|
|
46
|
+
initialize(options: SentryOptions): void;
|
|
47
|
+
/**
|
|
48
|
+
* 默认的 beforeSend 处理
|
|
49
|
+
*/
|
|
50
|
+
private defaultBeforeSend;
|
|
51
|
+
/**
|
|
52
|
+
* 捕获异常
|
|
53
|
+
*/
|
|
54
|
+
captureException(error: Error, context?: {
|
|
55
|
+
user?: User;
|
|
56
|
+
tags?: Record<string, string>;
|
|
57
|
+
extra?: Record<string, any>;
|
|
58
|
+
}): void;
|
|
59
|
+
/**
|
|
60
|
+
* 捕获消息
|
|
61
|
+
*/
|
|
62
|
+
captureMessage(message: string, level?: Sentry.SeverityLevel, context?: {
|
|
63
|
+
user?: User;
|
|
64
|
+
tags?: Record<string, string>;
|
|
65
|
+
extra?: Record<string, any>;
|
|
66
|
+
}): void;
|
|
67
|
+
/**
|
|
68
|
+
* 创建性能追踪事务
|
|
69
|
+
*/
|
|
70
|
+
startTransaction(context: TransactionContext): any;
|
|
71
|
+
/**
|
|
72
|
+
* 设置用户
|
|
73
|
+
*/
|
|
74
|
+
setUser(user: User): void;
|
|
75
|
+
/**
|
|
76
|
+
* 清除用户
|
|
77
|
+
*/
|
|
78
|
+
clearUser(): void;
|
|
79
|
+
/**
|
|
80
|
+
* 设置标签
|
|
81
|
+
*/
|
|
82
|
+
setTags(tags: Record<string, string>): void;
|
|
83
|
+
/**
|
|
84
|
+
* 设置额外信息
|
|
85
|
+
*/
|
|
86
|
+
setExtras(extras: Record<string, any>): void;
|
|
87
|
+
/**
|
|
88
|
+
* 添加面包屑
|
|
89
|
+
*/
|
|
90
|
+
addBreadcrumb(message: string, category?: string, level?: Sentry.SeverityLevel, data?: Record<string, any>): void;
|
|
91
|
+
/**
|
|
92
|
+
* 设置上下文
|
|
93
|
+
*/
|
|
94
|
+
setContext(key: string, context: Record<string, any>): void;
|
|
95
|
+
/**
|
|
96
|
+
* 检查是否已初始化
|
|
97
|
+
*/
|
|
98
|
+
isInitialized(): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* 健康检查
|
|
101
|
+
*/
|
|
102
|
+
healthCheck(): Promise<boolean>;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Sentry 服务单例
|
|
106
|
+
*/
|
|
107
|
+
export declare const sentryService: SentryService;
|
|
108
|
+
//# sourceMappingURL=SentryService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SentryService.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/monitoring/SentryService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AAKvC;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,SAAS,KAAK,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC;IACnF,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,cAAc,KAAK,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC;CAC9G;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,C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