lean-claudient-core 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/.reports/detailed-analysis_2026-06-20_01ed326b.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_08d39381.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_0a331144.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_0d54ffef.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_14bfa31c.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_211feac4.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_22381bc2.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_29b4ea0a.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_2df0ad14.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_343ec84c.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_3a01030d.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_3b4c99ec.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_3d368827.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_53544d3d.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_5721164a.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_57caf5e7.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_624302f5.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_62456384.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_636a52f1.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_63d1ad41.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_7451ccd7.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_74da4e9a.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_83a90083.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_867fbdd9.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_974c3299.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_a04639a2.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_a8e23d6d.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_aa9150f0.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_acbeee08.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_c4ffa0e2.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_c5f7684b.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_c963b1fa.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_d4bde41f.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_d6eb2497.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_ea6f7f58.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_ebf4e060.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_ec4313a9.html +200 -0
- package/.reports/detailed-analysis_2026-06-20_fc65d18e.html +200 -0
- package/.reports/executive-summary_2026-06-20_00406d50.html +109 -0
- package/.reports/executive-summary_2026-06-20_0bb202d3.html +109 -0
- package/.reports/executive-summary_2026-06-20_0bcd7481.html +109 -0
- package/.reports/executive-summary_2026-06-20_11506445.html +109 -0
- package/.reports/executive-summary_2026-06-20_13616cda.html +109 -0
- package/.reports/executive-summary_2026-06-20_19d41c2f.html +109 -0
- package/.reports/executive-summary_2026-06-20_1b0d6e96.html +109 -0
- package/.reports/executive-summary_2026-06-20_1e38670b.html +109 -0
- package/.reports/executive-summary_2026-06-20_1f32f793.html +109 -0
- package/.reports/executive-summary_2026-06-20_1f40f7d3.html +109 -0
- package/.reports/executive-summary_2026-06-20_25a40a7e.html +109 -0
- package/.reports/executive-summary_2026-06-20_26d11818.html +109 -0
- package/.reports/executive-summary_2026-06-20_26ed4593.html +109 -0
- package/.reports/executive-summary_2026-06-20_291b90a8.html +109 -0
- package/.reports/executive-summary_2026-06-20_2957a848.html +109 -0
- package/.reports/executive-summary_2026-06-20_2a04eb77.html +109 -0
- package/.reports/executive-summary_2026-06-20_2fa701f9.html +109 -0
- package/.reports/executive-summary_2026-06-20_327af8f5.html +109 -0
- package/.reports/executive-summary_2026-06-20_3418c729.html +109 -0
- package/.reports/executive-summary_2026-06-20_3571763d.html +109 -0
- package/.reports/executive-summary_2026-06-20_36225353.html +109 -0
- package/.reports/executive-summary_2026-06-20_3b2de891.html +109 -0
- package/.reports/executive-summary_2026-06-20_45b980c2.html +109 -0
- package/.reports/executive-summary_2026-06-20_46fcbf17.html +109 -0
- package/.reports/executive-summary_2026-06-20_48c8fa5e.html +109 -0
- package/.reports/executive-summary_2026-06-20_4ba55c43.html +109 -0
- package/.reports/executive-summary_2026-06-20_4f4498e6.html +109 -0
- package/.reports/executive-summary_2026-06-20_54c33bf0.html +109 -0
- package/.reports/executive-summary_2026-06-20_54cc7077.html +109 -0
- package/.reports/executive-summary_2026-06-20_5a12912e.html +109 -0
- package/.reports/executive-summary_2026-06-20_636fac87.html +109 -0
- package/.reports/executive-summary_2026-06-20_6587faaf.html +109 -0
- package/.reports/executive-summary_2026-06-20_6adbdd03.html +109 -0
- package/.reports/executive-summary_2026-06-20_6bf344ec.html +109 -0
- package/.reports/executive-summary_2026-06-20_7142aeed.html +109 -0
- package/.reports/executive-summary_2026-06-20_72bc0ceb.html +109 -0
- package/.reports/executive-summary_2026-06-20_775752ac.html +109 -0
- package/.reports/executive-summary_2026-06-20_7a9c3223.html +109 -0
- package/.reports/executive-summary_2026-06-20_808e6376.html +109 -0
- package/.reports/executive-summary_2026-06-20_8de9142d.html +109 -0
- package/.reports/executive-summary_2026-06-20_91981fbe.html +109 -0
- package/.reports/executive-summary_2026-06-20_93191c8c.html +109 -0
- package/.reports/executive-summary_2026-06-20_9be48a87.html +109 -0
- package/.reports/executive-summary_2026-06-20_9c127198.html +109 -0
- package/.reports/executive-summary_2026-06-20_9ee303ac.html +109 -0
- package/.reports/executive-summary_2026-06-20_9ee52709.html +109 -0
- package/.reports/executive-summary_2026-06-20_a0fa27de.html +109 -0
- package/.reports/executive-summary_2026-06-20_a1813e47.html +109 -0
- package/.reports/executive-summary_2026-06-20_a974edc1.html +109 -0
- package/.reports/executive-summary_2026-06-20_aa711737.html +109 -0
- package/.reports/executive-summary_2026-06-20_aa752246.html +109 -0
- package/.reports/executive-summary_2026-06-20_ac6f0927.html +109 -0
- package/.reports/executive-summary_2026-06-20_b231b143.html +109 -0
- package/.reports/executive-summary_2026-06-20_b570a2bd.html +109 -0
- package/.reports/executive-summary_2026-06-20_b6fbf650.html +109 -0
- package/.reports/executive-summary_2026-06-20_b9f8ddf3.html +109 -0
- package/.reports/executive-summary_2026-06-20_bf95cc63.html +109 -0
- package/.reports/executive-summary_2026-06-20_c0d0aefe.html +109 -0
- package/.reports/executive-summary_2026-06-20_c1933c36.html +109 -0
- package/.reports/executive-summary_2026-06-20_c99bba8a.html +109 -0
- package/.reports/executive-summary_2026-06-20_cc3846ac.html +109 -0
- package/.reports/executive-summary_2026-06-20_d485993c.html +109 -0
- package/.reports/executive-summary_2026-06-20_d56f75f7.html +109 -0
- package/.reports/executive-summary_2026-06-20_d57660cc.html +109 -0
- package/.reports/executive-summary_2026-06-20_dc036f62.html +109 -0
- package/.reports/executive-summary_2026-06-20_df783f47.html +109 -0
- package/.reports/executive-summary_2026-06-20_e2191adb.html +109 -0
- package/.reports/executive-summary_2026-06-20_e9f1d504.html +109 -0
- package/.reports/executive-summary_2026-06-20_ea82f5e1.html +109 -0
- package/.reports/executive-summary_2026-06-20_ec3e70cb.html +109 -0
- package/.reports/executive-summary_2026-06-20_ee6cf902.html +109 -0
- package/.reports/executive-summary_2026-06-20_f6cb657c.html +109 -0
- package/.reports/executive-summary_2026-06-20_f8c60046.html +109 -0
- package/.reports/executive-summary_2026-06-20_fa184840.html +109 -0
- package/.reports/executive-summary_2026-06-20_fc88bcb4.html +109 -0
- package/.reports/executive-summary_2026-06-20_ffa79c4e.html +109 -0
- package/README.md +53 -0
- package/dist/automation/actionApprover.d.ts +89 -0
- package/dist/automation/actionApprover.d.ts.map +1 -0
- package/dist/automation/actionApprover.js +264 -0
- package/dist/automation/actionApprover.js.map +1 -0
- package/dist/automation/actionExecutor.d.ts +125 -0
- package/dist/automation/actionExecutor.d.ts.map +1 -0
- package/dist/automation/actionExecutor.js +304 -0
- package/dist/automation/actionExecutor.js.map +1 -0
- package/dist/automation/alertRules.d.ts +55 -0
- package/dist/automation/alertRules.d.ts.map +1 -0
- package/dist/automation/alertRules.js +70 -0
- package/dist/automation/alertRules.js.map +1 -0
- package/dist/automation/alertSystem.d.ts +109 -0
- package/dist/automation/alertSystem.d.ts.map +1 -0
- package/dist/automation/alertSystem.js +303 -0
- package/dist/automation/alertSystem.js.map +1 -0
- package/dist/automation/competitorResponse.d.ts +119 -0
- package/dist/automation/competitorResponse.d.ts.map +1 -0
- package/dist/automation/competitorResponse.js +343 -0
- package/dist/automation/competitorResponse.js.map +1 -0
- package/dist/automation/composioClient.d.ts +107 -0
- package/dist/automation/composioClient.d.ts.map +1 -0
- package/dist/automation/composioClient.js +286 -0
- package/dist/automation/composioClient.js.map +1 -0
- package/dist/automation/crmExport.d.ts +116 -0
- package/dist/automation/crmExport.d.ts.map +1 -0
- package/dist/automation/crmExport.js +282 -0
- package/dist/automation/crmExport.js.map +1 -0
- package/dist/automation/crmIntegration.d.ts +83 -0
- package/dist/automation/crmIntegration.d.ts.map +1 -0
- package/dist/automation/crmIntegration.js +207 -0
- package/dist/automation/crmIntegration.js.map +1 -0
- package/dist/automation/gmailIntegration.d.ts +73 -0
- package/dist/automation/gmailIntegration.d.ts.map +1 -0
- package/dist/automation/gmailIntegration.js +184 -0
- package/dist/automation/gmailIntegration.js.map +1 -0
- package/dist/automation/index.d.ts +17 -0
- package/dist/automation/index.d.ts.map +1 -0
- package/dist/automation/index.js +17 -0
- package/dist/automation/index.js.map +1 -0
- package/dist/automation/jiraIntegration.d.ts +103 -0
- package/dist/automation/jiraIntegration.d.ts.map +1 -0
- package/dist/automation/jiraIntegration.js +222 -0
- package/dist/automation/jiraIntegration.js.map +1 -0
- package/dist/automation/jobQueue.d.ts +98 -0
- package/dist/automation/jobQueue.d.ts.map +1 -0
- package/dist/automation/jobQueue.js +207 -0
- package/dist/automation/jobQueue.js.map +1 -0
- package/dist/automation/leadQualification.d.ts +60 -0
- package/dist/automation/leadQualification.d.ts.map +1 -0
- package/dist/automation/leadQualification.js +204 -0
- package/dist/automation/leadQualification.js.map +1 -0
- package/dist/automation/qualificationRules.d.ts +100 -0
- package/dist/automation/qualificationRules.d.ts.map +1 -0
- package/dist/automation/qualificationRules.js +202 -0
- package/dist/automation/qualificationRules.js.map +1 -0
- package/dist/automation/responseTemplates.d.ts +64 -0
- package/dist/automation/responseTemplates.d.ts.map +1 -0
- package/dist/automation/responseTemplates.js +374 -0
- package/dist/automation/responseTemplates.js.map +1 -0
- package/dist/automation/scheduler.d.ts +85 -0
- package/dist/automation/scheduler.d.ts.map +1 -0
- package/dist/automation/scheduler.js +194 -0
- package/dist/automation/scheduler.js.map +1 -0
- package/dist/automation/types.d.ts +223 -0
- package/dist/automation/types.d.ts.map +1 -0
- package/dist/automation/types.js +32 -0
- package/dist/automation/types.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +575 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/compression/caveman.d.ts +14 -0
- package/dist/compression/caveman.d.ts.map +1 -0
- package/dist/compression/caveman.js +188 -0
- package/dist/compression/caveman.js.map +1 -0
- package/dist/compression/caveman.test.d.ts +2 -0
- package/dist/compression/caveman.test.d.ts.map +1 -0
- package/dist/compression/caveman.test.js.map +1 -0
- package/dist/config/configManager.d.ts +6 -0
- package/dist/config/configManager.d.ts.map +1 -0
- package/dist/config/configManager.js +62 -0
- package/dist/config/configManager.js.map +1 -0
- package/dist/config/schema.d.ts +95 -0
- package/dist/config/schema.d.ts.map +1 -0
- package/dist/config/schema.js +19 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/context/autoCompact.d.ts +19 -0
- package/dist/context/autoCompact.d.ts.map +1 -0
- package/dist/context/autoCompact.js +101 -0
- package/dist/context/autoCompact.js.map +1 -0
- package/dist/context/readDedup.d.ts +21 -0
- package/dist/context/readDedup.d.ts.map +1 -0
- package/dist/context/readDedup.js +55 -0
- package/dist/context/readDedup.js.map +1 -0
- package/dist/context/toolBudgets.d.ts +15 -0
- package/dist/context/toolBudgets.d.ts.map +1 -0
- package/dist/context/toolBudgets.js +35 -0
- package/dist/context/toolBudgets.js.map +1 -0
- package/dist/core/auditLogger.d.ts +30 -0
- package/dist/core/auditLogger.d.ts.map +1 -0
- package/dist/core/auditLogger.js +51 -0
- package/dist/core/auditLogger.js.map +1 -0
- package/dist/core/stateManager.d.ts +10 -0
- package/dist/core/stateManager.d.ts.map +1 -0
- package/dist/core/stateManager.js +59 -0
- package/dist/core/stateManager.js.map +1 -0
- package/dist/database/feedbackSchema.d.ts +80 -0
- package/dist/database/feedbackSchema.d.ts.map +1 -0
- package/dist/database/feedbackSchema.js +94 -0
- package/dist/database/feedbackSchema.js.map +1 -0
- package/dist/database/leadsSchema.d.ts +99 -0
- package/dist/database/leadsSchema.d.ts.map +1 -0
- package/dist/database/leadsSchema.js +136 -0
- package/dist/database/leadsSchema.js.map +1 -0
- package/dist/intelligence/competitorScoring.d.ts +25 -0
- package/dist/intelligence/competitorScoring.d.ts.map +1 -0
- package/dist/intelligence/competitorScoring.js +181 -0
- package/dist/intelligence/competitorScoring.js.map +1 -0
- package/dist/intelligence/competitorTracker.d.ts +36 -0
- package/dist/intelligence/competitorTracker.d.ts.map +1 -0
- package/dist/intelligence/competitorTracker.js +286 -0
- package/dist/intelligence/competitorTracker.js.map +1 -0
- package/dist/intelligence/competitorTypes.d.ts +93 -0
- package/dist/intelligence/competitorTypes.d.ts.map +1 -0
- package/dist/intelligence/competitorTypes.js +6 -0
- package/dist/intelligence/competitorTypes.js.map +1 -0
- package/dist/intelligence/competitors.json +76 -0
- package/dist/intelligence/feedbackLoop.d.ts +118 -0
- package/dist/intelligence/feedbackLoop.d.ts.map +1 -0
- package/dist/intelligence/feedbackLoop.js +368 -0
- package/dist/intelligence/feedbackLoop.js.map +1 -0
- package/dist/intelligence/gitHubTracker.d.ts +14 -0
- package/dist/intelligence/gitHubTracker.d.ts.map +1 -0
- package/dist/intelligence/gitHubTracker.js +153 -0
- package/dist/intelligence/gitHubTracker.js.map +1 -0
- package/dist/intelligence/hackerNewsScanner.d.ts +21 -0
- package/dist/intelligence/hackerNewsScanner.d.ts.map +1 -0
- package/dist/intelligence/hackerNewsScanner.js +88 -0
- package/dist/intelligence/hackerNewsScanner.js.map +1 -0
- package/dist/intelligence/hiringSignals.d.ts +16 -0
- package/dist/intelligence/hiringSignals.d.ts.map +1 -0
- package/dist/intelligence/hiringSignals.js +132 -0
- package/dist/intelligence/hiringSignals.js.map +1 -0
- package/dist/intelligence/index.d.ts +9 -0
- package/dist/intelligence/index.d.ts.map +1 -0
- package/dist/intelligence/index.js +9 -0
- package/dist/intelligence/index.js.map +1 -0
- package/dist/intelligence/leadEnrichment.d.ts +59 -0
- package/dist/intelligence/leadEnrichment.d.ts.map +1 -0
- package/dist/intelligence/leadEnrichment.js +209 -0
- package/dist/intelligence/leadEnrichment.js.map +1 -0
- package/dist/intelligence/leadEnrichmentTypes.d.ts +49 -0
- package/dist/intelligence/leadEnrichmentTypes.d.ts.map +1 -0
- package/dist/intelligence/leadEnrichmentTypes.js +7 -0
- package/dist/intelligence/leadEnrichmentTypes.js.map +1 -0
- package/dist/intelligence/marketScanner.d.ts +18 -0
- package/dist/intelligence/marketScanner.d.ts.map +1 -0
- package/dist/intelligence/marketScanner.js +225 -0
- package/dist/intelligence/marketScanner.js.map +1 -0
- package/dist/intelligence/polymarketScanner.d.ts +20 -0
- package/dist/intelligence/polymarketScanner.d.ts.map +1 -0
- package/dist/intelligence/polymarketScanner.js +88 -0
- package/dist/intelligence/polymarketScanner.js.map +1 -0
- package/dist/intelligence/redditScanner.d.ts +22 -0
- package/dist/intelligence/redditScanner.d.ts.map +1 -0
- package/dist/intelligence/redditScanner.js +89 -0
- package/dist/intelligence/redditScanner.js.map +1 -0
- package/dist/intelligence/signalAggregator.d.ts +10 -0
- package/dist/intelligence/signalAggregator.d.ts.map +1 -0
- package/dist/intelligence/signalAggregator.js +64 -0
- package/dist/intelligence/signalAggregator.js.map +1 -0
- package/dist/intelligence/trendAnalysis.d.ts +13 -0
- package/dist/intelligence/trendAnalysis.d.ts.map +1 -0
- package/dist/intelligence/trendAnalysis.js +106 -0
- package/dist/intelligence/trendAnalysis.js.map +1 -0
- package/dist/intelligence/twitterScanner.d.ts +22 -0
- package/dist/intelligence/twitterScanner.d.ts.map +1 -0
- package/dist/intelligence/twitterScanner.js +63 -0
- package/dist/intelligence/twitterScanner.js.map +1 -0
- package/dist/intelligence/types.d.ts +566 -0
- package/dist/intelligence/types.d.ts.map +1 -0
- package/dist/intelligence/types.js +87 -0
- package/dist/intelligence/types.js.map +1 -0
- package/dist/intelligence/userComplaints.d.ts +15 -0
- package/dist/intelligence/userComplaints.d.ts.map +1 -0
- package/dist/intelligence/userComplaints.js +193 -0
- package/dist/intelligence/userComplaints.js.map +1 -0
- package/dist/metrics/businessMetrics.d.ts +41 -0
- package/dist/metrics/businessMetrics.d.ts.map +1 -0
- package/dist/metrics/businessMetrics.js +120 -0
- package/dist/metrics/businessMetrics.js.map +1 -0
- package/dist/metrics/businessMetrics.test.d.ts +2 -0
- package/dist/metrics/businessMetrics.test.d.ts.map +1 -0
- package/dist/metrics/businessMetrics.test.js.map +1 -0
- package/dist/metrics/businessMetricsAgg.d.ts +85 -0
- package/dist/metrics/businessMetricsAgg.d.ts.map +1 -0
- package/dist/metrics/businessMetricsAgg.js +406 -0
- package/dist/metrics/businessMetricsAgg.js.map +1 -0
- package/dist/metrics/competitorMetrics.d.ts +57 -0
- package/dist/metrics/competitorMetrics.d.ts.map +1 -0
- package/dist/metrics/competitorMetrics.js +94 -0
- package/dist/metrics/competitorMetrics.js.map +1 -0
- package/dist/metrics/dashboardGenerator.d.ts +16 -0
- package/dist/metrics/dashboardGenerator.d.ts.map +1 -0
- package/dist/metrics/dashboardGenerator.js +313 -0
- package/dist/metrics/dashboardGenerator.js.map +1 -0
- package/dist/metrics/dashboardHTML.d.ts +18 -0
- package/dist/metrics/dashboardHTML.d.ts.map +1 -0
- package/dist/metrics/dashboardHTML.js +613 -0
- package/dist/metrics/dashboardHTML.js.map +1 -0
- package/dist/metrics/grafanaExport.d.ts +53 -0
- package/dist/metrics/grafanaExport.d.ts.map +1 -0
- package/dist/metrics/grafanaExport.js +277 -0
- package/dist/metrics/grafanaExport.js.map +1 -0
- package/dist/metrics/index.d.ts +17 -0
- package/dist/metrics/index.d.ts.map +1 -0
- package/dist/metrics/index.js +17 -0
- package/dist/metrics/index.js.map +1 -0
- package/dist/metrics/leadsMetrics.d.ts +48 -0
- package/dist/metrics/leadsMetrics.d.ts.map +1 -0
- package/dist/metrics/leadsMetrics.js +82 -0
- package/dist/metrics/leadsMetrics.js.map +1 -0
- package/dist/metrics/leadsMetrics.test.d.ts +2 -0
- package/dist/metrics/leadsMetrics.test.d.ts.map +1 -0
- package/dist/metrics/leadsMetrics.test.js.map +1 -0
- package/dist/metrics/metricsTypes.d.ts +114 -0
- package/dist/metrics/metricsTypes.d.ts.map +1 -0
- package/dist/metrics/metricsTypes.js +7 -0
- package/dist/metrics/metricsTypes.js.map +1 -0
- package/dist/metrics/revenueProjection.d.ts +44 -0
- package/dist/metrics/revenueProjection.d.ts.map +1 -0
- package/dist/metrics/revenueProjection.js +239 -0
- package/dist/metrics/revenueProjection.js.map +1 -0
- package/dist/metrics/revenueTypes.d.ts +62 -0
- package/dist/metrics/revenueTypes.d.ts.map +1 -0
- package/dist/metrics/revenueTypes.js +7 -0
- package/dist/metrics/revenueTypes.js.map +1 -0
- package/dist/metrics/roiCalculator.d.ts +39 -0
- package/dist/metrics/roiCalculator.d.ts.map +1 -0
- package/dist/metrics/roiCalculator.js +128 -0
- package/dist/metrics/roiCalculator.js.map +1 -0
- package/dist/metrics/roiCalculator.test.d.ts +2 -0
- package/dist/metrics/roiCalculator.test.d.ts.map +1 -0
- package/dist/metrics/roiCalculator.test.js.map +1 -0
- package/dist/metrics/trendMetrics.d.ts +51 -0
- package/dist/metrics/trendMetrics.d.ts.map +1 -0
- package/dist/metrics/trendMetrics.js +116 -0
- package/dist/metrics/trendMetrics.js.map +1 -0
- package/dist/modes/conservativeCTOMode.d.ts +32 -0
- package/dist/modes/conservativeCTOMode.d.ts.map +1 -0
- package/dist/modes/conservativeCTOMode.js +98 -0
- package/dist/modes/conservativeCTOMode.js.map +1 -0
- package/dist/modes/index.d.ts +3 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/index.js +3 -0
- package/dist/modes/index.js.map +1 -0
- package/dist/modes/seniorDeveloperMode.d.ts +17 -0
- package/dist/modes/seniorDeveloperMode.d.ts.map +1 -0
- package/dist/modes/seniorDeveloperMode.js +77 -0
- package/dist/modes/seniorDeveloperMode.js.map +1 -0
- package/dist/recovery/contextRecovery.d.ts +28 -0
- package/dist/recovery/contextRecovery.d.ts.map +1 -0
- package/dist/recovery/contextRecovery.js +113 -0
- package/dist/recovery/contextRecovery.js.map +1 -0
- package/dist/repair/errorDiagnostics.d.ts +28 -0
- package/dist/repair/errorDiagnostics.d.ts.map +1 -0
- package/dist/repair/errorDiagnostics.js +158 -0
- package/dist/repair/errorDiagnostics.js.map +1 -0
- package/dist/repair/skillCapture.d.ts +22 -0
- package/dist/repair/skillCapture.d.ts.map +1 -0
- package/dist/repair/skillCapture.js +119 -0
- package/dist/repair/skillCapture.js.map +1 -0
- package/dist/reporting/reportGenerator.d.ts +117 -0
- package/dist/reporting/reportGenerator.d.ts.map +1 -0
- package/dist/reporting/reportGenerator.js +613 -0
- package/dist/reporting/reportGenerator.js.map +1 -0
- package/dist/reporting/templates.d.ts +68 -0
- package/dist/reporting/templates.d.ts.map +1 -0
- package/dist/reporting/templates.js +629 -0
- package/dist/reporting/templates.js.map +1 -0
- package/dist/security/owaspScanner.d.ts +74 -0
- package/dist/security/owaspScanner.d.ts.map +1 -0
- package/dist/security/owaspScanner.js +309 -0
- package/dist/security/owaspScanner.js.map +1 -0
- package/dist/security/piiRedaction.d.ts +67 -0
- package/dist/security/piiRedaction.d.ts.map +1 -0
- package/dist/security/piiRedaction.js +189 -0
- package/dist/security/piiRedaction.js.map +1 -0
- package/dist/security/secretsDetection.d.ts +47 -0
- package/dist/security/secretsDetection.d.ts.map +1 -0
- package/dist/security/secretsDetection.js +272 -0
- package/dist/security/secretsDetection.js.map +1 -0
- package/dist/subagents/builder.d.ts +33 -0
- package/dist/subagents/builder.d.ts.map +1 -0
- package/dist/subagents/builder.js +158 -0
- package/dist/subagents/builder.js.map +1 -0
- package/dist/subagents/investigator.d.ts +31 -0
- package/dist/subagents/investigator.d.ts.map +1 -0
- package/dist/subagents/investigator.js +166 -0
- package/dist/subagents/investigator.js.map +1 -0
- package/dist/subagents/orchestrator.d.ts +48 -0
- package/dist/subagents/orchestrator.d.ts.map +1 -0
- package/dist/subagents/orchestrator.js +151 -0
- package/dist/subagents/orchestrator.js.map +1 -0
- package/dist/subagents/reviewer.d.ts +31 -0
- package/dist/subagents/reviewer.d.ts.map +1 -0
- package/dist/subagents/reviewer.js +154 -0
- package/dist/subagents/reviewer.js.map +1 -0
- package/dist/telemetry/tokenCounter.d.ts +21 -0
- package/dist/telemetry/tokenCounter.d.ts.map +1 -0
- package/dist/telemetry/tokenCounter.js +49 -0
- package/dist/telemetry/tokenCounter.js.map +1 -0
- package/package.json +61 -0
- package/src/automation/actionApprover.ts +342 -0
- package/src/automation/actionExecutor.ts +399 -0
- package/src/automation/alertRules.ts +113 -0
- package/src/automation/alertSystem.ts +402 -0
- package/src/automation/competitorResponse.ts +511 -0
- package/src/automation/composioClient.ts +360 -0
- package/src/automation/crmExport.ts +407 -0
- package/src/automation/crmIntegration.ts +268 -0
- package/src/automation/gmailIntegration.ts +244 -0
- package/src/automation/index.ts +17 -0
- package/src/automation/jiraIntegration.ts +310 -0
- package/src/automation/jobQueue.ts +278 -0
- package/src/automation/leadQualification.ts +270 -0
- package/src/automation/qualificationRules.ts +304 -0
- package/src/automation/responseTemplates.ts +419 -0
- package/src/automation/scheduler.ts +254 -0
- package/src/automation/types.ts +270 -0
- package/src/cli/index.ts +646 -0
- package/src/compression/caveman.ts +257 -0
- package/src/config/configManager.ts +63 -0
- package/src/config/schema.ts +27 -0
- package/src/context/autoCompact.ts +123 -0
- package/src/context/readDedup.ts +84 -0
- package/src/context/toolBudgets.ts +43 -0
- package/src/core/auditLogger.ts +69 -0
- package/src/core/stateManager.ts +73 -0
- package/src/database/feedbackSchema.ts +168 -0
- package/src/database/leadsSchema.ts +205 -0
- package/src/intelligence/competitorScoring.ts +292 -0
- package/src/intelligence/competitorTracker.ts +362 -0
- package/src/intelligence/competitorTypes.ts +100 -0
- package/src/intelligence/competitors.json +76 -0
- package/src/intelligence/feedbackLoop.ts +538 -0
- package/src/intelligence/gitHubTracker.ts +204 -0
- package/src/intelligence/hackerNewsScanner.ts +121 -0
- package/src/intelligence/hiringSignals.ts +162 -0
- package/src/intelligence/index.ts +9 -0
- package/src/intelligence/leadEnrichment.ts +275 -0
- package/src/intelligence/leadEnrichmentTypes.ts +54 -0
- package/src/intelligence/marketScanner.ts +285 -0
- package/src/intelligence/polymarketScanner.ts +120 -0
- package/src/intelligence/redditScanner.ts +122 -0
- package/src/intelligence/signalAggregator.ts +94 -0
- package/src/intelligence/trendAnalysis.ts +140 -0
- package/src/intelligence/twitterScanner.ts +94 -0
- package/src/intelligence/types.ts +130 -0
- package/src/intelligence/userComplaints.ts +236 -0
- package/src/metrics/businessMetrics.ts +186 -0
- package/src/metrics/businessMetricsAgg.ts +554 -0
- package/src/metrics/competitorMetrics.ts +175 -0
- package/src/metrics/dashboardGenerator.ts +335 -0
- package/src/metrics/dashboardHTML.ts +637 -0
- package/src/metrics/grafanaExport.ts +347 -0
- package/src/metrics/index.ts +17 -0
- package/src/metrics/leadsMetrics.ts +145 -0
- package/src/metrics/metricsTypes.ts +129 -0
- package/src/metrics/revenueProjection.ts +319 -0
- package/src/metrics/revenueTypes.ts +67 -0
- package/src/metrics/roiCalculator.ts +199 -0
- package/src/metrics/trendMetrics.ts +190 -0
- package/src/modes/conservativeCTOMode.ts +124 -0
- package/src/modes/index.ts +6 -0
- package/src/modes/seniorDeveloperMode.ts +94 -0
- package/src/recovery/contextRecovery.ts +141 -0
- package/src/repair/errorDiagnostics.ts +198 -0
- package/src/repair/skillCapture.ts +157 -0
- package/src/reporting/reportGenerator.ts +802 -0
- package/src/reporting/templates.ts +677 -0
- package/src/security/owaspScanner.ts +390 -0
- package/src/security/phase8Hardening.ts +536 -0
- package/src/security/piiRedaction.ts +215 -0
- package/src/security/secretsDetection.js +271 -0
- package/src/security/secretsDetection.ts +318 -0
- package/src/subagents/builder.ts +277 -0
- package/src/subagents/investigator.ts +224 -0
- package/src/subagents/orchestrator.ts +212 -0
- package/src/subagents/reviewer.ts +215 -0
- package/src/telemetry/tokenCounter.ts +81 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { readFileSync, readdirSync, statSync } from 'fs';
|
|
2
|
+
import { resolve, join, relative, extname } from 'path';
|
|
3
|
+
|
|
4
|
+
export interface GrepResult {
|
|
5
|
+
matches: Array<{
|
|
6
|
+
file: string;
|
|
7
|
+
line: number;
|
|
8
|
+
content: string;
|
|
9
|
+
}>;
|
|
10
|
+
truncated: boolean;
|
|
11
|
+
totalMatches: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface InvestigatorResult {
|
|
15
|
+
fileLinesMapping: Array<{
|
|
16
|
+
file: string;
|
|
17
|
+
lines: number[];
|
|
18
|
+
context: string;
|
|
19
|
+
}>;
|
|
20
|
+
dependencies: string[];
|
|
21
|
+
tokensUsed: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface FileMapping {
|
|
25
|
+
file: string;
|
|
26
|
+
lines: number[];
|
|
27
|
+
context: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export class InvestigatorSubagent {
|
|
31
|
+
private workingDir: string;
|
|
32
|
+
private tokenEstimate = 0;
|
|
33
|
+
|
|
34
|
+
constructor(workingDir: string) {
|
|
35
|
+
this.workingDir = workingDir;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async mapCodebase(query: string): Promise<InvestigatorResult> {
|
|
39
|
+
this.tokenEstimate = 0;
|
|
40
|
+
const fileMappings: FileMapping[] = [];
|
|
41
|
+
const dependencies = new Set<string>();
|
|
42
|
+
|
|
43
|
+
const tsFiles = this.findTypeScriptFiles(this.workingDir);
|
|
44
|
+
this.tokenEstimate += tsFiles.length * 50;
|
|
45
|
+
|
|
46
|
+
for (const file of tsFiles) {
|
|
47
|
+
try {
|
|
48
|
+
const content = readFileSync(file, 'utf-8');
|
|
49
|
+
const relPath = relative(this.workingDir, file);
|
|
50
|
+
const lines = content.split('\n');
|
|
51
|
+
|
|
52
|
+
const matchingLines = this.findMatchingLines(lines, query);
|
|
53
|
+
this.tokenEstimate += lines.length * 0.25;
|
|
54
|
+
|
|
55
|
+
if (matchingLines.length > 0) {
|
|
56
|
+
const context = this.extractContext(lines, matchingLines[0]);
|
|
57
|
+
fileMappings.push({
|
|
58
|
+
file: relPath,
|
|
59
|
+
lines: matchingLines,
|
|
60
|
+
context,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const fileDeps = this.extractDependencies(content);
|
|
64
|
+
fileDeps.forEach((dep) => dependencies.add(dep));
|
|
65
|
+
}
|
|
66
|
+
} catch {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
fileLinesMapping: fileMappings,
|
|
73
|
+
dependencies: Array.from(dependencies),
|
|
74
|
+
tokensUsed: Math.ceil(this.tokenEstimate),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async findDependencies(filePath: string): Promise<string[]> {
|
|
79
|
+
try {
|
|
80
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
81
|
+
this.tokenEstimate += content.split('\n').length * 0.25;
|
|
82
|
+
return this.extractDependencies(content);
|
|
83
|
+
} catch {
|
|
84
|
+
return [];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async grepWithBudget(
|
|
89
|
+
pattern: string,
|
|
90
|
+
maxLines: number = 120
|
|
91
|
+
): Promise<GrepResult> {
|
|
92
|
+
const matches: Array<{ file: string; line: number; content: string }> = [];
|
|
93
|
+
let totalMatches = 0;
|
|
94
|
+
const regex = new RegExp(pattern, 'gi');
|
|
95
|
+
|
|
96
|
+
const tsFiles = this.findTypeScriptFiles(this.workingDir);
|
|
97
|
+
|
|
98
|
+
for (const file of tsFiles) {
|
|
99
|
+
if (matches.length >= maxLines) {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
try {
|
|
104
|
+
const content = readFileSync(file, 'utf-8');
|
|
105
|
+
const relPath = relative(this.workingDir, file);
|
|
106
|
+
const lines = content.split('\n');
|
|
107
|
+
|
|
108
|
+
lines.forEach((line, index) => {
|
|
109
|
+
if (regex.test(line)) {
|
|
110
|
+
totalMatches += 1;
|
|
111
|
+
if (matches.length < maxLines) {
|
|
112
|
+
matches.push({
|
|
113
|
+
file: relPath,
|
|
114
|
+
line: index + 1,
|
|
115
|
+
content: line.trimStart(),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
this.tokenEstimate += lines.length * 0.1;
|
|
122
|
+
} catch {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
matches,
|
|
129
|
+
truncated: matches.length >= maxLines,
|
|
130
|
+
totalMatches,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private findTypeScriptFiles(dir: string): string[] {
|
|
135
|
+
const files: string[] = [];
|
|
136
|
+
const ignore = new Set(['node_modules', '.git', 'dist', '.vscode']);
|
|
137
|
+
|
|
138
|
+
const walk = (current: string) => {
|
|
139
|
+
try {
|
|
140
|
+
const entries = readdirSync(current, { withFileTypes: true });
|
|
141
|
+
|
|
142
|
+
for (const entry of entries) {
|
|
143
|
+
if (ignore.has(entry.name)) continue;
|
|
144
|
+
|
|
145
|
+
const path = join(current, entry.name);
|
|
146
|
+
|
|
147
|
+
if (entry.isDirectory()) {
|
|
148
|
+
walk(path);
|
|
149
|
+
} else if (
|
|
150
|
+
extname(entry.name) === '.ts' &&
|
|
151
|
+
!entry.name.endsWith('.test.ts')
|
|
152
|
+
) {
|
|
153
|
+
files.push(path);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
} catch {
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
walk(dir);
|
|
162
|
+
return files;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private findMatchingLines(lines: string[], query: string): number[] {
|
|
166
|
+
const matching: number[] = [];
|
|
167
|
+
const regex = new RegExp(query, 'i');
|
|
168
|
+
|
|
169
|
+
lines.forEach((line, index) => {
|
|
170
|
+
if (regex.test(line) && matching.length < 5) {
|
|
171
|
+
matching.push(index);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
return matching;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private extractContext(lines: string[], lineIndex: number): string {
|
|
179
|
+
const start = Math.max(0, lineIndex - 2);
|
|
180
|
+
const end = Math.min(lines.length, lineIndex + 3);
|
|
181
|
+
return lines.slice(start, end).join('\n');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private extractDependencies(content: string): string[] {
|
|
185
|
+
const deps = new Set<string>();
|
|
186
|
+
const importRegex =
|
|
187
|
+
/(?:import|from)\s+(?:'|")([^'"]+)(?:'|")/g;
|
|
188
|
+
|
|
189
|
+
let match;
|
|
190
|
+
while ((match = importRegex.exec(content)) !== null) {
|
|
191
|
+
const dep = match[1];
|
|
192
|
+
if (!dep.startsWith('.')) {
|
|
193
|
+
deps.add(dep.split('/')[0]);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return Array.from(deps);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
if (require.main === module) {
|
|
202
|
+
const workingDir = process.cwd();
|
|
203
|
+
const agent = new InvestigatorSubagent(workingDir);
|
|
204
|
+
|
|
205
|
+
process.on('message', async (message: unknown) => {
|
|
206
|
+
const msg = message as Record<string, unknown>;
|
|
207
|
+
|
|
208
|
+
if (msg.type === 'mapCodebase') {
|
|
209
|
+
try {
|
|
210
|
+
const result = await agent.mapCodebase(msg.query as string);
|
|
211
|
+
process.send?.({
|
|
212
|
+
type: 'result',
|
|
213
|
+
payload: result,
|
|
214
|
+
tokensUsed: result.tokensUsed,
|
|
215
|
+
});
|
|
216
|
+
} catch (error) {
|
|
217
|
+
process.send?.({
|
|
218
|
+
type: 'error',
|
|
219
|
+
payload: (error as Error).message,
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { fork, ChildProcess } from 'child_process';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
export interface SubagentMetrics {
|
|
5
|
+
investigatorCalls: number;
|
|
6
|
+
investigatorTokens: number;
|
|
7
|
+
builderCalls: number;
|
|
8
|
+
builderTokens: number;
|
|
9
|
+
reviewerCalls: number;
|
|
10
|
+
reviewerTokens: number;
|
|
11
|
+
totalTokens: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface InvestigatorResult {
|
|
15
|
+
fileLinesMapping: Array<{
|
|
16
|
+
file: string;
|
|
17
|
+
lines: number[];
|
|
18
|
+
context: string;
|
|
19
|
+
}>;
|
|
20
|
+
dependencies: string[];
|
|
21
|
+
tokensUsed: number;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface BuilderResult {
|
|
25
|
+
success: boolean;
|
|
26
|
+
filesEdited: string[];
|
|
27
|
+
testsPassed: boolean;
|
|
28
|
+
tokensUsed: number;
|
|
29
|
+
duration: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ReviewerResult {
|
|
33
|
+
findings: Array<{
|
|
34
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
35
|
+
file: string;
|
|
36
|
+
line: number;
|
|
37
|
+
issue: string;
|
|
38
|
+
}>;
|
|
39
|
+
tokensUsed: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface SubagentMessage {
|
|
43
|
+
type: 'result' | 'error' | 'progress';
|
|
44
|
+
payload: unknown;
|
|
45
|
+
tokensUsed?: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class SubagentOrchestrator {
|
|
49
|
+
private workingDir: string;
|
|
50
|
+
private metrics: SubagentMetrics = {
|
|
51
|
+
investigatorCalls: 0,
|
|
52
|
+
investigatorTokens: 0,
|
|
53
|
+
builderCalls: 0,
|
|
54
|
+
builderTokens: 0,
|
|
55
|
+
reviewerCalls: 0,
|
|
56
|
+
reviewerTokens: 0,
|
|
57
|
+
totalTokens: 0,
|
|
58
|
+
};
|
|
59
|
+
private workers: Map<string, ChildProcess> = new Map();
|
|
60
|
+
private workerCounter = 0;
|
|
61
|
+
|
|
62
|
+
constructor(workingDir: string) {
|
|
63
|
+
this.workingDir = workingDir;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
async spawnInvestigator(query: string): Promise<InvestigatorResult> {
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
const worker = this.forkWorker('investigator.js');
|
|
69
|
+
const workerId = `investigator_${this.workerCounter++}`;
|
|
70
|
+
|
|
71
|
+
const timeout = setTimeout(() => {
|
|
72
|
+
worker.kill();
|
|
73
|
+
this.workers.delete(workerId);
|
|
74
|
+
reject(new Error('Investigator timeout after 30s'));
|
|
75
|
+
}, 30000);
|
|
76
|
+
|
|
77
|
+
worker.on('message', (message: SubagentMessage) => {
|
|
78
|
+
if (message.type === 'result') {
|
|
79
|
+
clearTimeout(timeout);
|
|
80
|
+
const result = message.payload as InvestigatorResult;
|
|
81
|
+
this.metrics.investigatorCalls += 1;
|
|
82
|
+
this.metrics.investigatorTokens += result.tokensUsed;
|
|
83
|
+
this.metrics.totalTokens += result.tokensUsed;
|
|
84
|
+
worker.kill();
|
|
85
|
+
this.workers.delete(workerId);
|
|
86
|
+
resolve(result);
|
|
87
|
+
} else if (message.type === 'error') {
|
|
88
|
+
clearTimeout(timeout);
|
|
89
|
+
worker.kill();
|
|
90
|
+
this.workers.delete(workerId);
|
|
91
|
+
reject(new Error(`Investigator error: ${message.payload}`));
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
worker.on('error', (error) => {
|
|
96
|
+
clearTimeout(timeout);
|
|
97
|
+
this.workers.delete(workerId);
|
|
98
|
+
reject(error);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
worker.send({ type: 'mapCodebase', query, workingDir: this.workingDir });
|
|
102
|
+
this.workers.set(workerId, worker);
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async spawnBuilder(filePath: string, task: string): Promise<BuilderResult> {
|
|
107
|
+
return new Promise((resolve, reject) => {
|
|
108
|
+
const worker = this.forkWorker('builder.js');
|
|
109
|
+
const workerId = `builder_${this.workerCounter++}`;
|
|
110
|
+
const startTime = Date.now();
|
|
111
|
+
|
|
112
|
+
const timeout = setTimeout(() => {
|
|
113
|
+
worker.kill();
|
|
114
|
+
this.workers.delete(workerId);
|
|
115
|
+
reject(new Error('Builder timeout after 5m'));
|
|
116
|
+
}, 300000);
|
|
117
|
+
|
|
118
|
+
worker.on('message', (message: SubagentMessage) => {
|
|
119
|
+
if (message.type === 'result') {
|
|
120
|
+
clearTimeout(timeout);
|
|
121
|
+
const result = message.payload as BuilderResult;
|
|
122
|
+
this.metrics.builderCalls += 1;
|
|
123
|
+
this.metrics.builderTokens += result.tokensUsed;
|
|
124
|
+
this.metrics.totalTokens += result.tokensUsed;
|
|
125
|
+
worker.kill();
|
|
126
|
+
this.workers.delete(workerId);
|
|
127
|
+
resolve(result);
|
|
128
|
+
} else if (message.type === 'error') {
|
|
129
|
+
clearTimeout(timeout);
|
|
130
|
+
worker.kill();
|
|
131
|
+
this.workers.delete(workerId);
|
|
132
|
+
reject(new Error(`Builder error: ${message.payload}`));
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
worker.on('error', (error) => {
|
|
137
|
+
clearTimeout(timeout);
|
|
138
|
+
this.workers.delete(workerId);
|
|
139
|
+
reject(error);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
worker.send({
|
|
143
|
+
type: 'execute',
|
|
144
|
+
filePath,
|
|
145
|
+
task,
|
|
146
|
+
workingDir: this.workingDir,
|
|
147
|
+
});
|
|
148
|
+
this.workers.set(workerId, worker);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
async spawnReviewer(diffPath: string): Promise<ReviewerResult> {
|
|
153
|
+
return new Promise((resolve, reject) => {
|
|
154
|
+
const worker = this.forkWorker('reviewer.js');
|
|
155
|
+
const workerId = `reviewer_${this.workerCounter++}`;
|
|
156
|
+
|
|
157
|
+
const timeout = setTimeout(() => {
|
|
158
|
+
worker.kill();
|
|
159
|
+
this.workers.delete(workerId);
|
|
160
|
+
reject(new Error('Reviewer timeout after 2m'));
|
|
161
|
+
}, 120000);
|
|
162
|
+
|
|
163
|
+
worker.on('message', (message: SubagentMessage) => {
|
|
164
|
+
if (message.type === 'result') {
|
|
165
|
+
clearTimeout(timeout);
|
|
166
|
+
const result = message.payload as ReviewerResult;
|
|
167
|
+
this.metrics.reviewerCalls += 1;
|
|
168
|
+
this.metrics.reviewerTokens += result.tokensUsed;
|
|
169
|
+
this.metrics.totalTokens += result.tokensUsed;
|
|
170
|
+
worker.kill();
|
|
171
|
+
this.workers.delete(workerId);
|
|
172
|
+
resolve(result);
|
|
173
|
+
} else if (message.type === 'error') {
|
|
174
|
+
clearTimeout(timeout);
|
|
175
|
+
worker.kill();
|
|
176
|
+
this.workers.delete(workerId);
|
|
177
|
+
reject(new Error(`Reviewer error: ${message.payload}`));
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
worker.on('error', (error) => {
|
|
182
|
+
clearTimeout(timeout);
|
|
183
|
+
this.workers.delete(workerId);
|
|
184
|
+
reject(error);
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
worker.send({ type: 'review', diffPath, workingDir: this.workingDir });
|
|
188
|
+
this.workers.set(workerId, worker);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
getMetrics(): SubagentMetrics {
|
|
193
|
+
return { ...this.metrics };
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private forkWorker(scriptName: string): ChildProcess {
|
|
197
|
+
const scriptPath = resolve(this.workingDir, 'dist', 'subagents', scriptName);
|
|
198
|
+
return fork(scriptPath, [], {
|
|
199
|
+
silent: false,
|
|
200
|
+
cwd: this.workingDir,
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
cleanup(): void {
|
|
205
|
+
this.workers.forEach((worker) => {
|
|
206
|
+
if (!worker.killed) {
|
|
207
|
+
worker.kill();
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
this.workers.clear();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
|
|
4
|
+
export interface OWASPFinding {
|
|
5
|
+
vulnerability: string;
|
|
6
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
7
|
+
file: string;
|
|
8
|
+
line: number;
|
|
9
|
+
evidence: string;
|
|
10
|
+
remediation: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface SecretFinding {
|
|
14
|
+
type: string;
|
|
15
|
+
severity: 'critical' | 'high';
|
|
16
|
+
line: number;
|
|
17
|
+
pattern: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type Finding = OWASPFinding | SecretFinding;
|
|
21
|
+
|
|
22
|
+
export interface ReviewerResult {
|
|
23
|
+
findings: Finding[];
|
|
24
|
+
tokensUsed: number;
|
|
25
|
+
fileScanned: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface PatternRule {
|
|
29
|
+
pattern: RegExp;
|
|
30
|
+
type: string;
|
|
31
|
+
severity: 'critical' | 'high' | 'medium' | 'low';
|
|
32
|
+
remediation: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export class ReviewerSubagent {
|
|
36
|
+
private workingDir: string;
|
|
37
|
+
private readonly TOKEN_ESTIMATE_PER_CHAR = 0.25;
|
|
38
|
+
|
|
39
|
+
private readonly OWASP_PATTERNS: Record<string, PatternRule> = {
|
|
40
|
+
SQL_INJECTION: {
|
|
41
|
+
pattern: /SELECT\s+.*\s+WHERE\s+(?!.*\$\d+|.*\?|.*%s)/i,
|
|
42
|
+
type: 'SQL Injection',
|
|
43
|
+
severity: 'critical',
|
|
44
|
+
remediation:
|
|
45
|
+
'Use parameterized queries with placeholders (?) or prepared statements',
|
|
46
|
+
},
|
|
47
|
+
SQL_INJECTION_CONCAT: {
|
|
48
|
+
pattern: /SELECT\s+.*WHERE\s+.*\+\s*(?:string|input|param)/i,
|
|
49
|
+
type: 'SQL Injection',
|
|
50
|
+
severity: 'critical',
|
|
51
|
+
remediation:
|
|
52
|
+
'Replace string concatenation with parameterized queries',
|
|
53
|
+
},
|
|
54
|
+
XSS_INNERHTML: {
|
|
55
|
+
pattern: /\.innerHTML\s*=\s*(?!DOMPurify|sanitize|escape)/i,
|
|
56
|
+
type: 'XSS',
|
|
57
|
+
severity: 'critical',
|
|
58
|
+
remediation:
|
|
59
|
+
'Use textContent or sanitize input with DOMPurify before setting innerHTML',
|
|
60
|
+
},
|
|
61
|
+
XSS_EVAL: {
|
|
62
|
+
pattern: /\beval\s*\(/i,
|
|
63
|
+
type: 'XSS',
|
|
64
|
+
severity: 'critical',
|
|
65
|
+
remediation: 'Never use eval(); use JSON.parse() for JSON or Function() with caution',
|
|
66
|
+
},
|
|
67
|
+
COMMAND_INJECTION: {
|
|
68
|
+
pattern: /exec(?:Sync)?\s*\(\s*["`].*\$|exec(?:Sync)?\s*\(\s*template.*\$|exec(?:Sync)?\s*\(\s*\+/i,
|
|
69
|
+
type: 'Command Injection',
|
|
70
|
+
severity: 'critical',
|
|
71
|
+
remediation:
|
|
72
|
+
'Use array-based arguments (execFile) or validate and whitelist inputs strictly',
|
|
73
|
+
},
|
|
74
|
+
HARDCODED_SECRET_API_KEY: {
|
|
75
|
+
pattern: /API_KEY\s*=\s*["`][^"`]{20,}["`]/i,
|
|
76
|
+
type: 'API_KEY',
|
|
77
|
+
severity: 'critical',
|
|
78
|
+
remediation:
|
|
79
|
+
'Store API keys in environment variables (.env file, not committed)',
|
|
80
|
+
},
|
|
81
|
+
HARDCODED_SECRET_PASSWORD: {
|
|
82
|
+
pattern: /password\s*[:=]\s*["`][^"`]{6,}["`]/i,
|
|
83
|
+
type: 'PASSWORD',
|
|
84
|
+
severity: 'critical',
|
|
85
|
+
remediation:
|
|
86
|
+
'Store passwords in environment variables or secure vault, never hardcode',
|
|
87
|
+
},
|
|
88
|
+
HARDCODED_SECRET_TOKEN: {
|
|
89
|
+
pattern: /token\s*[:=]\s*["`][a-zA-Z0-9_-]{20,}["`]/i,
|
|
90
|
+
type: 'TOKEN',
|
|
91
|
+
severity: 'critical',
|
|
92
|
+
remediation:
|
|
93
|
+
'Store tokens in environment variables or secure credential store',
|
|
94
|
+
},
|
|
95
|
+
HARDCODED_SECRET_BEARER: {
|
|
96
|
+
pattern: /Bearer\s+[a-zA-Z0-9_-]{20,}/i,
|
|
97
|
+
type: 'TOKEN',
|
|
98
|
+
severity: 'high',
|
|
99
|
+
remediation: 'Move bearer tokens to environment variables',
|
|
100
|
+
},
|
|
101
|
+
PATH_TRAVERSAL: {
|
|
102
|
+
pattern: /\.\.\s*\/|readFile(?:Sync)?\s*\(\s*path\s*\+|join\s*\(\s*__dirname\s*,\s*\.\./i,
|
|
103
|
+
type: 'Path Traversal',
|
|
104
|
+
severity: 'high',
|
|
105
|
+
remediation:
|
|
106
|
+
'Validate and normalize file paths; use path.resolve() and check boundaries',
|
|
107
|
+
},
|
|
108
|
+
INSECURE_CRYPTO: {
|
|
109
|
+
pattern: /md5|sha1|Math\.random\(\)/i,
|
|
110
|
+
type: 'Insecure Crypto',
|
|
111
|
+
severity: 'high',
|
|
112
|
+
remediation:
|
|
113
|
+
'Use SHA-256 or bcrypt for hashing; use crypto.randomBytes() for randomness',
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
constructor(workingDir: string) {
|
|
118
|
+
this.workingDir = workingDir;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async auditCode(filePath: string): Promise<ReviewerResult> {
|
|
122
|
+
const fullPath = resolve(this.workingDir, filePath);
|
|
123
|
+
const code = readFileSync(fullPath, 'utf-8');
|
|
124
|
+
const findings: Finding[] = [];
|
|
125
|
+
|
|
126
|
+
const owaspFindings = this.scanOWASP(code);
|
|
127
|
+
const secretFindings = this.detectSecrets(code);
|
|
128
|
+
|
|
129
|
+
findings.push(...owaspFindings);
|
|
130
|
+
findings.push(...secretFindings);
|
|
131
|
+
|
|
132
|
+
const tokensUsed = Math.ceil(code.length * this.TOKEN_ESTIMATE_PER_CHAR);
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
findings: this.deduplicateFindings(findings),
|
|
136
|
+
tokensUsed,
|
|
137
|
+
fileScanned: filePath,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
scanOWASP(code: string): OWASPFinding[] {
|
|
142
|
+
const findings: OWASPFinding[] = [];
|
|
143
|
+
const lines = code.split('\n');
|
|
144
|
+
|
|
145
|
+
Object.values(this.OWASP_PATTERNS).forEach((rule) => {
|
|
146
|
+
lines.forEach((line, index) => {
|
|
147
|
+
if (rule.pattern.test(line)) {
|
|
148
|
+
findings.push({
|
|
149
|
+
vulnerability: rule.type,
|
|
150
|
+
severity: rule.severity,
|
|
151
|
+
file: 'unknown',
|
|
152
|
+
line: index + 1,
|
|
153
|
+
evidence: line.trim().substring(0, 100),
|
|
154
|
+
remediation: rule.remediation,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
return findings;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
detectSecrets(code: string): SecretFinding[] {
|
|
164
|
+
const findings: SecretFinding[] = [];
|
|
165
|
+
const lines = code.split('\n');
|
|
166
|
+
|
|
167
|
+
const secretPatterns = [
|
|
168
|
+
{ pattern: /API_KEY\s*[:=]/i, type: 'API_KEY' },
|
|
169
|
+
{ pattern: /password\s*[:=]/i, type: 'PASSWORD' },
|
|
170
|
+
{ pattern: /token\s*[:=]/i, type: 'TOKEN' },
|
|
171
|
+
{ pattern: /BEGIN\s+RSA\s+PRIVATE\s+KEY/i, type: 'PRIVATE_KEY' },
|
|
172
|
+
{ pattern: /BEGIN\s+PGP\s+PRIVATE\s+KEY/i, type: 'PGP_KEY' },
|
|
173
|
+
{ pattern: /aws_access_key_id/i, type: 'AWS_KEY' },
|
|
174
|
+
{ pattern: /aws_secret_access_key/i, type: 'AWS_SECRET' },
|
|
175
|
+
{ pattern: /GITHUB_TOKEN|GH_TOKEN|gh_pat_/i, type: 'GITHUB_TOKEN' },
|
|
176
|
+
{ pattern: /mongodb\+srv|mongodb:\/\/.*:.*@/i, type: 'MONGODB_URI' },
|
|
177
|
+
{ pattern: /postgres:\/\/.*:.*@|postgresql:\/\/.*:.*@/i, type: 'DB_PASSWORD' },
|
|
178
|
+
];
|
|
179
|
+
|
|
180
|
+
lines.forEach((line, index) => {
|
|
181
|
+
secretPatterns.forEach(({ pattern, type }) => {
|
|
182
|
+
if (pattern.test(line)) {
|
|
183
|
+
findings.push({
|
|
184
|
+
type,
|
|
185
|
+
severity: 'critical',
|
|
186
|
+
line: index + 1,
|
|
187
|
+
pattern: pattern.source,
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
return findings;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private deduplicateFindings(findings: Finding[]): Finding[] {
|
|
197
|
+
const seen = new Set<string>();
|
|
198
|
+
const unique: Finding[] = [];
|
|
199
|
+
|
|
200
|
+
findings.forEach((finding) => {
|
|
201
|
+
const key = `${finding.line}:${
|
|
202
|
+
'vulnerability' in finding
|
|
203
|
+
? finding.vulnerability
|
|
204
|
+
: finding.type
|
|
205
|
+
}`;
|
|
206
|
+
|
|
207
|
+
if (!seen.has(key)) {
|
|
208
|
+
seen.add(key);
|
|
209
|
+
unique.push(finding);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
return unique.sort((a, b) => a.line - b.line);
|
|
214
|
+
}
|
|
215
|
+
}
|