empathy-framework 5.2.1__py3-none-any.whl → 5.4.0__py3-none-any.whl

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.
Files changed (480) hide show
  1. empathy_framework-5.4.0.dist-info/METADATA +47 -0
  2. empathy_framework-5.4.0.dist-info/RECORD +8 -0
  3. {empathy_framework-5.2.1.dist-info → empathy_framework-5.4.0.dist-info}/top_level.txt +0 -1
  4. empathy_healthcare_plugin/__init__.py +12 -11
  5. empathy_llm_toolkit/__init__.py +12 -26
  6. empathy_os/__init__.py +12 -356
  7. empathy_software_plugin/__init__.py +12 -11
  8. empathy_framework-5.2.1.dist-info/METADATA +0 -1002
  9. empathy_framework-5.2.1.dist-info/RECORD +0 -478
  10. empathy_framework-5.2.1.dist-info/entry_points.txt +0 -26
  11. empathy_framework-5.2.1.dist-info/licenses/LICENSE +0 -201
  12. empathy_framework-5.2.1.dist-info/licenses/LICENSE_CHANGE_ANNOUNCEMENT.md +0 -101
  13. empathy_healthcare_plugin/monitors/__init__.py +0 -9
  14. empathy_healthcare_plugin/monitors/clinical_protocol_monitor.py +0 -315
  15. empathy_healthcare_plugin/monitors/monitoring/__init__.py +0 -44
  16. empathy_healthcare_plugin/monitors/monitoring/protocol_checker.py +0 -300
  17. empathy_healthcare_plugin/monitors/monitoring/protocol_loader.py +0 -214
  18. empathy_healthcare_plugin/monitors/monitoring/sensor_parsers.py +0 -306
  19. empathy_healthcare_plugin/monitors/monitoring/trajectory_analyzer.py +0 -389
  20. empathy_healthcare_plugin/protocols/cardiac.json +0 -93
  21. empathy_healthcare_plugin/protocols/post_operative.json +0 -92
  22. empathy_healthcare_plugin/protocols/respiratory.json +0 -92
  23. empathy_healthcare_plugin/protocols/sepsis.json +0 -141
  24. empathy_llm_toolkit/README.md +0 -553
  25. empathy_llm_toolkit/agent_factory/__init__.py +0 -53
  26. empathy_llm_toolkit/agent_factory/adapters/__init__.py +0 -85
  27. empathy_llm_toolkit/agent_factory/adapters/autogen_adapter.py +0 -312
  28. empathy_llm_toolkit/agent_factory/adapters/crewai_adapter.py +0 -483
  29. empathy_llm_toolkit/agent_factory/adapters/haystack_adapter.py +0 -298
  30. empathy_llm_toolkit/agent_factory/adapters/langchain_adapter.py +0 -362
  31. empathy_llm_toolkit/agent_factory/adapters/langgraph_adapter.py +0 -333
  32. empathy_llm_toolkit/agent_factory/adapters/native.py +0 -228
  33. empathy_llm_toolkit/agent_factory/adapters/wizard_adapter.py +0 -423
  34. empathy_llm_toolkit/agent_factory/base.py +0 -305
  35. empathy_llm_toolkit/agent_factory/crews/__init__.py +0 -67
  36. empathy_llm_toolkit/agent_factory/crews/code_review.py +0 -1113
  37. empathy_llm_toolkit/agent_factory/crews/health_check.py +0 -1262
  38. empathy_llm_toolkit/agent_factory/crews/refactoring.py +0 -1128
  39. empathy_llm_toolkit/agent_factory/crews/security_audit.py +0 -1018
  40. empathy_llm_toolkit/agent_factory/decorators.py +0 -287
  41. empathy_llm_toolkit/agent_factory/factory.py +0 -558
  42. empathy_llm_toolkit/agent_factory/framework.py +0 -193
  43. empathy_llm_toolkit/agent_factory/memory_integration.py +0 -328
  44. empathy_llm_toolkit/agent_factory/resilient.py +0 -320
  45. empathy_llm_toolkit/agents_md/__init__.py +0 -22
  46. empathy_llm_toolkit/agents_md/loader.py +0 -218
  47. empathy_llm_toolkit/agents_md/parser.py +0 -271
  48. empathy_llm_toolkit/agents_md/registry.py +0 -307
  49. empathy_llm_toolkit/claude_memory.py +0 -466
  50. empathy_llm_toolkit/cli/__init__.py +0 -8
  51. empathy_llm_toolkit/cli/sync_claude.py +0 -487
  52. empathy_llm_toolkit/code_health.py +0 -1313
  53. empathy_llm_toolkit/commands/__init__.py +0 -51
  54. empathy_llm_toolkit/commands/context.py +0 -375
  55. empathy_llm_toolkit/commands/loader.py +0 -301
  56. empathy_llm_toolkit/commands/models.py +0 -231
  57. empathy_llm_toolkit/commands/parser.py +0 -371
  58. empathy_llm_toolkit/commands/registry.py +0 -429
  59. empathy_llm_toolkit/config/__init__.py +0 -29
  60. empathy_llm_toolkit/config/unified.py +0 -291
  61. empathy_llm_toolkit/context/__init__.py +0 -22
  62. empathy_llm_toolkit/context/compaction.py +0 -455
  63. empathy_llm_toolkit/context/manager.py +0 -434
  64. empathy_llm_toolkit/contextual_patterns.py +0 -361
  65. empathy_llm_toolkit/core.py +0 -907
  66. empathy_llm_toolkit/git_pattern_extractor.py +0 -435
  67. empathy_llm_toolkit/hooks/__init__.py +0 -24
  68. empathy_llm_toolkit/hooks/config.py +0 -306
  69. empathy_llm_toolkit/hooks/executor.py +0 -289
  70. empathy_llm_toolkit/hooks/registry.py +0 -302
  71. empathy_llm_toolkit/hooks/scripts/__init__.py +0 -39
  72. empathy_llm_toolkit/hooks/scripts/evaluate_session.py +0 -201
  73. empathy_llm_toolkit/hooks/scripts/first_time_init.py +0 -285
  74. empathy_llm_toolkit/hooks/scripts/pre_compact.py +0 -207
  75. empathy_llm_toolkit/hooks/scripts/session_end.py +0 -183
  76. empathy_llm_toolkit/hooks/scripts/session_start.py +0 -163
  77. empathy_llm_toolkit/hooks/scripts/suggest_compact.py +0 -225
  78. empathy_llm_toolkit/learning/__init__.py +0 -30
  79. empathy_llm_toolkit/learning/evaluator.py +0 -438
  80. empathy_llm_toolkit/learning/extractor.py +0 -514
  81. empathy_llm_toolkit/learning/storage.py +0 -560
  82. empathy_llm_toolkit/levels.py +0 -227
  83. empathy_llm_toolkit/pattern_confidence.py +0 -414
  84. empathy_llm_toolkit/pattern_resolver.py +0 -272
  85. empathy_llm_toolkit/pattern_summary.py +0 -350
  86. empathy_llm_toolkit/providers.py +0 -967
  87. empathy_llm_toolkit/routing/__init__.py +0 -32
  88. empathy_llm_toolkit/routing/model_router.py +0 -362
  89. empathy_llm_toolkit/security/IMPLEMENTATION_SUMMARY.md +0 -413
  90. empathy_llm_toolkit/security/PHASE2_COMPLETE.md +0 -384
  91. empathy_llm_toolkit/security/PHASE2_SECRETS_DETECTOR_COMPLETE.md +0 -271
  92. empathy_llm_toolkit/security/QUICK_REFERENCE.md +0 -316
  93. empathy_llm_toolkit/security/README.md +0 -262
  94. empathy_llm_toolkit/security/__init__.py +0 -62
  95. empathy_llm_toolkit/security/audit_logger.py +0 -929
  96. empathy_llm_toolkit/security/audit_logger_example.py +0 -152
  97. empathy_llm_toolkit/security/pii_scrubber.py +0 -640
  98. empathy_llm_toolkit/security/secrets_detector.py +0 -678
  99. empathy_llm_toolkit/security/secrets_detector_example.py +0 -304
  100. empathy_llm_toolkit/security/secure_memdocs.py +0 -1192
  101. empathy_llm_toolkit/security/secure_memdocs_example.py +0 -278
  102. empathy_llm_toolkit/session_status.py +0 -745
  103. empathy_llm_toolkit/state.py +0 -246
  104. empathy_llm_toolkit/utils/__init__.py +0 -5
  105. empathy_llm_toolkit/utils/tokens.py +0 -349
  106. empathy_os/adaptive/__init__.py +0 -13
  107. empathy_os/adaptive/task_complexity.py +0 -127
  108. empathy_os/agent_monitoring.py +0 -414
  109. empathy_os/cache/__init__.py +0 -117
  110. empathy_os/cache/base.py +0 -166
  111. empathy_os/cache/dependency_manager.py +0 -256
  112. empathy_os/cache/hash_only.py +0 -251
  113. empathy_os/cache/hybrid.py +0 -453
  114. empathy_os/cache/storage.py +0 -285
  115. empathy_os/cache_monitor.py +0 -356
  116. empathy_os/cache_stats.py +0 -298
  117. empathy_os/cli/__init__.py +0 -152
  118. empathy_os/cli/__main__.py +0 -12
  119. empathy_os/cli/commands/__init__.py +0 -1
  120. empathy_os/cli/commands/batch.py +0 -256
  121. empathy_os/cli/commands/cache.py +0 -248
  122. empathy_os/cli/commands/help.py +0 -331
  123. empathy_os/cli/commands/info.py +0 -140
  124. empathy_os/cli/commands/inspect.py +0 -436
  125. empathy_os/cli/commands/inspection.py +0 -57
  126. empathy_os/cli/commands/memory.py +0 -48
  127. empathy_os/cli/commands/metrics.py +0 -92
  128. empathy_os/cli/commands/orchestrate.py +0 -184
  129. empathy_os/cli/commands/patterns.py +0 -207
  130. empathy_os/cli/commands/profiling.py +0 -198
  131. empathy_os/cli/commands/provider.py +0 -98
  132. empathy_os/cli/commands/routing.py +0 -285
  133. empathy_os/cli/commands/setup.py +0 -96
  134. empathy_os/cli/commands/status.py +0 -235
  135. empathy_os/cli/commands/sync.py +0 -166
  136. empathy_os/cli/commands/tier.py +0 -121
  137. empathy_os/cli/commands/utilities.py +0 -114
  138. empathy_os/cli/commands/workflow.py +0 -575
  139. empathy_os/cli/core.py +0 -32
  140. empathy_os/cli/parsers/__init__.py +0 -68
  141. empathy_os/cli/parsers/batch.py +0 -118
  142. empathy_os/cli/parsers/cache 2.py +0 -65
  143. empathy_os/cli/parsers/cache.py +0 -65
  144. empathy_os/cli/parsers/help.py +0 -41
  145. empathy_os/cli/parsers/info.py +0 -26
  146. empathy_os/cli/parsers/inspect.py +0 -66
  147. empathy_os/cli/parsers/metrics.py +0 -42
  148. empathy_os/cli/parsers/orchestrate.py +0 -61
  149. empathy_os/cli/parsers/patterns.py +0 -54
  150. empathy_os/cli/parsers/provider.py +0 -40
  151. empathy_os/cli/parsers/routing.py +0 -110
  152. empathy_os/cli/parsers/setup.py +0 -42
  153. empathy_os/cli/parsers/status.py +0 -47
  154. empathy_os/cli/parsers/sync.py +0 -31
  155. empathy_os/cli/parsers/tier.py +0 -33
  156. empathy_os/cli/parsers/workflow.py +0 -77
  157. empathy_os/cli/utils/__init__.py +0 -1
  158. empathy_os/cli/utils/data.py +0 -242
  159. empathy_os/cli/utils/helpers.py +0 -68
  160. empathy_os/cli_legacy.py +0 -3957
  161. empathy_os/cli_minimal.py +0 -1159
  162. empathy_os/cli_router 2.py +0 -416
  163. empathy_os/cli_router.py +0 -437
  164. empathy_os/cli_unified.py +0 -814
  165. empathy_os/config/__init__.py +0 -66
  166. empathy_os/config/xml_config.py +0 -286
  167. empathy_os/config.py +0 -532
  168. empathy_os/coordination.py +0 -870
  169. empathy_os/core.py +0 -1511
  170. empathy_os/core_modules/__init__.py +0 -15
  171. empathy_os/cost_tracker.py +0 -626
  172. empathy_os/dashboard/__init__.py +0 -41
  173. empathy_os/dashboard/app 2.py +0 -512
  174. empathy_os/dashboard/app.py +0 -512
  175. empathy_os/dashboard/simple_server 2.py +0 -403
  176. empathy_os/dashboard/simple_server.py +0 -403
  177. empathy_os/dashboard/standalone_server 2.py +0 -536
  178. empathy_os/dashboard/standalone_server.py +0 -547
  179. empathy_os/discovery.py +0 -306
  180. empathy_os/emergence.py +0 -306
  181. empathy_os/exceptions.py +0 -123
  182. empathy_os/feedback_loops.py +0 -373
  183. empathy_os/hot_reload/README.md +0 -473
  184. empathy_os/hot_reload/__init__.py +0 -62
  185. empathy_os/hot_reload/config.py +0 -83
  186. empathy_os/hot_reload/integration.py +0 -229
  187. empathy_os/hot_reload/reloader.py +0 -298
  188. empathy_os/hot_reload/watcher.py +0 -183
  189. empathy_os/hot_reload/websocket.py +0 -177
  190. empathy_os/levels.py +0 -577
  191. empathy_os/leverage_points.py +0 -441
  192. empathy_os/logging_config.py +0 -261
  193. empathy_os/mcp/__init__.py +0 -10
  194. empathy_os/mcp/server.py +0 -506
  195. empathy_os/memory/__init__.py +0 -237
  196. empathy_os/memory/claude_memory.py +0 -469
  197. empathy_os/memory/config.py +0 -224
  198. empathy_os/memory/control_panel.py +0 -1290
  199. empathy_os/memory/control_panel_support.py +0 -145
  200. empathy_os/memory/cross_session.py +0 -845
  201. empathy_os/memory/edges.py +0 -179
  202. empathy_os/memory/encryption.py +0 -159
  203. empathy_os/memory/file_session.py +0 -770
  204. empathy_os/memory/graph.py +0 -570
  205. empathy_os/memory/long_term.py +0 -913
  206. empathy_os/memory/long_term_types.py +0 -99
  207. empathy_os/memory/mixins/__init__.py +0 -25
  208. empathy_os/memory/mixins/backend_init_mixin.py +0 -244
  209. empathy_os/memory/mixins/capabilities_mixin.py +0 -199
  210. empathy_os/memory/mixins/handoff_mixin.py +0 -208
  211. empathy_os/memory/mixins/lifecycle_mixin.py +0 -49
  212. empathy_os/memory/mixins/long_term_mixin.py +0 -352
  213. empathy_os/memory/mixins/promotion_mixin.py +0 -109
  214. empathy_os/memory/mixins/short_term_mixin.py +0 -182
  215. empathy_os/memory/nodes.py +0 -179
  216. empathy_os/memory/redis_bootstrap.py +0 -540
  217. empathy_os/memory/security/__init__.py +0 -31
  218. empathy_os/memory/security/audit_logger.py +0 -932
  219. empathy_os/memory/security/pii_scrubber.py +0 -640
  220. empathy_os/memory/security/secrets_detector.py +0 -678
  221. empathy_os/memory/short_term.py +0 -2150
  222. empathy_os/memory/simple_storage.py +0 -302
  223. empathy_os/memory/storage/__init__.py +0 -15
  224. empathy_os/memory/storage_backend.py +0 -167
  225. empathy_os/memory/summary_index.py +0 -583
  226. empathy_os/memory/types.py +0 -441
  227. empathy_os/memory/unified.py +0 -182
  228. empathy_os/meta_workflows/__init__.py +0 -74
  229. empathy_os/meta_workflows/agent_creator.py +0 -248
  230. empathy_os/meta_workflows/builtin_templates.py +0 -567
  231. empathy_os/meta_workflows/cli_commands/__init__.py +0 -56
  232. empathy_os/meta_workflows/cli_commands/agent_commands.py +0 -321
  233. empathy_os/meta_workflows/cli_commands/analytics_commands.py +0 -442
  234. empathy_os/meta_workflows/cli_commands/config_commands.py +0 -232
  235. empathy_os/meta_workflows/cli_commands/memory_commands.py +0 -182
  236. empathy_os/meta_workflows/cli_commands/template_commands.py +0 -354
  237. empathy_os/meta_workflows/cli_commands/workflow_commands.py +0 -382
  238. empathy_os/meta_workflows/cli_meta_workflows.py +0 -59
  239. empathy_os/meta_workflows/form_engine.py +0 -292
  240. empathy_os/meta_workflows/intent_detector.py +0 -409
  241. empathy_os/meta_workflows/models.py +0 -569
  242. empathy_os/meta_workflows/pattern_learner.py +0 -738
  243. empathy_os/meta_workflows/plan_generator.py +0 -384
  244. empathy_os/meta_workflows/session_context.py +0 -397
  245. empathy_os/meta_workflows/template_registry.py +0 -229
  246. empathy_os/meta_workflows/workflow.py +0 -984
  247. empathy_os/metrics/__init__.py +0 -12
  248. empathy_os/metrics/collector.py +0 -31
  249. empathy_os/metrics/prompt_metrics.py +0 -194
  250. empathy_os/models/__init__.py +0 -172
  251. empathy_os/models/__main__.py +0 -13
  252. empathy_os/models/adaptive_routing 2.py +0 -437
  253. empathy_os/models/adaptive_routing.py +0 -437
  254. empathy_os/models/auth_cli.py +0 -444
  255. empathy_os/models/auth_strategy.py +0 -450
  256. empathy_os/models/cli.py +0 -655
  257. empathy_os/models/empathy_executor.py +0 -354
  258. empathy_os/models/executor.py +0 -257
  259. empathy_os/models/fallback.py +0 -762
  260. empathy_os/models/provider_config.py +0 -282
  261. empathy_os/models/registry.py +0 -472
  262. empathy_os/models/tasks.py +0 -359
  263. empathy_os/models/telemetry/__init__.py +0 -71
  264. empathy_os/models/telemetry/analytics.py +0 -594
  265. empathy_os/models/telemetry/backend.py +0 -196
  266. empathy_os/models/telemetry/data_models.py +0 -431
  267. empathy_os/models/telemetry/storage.py +0 -489
  268. empathy_os/models/token_estimator.py +0 -420
  269. empathy_os/models/validation.py +0 -280
  270. empathy_os/monitoring/__init__.py +0 -52
  271. empathy_os/monitoring/alerts.py +0 -946
  272. empathy_os/monitoring/alerts_cli.py +0 -448
  273. empathy_os/monitoring/multi_backend.py +0 -271
  274. empathy_os/monitoring/otel_backend.py +0 -362
  275. empathy_os/optimization/__init__.py +0 -19
  276. empathy_os/optimization/context_optimizer.py +0 -272
  277. empathy_os/orchestration/__init__.py +0 -67
  278. empathy_os/orchestration/agent_templates.py +0 -707
  279. empathy_os/orchestration/config_store.py +0 -499
  280. empathy_os/orchestration/execution_strategies.py +0 -2111
  281. empathy_os/orchestration/meta_orchestrator.py +0 -1168
  282. empathy_os/orchestration/pattern_learner.py +0 -696
  283. empathy_os/orchestration/real_tools.py +0 -931
  284. empathy_os/pattern_cache.py +0 -187
  285. empathy_os/pattern_library.py +0 -542
  286. empathy_os/patterns/debugging/all_patterns.json +0 -81
  287. empathy_os/patterns/debugging/workflow_20260107_1770825e.json +0 -77
  288. empathy_os/patterns/refactoring_memory.json +0 -89
  289. empathy_os/persistence.py +0 -564
  290. empathy_os/platform_utils.py +0 -265
  291. empathy_os/plugins/__init__.py +0 -28
  292. empathy_os/plugins/base.py +0 -361
  293. empathy_os/plugins/registry.py +0 -268
  294. empathy_os/project_index/__init__.py +0 -32
  295. empathy_os/project_index/cli.py +0 -335
  296. empathy_os/project_index/index.py +0 -667
  297. empathy_os/project_index/models.py +0 -504
  298. empathy_os/project_index/reports.py +0 -474
  299. empathy_os/project_index/scanner.py +0 -777
  300. empathy_os/project_index/scanner_parallel 2.py +0 -291
  301. empathy_os/project_index/scanner_parallel.py +0 -291
  302. empathy_os/prompts/__init__.py +0 -61
  303. empathy_os/prompts/config.py +0 -77
  304. empathy_os/prompts/context.py +0 -177
  305. empathy_os/prompts/parser.py +0 -285
  306. empathy_os/prompts/registry.py +0 -313
  307. empathy_os/prompts/templates.py +0 -208
  308. empathy_os/redis_config.py +0 -302
  309. empathy_os/redis_memory.py +0 -799
  310. empathy_os/resilience/__init__.py +0 -56
  311. empathy_os/resilience/circuit_breaker.py +0 -256
  312. empathy_os/resilience/fallback.py +0 -179
  313. empathy_os/resilience/health.py +0 -300
  314. empathy_os/resilience/retry.py +0 -209
  315. empathy_os/resilience/timeout.py +0 -135
  316. empathy_os/routing/__init__.py +0 -43
  317. empathy_os/routing/chain_executor.py +0 -433
  318. empathy_os/routing/classifier.py +0 -217
  319. empathy_os/routing/smart_router.py +0 -234
  320. empathy_os/routing/workflow_registry.py +0 -343
  321. empathy_os/scaffolding/README.md +0 -589
  322. empathy_os/scaffolding/__init__.py +0 -35
  323. empathy_os/scaffolding/__main__.py +0 -14
  324. empathy_os/scaffolding/cli.py +0 -240
  325. empathy_os/socratic/__init__.py +0 -256
  326. empathy_os/socratic/ab_testing.py +0 -958
  327. empathy_os/socratic/blueprint.py +0 -533
  328. empathy_os/socratic/cli.py +0 -703
  329. empathy_os/socratic/collaboration.py +0 -1114
  330. empathy_os/socratic/domain_templates.py +0 -924
  331. empathy_os/socratic/embeddings.py +0 -738
  332. empathy_os/socratic/engine.py +0 -794
  333. empathy_os/socratic/explainer.py +0 -682
  334. empathy_os/socratic/feedback.py +0 -772
  335. empathy_os/socratic/forms.py +0 -629
  336. empathy_os/socratic/generator.py +0 -732
  337. empathy_os/socratic/llm_analyzer.py +0 -637
  338. empathy_os/socratic/mcp_server.py +0 -702
  339. empathy_os/socratic/session.py +0 -312
  340. empathy_os/socratic/storage.py +0 -667
  341. empathy_os/socratic/success.py +0 -730
  342. empathy_os/socratic/visual_editor.py +0 -860
  343. empathy_os/socratic/web_ui.py +0 -958
  344. empathy_os/telemetry/__init__.py +0 -39
  345. empathy_os/telemetry/agent_coordination 2.py +0 -478
  346. empathy_os/telemetry/agent_coordination.py +0 -476
  347. empathy_os/telemetry/agent_tracking 2.py +0 -350
  348. empathy_os/telemetry/agent_tracking.py +0 -348
  349. empathy_os/telemetry/approval_gates 2.py +0 -563
  350. empathy_os/telemetry/approval_gates.py +0 -551
  351. empathy_os/telemetry/cli.py +0 -1231
  352. empathy_os/telemetry/commands/__init__.py +0 -14
  353. empathy_os/telemetry/commands/dashboard_commands.py +0 -696
  354. empathy_os/telemetry/event_streaming 2.py +0 -405
  355. empathy_os/telemetry/event_streaming.py +0 -405
  356. empathy_os/telemetry/feedback_loop 2.py +0 -557
  357. empathy_os/telemetry/feedback_loop.py +0 -554
  358. empathy_os/telemetry/usage_tracker.py +0 -591
  359. empathy_os/templates.py +0 -754
  360. empathy_os/test_generator/__init__.py +0 -38
  361. empathy_os/test_generator/__main__.py +0 -14
  362. empathy_os/test_generator/cli.py +0 -234
  363. empathy_os/test_generator/generator.py +0 -355
  364. empathy_os/test_generator/risk_analyzer.py +0 -216
  365. empathy_os/tier_recommender.py +0 -384
  366. empathy_os/tools.py +0 -183
  367. empathy_os/trust/__init__.py +0 -28
  368. empathy_os/trust/circuit_breaker.py +0 -579
  369. empathy_os/trust_building.py +0 -527
  370. empathy_os/validation/__init__.py +0 -19
  371. empathy_os/validation/xml_validator.py +0 -281
  372. empathy_os/vscode_bridge 2.py +0 -173
  373. empathy_os/vscode_bridge.py +0 -173
  374. empathy_os/workflow_commands.py +0 -780
  375. empathy_os/workflow_patterns/__init__.py +0 -33
  376. empathy_os/workflow_patterns/behavior.py +0 -249
  377. empathy_os/workflow_patterns/core.py +0 -76
  378. empathy_os/workflow_patterns/output.py +0 -99
  379. empathy_os/workflow_patterns/registry.py +0 -255
  380. empathy_os/workflow_patterns/structural.py +0 -288
  381. empathy_os/workflows/__init__.py +0 -539
  382. empathy_os/workflows/autonomous_test_gen.py +0 -1268
  383. empathy_os/workflows/base.py +0 -2667
  384. empathy_os/workflows/batch_processing.py +0 -342
  385. empathy_os/workflows/bug_predict.py +0 -1084
  386. empathy_os/workflows/builder.py +0 -273
  387. empathy_os/workflows/caching.py +0 -253
  388. empathy_os/workflows/code_review.py +0 -1048
  389. empathy_os/workflows/code_review_adapters.py +0 -312
  390. empathy_os/workflows/code_review_pipeline.py +0 -722
  391. empathy_os/workflows/config.py +0 -645
  392. empathy_os/workflows/dependency_check.py +0 -644
  393. empathy_os/workflows/document_gen/__init__.py +0 -25
  394. empathy_os/workflows/document_gen/config.py +0 -30
  395. empathy_os/workflows/document_gen/report_formatter.py +0 -162
  396. empathy_os/workflows/document_gen/workflow.py +0 -1426
  397. empathy_os/workflows/document_gen.py +0 -29
  398. empathy_os/workflows/document_manager.py +0 -216
  399. empathy_os/workflows/document_manager_README.md +0 -134
  400. empathy_os/workflows/documentation_orchestrator.py +0 -1205
  401. empathy_os/workflows/history.py +0 -510
  402. empathy_os/workflows/keyboard_shortcuts/__init__.py +0 -39
  403. empathy_os/workflows/keyboard_shortcuts/generators.py +0 -391
  404. empathy_os/workflows/keyboard_shortcuts/parsers.py +0 -416
  405. empathy_os/workflows/keyboard_shortcuts/prompts.py +0 -295
  406. empathy_os/workflows/keyboard_shortcuts/schema.py +0 -193
  407. empathy_os/workflows/keyboard_shortcuts/workflow.py +0 -509
  408. empathy_os/workflows/llm_base.py +0 -363
  409. empathy_os/workflows/manage_docs.py +0 -87
  410. empathy_os/workflows/manage_docs_README.md +0 -134
  411. empathy_os/workflows/manage_documentation.py +0 -821
  412. empathy_os/workflows/new_sample_workflow1.py +0 -149
  413. empathy_os/workflows/new_sample_workflow1_README.md +0 -150
  414. empathy_os/workflows/orchestrated_health_check.py +0 -849
  415. empathy_os/workflows/orchestrated_release_prep.py +0 -600
  416. empathy_os/workflows/output.py +0 -410
  417. empathy_os/workflows/perf_audit.py +0 -863
  418. empathy_os/workflows/pr_review.py +0 -762
  419. empathy_os/workflows/progress.py +0 -779
  420. empathy_os/workflows/progress_server.py +0 -322
  421. empathy_os/workflows/progressive/README 2.md +0 -454
  422. empathy_os/workflows/progressive/README.md +0 -454
  423. empathy_os/workflows/progressive/__init__ 2.py +0 -92
  424. empathy_os/workflows/progressive/__init__.py +0 -82
  425. empathy_os/workflows/progressive/cli 2.py +0 -242
  426. empathy_os/workflows/progressive/cli.py +0 -219
  427. empathy_os/workflows/progressive/core 2.py +0 -488
  428. empathy_os/workflows/progressive/core.py +0 -488
  429. empathy_os/workflows/progressive/orchestrator 2.py +0 -701
  430. empathy_os/workflows/progressive/orchestrator.py +0 -723
  431. empathy_os/workflows/progressive/reports 2.py +0 -528
  432. empathy_os/workflows/progressive/reports.py +0 -520
  433. empathy_os/workflows/progressive/telemetry 2.py +0 -280
  434. empathy_os/workflows/progressive/telemetry.py +0 -274
  435. empathy_os/workflows/progressive/test_gen 2.py +0 -514
  436. empathy_os/workflows/progressive/test_gen.py +0 -495
  437. empathy_os/workflows/progressive/workflow 2.py +0 -628
  438. empathy_os/workflows/progressive/workflow.py +0 -589
  439. empathy_os/workflows/refactor_plan.py +0 -694
  440. empathy_os/workflows/release_prep.py +0 -895
  441. empathy_os/workflows/release_prep_crew.py +0 -969
  442. empathy_os/workflows/research_synthesis.py +0 -404
  443. empathy_os/workflows/routing.py +0 -168
  444. empathy_os/workflows/secure_release.py +0 -593
  445. empathy_os/workflows/security_adapters.py +0 -297
  446. empathy_os/workflows/security_audit.py +0 -1329
  447. empathy_os/workflows/security_audit_phase3.py +0 -355
  448. empathy_os/workflows/seo_optimization.py +0 -633
  449. empathy_os/workflows/step_config.py +0 -234
  450. empathy_os/workflows/telemetry_mixin.py +0 -269
  451. empathy_os/workflows/test5.py +0 -125
  452. empathy_os/workflows/test5_README.md +0 -158
  453. empathy_os/workflows/test_coverage_boost_crew.py +0 -849
  454. empathy_os/workflows/test_gen/__init__.py +0 -52
  455. empathy_os/workflows/test_gen/ast_analyzer.py +0 -249
  456. empathy_os/workflows/test_gen/config.py +0 -88
  457. empathy_os/workflows/test_gen/data_models.py +0 -38
  458. empathy_os/workflows/test_gen/report_formatter.py +0 -289
  459. empathy_os/workflows/test_gen/test_templates.py +0 -381
  460. empathy_os/workflows/test_gen/workflow.py +0 -655
  461. empathy_os/workflows/test_gen.py +0 -54
  462. empathy_os/workflows/test_gen_behavioral.py +0 -477
  463. empathy_os/workflows/test_gen_parallel.py +0 -341
  464. empathy_os/workflows/test_lifecycle.py +0 -526
  465. empathy_os/workflows/test_maintenance.py +0 -627
  466. empathy_os/workflows/test_maintenance_cli.py +0 -590
  467. empathy_os/workflows/test_maintenance_crew.py +0 -840
  468. empathy_os/workflows/test_runner.py +0 -622
  469. empathy_os/workflows/tier_tracking.py +0 -531
  470. empathy_os/workflows/xml_enhanced_crew.py +0 -285
  471. empathy_software_plugin/SOFTWARE_PLUGIN_README.md +0 -57
  472. empathy_software_plugin/cli/__init__.py +0 -120
  473. empathy_software_plugin/cli/inspect.py +0 -362
  474. empathy_software_plugin/cli.py +0 -574
  475. empathy_software_plugin/plugin.py +0 -188
  476. workflow_scaffolding/__init__.py +0 -11
  477. workflow_scaffolding/__main__.py +0 -12
  478. workflow_scaffolding/cli.py +0 -206
  479. workflow_scaffolding/generator.py +0 -265
  480. {empathy_framework-5.2.1.dist-info → empathy_framework-5.4.0.dist-info}/WHEEL +0 -0
