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,536 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Phase 8 Security & Audit Hardening
|
|
3
|
+
* CRM data redaction, financial validation, access control, audit trail integrity
|
|
4
|
+
* Phase 8D Task 13
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
8
|
+
import { EnrichedLead } from '../intelligence/leadEnrichmentTypes.js';
|
|
9
|
+
import { RevenueProjection } from '../metrics/revenueTypes.js';
|
|
10
|
+
import { CRMOpportunity } from '../automation/crmExport.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Redaction result tracking
|
|
14
|
+
*/
|
|
15
|
+
export interface RedactionResult {
|
|
16
|
+
original: string;
|
|
17
|
+
redacted: string;
|
|
18
|
+
patternType: string;
|
|
19
|
+
count: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Revenue projection validation result
|
|
24
|
+
*/
|
|
25
|
+
export interface ProjectionValidation {
|
|
26
|
+
valid: boolean;
|
|
27
|
+
errors: string[];
|
|
28
|
+
warnings: string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Audit log entry
|
|
33
|
+
*/
|
|
34
|
+
export interface AuditEntry {
|
|
35
|
+
id: string;
|
|
36
|
+
timestamp: string;
|
|
37
|
+
eventType: string;
|
|
38
|
+
userId?: string;
|
|
39
|
+
entityId: string;
|
|
40
|
+
entityType: string;
|
|
41
|
+
action: string;
|
|
42
|
+
changes?: Record<string, any>;
|
|
43
|
+
context?: Record<string, any>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Role-based access control
|
|
48
|
+
*/
|
|
49
|
+
export type UserRole = 'ADMIN' | 'SALES' | 'OBSERVER';
|
|
50
|
+
|
|
51
|
+
export interface AccessRequest {
|
|
52
|
+
userId: string;
|
|
53
|
+
role: UserRole;
|
|
54
|
+
endpoint: string;
|
|
55
|
+
method: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface AccessDecision {
|
|
59
|
+
allowed: boolean;
|
|
60
|
+
reason?: string;
|
|
61
|
+
requiredRole?: UserRole;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Token rotation status
|
|
66
|
+
*/
|
|
67
|
+
export interface TokenStatus {
|
|
68
|
+
tokenId: string;
|
|
69
|
+
createdAt: string;
|
|
70
|
+
lastRotatedAt: string;
|
|
71
|
+
expiresAt: string;
|
|
72
|
+
daysUntilExpiry: number;
|
|
73
|
+
needsRotation: boolean;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Phase 8 Security Hardener
|
|
78
|
+
*/
|
|
79
|
+
export class Phase8SecurityHardener {
|
|
80
|
+
private auditLog: AuditEntry[] = [];
|
|
81
|
+
private auditLogLocked: boolean = false; // Append-only enforcement
|
|
82
|
+
private redactionPatterns = {
|
|
83
|
+
email: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,
|
|
84
|
+
phone: /\d{3}-\d{3}-\d{4}/g,
|
|
85
|
+
creditCard: /\d{4}-\d{4}-\d{4}-\d{4}/g,
|
|
86
|
+
ssn: /\d{3}-\d{2}-\d{4}/g,
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
private rolePermissions: Record<UserRole, Set<string>> = {
|
|
90
|
+
ADMIN: new Set([
|
|
91
|
+
'/api/leads',
|
|
92
|
+
'/api/leads/:id',
|
|
93
|
+
'/api/revenue',
|
|
94
|
+
'/api/alerts',
|
|
95
|
+
'/api/admin',
|
|
96
|
+
'/api/export',
|
|
97
|
+
'/api/audit',
|
|
98
|
+
'/api/dashboard',
|
|
99
|
+
]),
|
|
100
|
+
SALES: new Set([
|
|
101
|
+
'/api/leads',
|
|
102
|
+
'/api/leads/:id',
|
|
103
|
+
'/api/revenue',
|
|
104
|
+
'/api/dashboard',
|
|
105
|
+
]),
|
|
106
|
+
OBSERVER: new Set([
|
|
107
|
+
'/api/dashboard',
|
|
108
|
+
]),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Redact PII from CRM export data
|
|
113
|
+
*/
|
|
114
|
+
redactCRMExport(exportData: any): any {
|
|
115
|
+
const redacted = JSON.parse(JSON.stringify(exportData));
|
|
116
|
+
const redactions: RedactionResult[] = [];
|
|
117
|
+
|
|
118
|
+
const redactValue = (value: string, pattern: RegExp, type: string): [string, number] => {
|
|
119
|
+
let count = 0;
|
|
120
|
+
const replacement = value.replace(pattern, () => {
|
|
121
|
+
count++;
|
|
122
|
+
return `[${type.toUpperCase()}_REDACTED]`;
|
|
123
|
+
});
|
|
124
|
+
return [replacement, count];
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Recursively redact all string fields
|
|
128
|
+
const walk = (obj: any, path: string[] = []) => {
|
|
129
|
+
if (obj === null || obj === undefined) return;
|
|
130
|
+
|
|
131
|
+
if (typeof obj === 'string') {
|
|
132
|
+
let current = obj;
|
|
133
|
+
let totalCount = 0;
|
|
134
|
+
|
|
135
|
+
// Apply all redaction patterns
|
|
136
|
+
for (const [type, pattern] of Object.entries(this.redactionPatterns)) {
|
|
137
|
+
const [redacted, count] = redactValue(current, pattern, type);
|
|
138
|
+
if (count > 0) {
|
|
139
|
+
redactions.push({
|
|
140
|
+
original: obj,
|
|
141
|
+
redacted,
|
|
142
|
+
patternType: type,
|
|
143
|
+
count,
|
|
144
|
+
});
|
|
145
|
+
current = redacted;
|
|
146
|
+
totalCount += count;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return current;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (Array.isArray(obj)) {
|
|
154
|
+
obj.forEach((item, idx) => {
|
|
155
|
+
obj[idx] = walk(item, [...path, `[${idx}]`]);
|
|
156
|
+
});
|
|
157
|
+
} else if (typeof obj === 'object') {
|
|
158
|
+
Object.entries(obj).forEach(([key, value]) => {
|
|
159
|
+
obj[key] = walk(value, [...path, key]);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return obj;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
walk(redacted);
|
|
167
|
+
return redacted;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Validate revenue projection against business rules
|
|
172
|
+
*/
|
|
173
|
+
validateRevenueProjection(projection: RevenueProjection, acv?: number): ProjectionValidation {
|
|
174
|
+
const errors: string[] = [];
|
|
175
|
+
const warnings: string[] = [];
|
|
176
|
+
|
|
177
|
+
const usedAcv = acv ?? 50000; // Default ACV
|
|
178
|
+
|
|
179
|
+
// Validate projected revenue is positive
|
|
180
|
+
if (projection.projectedRevenue < 0) {
|
|
181
|
+
errors.push('Projected revenue cannot be negative');
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Prevent unrealistic inflation (>200% of ACV)
|
|
185
|
+
const maxRevenue = usedAcv * 2;
|
|
186
|
+
if (projection.projectedRevenue > maxRevenue) {
|
|
187
|
+
errors.push(
|
|
188
|
+
`Projected revenue $${projection.projectedRevenue} exceeds 2x ACV limit ($${maxRevenue})`
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Validate confidence score
|
|
193
|
+
if (projection.confidence < 0 || projection.confidence > 100) {
|
|
194
|
+
errors.push('Confidence must be between 0-100');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Validate conversion rate if present
|
|
198
|
+
if (projection.factors?.conversionRate !== undefined) {
|
|
199
|
+
if (projection.factors.conversionRate < 0 || projection.factors.conversionRate > 1) {
|
|
200
|
+
errors.push('Conversion rate must be between 0-1 (0-100%)');
|
|
201
|
+
}
|
|
202
|
+
if (projection.factors.conversionRate < 0.05) {
|
|
203
|
+
warnings.push('Conversion rate is unusually low (<5%)');
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Validate signal count if present
|
|
208
|
+
if (projection.factors?.signalBoost !== undefined) {
|
|
209
|
+
// signalBoost is typically 1.0 to 1.2, so implied signal count is 0-10
|
|
210
|
+
const impliedSignalCount = (projection.factors.signalBoost - 1.0) * 50; // Rough estimate
|
|
211
|
+
if (impliedSignalCount < 0 || impliedSignalCount > 10) {
|
|
212
|
+
warnings.push('Signal count appears out of typical range (0-10)');
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
valid: errors.length === 0,
|
|
218
|
+
errors,
|
|
219
|
+
warnings,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Enforce role-based access control
|
|
225
|
+
* Usage: enforceAccessControl(req, 'SALES')
|
|
226
|
+
*/
|
|
227
|
+
enforceAccessControl(
|
|
228
|
+
request: AccessRequest
|
|
229
|
+
): AccessDecision {
|
|
230
|
+
const role = request.role;
|
|
231
|
+
const endpoint = request.endpoint;
|
|
232
|
+
|
|
233
|
+
// Find matching endpoint permission
|
|
234
|
+
const permissions = this.rolePermissions[role];
|
|
235
|
+
if (!permissions) {
|
|
236
|
+
return {
|
|
237
|
+
allowed: false,
|
|
238
|
+
reason: `Unknown role: ${role}`,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// Check exact match
|
|
243
|
+
if (permissions.has(endpoint)) {
|
|
244
|
+
return { allowed: true };
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// Check wildcard match (e.g., /api/leads/:id)
|
|
248
|
+
for (const perm of permissions) {
|
|
249
|
+
const pattern = perm.replace(/:[\w]+/g, '[^/]+');
|
|
250
|
+
const regex = new RegExp(`^${pattern}$`);
|
|
251
|
+
if (regex.test(endpoint)) {
|
|
252
|
+
return { allowed: true };
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
allowed: false,
|
|
258
|
+
reason: `Role ${role} does not have access to ${endpoint}`,
|
|
259
|
+
requiredRole: 'ADMIN',
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Validate and log lead mutations
|
|
265
|
+
*/
|
|
266
|
+
validateLeadMutation(
|
|
267
|
+
lead: EnrichedLead,
|
|
268
|
+
operation: 'CREATE' | 'UPDATE' | 'DELETE' | 'EXPORT',
|
|
269
|
+
userId?: string
|
|
270
|
+
): [boolean, string[]] {
|
|
271
|
+
const errors: string[] = [];
|
|
272
|
+
|
|
273
|
+
// Validate lead structure
|
|
274
|
+
if (!lead.id) {
|
|
275
|
+
errors.push('Lead ID is required');
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
if (!lead.name && !lead.company) {
|
|
279
|
+
errors.push('Lead must have name or company');
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (lead.score < 0 || lead.score > 100) {
|
|
283
|
+
errors.push('Lead quality score must be 0-100');
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (lead.signalCount < 0 || lead.signalCount > 10) {
|
|
287
|
+
errors.push('Signal count must be 0-10');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Log the mutation
|
|
291
|
+
const entry: AuditEntry = {
|
|
292
|
+
id: uuidv4(),
|
|
293
|
+
timestamp: new Date().toISOString(),
|
|
294
|
+
eventType: `lead:${operation.toLowerCase()}`,
|
|
295
|
+
userId,
|
|
296
|
+
entityId: lead.id,
|
|
297
|
+
entityType: 'lead',
|
|
298
|
+
action: operation,
|
|
299
|
+
context: {
|
|
300
|
+
leadName: lead.name,
|
|
301
|
+
leadCompany: lead.company,
|
|
302
|
+
quality: lead.score,
|
|
303
|
+
signals: lead.signalCount,
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
this.logAuditEntry(entry);
|
|
308
|
+
|
|
309
|
+
return [errors.length === 0, errors];
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Append-only audit log entry
|
|
314
|
+
* Prevents deletion or modification of audit records
|
|
315
|
+
*/
|
|
316
|
+
private logAuditEntry(entry: AuditEntry): void {
|
|
317
|
+
this.auditLog.push(entry);
|
|
318
|
+
// In production: persist to immutable storage (append-only database)
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Retrieve audit trail with filtering
|
|
323
|
+
* Immutable read-only access
|
|
324
|
+
*/
|
|
325
|
+
getAuditTrail(filters?: {
|
|
326
|
+
entityId?: string;
|
|
327
|
+
eventType?: string;
|
|
328
|
+
userId?: string;
|
|
329
|
+
startDate?: string;
|
|
330
|
+
endDate?: string;
|
|
331
|
+
}): AuditEntry[] {
|
|
332
|
+
let results = [...this.auditLog]; // Copy for immutability
|
|
333
|
+
|
|
334
|
+
if (filters) {
|
|
335
|
+
if (filters.entityId) {
|
|
336
|
+
results = results.filter((e) => e.entityId === filters.entityId);
|
|
337
|
+
}
|
|
338
|
+
if (filters.eventType) {
|
|
339
|
+
results = results.filter((e) => e.eventType === filters.eventType);
|
|
340
|
+
}
|
|
341
|
+
if (filters.userId) {
|
|
342
|
+
results = results.filter((e) => e.userId === filters.userId);
|
|
343
|
+
}
|
|
344
|
+
if (filters.startDate) {
|
|
345
|
+
const startTime = new Date(filters.startDate).getTime();
|
|
346
|
+
results = results.filter((e) => new Date(e.timestamp).getTime() >= startTime);
|
|
347
|
+
}
|
|
348
|
+
if (filters.endDate) {
|
|
349
|
+
const endTime = new Date(filters.endDate).getTime();
|
|
350
|
+
results = results.filter((e) => new Date(e.timestamp).getTime() <= endTime);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
return results;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Check for stale tokens requiring rotation
|
|
359
|
+
*/
|
|
360
|
+
checkTokenRotation(tokens: Map<string, TokenStatus>): TokenStatus[] {
|
|
361
|
+
const needsRotation: TokenStatus[] = [];
|
|
362
|
+
const now = new Date();
|
|
363
|
+
|
|
364
|
+
tokens.forEach((status) => {
|
|
365
|
+
const expiryDate = new Date(status.expiresAt);
|
|
366
|
+
const daysUntilExpiry = (expiryDate.getTime() - now.getTime()) / (1000 * 60 * 60 * 24);
|
|
367
|
+
|
|
368
|
+
status.daysUntilExpiry = daysUntilExpiry;
|
|
369
|
+
status.needsRotation = daysUntilExpiry < 7; // Rotate if <7 days remaining
|
|
370
|
+
|
|
371
|
+
if (status.needsRotation) {
|
|
372
|
+
needsRotation.push(status);
|
|
373
|
+
|
|
374
|
+
// Log token rotation alert
|
|
375
|
+
this.logAuditEntry({
|
|
376
|
+
id: uuidv4(),
|
|
377
|
+
timestamp: new Date().toISOString(),
|
|
378
|
+
eventType: 'security:token-rotation-needed',
|
|
379
|
+
entityId: status.tokenId,
|
|
380
|
+
entityType: 'token',
|
|
381
|
+
action: 'ALERT',
|
|
382
|
+
context: {
|
|
383
|
+
daysUntilExpiry: Math.round(daysUntilExpiry),
|
|
384
|
+
expiresAt: status.expiresAt,
|
|
385
|
+
},
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
return needsRotation;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Validate CRM export for sensitive data leakage
|
|
395
|
+
*/
|
|
396
|
+
validateCRMExportSecurity(opportunity: CRMOpportunity): [boolean, string[]] {
|
|
397
|
+
const issues: string[] = [];
|
|
398
|
+
const jsonString = JSON.stringify(opportunity);
|
|
399
|
+
|
|
400
|
+
// Check for common sensitive patterns
|
|
401
|
+
if (this.redactionPatterns.email.test(jsonString)) {
|
|
402
|
+
issues.push('CRM export contains unredacted email addresses');
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (this.redactionPatterns.phone.test(jsonString)) {
|
|
406
|
+
issues.push('CRM export contains unredacted phone numbers');
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (this.redactionPatterns.creditCard.test(jsonString)) {
|
|
410
|
+
issues.push('CRM export contains unredacted credit card numbers');
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if (this.redactionPatterns.ssn.test(jsonString)) {
|
|
414
|
+
issues.push('CRM export contains unredacted SSNs');
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
return [issues.length === 0, issues];
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Get audit statistics
|
|
422
|
+
*/
|
|
423
|
+
getAuditStats(): {
|
|
424
|
+
totalEntries: number;
|
|
425
|
+
byEventType: Record<string, number>;
|
|
426
|
+
timeRange: { oldest: string; newest: string };
|
|
427
|
+
} {
|
|
428
|
+
const byEventType: Record<string, number> = {};
|
|
429
|
+
let oldest = '';
|
|
430
|
+
let newest = '';
|
|
431
|
+
|
|
432
|
+
this.auditLog.forEach((entry) => {
|
|
433
|
+
byEventType[entry.eventType] = (byEventType[entry.eventType] || 0) + 1;
|
|
434
|
+
|
|
435
|
+
if (!oldest || entry.timestamp < oldest) oldest = entry.timestamp;
|
|
436
|
+
if (!newest || entry.timestamp > newest) newest = entry.timestamp;
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
return {
|
|
440
|
+
totalEntries: this.auditLog.length,
|
|
441
|
+
byEventType,
|
|
442
|
+
timeRange: { oldest, newest },
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* Clear audit log (admin only - should require approval)
|
|
448
|
+
* Returns false if log is locked
|
|
449
|
+
*/
|
|
450
|
+
clearAuditLog(): boolean {
|
|
451
|
+
if (this.auditLogLocked) {
|
|
452
|
+
return false; // Cannot clear locked log
|
|
453
|
+
}
|
|
454
|
+
// In production: prevent clearing without cryptographic approval
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Lock audit log to prevent modifications (admin function)
|
|
460
|
+
*/
|
|
461
|
+
lockAuditLog(): void {
|
|
462
|
+
this.auditLogLocked = true;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* SQL injection prevention check
|
|
467
|
+
*/
|
|
468
|
+
sanitizeSQLInput(input: string): [string, boolean] {
|
|
469
|
+
const sqlInjectionPatterns = [
|
|
470
|
+
/(\bOR\b|\bAND\b)\s+1\s*=\s*1/gi,
|
|
471
|
+
/;\s*(DROP|DELETE|UPDATE|INSERT)/gi,
|
|
472
|
+
/--\s*$/m,
|
|
473
|
+
/\/\*.*?\*\//gs,
|
|
474
|
+
];
|
|
475
|
+
|
|
476
|
+
let hasSuspiciousPatterns = false;
|
|
477
|
+
|
|
478
|
+
for (const pattern of sqlInjectionPatterns) {
|
|
479
|
+
if (pattern.test(input)) {
|
|
480
|
+
hasSuspiciousPatterns = true;
|
|
481
|
+
break;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
// Sanitize by escaping special characters
|
|
486
|
+
const sanitized = input
|
|
487
|
+
.replace(/'/g, "''")
|
|
488
|
+
.replace(/"/g, '""')
|
|
489
|
+
.replace(/\\/g, '\\\\');
|
|
490
|
+
|
|
491
|
+
return [sanitized, hasSuspiciousPatterns];
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* HTML escaping for XSS prevention
|
|
496
|
+
*/
|
|
497
|
+
escapeHTMLContent(html: string): string {
|
|
498
|
+
const map: Record<string, string> = {
|
|
499
|
+
'&': '&',
|
|
500
|
+
'<': '<',
|
|
501
|
+
'>': '>',
|
|
502
|
+
'"': '"',
|
|
503
|
+
"'": ''',
|
|
504
|
+
};
|
|
505
|
+
return html.replace(/[&<>"']/g, (char) => map[char]);
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Validate Composio token before use
|
|
510
|
+
*/
|
|
511
|
+
validateComposioToken(token: string): [boolean, string] {
|
|
512
|
+
if (!token || token.length === 0) {
|
|
513
|
+
return [false, 'Token is empty'];
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
if (token.length < 20) {
|
|
517
|
+
return [false, 'Token appears invalid (too short)'];
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
// Check if token contains suspicious patterns
|
|
521
|
+
if (/[^a-zA-Z0-9._-]/.test(token)) {
|
|
522
|
+
return [false, 'Token contains invalid characters'];
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
return [true, 'Token is valid'];
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
/**
|
|
530
|
+
* Factory function
|
|
531
|
+
*/
|
|
532
|
+
export function createPhase8SecurityHardener(): Phase8SecurityHardener {
|
|
533
|
+
return new Phase8SecurityHardener();
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export default Phase8SecurityHardener;
|