@@ -1,1018 +0,0 @@
1
- """Security Audit Crew
2
-
3
- A multi-agent crew that performs comprehensive security audits.
4
- Demonstrates CrewAI's hierarchical collaboration patterns with:
5
- - 5 specialized agents with distinct roles
6
- - Hierarchical task delegation from Security Lead
7
- - Memory Graph integration for cross-analysis learning
8
- - Structured output with severity scoring
9
-
10
- Usage:
11
- from empathy_llm_toolkit.agent_factory.crews import SecurityAuditCrew
12
-
13
- crew = SecurityAuditCrew(api_key="...")
14
- report = await crew.audit("path/to/codebase")
15
-
16
- print(f"Found {len(report.findings)} security issues")
17
- for finding in report.critical_findings:
18
- print(f" - {finding.title}: {finding.remediation}")
19
-
20
- Copyright 2025 Smart-AI-Memory
21
- Licensed under Fair Source License 0.9
22
- """
23
-
24
- import logging
25
- from dataclasses import dataclass, field
26
- from enum import Enum
27
- from typing import Any
28
-
29
- logger = logging.getLogger(__name__)
30
-
31
-
32
- class Severity(Enum):
33
- """Security finding severity levels."""
34
-
35
- CRITICAL = "critical"
36
- HIGH = "high"
37
- MEDIUM = "medium"
38
- LOW = "low"
39
- INFO = "info"
40
-
41
-
42
- class FindingCategory(Enum):
43
- """Security finding categories (OWASP-aligned)."""
44
-
45
- INJECTION = "injection"
46
- BROKEN_AUTH = "broken_authentication"
47
- SENSITIVE_DATA = "sensitive_data_exposure"
48
- XXE = "xml_external_entities"
49
- BROKEN_ACCESS = "broken_access_control"
50
- MISCONFIGURATION = "security_misconfiguration"
51
- XSS = "cross_site_scripting"
52
- INSECURE_DESERIALIZATION = "insecure_deserialization"
53
- VULNERABLE_COMPONENTS = "vulnerable_components"
54
- INSUFFICIENT_LOGGING = "insufficient_logging"
55
- OTHER = "other"
56
-
57
-
58
- @dataclass
59
- class SecurityFinding:
60
- """A single security finding from the audit."""
61
-
62
- title: str
63
- description: str
64
- severity: Severity
65
- category: FindingCategory
66
- file_path: str | None = None
67
- line_number: int | None = None
68
- code_snippet: str | None = None
69
- remediation: str | None = None
70
- cwe_id: str | None = None
71
- cvss_score: float | None = None
72
- confidence: float = 1.0
73
- metadata: dict = field(default_factory=dict)
74
-
75
- def to_dict(self) -> dict:
76
- """Convert finding to dictionary."""
77
- return {
78
- "title": self.title,
79
- "description": self.description,
80
- "severity": self.severity.value,
81
- "category": self.category.value,
82
- "file_path": self.file_path,
83
- "line_number": self.line_number,
84
- "code_snippet": self.code_snippet,
85
- "remediation": self.remediation,
86
- "cwe_id": self.cwe_id,
87
- "cvss_score": self.cvss_score,
88
- "confidence": self.confidence,
89
- "metadata": self.metadata,
90
- }
91
-
92
-
93
- @dataclass
94
- class SecurityReport:
95
- """Complete security audit report."""
96
-
97
- target: str
98
- findings: list[SecurityFinding]
99
- summary: str = ""
100
- audit_duration_seconds: float = 0.0
101
- agents_used: list[str] = field(default_factory=list)
102
- memory_graph_hits: int = 0
103
- metadata: dict = field(default_factory=dict)
104
-
105
- @property
106
- def critical_findings(self) -> list[SecurityFinding]:
107
- """Get critical severity findings."""
108
- return [f for f in self.findings if f.severity == Severity.CRITICAL]
109
-
110
- @property
111
- def high_findings(self) -> list[SecurityFinding]:
112
- """Get high severity findings."""
113
- return [f for f in self.findings if f.severity == Severity.HIGH]
114
-
115
- @property
116
- def findings_by_category(self) -> dict[str, list[SecurityFinding]]:
117
- """Group findings by category."""
118
- result: dict[str, list[SecurityFinding]] = {}
119
- for finding in self.findings:
120
- cat = finding.category.value
121
- if cat not in result:
122
- result[cat] = []
123
- result[cat].append(finding)
124
- return result
125
-
126
- @property
127
- def risk_score(self) -> float:
128
- """Calculate overall risk score (0-100)."""
129
- if not self.findings:
130
- return 0.0
131
-
132
- weights = {
133
- Severity.CRITICAL: 25,
134
- Severity.HIGH: 15,
135
- Severity.MEDIUM: 5,
136
- Severity.LOW: 2,
137
- Severity.INFO: 0.5,
138
- }
139
-
140
- total = sum(weights[f.severity] * f.confidence for f in self.findings)
141
- return min(100.0, total)
142
-
143
- def to_dict(self) -> dict:
144
- """Convert report to dictionary."""
145
- return {
146
- "target": self.target,
147
- "findings": [f.to_dict() for f in self.findings],
148
- "summary": self.summary,
149
- "audit_duration_seconds": self.audit_duration_seconds,
150
- "agents_used": self.agents_used,
151
- "memory_graph_hits": self.memory_graph_hits,
152
- "risk_score": self.risk_score,
153
- "finding_counts": {
154
- "critical": len(self.critical_findings),
155
- "high": len(self.high_findings),
156
- "total": len(self.findings),
157
- },
158
- "metadata": self.metadata,
159
- }
160
-
161
-
162
- @dataclass
163
- class SecurityAuditConfig:
164
- """Configuration for security audit crew."""
165
-
166
- # API Configuration
167
- provider: str = "anthropic"
168
- api_key: str | None = None
169
-
170
- # Scan Configuration
171
- scan_depth: str = "standard" # "quick", "standard", "thorough"
172
- include_patterns: list[str] = field(
173
- default_factory=lambda: ["*.py", "*.js", "*.ts", "*.java", "*.go"],
174
- )
175
- exclude_patterns: list[str] = field(
176
- default_factory=lambda: ["*test*", "*spec*", "node_modules/*", "venv/*"],
177
- )
178
-
179
- # Memory Graph
180
- memory_graph_enabled: bool = True
181
- memory_graph_path: str = "patterns/security_memory.json"
182
-
183
- # Agent Tiers
184
- lead_tier: str = "premium"
185
- hunter_tier: str = "capable"
186
- assessor_tier: str = "capable"
187
- remediation_tier: str = "premium"
188
- compliance_tier: str = "cheap"
189
-
190
- # Resilience
191
- resilience_enabled: bool = True
192
- timeout_seconds: float = 300.0
193
-
194
- # XML Prompts
195
- xml_prompts_enabled: bool = True
196
- xml_schema_version: str = "1.0"
197
-
198
-
199
- # XML Prompt Templates for Security Audit Agents
200
- XML_PROMPT_TEMPLATES = {
201
- "security_lead": """<agent role="security_lead" version="{schema_version}">
202
- <identity>
203
- <role>Security Audit Lead</role>
204
- <expertise>Security coordination, risk prioritization, executive reporting</expertise>
205
- </identity>
206
-
207
- <goal>
208
- Coordinate the security audit team to identify and prioritize vulnerabilities.
209
- Synthesize findings into an actionable security report.
210
- </goal>
211
-
212
- <instructions>
213
- <step>Coordinate the security audit team and assign analysis tasks</step>
214
- <step>Review and deduplicate findings from all specialists</step>
215
- <step>Prioritize findings by risk score and exploitability</step>
216
- <step>Calculate overall risk score for the target</step>
217
- <step>Generate executive summary with key recommendations</step>
218
- </instructions>
219
-
220
- <constraints>
221
- <rule>Focus on actionable, exploitable vulnerabilities</rule>
222
- <rule>Minimize false positives through validation</rule>
223
- <rule>Provide clear risk context for each finding</rule>
224
- <rule>Include both technical and business impact</rule>
225
- </constraints>
226
-
227
- <output_format>
228
- <section name="summary">Executive summary of security posture</section>
229
- <section name="risk_score">Overall risk score 0-100</section>
230
- <section name="critical_findings">Vulnerabilities requiring immediate attention</section>
231
- <section name="recommendations">Prioritized remediation roadmap</section>
232
- </output_format>
233
- </agent>""",
234
- "vulnerability_hunter": """<agent role="vulnerability_hunter" version="{schema_version}">
235
- <identity>
236
- <role>Vulnerability Hunter</role>
237
- <expertise>OWASP Top 10, penetration testing, vulnerability identification</expertise>
238
- </identity>
239
-
240
- <goal>
241
- Identify security vulnerabilities in code and configuration.
242
- </goal>
243
-
244
- <instructions>
245
- <step>Scan for OWASP Top 10 vulnerabilities</step>
246
- <step>Identify injection points (SQL, command, LDAP)</step>
247
- <step>Check for authentication and authorization flaws</step>
248
- <step>Review cryptographic implementations</step>
249
- <step>Detect hardcoded secrets and credentials</step>
250
- <step>Document each finding with file, line, and evidence</step>
251
- </instructions>
252
-
253
- <constraints>
254
- <rule>Focus on exploitable vulnerabilities</rule>
255
- <rule>Provide proof-of-concept or attack vector</rule>
256
- <rule>Include file path and line number</rule>
257
- <rule>Rate severity using CVSS methodology</rule>
258
- </constraints>
259
-
260
- <owasp_categories>
261
- <category>A01 - Broken Access Control</category>
262
- <category>A02 - Cryptographic Failures</category>
263
- <category>A03 - Injection</category>
264
- <category>A04 - Insecure Design</category>
265
- <category>A05 - Security Misconfiguration</category>
266
- <category>A06 - Vulnerable Components</category>
267
- <category>A07 - Auth Failures</category>
268
- <category>A08 - Software Integrity Failures</category>
269
- <category>A09 - Logging Failures</category>
270
- <category>A10 - SSRF</category>
271
- </owasp_categories>
272
-
273
- <output_format>
274
- <section name="findings">Vulnerabilities with severity, location, and evidence</section>
275
- <section name="summary">Vulnerability distribution summary</section>
276
- </output_format>
277
- </agent>""",
278
- "risk_assessor": """<agent role="risk_assessor" version="{schema_version}">
279
- <identity>
280
- <role>Risk Assessor</role>
281
- <expertise>CVSS scoring, risk analysis, threat modeling</expertise>
282
- </identity>
283
-
284
- <goal>
285
- Assess the risk level of identified vulnerabilities.
286
- </goal>
287
-
288
- <instructions>
289
- <step>Calculate CVSS scores for each vulnerability</step>
290
- <step>Assess exploitability and attack complexity</step>
291
- <step>Evaluate blast radius and data sensitivity</step>
292
- <step>Consider existing mitigating controls</step>
293
- <step>Prioritize by business impact</step>
294
- <step>Identify attack chains and compound risks</step>
295
- </instructions>
296
-
297
- <constraints>
298
- <rule>Use CVSS 3.1 methodology consistently</rule>
299
- <rule>Consider environmental factors</rule>
300
- <rule>Identify dependencies between findings</rule>
301
- <rule>Provide confidence levels for assessments</rule>
302
- </constraints>
303
-
304
- <cvss_vectors>
305
- <metric name="AV">Attack Vector (Network, Adjacent, Local, Physical)</metric>
306
- <metric name="AC">Attack Complexity (Low, High)</metric>
307
- <metric name="PR">Privileges Required (None, Low, High)</metric>
308
- <metric name="UI">User Interaction (None, Required)</metric>
309
- <metric name="S">Scope (Unchanged, Changed)</metric>
310
- <metric name="C">Confidentiality Impact (None, Low, High)</metric>
311
- <metric name="I">Integrity Impact (None, Low, High)</metric>
312
- <metric name="A">Availability Impact (None, Low, High)</metric>
313
- </cvss_vectors>
314
-
315
- <output_format>
316
- <section name="assessments">Risk assessments with CVSS scores</section>
317
- <section name="summary">Overall risk level and key concerns</section>
318
- </output_format>
319
- </agent>""",
320
- "remediation_expert": """<agent role="remediation_expert" version="{schema_version}">
321
- <identity>
322
- <role>Remediation Expert</role>
323
- <expertise>Secure coding, security engineering, fix implementation</expertise>
324
- </identity>
325
-
326
- <goal>
327
- Generate actionable remediation strategies for each vulnerability.
328
- </goal>
329
-
330
- <instructions>
331
- <step>Analyze root cause of each vulnerability</step>
332
- <step>Design fix strategy with code examples</step>
333
- <step>Consider backwards compatibility</step>
334
- <step>Prioritize fixes by effort vs impact</step>
335
- <step>Identify quick wins and long-term improvements</step>
336
- <step>Suggest testing approach for each fix</step>
337
- </instructions>
338
-
339
- <constraints>
340
- <rule>Provide complete, copy-pasteable code fixes</rule>
341
- <rule>Consider side effects and regressions</rule>
342
- <rule>Include before/after code snippets</rule>
343
- <rule>Reference security best practices</rule>
344
- </constraints>
345
-
346
- <remediation_types>
347
- <type>Code Fix - Direct code changes</type>
348
- <type>Configuration - Settings/environment changes</type>
349
- <type>Architecture - Structural improvements</type>
350
- <type>Dependency - Library updates/replacements</type>
351
- <type>Process - Development workflow changes</type>
352
- </remediation_types>
353
-
354
- <output_format>
355
- <section name="remediations">Fix strategies with code examples</section>
356
- <section name="summary">Remediation roadmap by priority</section>
357
- </output_format>
358
- </agent>""",
359
- "compliance_mapper": """<agent role="compliance_mapper" version="{schema_version}">
360
- <identity>
361
- <role>Compliance Mapper</role>
362
- <expertise>Security standards, CWE/CVE mapping, regulatory compliance</expertise>
363
- </identity>
364
-
365
- <goal>
366
- Map vulnerabilities to standards and identify compliance implications.
367
- </goal>
368
-
369
- <instructions>
370
- <step>Map each finding to CWE identifiers</step>
371
- <step>Check for related CVEs in dependencies</step>
372
- <step>Identify OWASP category alignment</step>
373
- <step>Assess regulatory compliance impact (GDPR, HIPAA, PCI-DSS)</step>
374
- <step>Document audit trail requirements</step>
375
- <step>Suggest compliance-focused remediation priorities</step>
376
- </instructions>
377
-
378
- <constraints>
379
- <rule>Use official CWE/CVE identifiers</rule>
380
- <rule>Consider multiple compliance frameworks</rule>
381
- <rule>Highlight mandatory vs recommended fixes</rule>
382
- <rule>Include references to standards</rule>
383
- </constraints>
384
-
385
- <compliance_frameworks>
386
- <framework>OWASP Top 10</framework>
387
- <framework>CWE/SANS Top 25</framework>
388
- <framework>PCI-DSS</framework>
389
- <framework>HIPAA</framework>
390
- <framework>GDPR</framework>
391
- <framework>SOC 2</framework>
392
- </compliance_frameworks>
393
-
394
- <output_format>
395
- <section name="mappings">CWE/CVE mappings for each finding</section>
396
- <section name="compliance">Regulatory implications and requirements</section>
397
- <section name="summary">Compliance status overview</section>
398
- </output_format>
399
- </agent>""",
400
- }
401
-
402
-
403
- class SecurityAuditCrew:
404
- """Multi-agent crew for comprehensive security audits.
405
-
406
- The crew consists of 5 specialized agents:
407
-
408
- 1. **Security Lead** (Coordinator)
409
- - Orchestrates the team
410
- - Prioritizes and deduplicates findings
411
- - Generates executive summary
412
- - Model: Premium tier
413
-
414
- 2. **Vulnerability Hunter** (Security Analyst)
415
- - Scans for OWASP Top 10 vulnerabilities
416
- - Identifies injection, XSS, auth issues
417
- - Model: Capable tier
418
-
419
- 3. **Risk Assessor** (Risk Analyst)
420
- - Scores severity using CVSS methodology
421
- - Assesses blast radius and exploitability
422
- - Model: Capable tier
423
-
424
- 4. **Remediation Expert** (Security Engineer)
425
- - Generates fix strategies with code examples
426
- - Prioritizes based on effort vs. impact
427
- - Model: Premium tier
428
-
429
- 5. **Compliance Mapper** (Compliance Officer)
430
- - Maps findings to CWE, CVE, OWASP
431
- - Identifies compliance implications
432
- - Model: Cheap tier
433
-
434
- Example:
435
- crew = SecurityAuditCrew(api_key="...")
436
- report = await crew.audit("./src")
437
-
438
- # Access findings
439
- for finding in report.critical_findings:
440
- print(f"{finding.title}: {finding.remediation}")
441
-
442
- # Get risk score
443
- print(f"Risk Score: {report.risk_score}/100")
444
-
445
- """
446
-
447
- def __init__(self, config: SecurityAuditConfig | None = None, **kwargs):
448
- """Initialize the Security Audit Crew.
449
-
450
- Args:
451
- config: SecurityAuditConfig or pass individual params as kwargs
452
- **kwargs: Individual config parameters (api_key, provider, etc.)
453
-
454
- """
455
- if config:
456
- self.config = config
457
- else:
458
- self.config = SecurityAuditConfig(**kwargs)
459
-
460
- self._factory: Any = None
461
- self._agents: dict[str, Any] = {}
462
- self._workflow: Any = None
463
- self._graph: Any = None
464
- self._initialized = False
465
-
466
- def _render_xml_prompt(self, template_key: str) -> str:
467
- """Render XML prompt template with config values."""
468
- template = XML_PROMPT_TEMPLATES.get(template_key, "")
469
- return template.format(schema_version=self.config.xml_schema_version)
470
-
471
- def _get_system_prompt(self, agent_key: str, fallback: str) -> str:
472
- """Get system prompt - XML if enabled, fallback otherwise."""
473
- if self.config.xml_prompts_enabled:
474
- return self._render_xml_prompt(agent_key)
475
- return fallback
476
-
477
- async def _initialize(self) -> None:
478
- """Lazy initialization of agents and workflow."""
479
- if self._initialized:
480
- return
481
-
482
- from empathy_llm_toolkit.agent_factory import AgentFactory, Framework
483
-
484
- # Check if CrewAI is available
485
- try:
486
- from empathy_llm_toolkit.agent_factory.adapters.crewai_adapter import _check_crewai
487
-
488
- use_crewai = _check_crewai()
489
- except ImportError:
490
- use_crewai = False
491
-
492
- # Use CrewAI if available, otherwise fall back to Native
493
- framework = Framework.CREWAI if use_crewai else Framework.NATIVE
494
-
495
- self._factory = AgentFactory(
496
- framework=framework,
497
- provider=self.config.provider,
498
- api_key=self.config.api_key,
499
- )
500
-
501
- # Initialize Memory Graph if enabled
502
- if self.config.memory_graph_enabled:
503
- try:
504
- from empathy_os.memory import MemoryGraph
505
-
506
- self._graph = MemoryGraph(path=self.config.memory_graph_path)
507
- except ImportError:
508
- logger.warning("Memory Graph not available, continuing without it")
509
-
510
- # Create the 5 specialized agents
511
- await self._create_agents()
512
-
513
- # Create hierarchical workflow
514
- await self._create_workflow()
515
-
516
- self._initialized = True
517
-
518
- async def _create_agents(self) -> None:
519
- """Create the 5 specialized security agents."""
520
- # 1. Security Lead (Coordinator)
521
- lead_fallback = """You are the Security Lead, a senior security architect.
522
-
523
- Your responsibilities:
524
- 1. Coordinate the security audit team
525
- 2. Prioritize findings based on business impact
526
- 3. Deduplicate overlapping findings
527
- 4. Generate executive summaries
528
- 5. Ensure comprehensive coverage
529
-
530
- You delegate tasks to your team:
531
- - Vulnerability Hunter: Initial scanning and detection
532
- - Risk Assessor: Severity scoring and impact analysis
533
- - Remediation Expert: Fix strategies and code samples
534
- - Compliance Mapper: Regulatory and standards mapping
535
-
536
- Always think strategically about the overall security posture."""
537
-
538
- self._agents["lead"] = self._factory.create_agent(
539
- name="security_lead",
540
- role="coordinator",
541
- description="Senior security architect who orchestrates the security audit team",
542
- system_prompt=self._get_system_prompt("security_lead", lead_fallback),
543
- model_tier=self.config.lead_tier,
544
- memory_graph_enabled=self.config.memory_graph_enabled,
545
- memory_graph_path=self.config.memory_graph_path,
546
- resilience_enabled=self.config.resilience_enabled,
547
- )
548
-
549
- # 2. Vulnerability Hunter (Security Analyst)
550
- hunter_fallback = """You are the Vulnerability Hunter, an expert security analyst.
551
-
552
- Your focus areas:
553
- 1. OWASP Top 10 vulnerabilities
554
- 2. Injection attacks (SQL, NoSQL, OS command, LDAP)
555
- 3. Cross-Site Scripting (XSS) - stored, reflected, DOM
556
- 4. Authentication and session management flaws
557
- 5. Sensitive data exposure
558
- 6. Security misconfigurations
559
- 7. Insecure deserialization
560
- 8. Known vulnerable components
561
-
562
- For each finding, provide:
563
- - Clear description of the vulnerability
564
- - Exact file and line number
565
- - Code snippet showing the issue
566
- - Confidence level (0.0-1.0)
567
-
568
- Be thorough but avoid false positives. When uncertain, note the confidence level."""
569
-
570
- self._agents["hunter"] = self._factory.create_agent(
571
- name="vulnerability_hunter",
572
- role="security",
573
- description="Expert at finding OWASP Top 10 and common vulnerabilities",
574
- system_prompt=self._get_system_prompt("vulnerability_hunter", hunter_fallback),
575
- model_tier=self.config.hunter_tier,
576
- memory_graph_enabled=self.config.memory_graph_enabled,
577
- memory_graph_path=self.config.memory_graph_path,
578
- )
579
-
580
- # 3. Risk Assessor (Risk Analyst)
581
- assessor_fallback = """You are the Risk Assessor, a security risk analyst.
582
-
583
- Your methodology:
584
- 1. Apply CVSS v3.1 scoring methodology
585
- 2. Consider attack vector (Network, Adjacent, Local, Physical)
586
- 3. Assess attack complexity (Low, High)
587
- 4. Evaluate privileges required (None, Low, High)
588
- 5. Determine user interaction requirements
589
- 6. Calculate impact on Confidentiality, Integrity, Availability
590
-
591
- For each vulnerability:
592
- - Assign CVSS base score (0.0-10.0)
593
- - Map to severity level (Critical: 9.0-10.0, High: 7.0-8.9, Medium: 4.0-6.9, Low: 0.1-3.9)
594
- - Assess blast radius (single component, service, system-wide)
595
- - Evaluate exploitability (known exploits, proof of concept, theoretical)
596
- - Consider business context impact
597
-
598
- Be precise and consistent in your scoring methodology."""
599
-
600
- self._agents["assessor"] = self._factory.create_agent(
601
- name="risk_assessor",
602
- role="analyst",
603
- description="Scores vulnerability severity and assesses blast radius",
604
- system_prompt=self._get_system_prompt("risk_assessor", assessor_fallback),
605
- model_tier=self.config.assessor_tier,
606
- memory_graph_enabled=self.config.memory_graph_enabled,
607
- memory_graph_path=self.config.memory_graph_path,
608
- )
609
-
610
- # 4. Remediation Expert (Security Engineer)
611
- remediation_fallback = """You are the Remediation Expert, a senior security engineer.
612
-
613
- For each vulnerability, provide:
614
-
615
- 1. **Immediate Fix**
616
- - Specific code changes required
617
- - Before/after code examples
618
- - Step-by-step implementation guide
619
-
620
- 2. **Defense in Depth**
621
- - Additional protective measures
622
- - Monitoring and alerting recommendations
623
- - Related hardening suggestions
624
-
625
- 3. **Effort Estimation**
626
- - Time to implement (hours/days)
627
- - Required expertise level
628
- - Dependencies or prerequisites
629
-
630
- 4. **Verification**
631
- - How to test the fix
632
- - Regression test suggestions
633
- - Security test cases
634
-
635
- Prioritize fixes by:
636
- - Severity × Exploitability × Effort
637
- - Quick wins (high impact, low effort) first
638
- - Group related fixes for efficiency"""
639
-
640
- self._agents["remediation"] = self._factory.create_agent(
641
- name="remediation_expert",
642
- role="debugger",
643
- description="Generates fix strategies with code examples",
644
- system_prompt=self._get_system_prompt("remediation_expert", remediation_fallback),
645
- model_tier=self.config.remediation_tier,
646
- memory_graph_enabled=self.config.memory_graph_enabled,
647
- memory_graph_path=self.config.memory_graph_path,
648
- )
649
-
650
- # 5. Compliance Mapper (Compliance Officer)
651
- compliance_fallback = """You are the Compliance Mapper, a security compliance specialist.
652
-
653
- Your responsibilities:
654
-
655
- 1. **CWE Mapping**
656
- - Map each finding to relevant CWE IDs
657
- - Provide CWE category and description
658
- - Link to mitre.org references
659
-
660
- 2. **CVE Correlation**
661
- - Check if vulnerability matches known CVEs
662
- - Note CVE IDs when applicable
663
- - Reference NVD entries
664
-
665
- 3. **OWASP Classification**
666
- - Map to OWASP Top 10 categories
667
- - Reference OWASP testing guides
668
- - Note ASVS requirements
669
-
670
- 4. **Compliance Impact**
671
- - PCI-DSS requirements affected
672
- - HIPAA considerations (if healthcare)
673
- - GDPR implications (if personal data)
674
- - SOC2 control mappings
675
-
676
- 5. **Reporting Format**
677
- - Structured output for compliance reports
678
- - Evidence gathering suggestions
679
- - Audit trail recommendations
680
-
681
- Be precise with ID references. Verify CWE/CVE mappings are accurate."""
682
-
683
- self._agents["compliance"] = self._factory.create_agent(
684
- name="compliance_mapper",
685
- role="analyst",
686
- description="Maps findings to CWE, CVE, and compliance standards",
687
- system_prompt=self._get_system_prompt("compliance_mapper", compliance_fallback),
688
- model_tier=self.config.compliance_tier,
689
- memory_graph_enabled=self.config.memory_graph_enabled,
690
- memory_graph_path=self.config.memory_graph_path,
691
- )
692
-
693
- async def _create_workflow(self) -> None:
694
- """Create hierarchical workflow with Security Lead as manager."""
695
- agents = list(self._agents.values())
696
-
697
- self._workflow = self._factory.create_workflow(
698
- name="security_audit_workflow",
699
- agents=agents,
700
- mode="hierarchical", # Security Lead delegates to others
701
- description="Comprehensive security audit with coordinated analysis",
702
- )
703
-
704
- async def audit(
705
- self,
706
- target: str,
707
- context: dict | None = None,
708
- ) -> SecurityReport:
709
- """Perform a comprehensive security audit.
710
-
711
- Args:
712
- target: Path to codebase or repository URL
713
- context: Optional context (previous findings, focus areas, etc.)
714
-
715
- Returns:
716
- SecurityReport with all findings and recommendations
717
-
718
- """
719
- import time
720
-
721
- start_time = time.time()
722
-
723
- # Initialize if needed
724
- await self._initialize()
725
-
726
- context = context or {}
727
- findings: list[SecurityFinding] = []
728
- memory_hits = 0
729
-
730
- # Check Memory Graph for similar past findings
731
- if self._graph and self.config.memory_graph_enabled:
732
- try:
733
- similar = self._graph.find_similar(
734
- {"name": f"security_audit:{target}", "description": target},
735
- threshold=0.4,
736
- limit=10,
737
- )
738
- if similar:
739
- memory_hits = len(similar)
740
- context["similar_audits"] = [
741
- {
742
- "name": node.name,
743
- "findings_count": node.metadata.get("findings_count", 0),
744
- "risk_score": node.metadata.get("risk_score", 0),
745
- }
746
- for node, score in similar
747
- ]
748
- logger.info(f"Found {memory_hits} similar past audits in Memory Graph")
749
- except Exception as e:
750
- logger.warning(f"Error querying Memory Graph: {e}")
751
-
752
- # Build audit task for the crew
753
- audit_task = self._build_audit_task(target, context)
754
-
755
- # Execute the workflow
756
- try:
757
- result = await self._workflow.run(audit_task, initial_state=context)
758
-
759
- # Parse findings from result
760
- findings = self._parse_findings(result)
761
-
762
- except Exception as e:
763
- logger.error(f"Security audit failed: {e}")
764
- # Return partial report with error
765
- return SecurityReport(
766
- target=target,
767
- findings=findings,
768
- summary=f"Audit failed with error: {e}",
769
- audit_duration_seconds=time.time() - start_time,
770
- agents_used=list(self._agents.keys()),
771
- memory_graph_hits=memory_hits,
772
- metadata={"error": str(e)},
773
- )
774
-
775
- # Build the report
776
- duration = time.time() - start_time
777
- report = SecurityReport(
778
- target=target,
779
- findings=findings,
780
- summary=self._generate_summary(findings),
781
- audit_duration_seconds=duration,
782
- agents_used=list(self._agents.keys()),
783
- memory_graph_hits=memory_hits,
784
- metadata={
785
- "scan_depth": self.config.scan_depth,
786
- "framework": str(self._factory.framework.value),
787
- },
788
- )
789
-
790
- # Store findings in Memory Graph
791
- if self._graph and self.config.memory_graph_enabled and findings:
792
- try:
793
- self._graph.add_finding(
794
- "security_audit_crew",
795
- {
796
- "type": "security_audit",
797
- "name": f"audit:{target}",
798
- "description": report.summary,
799
- "findings_count": len(findings),
800
- "risk_score": report.risk_score,
801
- "critical_count": len(report.critical_findings),
802
- },
803
- )
804
- self._graph._save()
805
- except Exception as e:
806
- logger.warning(f"Error storing audit in Memory Graph: {e}")
807
-
808
- return report
809
-
810
- def _build_audit_task(self, target: str, context: dict) -> str:
811
- """Build the audit task description for the crew."""
812
- depth_instructions = {
813
- "quick": "Focus on critical and high severity issues only. Skip detailed analysis.",
814
- "standard": "Cover all OWASP Top 10 categories with moderate depth.",
815
- "thorough": "Perform deep analysis including edge cases and complex attack chains.",
816
- }
817
-
818
- task = f"""Perform a comprehensive security audit of: {target}
819
-
820
- Scan Depth: {self.config.scan_depth}
821
- Instructions: {depth_instructions.get(self.config.scan_depth, depth_instructions["standard"])}
822
-
823
- File Patterns to Include: {", ".join(self.config.include_patterns)}
824
- File Patterns to Exclude: {", ".join(self.config.exclude_patterns)}
825
-
826
- Workflow:
827
- 1. Security Lead coordinates the overall audit strategy
828
- 2. Vulnerability Hunter scans for security issues
829
- 3. Risk Assessor scores each finding by severity
830
- 4. Remediation Expert provides fix strategies
831
- 5. Compliance Mapper adds CWE/CVE references
832
-
833
- For each finding, provide:
834
- - Title and description
835
- - Severity (critical/high/medium/low/info)
836
- - Category (OWASP classification)
837
- - File path and line number
838
- - Code snippet
839
- - Remediation steps
840
- - CWE ID if applicable
841
- - CVSS score
842
-
843
- """
844
- if context.get("similar_audits"):
845
- task += f"""
846
- Previous Similar Audits Found: {len(context["similar_audits"])}
847
- Consider patterns from past audits when analyzing.
848
- """
849
-
850
- if context.get("focus_areas"):
851
- task += f"""
852
- Focus Areas Requested: {", ".join(context["focus_areas"])}
853
- """
854
-
855
- return task
856
-
857
- def _parse_findings(self, result: dict) -> list[SecurityFinding]:
858
- """Parse findings from workflow result."""
859
- findings = []
860
-
861
- output = result.get("output", "")
862
- metadata = result.get("metadata", {})
863
-
864
- # Check for structured findings in metadata
865
- if "findings" in metadata:
866
- for f in metadata["findings"]:
867
- findings.append(self._dict_to_finding(f))
868
- return findings
869
-
870
- # Parse from text output (fallback)
871
- # This is a simplified parser - in production, use structured output
872
- findings = self._parse_text_findings(output)
873
-
874
- return findings
875
-
876
- def _dict_to_finding(self, data: dict) -> SecurityFinding:
877
- """Convert dictionary to SecurityFinding."""
878
- return SecurityFinding(
879
- title=data.get("title", "Untitled Finding"),
880
- description=data.get("description", ""),
881
- severity=Severity(data.get("severity", "medium")),
882
- category=FindingCategory(data.get("category", "other")),
883
- file_path=data.get("file_path"),
884
- line_number=data.get("line_number"),
885
- code_snippet=data.get("code_snippet"),
886
- remediation=data.get("remediation"),
887
- cwe_id=data.get("cwe_id"),
888
- cvss_score=data.get("cvss_score"),
889
- confidence=data.get("confidence", 1.0),
890
- metadata=data.get("metadata", {}),
891
- )
892
-
893
- def _parse_text_findings(self, text: str) -> list[SecurityFinding]:
894
- """Parse findings from unstructured text output."""
895
- findings = []
896
-
897
- # Simple heuristic parsing - look for severity indicators
898
- severity_keywords = {
899
- Severity.CRITICAL: ["critical", "rce", "remote code execution"],
900
- Severity.HIGH: ["high", "injection", "authentication bypass"],
901
- Severity.MEDIUM: ["medium", "xss", "csrf"],
902
- Severity.LOW: ["low", "information disclosure"],
903
- Severity.INFO: ["info", "informational", "best practice"],
904
- }
905
-
906
- category_keywords = {
907
- FindingCategory.INJECTION: ["sql injection", "command injection", "ldap"],
908
- FindingCategory.XSS: ["xss", "cross-site scripting", "script injection"],
909
- FindingCategory.BROKEN_AUTH: ["authentication", "session", "password"],
910
- FindingCategory.SENSITIVE_DATA: ["sensitive data", "encryption", "plaintext"],
911
- FindingCategory.MISCONFIGURATION: ["misconfiguration", "default", "exposed"],
912
- }
913
-
914
- # Split into potential findings (very basic)
915
- lines = text.split("\n")
916
- current_finding = None
917
-
918
- for line in lines:
919
- line_lower = line.lower().strip()
920
-
921
- # Detect severity
922
- detected_severity = Severity.MEDIUM
923
- for sev, keywords in severity_keywords.items():
924
- if any(kw in line_lower for kw in keywords):
925
- detected_severity = sev
926
- break
927
-
928
- # Detect category
929
- detected_category = FindingCategory.OTHER
930
- for cat, keywords in category_keywords.items():
931
- if any(kw in line_lower for kw in keywords):
932
- detected_category = cat
933
- break
934
-
935
- # Simple finding detection
936
- if any(
937
- indicator in line_lower
938
- for indicator in ["vulnerability", "issue", "finding", "detected"]
939
- ):
940
- if current_finding:
941
- findings.append(current_finding)
942
-
943
- current_finding = SecurityFinding(
944
- title=line[:100].strip(),
945
- description=line,
946
- severity=detected_severity,
947
- category=detected_category,
948
- )
949
-
950
- if current_finding:
951
- findings.append(current_finding)
952
-
953
- return findings
954
-
955
- def _generate_summary(self, findings: list[SecurityFinding]) -> str:
956
- """Generate executive summary of findings."""
957
- if not findings:
958
- return "No security issues were identified during the audit."
959
-
960
- critical = sum(1 for f in findings if f.severity == Severity.CRITICAL)
961
- high = sum(1 for f in findings if f.severity == Severity.HIGH)
962
- medium = sum(1 for f in findings if f.severity == Severity.MEDIUM)
963
- low = sum(1 for f in findings if f.severity == Severity.LOW)
964
-
965
- summary_parts = [f"Security audit identified {len(findings)} findings:"]
966
-
967
- if critical > 0:
968
- summary_parts.append(f" - {critical} CRITICAL (immediate action required)")
969
- if high > 0:
970
- summary_parts.append(f" - {high} HIGH (address within 7 days)")
971
- if medium > 0:
972
- summary_parts.append(f" - {medium} MEDIUM (address within 30 days)")
973
- if low > 0:
974
- summary_parts.append(f" - {low} LOW (address in next sprint)")
975
-
976
- # Add top categories
977
- by_category: dict[str, int] = {}
978
- for f in findings:
979
- cat = f.category.value
980
- by_category[cat] = by_category.get(cat, 0) + 1
981
-
982
- if by_category:
983
- top_cats = sorted(by_category.items(), key=lambda x: x[1], reverse=True)[:3]
984
- summary_parts.append("\nTop vulnerability categories:")
985
- for cat, count in top_cats:
986
- summary_parts.append(f" - {cat}: {count}")
987
-
988
- return "\n".join(summary_parts)
989
-
990
- @property
991
- def agents(self) -> dict[str, Any]:
992
- """Get the crew's agents."""
993
- return self._agents
994
-
995
- @property
996
- def is_initialized(self) -> bool:
997
- """Check if crew is initialized."""
998
- return self._initialized
999
-
1000
- async def get_agent_stats(self) -> dict:
1001
- """Get statistics about crew agents."""
1002
- await self._initialize()
1003
-
1004
- agents_dict: dict = {}
1005
- stats: dict = {
1006
- "agent_count": len(self._agents),
1007
- "agents": agents_dict,
1008
- "framework": self._factory.framework.value if self._factory else "unknown",
1009
- "memory_graph_enabled": self.config.memory_graph_enabled,
1010
- }
1011
-
1012
- for name, agent in self._agents.items():
1013
- agents_dict[name] = {
1014
- "role": agent.config.role if hasattr(agent, "config") else "unknown",
1015
- "model_tier": getattr(agent.config, "model_tier", "unknown"),
1016
- }
1017
-
1018
- return stats