empathy-framework 2.4.0__py3-none-any.whl → 3.8.2__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.
- coach_wizards/__init__.py +13 -12
- coach_wizards/accessibility_wizard.py +12 -12
- coach_wizards/api_wizard.py +12 -12
- coach_wizards/base_wizard.py +26 -20
- coach_wizards/cicd_wizard.py +15 -13
- coach_wizards/code_reviewer_README.md +60 -0
- coach_wizards/code_reviewer_wizard.py +180 -0
- coach_wizards/compliance_wizard.py +12 -12
- coach_wizards/database_wizard.py +12 -12
- coach_wizards/debugging_wizard.py +12 -12
- coach_wizards/documentation_wizard.py +12 -12
- coach_wizards/generate_wizards.py +1 -2
- coach_wizards/localization_wizard.py +101 -19
- coach_wizards/migration_wizard.py +12 -12
- coach_wizards/monitoring_wizard.py +12 -12
- coach_wizards/observability_wizard.py +12 -12
- coach_wizards/performance_wizard.py +12 -12
- coach_wizards/prompt_engineering_wizard.py +661 -0
- coach_wizards/refactoring_wizard.py +12 -12
- coach_wizards/scaling_wizard.py +12 -12
- coach_wizards/security_wizard.py +12 -12
- coach_wizards/testing_wizard.py +12 -12
- empathy_framework-3.8.2.dist-info/METADATA +1176 -0
- empathy_framework-3.8.2.dist-info/RECORD +333 -0
- empathy_framework-3.8.2.dist-info/entry_points.txt +22 -0
- {empathy_framework-2.4.0.dist-info → empathy_framework-3.8.2.dist-info}/top_level.txt +5 -1
- empathy_healthcare_plugin/__init__.py +1 -2
- empathy_healthcare_plugin/monitors/__init__.py +9 -0
- empathy_healthcare_plugin/monitors/clinical_protocol_monitor.py +315 -0
- empathy_healthcare_plugin/monitors/monitoring/__init__.py +44 -0
- empathy_healthcare_plugin/monitors/monitoring/protocol_checker.py +300 -0
- empathy_healthcare_plugin/monitors/monitoring/protocol_loader.py +214 -0
- empathy_healthcare_plugin/monitors/monitoring/sensor_parsers.py +306 -0
- empathy_healthcare_plugin/monitors/monitoring/trajectory_analyzer.py +389 -0
- empathy_llm_toolkit/__init__.py +7 -7
- empathy_llm_toolkit/agent_factory/__init__.py +53 -0
- empathy_llm_toolkit/agent_factory/adapters/__init__.py +85 -0
- empathy_llm_toolkit/agent_factory/adapters/autogen_adapter.py +312 -0
- empathy_llm_toolkit/agent_factory/adapters/crewai_adapter.py +454 -0
- empathy_llm_toolkit/agent_factory/adapters/haystack_adapter.py +298 -0
- empathy_llm_toolkit/agent_factory/adapters/langchain_adapter.py +362 -0
- empathy_llm_toolkit/agent_factory/adapters/langgraph_adapter.py +333 -0
- empathy_llm_toolkit/agent_factory/adapters/native.py +228 -0
- empathy_llm_toolkit/agent_factory/adapters/wizard_adapter.py +426 -0
- empathy_llm_toolkit/agent_factory/base.py +305 -0
- empathy_llm_toolkit/agent_factory/crews/__init__.py +67 -0
- empathy_llm_toolkit/agent_factory/crews/code_review.py +1113 -0
- empathy_llm_toolkit/agent_factory/crews/health_check.py +1246 -0
- empathy_llm_toolkit/agent_factory/crews/refactoring.py +1128 -0
- empathy_llm_toolkit/agent_factory/crews/security_audit.py +1018 -0
- empathy_llm_toolkit/agent_factory/decorators.py +286 -0
- empathy_llm_toolkit/agent_factory/factory.py +558 -0
- empathy_llm_toolkit/agent_factory/framework.py +192 -0
- empathy_llm_toolkit/agent_factory/memory_integration.py +324 -0
- empathy_llm_toolkit/agent_factory/resilient.py +320 -0
- empathy_llm_toolkit/claude_memory.py +14 -15
- empathy_llm_toolkit/cli/__init__.py +8 -0
- empathy_llm_toolkit/cli/sync_claude.py +487 -0
- empathy_llm_toolkit/code_health.py +186 -28
- empathy_llm_toolkit/config/__init__.py +29 -0
- empathy_llm_toolkit/config/unified.py +295 -0
- empathy_llm_toolkit/contextual_patterns.py +11 -12
- empathy_llm_toolkit/core.py +168 -53
- empathy_llm_toolkit/git_pattern_extractor.py +17 -13
- empathy_llm_toolkit/levels.py +6 -13
- empathy_llm_toolkit/pattern_confidence.py +14 -18
- empathy_llm_toolkit/pattern_resolver.py +10 -12
- empathy_llm_toolkit/pattern_summary.py +16 -14
- empathy_llm_toolkit/providers.py +194 -28
- empathy_llm_toolkit/routing/__init__.py +32 -0
- empathy_llm_toolkit/routing/model_router.py +362 -0
- empathy_llm_toolkit/security/IMPLEMENTATION_SUMMARY.md +413 -0
- empathy_llm_toolkit/security/PHASE2_COMPLETE.md +384 -0
- empathy_llm_toolkit/security/PHASE2_SECRETS_DETECTOR_COMPLETE.md +271 -0
- empathy_llm_toolkit/security/QUICK_REFERENCE.md +316 -0
- empathy_llm_toolkit/security/README.md +262 -0
- empathy_llm_toolkit/security/__init__.py +62 -0
- empathy_llm_toolkit/security/audit_logger.py +929 -0
- empathy_llm_toolkit/security/audit_logger_example.py +152 -0
- empathy_llm_toolkit/security/pii_scrubber.py +640 -0
- empathy_llm_toolkit/security/secrets_detector.py +678 -0
- empathy_llm_toolkit/security/secrets_detector_example.py +304 -0
- empathy_llm_toolkit/security/secure_memdocs.py +1192 -0
- empathy_llm_toolkit/security/secure_memdocs_example.py +278 -0
- empathy_llm_toolkit/session_status.py +20 -22
- empathy_llm_toolkit/state.py +28 -21
- empathy_llm_toolkit/wizards/__init__.py +38 -0
- empathy_llm_toolkit/wizards/base_wizard.py +364 -0
- empathy_llm_toolkit/wizards/customer_support_wizard.py +190 -0
- empathy_llm_toolkit/wizards/healthcare_wizard.py +362 -0
- empathy_llm_toolkit/wizards/patient_assessment_README.md +64 -0
- empathy_llm_toolkit/wizards/patient_assessment_wizard.py +193 -0
- empathy_llm_toolkit/wizards/technology_wizard.py +194 -0
- empathy_os/__init__.py +125 -84
- empathy_os/adaptive/__init__.py +13 -0
- empathy_os/adaptive/task_complexity.py +127 -0
- empathy_os/{monitoring.py → agent_monitoring.py} +28 -28
- empathy_os/cache/__init__.py +117 -0
- empathy_os/cache/base.py +166 -0
- empathy_os/cache/dependency_manager.py +253 -0
- empathy_os/cache/hash_only.py +248 -0
- empathy_os/cache/hybrid.py +390 -0
- empathy_os/cache/storage.py +282 -0
- empathy_os/cli.py +1516 -70
- empathy_os/cli_unified.py +597 -0
- empathy_os/config/__init__.py +63 -0
- empathy_os/config/xml_config.py +239 -0
- empathy_os/config.py +95 -37
- empathy_os/coordination.py +72 -68
- empathy_os/core.py +94 -107
- empathy_os/cost_tracker.py +74 -55
- empathy_os/dashboard/__init__.py +15 -0
- empathy_os/dashboard/server.py +743 -0
- empathy_os/discovery.py +17 -14
- empathy_os/emergence.py +21 -22
- empathy_os/exceptions.py +18 -30
- empathy_os/feedback_loops.py +30 -33
- empathy_os/levels.py +32 -35
- empathy_os/leverage_points.py +31 -32
- empathy_os/logging_config.py +19 -16
- empathy_os/memory/__init__.py +195 -0
- empathy_os/memory/claude_memory.py +466 -0
- empathy_os/memory/config.py +224 -0
- empathy_os/memory/control_panel.py +1298 -0
- empathy_os/memory/edges.py +179 -0
- empathy_os/memory/graph.py +567 -0
- empathy_os/memory/long_term.py +1194 -0
- empathy_os/memory/nodes.py +179 -0
- empathy_os/memory/redis_bootstrap.py +540 -0
- empathy_os/memory/security/__init__.py +31 -0
- empathy_os/memory/security/audit_logger.py +930 -0
- empathy_os/memory/security/pii_scrubber.py +640 -0
- empathy_os/memory/security/secrets_detector.py +678 -0
- empathy_os/memory/short_term.py +2119 -0
- empathy_os/memory/storage/__init__.py +15 -0
- empathy_os/memory/summary_index.py +583 -0
- empathy_os/memory/unified.py +619 -0
- empathy_os/metrics/__init__.py +12 -0
- empathy_os/metrics/prompt_metrics.py +190 -0
- empathy_os/models/__init__.py +136 -0
- empathy_os/models/__main__.py +13 -0
- empathy_os/models/cli.py +655 -0
- empathy_os/models/empathy_executor.py +354 -0
- empathy_os/models/executor.py +252 -0
- empathy_os/models/fallback.py +671 -0
- empathy_os/models/provider_config.py +563 -0
- empathy_os/models/registry.py +382 -0
- empathy_os/models/tasks.py +302 -0
- empathy_os/models/telemetry.py +548 -0
- empathy_os/models/token_estimator.py +378 -0
- empathy_os/models/validation.py +274 -0
- empathy_os/monitoring/__init__.py +52 -0
- empathy_os/monitoring/alerts.py +23 -0
- empathy_os/monitoring/alerts_cli.py +268 -0
- empathy_os/monitoring/multi_backend.py +271 -0
- empathy_os/monitoring/otel_backend.py +363 -0
- empathy_os/optimization/__init__.py +19 -0
- empathy_os/optimization/context_optimizer.py +272 -0
- empathy_os/pattern_library.py +30 -29
- empathy_os/persistence.py +35 -37
- empathy_os/platform_utils.py +261 -0
- empathy_os/plugins/__init__.py +28 -0
- empathy_os/plugins/base.py +361 -0
- empathy_os/plugins/registry.py +268 -0
- empathy_os/project_index/__init__.py +30 -0
- empathy_os/project_index/cli.py +335 -0
- empathy_os/project_index/crew_integration.py +430 -0
- empathy_os/project_index/index.py +425 -0
- empathy_os/project_index/models.py +501 -0
- empathy_os/project_index/reports.py +473 -0
- empathy_os/project_index/scanner.py +538 -0
- empathy_os/prompts/__init__.py +61 -0
- empathy_os/prompts/config.py +77 -0
- empathy_os/prompts/context.py +177 -0
- empathy_os/prompts/parser.py +285 -0
- empathy_os/prompts/registry.py +313 -0
- empathy_os/prompts/templates.py +208 -0
- empathy_os/redis_config.py +144 -58
- empathy_os/redis_memory.py +79 -77
- empathy_os/resilience/__init__.py +56 -0
- empathy_os/resilience/circuit_breaker.py +256 -0
- empathy_os/resilience/fallback.py +179 -0
- empathy_os/resilience/health.py +300 -0
- empathy_os/resilience/retry.py +209 -0
- empathy_os/resilience/timeout.py +135 -0
- empathy_os/routing/__init__.py +43 -0
- empathy_os/routing/chain_executor.py +433 -0
- empathy_os/routing/classifier.py +217 -0
- empathy_os/routing/smart_router.py +234 -0
- empathy_os/routing/wizard_registry.py +307 -0
- empathy_os/templates.py +19 -14
- empathy_os/trust/__init__.py +28 -0
- empathy_os/trust/circuit_breaker.py +579 -0
- empathy_os/trust_building.py +67 -58
- empathy_os/validation/__init__.py +19 -0
- empathy_os/validation/xml_validator.py +281 -0
- empathy_os/wizard_factory_cli.py +170 -0
- empathy_os/{workflows.py → workflow_commands.py} +131 -37
- empathy_os/workflows/__init__.py +360 -0
- empathy_os/workflows/base.py +1660 -0
- empathy_os/workflows/bug_predict.py +962 -0
- empathy_os/workflows/code_review.py +960 -0
- empathy_os/workflows/code_review_adapters.py +310 -0
- empathy_os/workflows/code_review_pipeline.py +720 -0
- empathy_os/workflows/config.py +600 -0
- empathy_os/workflows/dependency_check.py +648 -0
- empathy_os/workflows/document_gen.py +1069 -0
- empathy_os/workflows/documentation_orchestrator.py +1205 -0
- empathy_os/workflows/health_check.py +679 -0
- empathy_os/workflows/keyboard_shortcuts/__init__.py +39 -0
- empathy_os/workflows/keyboard_shortcuts/generators.py +386 -0
- empathy_os/workflows/keyboard_shortcuts/parsers.py +414 -0
- empathy_os/workflows/keyboard_shortcuts/prompts.py +295 -0
- empathy_os/workflows/keyboard_shortcuts/schema.py +193 -0
- empathy_os/workflows/keyboard_shortcuts/workflow.py +505 -0
- empathy_os/workflows/manage_documentation.py +804 -0
- empathy_os/workflows/new_sample_workflow1.py +146 -0
- empathy_os/workflows/new_sample_workflow1_README.md +150 -0
- empathy_os/workflows/perf_audit.py +687 -0
- empathy_os/workflows/pr_review.py +748 -0
- empathy_os/workflows/progress.py +445 -0
- empathy_os/workflows/progress_server.py +322 -0
- empathy_os/workflows/refactor_plan.py +693 -0
- empathy_os/workflows/release_prep.py +808 -0
- empathy_os/workflows/research_synthesis.py +404 -0
- empathy_os/workflows/secure_release.py +585 -0
- empathy_os/workflows/security_adapters.py +297 -0
- empathy_os/workflows/security_audit.py +1046 -0
- empathy_os/workflows/step_config.py +234 -0
- empathy_os/workflows/test5.py +125 -0
- empathy_os/workflows/test5_README.md +158 -0
- empathy_os/workflows/test_gen.py +1855 -0
- empathy_os/workflows/test_lifecycle.py +526 -0
- empathy_os/workflows/test_maintenance.py +626 -0
- empathy_os/workflows/test_maintenance_cli.py +590 -0
- empathy_os/workflows/test_maintenance_crew.py +821 -0
- empathy_os/workflows/xml_enhanced_crew.py +285 -0
- empathy_software_plugin/__init__.py +1 -2
- empathy_software_plugin/cli/__init__.py +120 -0
- empathy_software_plugin/cli/inspect.py +362 -0
- empathy_software_plugin/cli.py +49 -27
- empathy_software_plugin/plugin.py +4 -8
- empathy_software_plugin/wizards/__init__.py +42 -0
- empathy_software_plugin/wizards/advanced_debugging_wizard.py +392 -0
- empathy_software_plugin/wizards/agent_orchestration_wizard.py +511 -0
- empathy_software_plugin/wizards/ai_collaboration_wizard.py +503 -0
- empathy_software_plugin/wizards/ai_context_wizard.py +441 -0
- empathy_software_plugin/wizards/ai_documentation_wizard.py +503 -0
- empathy_software_plugin/wizards/base_wizard.py +288 -0
- empathy_software_plugin/wizards/book_chapter_wizard.py +519 -0
- empathy_software_plugin/wizards/code_review_wizard.py +606 -0
- empathy_software_plugin/wizards/debugging/__init__.py +50 -0
- empathy_software_plugin/wizards/debugging/bug_risk_analyzer.py +414 -0
- empathy_software_plugin/wizards/debugging/config_loaders.py +442 -0
- empathy_software_plugin/wizards/debugging/fix_applier.py +469 -0
- empathy_software_plugin/wizards/debugging/language_patterns.py +383 -0
- empathy_software_plugin/wizards/debugging/linter_parsers.py +470 -0
- empathy_software_plugin/wizards/debugging/verification.py +369 -0
- empathy_software_plugin/wizards/enhanced_testing_wizard.py +537 -0
- empathy_software_plugin/wizards/memory_enhanced_debugging_wizard.py +816 -0
- empathy_software_plugin/wizards/multi_model_wizard.py +501 -0
- empathy_software_plugin/wizards/pattern_extraction_wizard.py +422 -0
- empathy_software_plugin/wizards/pattern_retriever_wizard.py +400 -0
- empathy_software_plugin/wizards/performance/__init__.py +9 -0
- empathy_software_plugin/wizards/performance/bottleneck_detector.py +221 -0
- empathy_software_plugin/wizards/performance/profiler_parsers.py +278 -0
- empathy_software_plugin/wizards/performance/trajectory_analyzer.py +429 -0
- empathy_software_plugin/wizards/performance_profiling_wizard.py +305 -0
- empathy_software_plugin/wizards/prompt_engineering_wizard.py +425 -0
- empathy_software_plugin/wizards/rag_pattern_wizard.py +461 -0
- empathy_software_plugin/wizards/security/__init__.py +32 -0
- empathy_software_plugin/wizards/security/exploit_analyzer.py +290 -0
- empathy_software_plugin/wizards/security/owasp_patterns.py +241 -0
- empathy_software_plugin/wizards/security/vulnerability_scanner.py +604 -0
- empathy_software_plugin/wizards/security_analysis_wizard.py +322 -0
- empathy_software_plugin/wizards/security_learning_wizard.py +740 -0
- empathy_software_plugin/wizards/tech_debt_wizard.py +726 -0
- empathy_software_plugin/wizards/testing/__init__.py +27 -0
- empathy_software_plugin/wizards/testing/coverage_analyzer.py +459 -0
- empathy_software_plugin/wizards/testing/quality_analyzer.py +531 -0
- empathy_software_plugin/wizards/testing/test_suggester.py +533 -0
- empathy_software_plugin/wizards/testing_wizard.py +274 -0
- hot_reload/README.md +473 -0
- hot_reload/__init__.py +62 -0
- hot_reload/config.py +84 -0
- hot_reload/integration.py +228 -0
- hot_reload/reloader.py +298 -0
- hot_reload/watcher.py +179 -0
- hot_reload/websocket.py +176 -0
- scaffolding/README.md +589 -0
- scaffolding/__init__.py +35 -0
- scaffolding/__main__.py +14 -0
- scaffolding/cli.py +240 -0
- test_generator/__init__.py +38 -0
- test_generator/__main__.py +14 -0
- test_generator/cli.py +226 -0
- test_generator/generator.py +325 -0
- test_generator/risk_analyzer.py +216 -0
- workflow_patterns/__init__.py +33 -0
- workflow_patterns/behavior.py +249 -0
- workflow_patterns/core.py +76 -0
- workflow_patterns/output.py +99 -0
- workflow_patterns/registry.py +255 -0
- workflow_patterns/structural.py +288 -0
- workflow_scaffolding/__init__.py +11 -0
- workflow_scaffolding/__main__.py +12 -0
- workflow_scaffolding/cli.py +206 -0
- workflow_scaffolding/generator.py +265 -0
- agents/code_inspection/patterns/inspection/recurring_B112.json +0 -18
- agents/code_inspection/patterns/inspection/recurring_F541.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_FORMAT.json +0 -25
- agents/code_inspection/patterns/inspection/recurring_bug_20250822_def456.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20250915_abc123.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20251212_3c5b9951.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20251212_97c0f72f.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20251212_a0871d53.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_20251212_a9b6ec41.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_bug_null_001.json +0 -16
- agents/code_inspection/patterns/inspection/recurring_builtin.json +0 -16
- agents/compliance_anticipation_agent.py +0 -1427
- agents/epic_integration_wizard.py +0 -541
- agents/trust_building_behaviors.py +0 -891
- empathy_framework-2.4.0.dist-info/METADATA +0 -485
- empathy_framework-2.4.0.dist-info/RECORD +0 -102
- empathy_framework-2.4.0.dist-info/entry_points.txt +0 -6
- empathy_llm_toolkit/htmlcov/status.json +0 -1
- empathy_llm_toolkit/security/htmlcov/status.json +0 -1
- {empathy_framework-2.4.0.dist-info → empathy_framework-3.8.2.dist-info}/WHEEL +0 -0
- {empathy_framework-2.4.0.dist-info → empathy_framework-3.8.2.dist-info}/licenses/LICENSE +0 -0
empathy_os/core.py
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
"""
|
|
2
|
-
EmpathyOS - Core Implementation
|
|
1
|
+
"""EmpathyOS - Core Implementation
|
|
3
2
|
|
|
4
3
|
The main entry point for the Empathy Framework, providing access to all
|
|
5
4
|
5 empathy levels and system thinking integrations.
|
|
@@ -20,12 +19,7 @@ from .exceptions import ValidationError
|
|
|
20
19
|
from .feedback_loops import FeedbackLoopDetector
|
|
21
20
|
from .leverage_points import LeveragePoint, LeveragePointAnalyzer
|
|
22
21
|
from .memory import Classification, UnifiedMemory
|
|
23
|
-
from .redis_memory import
|
|
24
|
-
AccessTier,
|
|
25
|
-
AgentCredentials,
|
|
26
|
-
RedisShortTermMemory,
|
|
27
|
-
StagedPattern,
|
|
28
|
-
)
|
|
22
|
+
from .redis_memory import AccessTier, AgentCredentials, RedisShortTermMemory, StagedPattern
|
|
29
23
|
|
|
30
24
|
if TYPE_CHECKING:
|
|
31
25
|
from .pattern_library import PatternLibrary
|
|
@@ -33,8 +27,7 @@ if TYPE_CHECKING:
|
|
|
33
27
|
|
|
34
28
|
@dataclass
|
|
35
29
|
class CollaborationState:
|
|
36
|
-
"""
|
|
37
|
-
Stock & Flow model of AI-human collaboration
|
|
30
|
+
"""Stock & Flow model of AI-human collaboration
|
|
38
31
|
|
|
39
32
|
Tracks:
|
|
40
33
|
- Trust level (stock that accumulates/erodes)
|
|
@@ -77,8 +70,7 @@ class CollaborationState:
|
|
|
77
70
|
|
|
78
71
|
|
|
79
72
|
class EmpathyOS:
|
|
80
|
-
"""
|
|
81
|
-
Empathy Operating System for AI-Human Collaboration
|
|
73
|
+
"""Empathy Operating System for AI-Human Collaboration
|
|
82
74
|
|
|
83
75
|
Integrates:
|
|
84
76
|
- 5-level Empathy Maturity Model
|
|
@@ -93,6 +85,7 @@ class EmpathyOS:
|
|
|
93
85
|
>>> empathy = EmpathyOS(user_id="developer_123", target_level=4)
|
|
94
86
|
>>> result = await empathy.level_4_anticipatory(system_trajectory)
|
|
95
87
|
>>> print(result["bottlenecks_predicted"])
|
|
88
|
+
|
|
96
89
|
"""
|
|
97
90
|
|
|
98
91
|
def __init__(
|
|
@@ -105,8 +98,7 @@ class EmpathyOS:
|
|
|
105
98
|
short_term_memory: RedisShortTermMemory | None = None,
|
|
106
99
|
access_tier: AccessTier = AccessTier.CONTRIBUTOR,
|
|
107
100
|
):
|
|
108
|
-
"""
|
|
109
|
-
Initialize EmpathyOS
|
|
101
|
+
"""Initialize EmpathyOS
|
|
110
102
|
|
|
111
103
|
Args:
|
|
112
104
|
user_id: Unique identifier for user/team
|
|
@@ -121,6 +113,7 @@ class EmpathyOS:
|
|
|
121
113
|
staging, and conflict resolution.
|
|
122
114
|
access_tier: Access tier for this agent (Observer, Contributor, Validator, Steward).
|
|
123
115
|
Determines what operations the agent can perform on shared memory.
|
|
116
|
+
|
|
124
117
|
"""
|
|
125
118
|
self.user_id = user_id
|
|
126
119
|
self.target_level = target_level
|
|
@@ -155,8 +148,7 @@ class EmpathyOS:
|
|
|
155
148
|
|
|
156
149
|
@property
|
|
157
150
|
def memory(self) -> UnifiedMemory:
|
|
158
|
-
"""
|
|
159
|
-
Unified memory interface for both short-term and long-term storage.
|
|
151
|
+
"""Unified memory interface for both short-term and long-term storage.
|
|
160
152
|
|
|
161
153
|
Lazily initializes on first access with environment auto-detection.
|
|
162
154
|
|
|
@@ -193,8 +185,7 @@ class EmpathyOS:
|
|
|
193
185
|
classification: Classification | str | None = None,
|
|
194
186
|
auto_classify: bool = True,
|
|
195
187
|
) -> dict | None:
|
|
196
|
-
"""
|
|
197
|
-
Store a pattern in long-term memory with security controls.
|
|
188
|
+
"""Store a pattern in long-term memory with security controls.
|
|
198
189
|
|
|
199
190
|
This is a convenience method that delegates to memory.persist_pattern().
|
|
200
191
|
|
|
@@ -214,6 +205,7 @@ class EmpathyOS:
|
|
|
214
205
|
... pattern_type="algorithm",
|
|
215
206
|
... )
|
|
216
207
|
>>> print(result["classification"]) # "INTERNAL"
|
|
208
|
+
|
|
217
209
|
"""
|
|
218
210
|
return self.memory.persist_pattern(
|
|
219
211
|
content=content,
|
|
@@ -223,8 +215,7 @@ class EmpathyOS:
|
|
|
223
215
|
)
|
|
224
216
|
|
|
225
217
|
def recall_pattern(self, pattern_id: str) -> dict | None:
|
|
226
|
-
"""
|
|
227
|
-
Retrieve a pattern from long-term memory.
|
|
218
|
+
"""Retrieve a pattern from long-term memory.
|
|
228
219
|
|
|
229
220
|
This is a convenience method that delegates to memory.recall_pattern().
|
|
230
221
|
|
|
@@ -237,12 +228,12 @@ class EmpathyOS:
|
|
|
237
228
|
Example:
|
|
238
229
|
>>> pattern = empathy.recall_pattern("pat_123")
|
|
239
230
|
>>> print(pattern["content"])
|
|
231
|
+
|
|
240
232
|
"""
|
|
241
233
|
return self.memory.recall_pattern(pattern_id)
|
|
242
234
|
|
|
243
235
|
def stash(self, key: str, value: Any, ttl_seconds: int = 3600) -> bool:
|
|
244
|
-
"""
|
|
245
|
-
Store data in short-term memory with TTL.
|
|
236
|
+
"""Store data in short-term memory with TTL.
|
|
246
237
|
|
|
247
238
|
This is a convenience method that delegates to memory.stash().
|
|
248
239
|
|
|
@@ -253,12 +244,12 @@ class EmpathyOS:
|
|
|
253
244
|
|
|
254
245
|
Returns:
|
|
255
246
|
True if stored successfully
|
|
247
|
+
|
|
256
248
|
"""
|
|
257
249
|
return self.memory.stash(key, value, ttl_seconds)
|
|
258
250
|
|
|
259
251
|
def retrieve(self, key: str) -> Any:
|
|
260
|
-
"""
|
|
261
|
-
Retrieve data from short-term memory.
|
|
252
|
+
"""Retrieve data from short-term memory.
|
|
262
253
|
|
|
263
254
|
This is a convenience method that delegates to memory.retrieve().
|
|
264
255
|
|
|
@@ -267,24 +258,24 @@ class EmpathyOS:
|
|
|
267
258
|
|
|
268
259
|
Returns:
|
|
269
260
|
Stored data or None
|
|
261
|
+
|
|
270
262
|
"""
|
|
271
263
|
return self.memory.retrieve(key)
|
|
272
264
|
|
|
273
265
|
async def __aenter__(self):
|
|
274
|
-
"""
|
|
275
|
-
Enter async context manager
|
|
266
|
+
"""Enter async context manager
|
|
276
267
|
|
|
277
268
|
Enables usage: async with EmpathyOS(...) as empathy:
|
|
278
269
|
|
|
279
270
|
Returns:
|
|
280
271
|
self: The EmpathyOS instance
|
|
272
|
+
|
|
281
273
|
"""
|
|
282
274
|
# Initialize any async resources here if needed
|
|
283
275
|
return self
|
|
284
276
|
|
|
285
277
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
|
286
|
-
"""
|
|
287
|
-
Exit async context manager
|
|
278
|
+
"""Exit async context manager
|
|
288
279
|
|
|
289
280
|
Performs cleanup when exiting the context:
|
|
290
281
|
- Saves patterns if persistence is enabled
|
|
@@ -298,13 +289,13 @@ class EmpathyOS:
|
|
|
298
289
|
|
|
299
290
|
Returns:
|
|
300
291
|
False to propagate exceptions (standard behavior)
|
|
292
|
+
|
|
301
293
|
"""
|
|
302
294
|
await self._cleanup()
|
|
303
295
|
return False # Don't suppress exceptions
|
|
304
296
|
|
|
305
297
|
async def _cleanup(self):
|
|
306
|
-
"""
|
|
307
|
-
Cleanup resources on context exit
|
|
298
|
+
"""Cleanup resources on context exit
|
|
308
299
|
|
|
309
300
|
**Extension Point**: Override to add custom cleanup logic
|
|
310
301
|
(e.g., save state to database, close connections, send metrics)
|
|
@@ -312,15 +303,13 @@ class EmpathyOS:
|
|
|
312
303
|
# Future: Save patterns to disk
|
|
313
304
|
# Future: Send final metrics
|
|
314
305
|
# Future: Close async connections
|
|
315
|
-
pass
|
|
316
306
|
|
|
317
307
|
# =========================================================================
|
|
318
308
|
# SHARED PATTERN LIBRARY (Multi-Agent Collaboration)
|
|
319
309
|
# =========================================================================
|
|
320
310
|
|
|
321
311
|
def contribute_pattern(self, pattern) -> None:
|
|
322
|
-
"""
|
|
323
|
-
Contribute a discovered pattern to the shared library.
|
|
312
|
+
"""Contribute a discovered pattern to the shared library.
|
|
324
313
|
|
|
325
314
|
Enables Level 5 Systems Empathy: patterns discovered by this agent
|
|
326
315
|
become available to all other agents sharing the same library.
|
|
@@ -343,17 +332,17 @@ class EmpathyOS:
|
|
|
343
332
|
... description="A discovered pattern",
|
|
344
333
|
... )
|
|
345
334
|
>>> agent.contribute_pattern(pattern)
|
|
335
|
+
|
|
346
336
|
"""
|
|
347
337
|
if self.shared_library is None:
|
|
348
338
|
raise RuntimeError(
|
|
349
339
|
"No shared library configured. Pass shared_library to __init__ "
|
|
350
|
-
"to enable multi-agent pattern sharing."
|
|
340
|
+
"to enable multi-agent pattern sharing.",
|
|
351
341
|
)
|
|
352
342
|
self.shared_library.contribute_pattern(self.user_id, pattern)
|
|
353
343
|
|
|
354
344
|
def query_patterns(self, context: dict, **kwargs):
|
|
355
|
-
"""
|
|
356
|
-
Query the shared library for patterns relevant to the current context.
|
|
345
|
+
"""Query the shared library for patterns relevant to the current context.
|
|
357
346
|
|
|
358
347
|
Enables agents to benefit from patterns discovered by other agents
|
|
359
348
|
in the distributed memory network.
|
|
@@ -376,11 +365,12 @@ class EmpathyOS:
|
|
|
376
365
|
... )
|
|
377
366
|
>>> for match in matches:
|
|
378
367
|
... print(f"{match.pattern.name}: {match.relevance_score:.0%}")
|
|
368
|
+
|
|
379
369
|
"""
|
|
380
370
|
if self.shared_library is None:
|
|
381
371
|
raise RuntimeError(
|
|
382
372
|
"No shared library configured. Pass shared_library to __init__ "
|
|
383
|
-
"to enable multi-agent pattern sharing."
|
|
373
|
+
"to enable multi-agent pattern sharing.",
|
|
384
374
|
)
|
|
385
375
|
return self.shared_library.query_patterns(self.user_id, context, **kwargs)
|
|
386
376
|
|
|
@@ -393,8 +383,7 @@ class EmpathyOS:
|
|
|
393
383
|
# =========================================================================
|
|
394
384
|
|
|
395
385
|
async def level_1_reactive(self, user_request: str) -> dict:
|
|
396
|
-
"""
|
|
397
|
-
Level 1: Reactive Empathy
|
|
386
|
+
"""Level 1: Reactive Empathy
|
|
398
387
|
|
|
399
388
|
Respond to explicit request accurately and helpfully.
|
|
400
389
|
No anticipation, no proactive action.
|
|
@@ -407,11 +396,12 @@ class EmpathyOS:
|
|
|
407
396
|
|
|
408
397
|
Raises:
|
|
409
398
|
ValueError: If user_request is empty or not a string
|
|
399
|
+
|
|
410
400
|
"""
|
|
411
401
|
# Input validation
|
|
412
402
|
if not isinstance(user_request, str):
|
|
413
403
|
raise ValidationError(
|
|
414
|
-
f"user_request must be a string, got {type(user_request).__name__}"
|
|
404
|
+
f"user_request must be a string, got {type(user_request).__name__}",
|
|
415
405
|
)
|
|
416
406
|
if not user_request.strip():
|
|
417
407
|
raise ValidationError("user_request cannot be empty")
|
|
@@ -451,8 +441,7 @@ class EmpathyOS:
|
|
|
451
441
|
# =========================================================================
|
|
452
442
|
|
|
453
443
|
async def level_2_guided(self, user_request: str) -> dict:
|
|
454
|
-
"""
|
|
455
|
-
Level 2: Guided Empathy
|
|
444
|
+
"""Level 2: Guided Empathy
|
|
456
445
|
|
|
457
446
|
Use calibrated questions (Voss) to clarify intent before acting.
|
|
458
447
|
Collaborative exploration to uncover hidden needs.
|
|
@@ -465,11 +454,12 @@ class EmpathyOS:
|
|
|
465
454
|
|
|
466
455
|
Raises:
|
|
467
456
|
ValueError: If user_request is empty or not a string
|
|
457
|
+
|
|
468
458
|
"""
|
|
469
459
|
# Input validation
|
|
470
460
|
if not isinstance(user_request, str):
|
|
471
461
|
raise ValidationError(
|
|
472
|
-
f"user_request must be a string, got {type(user_request).__name__}"
|
|
462
|
+
f"user_request must be a string, got {type(user_request).__name__}",
|
|
473
463
|
)
|
|
474
464
|
if not user_request.strip():
|
|
475
465
|
raise ValidationError("user_request cannot be empty")
|
|
@@ -533,8 +523,7 @@ class EmpathyOS:
|
|
|
533
523
|
# =========================================================================
|
|
534
524
|
|
|
535
525
|
async def level_3_proactive(self, context: dict) -> dict:
|
|
536
|
-
"""
|
|
537
|
-
Level 3: Proactive Empathy
|
|
526
|
+
"""Level 3: Proactive Empathy
|
|
538
527
|
|
|
539
528
|
Detect patterns, act on leading indicators.
|
|
540
529
|
Take initiative without being asked.
|
|
@@ -547,6 +536,7 @@ class EmpathyOS:
|
|
|
547
536
|
|
|
548
537
|
Raises:
|
|
549
538
|
ValueError: If context is not a dict or is empty
|
|
539
|
+
|
|
550
540
|
"""
|
|
551
541
|
# Input validation
|
|
552
542
|
if not isinstance(context, dict):
|
|
@@ -615,8 +605,7 @@ class EmpathyOS:
|
|
|
615
605
|
# =========================================================================
|
|
616
606
|
|
|
617
607
|
async def level_4_anticipatory(self, system_trajectory: dict) -> dict:
|
|
618
|
-
"""
|
|
619
|
-
Level 4: Anticipatory Empathy (THE INNOVATION)
|
|
608
|
+
"""Level 4: Anticipatory Empathy (THE INNOVATION)
|
|
620
609
|
|
|
621
610
|
Predict future bottlenecks, design relief in advance.
|
|
622
611
|
|
|
@@ -633,11 +622,12 @@ class EmpathyOS:
|
|
|
633
622
|
|
|
634
623
|
Raises:
|
|
635
624
|
ValueError: If system_trajectory is not a dict or is empty
|
|
625
|
+
|
|
636
626
|
"""
|
|
637
627
|
# Input validation
|
|
638
628
|
if not isinstance(system_trajectory, dict):
|
|
639
629
|
raise ValidationError(
|
|
640
|
-
f"system_trajectory must be a dict, got {type(system_trajectory).__name__}"
|
|
630
|
+
f"system_trajectory must be a dict, got {type(system_trajectory).__name__}",
|
|
641
631
|
)
|
|
642
632
|
if not system_trajectory:
|
|
643
633
|
raise ValidationError("system_trajectory cannot be empty")
|
|
@@ -705,8 +695,7 @@ class EmpathyOS:
|
|
|
705
695
|
# =========================================================================
|
|
706
696
|
|
|
707
697
|
async def level_5_systems(self, domain_context: dict) -> dict:
|
|
708
|
-
"""
|
|
709
|
-
Level 5: Systems Empathy
|
|
698
|
+
"""Level 5: Systems Empathy
|
|
710
699
|
|
|
711
700
|
Build structures that help at scale.
|
|
712
701
|
Design leverage points, frameworks, self-sustaining systems.
|
|
@@ -724,11 +713,12 @@ class EmpathyOS:
|
|
|
724
713
|
|
|
725
714
|
Raises:
|
|
726
715
|
ValueError: If domain_context is not a dict or is empty
|
|
716
|
+
|
|
727
717
|
"""
|
|
728
718
|
# Input validation
|
|
729
719
|
if not isinstance(domain_context, dict):
|
|
730
720
|
raise ValidationError(
|
|
731
|
-
f"domain_context must be a dict, got {type(domain_context).__name__}"
|
|
721
|
+
f"domain_context must be a dict, got {type(domain_context).__name__}",
|
|
732
722
|
)
|
|
733
723
|
if not domain_context:
|
|
734
724
|
raise ValidationError("domain_context cannot be empty")
|
|
@@ -790,8 +780,7 @@ class EmpathyOS:
|
|
|
790
780
|
# =========================================================================
|
|
791
781
|
|
|
792
782
|
async def _process_request(self, request: str) -> dict:
|
|
793
|
-
"""
|
|
794
|
-
Process user request (implement domain logic)
|
|
783
|
+
"""Process user request (implement domain logic)
|
|
795
784
|
|
|
796
785
|
**Extension Point**: Override this method in subclasses to implement
|
|
797
786
|
your specific domain logic for processing user requests.
|
|
@@ -801,13 +790,13 @@ class EmpathyOS:
|
|
|
801
790
|
|
|
802
791
|
Returns:
|
|
803
792
|
Dict with processed result and status
|
|
793
|
+
|
|
804
794
|
"""
|
|
805
795
|
# Placeholder - implement your actual request processing
|
|
806
796
|
return {"processed": request, "status": "success"}
|
|
807
797
|
|
|
808
798
|
async def _ask_calibrated_questions(self, request: str) -> dict:
|
|
809
|
-
"""
|
|
810
|
-
Voss's tactical empathy: Ask calibrated questions
|
|
799
|
+
"""Voss's tactical empathy: Ask calibrated questions
|
|
811
800
|
|
|
812
801
|
**Extension Point**: Override to implement sophisticated clarification
|
|
813
802
|
logic using NLP, LLMs, or domain-specific heuristics.
|
|
@@ -817,6 +806,7 @@ class EmpathyOS:
|
|
|
817
806
|
|
|
818
807
|
Returns:
|
|
819
808
|
Dict with needs_clarification flag and optional questions list
|
|
809
|
+
|
|
820
810
|
"""
|
|
821
811
|
# Simple heuristic - in production, use NLP/LLM
|
|
822
812
|
needs_clarification = any(
|
|
@@ -835,8 +825,7 @@ class EmpathyOS:
|
|
|
835
825
|
return {"needs_clarification": False}
|
|
836
826
|
|
|
837
827
|
def _refine_request(self, original: str, clarification: dict) -> str:
|
|
838
|
-
"""
|
|
839
|
-
Refine request based on clarification responses
|
|
828
|
+
"""Refine request based on clarification responses
|
|
840
829
|
|
|
841
830
|
**Extension Point**: Override to implement domain-specific request refinement
|
|
842
831
|
based on clarification questions and user responses.
|
|
@@ -847,6 +836,7 @@ class EmpathyOS:
|
|
|
847
836
|
|
|
848
837
|
Returns:
|
|
849
838
|
Refined request string with added context
|
|
839
|
+
|
|
850
840
|
"""
|
|
851
841
|
# If no clarification was needed, return original
|
|
852
842
|
if not clarification.get("needs_clarification", False):
|
|
@@ -875,7 +865,7 @@ class EmpathyOS:
|
|
|
875
865
|
"type": "sequential",
|
|
876
866
|
"pattern": "user_always_does_X_before_Y",
|
|
877
867
|
"confidence": 0.85,
|
|
878
|
-
}
|
|
868
|
+
},
|
|
879
869
|
)
|
|
880
870
|
|
|
881
871
|
return patterns
|
|
@@ -888,13 +878,13 @@ class EmpathyOS:
|
|
|
888
878
|
"confidence": pattern["confidence"],
|
|
889
879
|
}
|
|
890
880
|
|
|
891
|
-
def _is_safe_to_execute(self, action: dict) -> bool:
|
|
881
|
+
def _is_safe_to_execute(self, action: dict[str, Any]) -> bool:
|
|
892
882
|
"""Safety check for proactive actions"""
|
|
893
|
-
|
|
883
|
+
confidence: float = action.get("confidence", 0)
|
|
884
|
+
return confidence > 0.8
|
|
894
885
|
|
|
895
886
|
async def _execute_proactive_actions(self, actions: list[dict]) -> list[dict]:
|
|
896
|
-
"""
|
|
897
|
-
Execute proactive actions
|
|
887
|
+
"""Execute proactive actions
|
|
898
888
|
|
|
899
889
|
**Extension Point**: Override to implement actual execution of proactive
|
|
900
890
|
actions in your domain (e.g., file operations, API calls, UI updates).
|
|
@@ -907,13 +897,14 @@ class EmpathyOS:
|
|
|
907
897
|
|
|
908
898
|
Returns:
|
|
909
899
|
List of result dicts with action and success status
|
|
900
|
+
|
|
910
901
|
"""
|
|
911
902
|
results = []
|
|
912
903
|
for action in actions:
|
|
913
904
|
# Validate action has required fields
|
|
914
905
|
if not action.get("action"):
|
|
915
906
|
results.append(
|
|
916
|
-
{"action": action, "success": False, "error": "Missing 'action' field"}
|
|
907
|
+
{"action": action, "success": False, "error": "Missing 'action' field"},
|
|
917
908
|
)
|
|
918
909
|
continue
|
|
919
910
|
|
|
@@ -929,14 +920,13 @@ class EmpathyOS:
|
|
|
929
920
|
|
|
930
921
|
# Simulate successful execution
|
|
931
922
|
results.append(
|
|
932
|
-
{"action": action, "success": True, "executed_at": datetime.now().isoformat()}
|
|
923
|
+
{"action": action, "success": True, "executed_at": datetime.now().isoformat()},
|
|
933
924
|
)
|
|
934
925
|
|
|
935
926
|
return results
|
|
936
927
|
|
|
937
928
|
def _predict_future_bottlenecks(self, trajectory: dict) -> list[dict]:
|
|
938
|
-
"""
|
|
939
|
-
Predict where system will hit friction/overload
|
|
929
|
+
"""Predict where system will hit friction/overload
|
|
940
930
|
|
|
941
931
|
Uses trajectory analysis, domain knowledge, historical patterns
|
|
942
932
|
"""
|
|
@@ -959,14 +949,13 @@ class EmpathyOS:
|
|
|
959
949
|
"current_state": f"{current} features",
|
|
960
950
|
"predicted_state": f"{projected_3mo} features",
|
|
961
951
|
"impact": trajectory.get("impact", "low"),
|
|
962
|
-
}
|
|
952
|
+
},
|
|
963
953
|
)
|
|
964
954
|
|
|
965
955
|
return bottlenecks
|
|
966
956
|
|
|
967
957
|
def _should_anticipate(self, bottleneck: dict) -> bool:
|
|
968
|
-
"""
|
|
969
|
-
Safety checks for Level 4 anticipatory actions
|
|
958
|
+
"""Safety checks for Level 4 anticipatory actions
|
|
970
959
|
|
|
971
960
|
Validates:
|
|
972
961
|
1. Confidence is above threshold
|
|
@@ -993,8 +982,7 @@ class EmpathyOS:
|
|
|
993
982
|
return True
|
|
994
983
|
|
|
995
984
|
def _parse_timeframe_to_days(self, timeframe: str) -> int | None:
|
|
996
|
-
"""
|
|
997
|
-
Parse timeframe string to days
|
|
985
|
+
"""Parse timeframe string to days
|
|
998
986
|
|
|
999
987
|
Examples:
|
|
1000
988
|
"2-3 months" -> 75 (midpoint)
|
|
@@ -1003,6 +991,7 @@ class EmpathyOS:
|
|
|
1003
991
|
|
|
1004
992
|
Returns:
|
|
1005
993
|
Number of days, or None if unparseable
|
|
994
|
+
|
|
1006
995
|
"""
|
|
1007
996
|
import re
|
|
1008
997
|
|
|
@@ -1042,8 +1031,7 @@ class EmpathyOS:
|
|
|
1042
1031
|
}
|
|
1043
1032
|
|
|
1044
1033
|
async def _execute_anticipatory_interventions(self, interventions: list[dict]) -> list[dict]:
|
|
1045
|
-
"""
|
|
1046
|
-
Execute anticipatory interventions
|
|
1034
|
+
"""Execute anticipatory interventions
|
|
1047
1035
|
|
|
1048
1036
|
**Extension Point**: Override to implement actual execution of
|
|
1049
1037
|
anticipatory interventions (e.g., scaling resources, provisioning
|
|
@@ -1057,6 +1045,7 @@ class EmpathyOS:
|
|
|
1057
1045
|
|
|
1058
1046
|
Returns:
|
|
1059
1047
|
List of result dicts with intervention and success status
|
|
1048
|
+
|
|
1060
1049
|
"""
|
|
1061
1050
|
results = []
|
|
1062
1051
|
for intervention in interventions:
|
|
@@ -1067,7 +1056,7 @@ class EmpathyOS:
|
|
|
1067
1056
|
"intervention": intervention,
|
|
1068
1057
|
"success": False,
|
|
1069
1058
|
"error": "Missing 'type' field",
|
|
1070
|
-
}
|
|
1059
|
+
},
|
|
1071
1060
|
)
|
|
1072
1061
|
continue
|
|
1073
1062
|
|
|
@@ -1089,14 +1078,13 @@ class EmpathyOS:
|
|
|
1089
1078
|
"success": True,
|
|
1090
1079
|
"executed_at": datetime.now().isoformat(),
|
|
1091
1080
|
"status": "intervention_deployed",
|
|
1092
|
-
}
|
|
1081
|
+
},
|
|
1093
1082
|
)
|
|
1094
1083
|
|
|
1095
1084
|
return results
|
|
1096
1085
|
|
|
1097
1086
|
def _identify_problem_classes(self, domain_context: dict) -> list[dict]:
|
|
1098
|
-
"""
|
|
1099
|
-
Identify recurring problem classes (not individual instances)
|
|
1087
|
+
"""Identify recurring problem classes (not individual instances)
|
|
1100
1088
|
|
|
1101
1089
|
Use "Rule of Three":
|
|
1102
1090
|
- Occurred at least 3 times
|
|
@@ -1112,7 +1100,7 @@ class EmpathyOS:
|
|
|
1112
1100
|
"class": "documentation_burden",
|
|
1113
1101
|
"instances": domain_context["instances"],
|
|
1114
1102
|
"frequency": "every_new_feature",
|
|
1115
|
-
}
|
|
1103
|
+
},
|
|
1116
1104
|
)
|
|
1117
1105
|
|
|
1118
1106
|
return problem_classes
|
|
@@ -1128,8 +1116,7 @@ class EmpathyOS:
|
|
|
1128
1116
|
}
|
|
1129
1117
|
|
|
1130
1118
|
async def _implement_frameworks(self, frameworks: list[dict]) -> list[dict]:
|
|
1131
|
-
"""
|
|
1132
|
-
Implement designed frameworks
|
|
1119
|
+
"""Implement designed frameworks
|
|
1133
1120
|
|
|
1134
1121
|
**Extension Point**: Override to implement actual framework deployment
|
|
1135
1122
|
(e.g., generating code templates, creating CI/CD pipelines, deploying
|
|
@@ -1143,13 +1130,14 @@ class EmpathyOS:
|
|
|
1143
1130
|
|
|
1144
1131
|
Returns:
|
|
1145
1132
|
List of result dicts with framework and deployed status
|
|
1133
|
+
|
|
1146
1134
|
"""
|
|
1147
1135
|
results = []
|
|
1148
1136
|
for framework in frameworks:
|
|
1149
1137
|
# Validate framework has required fields
|
|
1150
1138
|
if not framework.get("name"):
|
|
1151
1139
|
results.append(
|
|
1152
|
-
{"framework": framework, "deployed": False, "error": "Missing 'name' field"}
|
|
1140
|
+
{"framework": framework, "deployed": False, "error": "Missing 'name' field"},
|
|
1153
1141
|
)
|
|
1154
1142
|
continue
|
|
1155
1143
|
|
|
@@ -1172,7 +1160,7 @@ class EmpathyOS:
|
|
|
1172
1160
|
"deployed_at": datetime.now().isoformat(),
|
|
1173
1161
|
"status": "framework_active",
|
|
1174
1162
|
"impact_scope": "system_wide",
|
|
1175
|
-
}
|
|
1163
|
+
},
|
|
1176
1164
|
)
|
|
1177
1165
|
|
|
1178
1166
|
return results
|
|
@@ -1182,9 +1170,7 @@ class EmpathyOS:
|
|
|
1182
1170
|
# =========================================================================
|
|
1183
1171
|
|
|
1184
1172
|
def monitor_feedback_loops(self, session_history: list) -> dict:
|
|
1185
|
-
"""
|
|
1186
|
-
Detect and manage feedback loops in collaboration
|
|
1187
|
-
"""
|
|
1173
|
+
"""Detect and manage feedback loops in collaboration"""
|
|
1188
1174
|
active_loops = self.feedback_detector.detect_active_loop(session_history)
|
|
1189
1175
|
|
|
1190
1176
|
# Take action based on loop type
|
|
@@ -1192,7 +1178,7 @@ class EmpathyOS:
|
|
|
1192
1178
|
# URGENT: Break vicious cycle
|
|
1193
1179
|
return self._break_trust_erosion_loop()
|
|
1194
1180
|
|
|
1195
|
-
|
|
1181
|
+
if active_loops.get("dominant_loop") == "R1_trust_building":
|
|
1196
1182
|
# MAINTAIN: Keep virtuous cycle going
|
|
1197
1183
|
return self._maintain_trust_building_loop()
|
|
1198
1184
|
|
|
@@ -1262,8 +1248,7 @@ class EmpathyOS:
|
|
|
1262
1248
|
return self._session_id
|
|
1263
1249
|
|
|
1264
1250
|
def stage_pattern(self, pattern: StagedPattern) -> bool:
|
|
1265
|
-
"""
|
|
1266
|
-
Stage a discovered pattern for validation.
|
|
1251
|
+
"""Stage a discovered pattern for validation.
|
|
1267
1252
|
|
|
1268
1253
|
Patterns are held in a staging area until a Validator promotes them
|
|
1269
1254
|
to the active pattern library. This implements the trust-but-verify
|
|
@@ -1290,17 +1275,17 @@ class EmpathyOS:
|
|
|
1290
1275
|
... confidence=0.85,
|
|
1291
1276
|
... )
|
|
1292
1277
|
>>> empathy.stage_pattern(pattern)
|
|
1278
|
+
|
|
1293
1279
|
"""
|
|
1294
1280
|
if self.short_term_memory is None:
|
|
1295
1281
|
raise RuntimeError(
|
|
1296
1282
|
"No short-term memory configured. Pass short_term_memory to __init__ "
|
|
1297
|
-
"to enable pattern staging."
|
|
1283
|
+
"to enable pattern staging.",
|
|
1298
1284
|
)
|
|
1299
1285
|
return self.short_term_memory.stage_pattern(pattern, self.credentials)
|
|
1300
1286
|
|
|
1301
1287
|
def get_staged_patterns(self) -> list[StagedPattern]:
|
|
1302
|
-
"""
|
|
1303
|
-
Get all patterns currently in staging.
|
|
1288
|
+
"""Get all patterns currently in staging.
|
|
1304
1289
|
|
|
1305
1290
|
Returns patterns staged by any agent that are awaiting validation.
|
|
1306
1291
|
Validators use this to review and promote/reject patterns.
|
|
@@ -1310,11 +1295,12 @@ class EmpathyOS:
|
|
|
1310
1295
|
|
|
1311
1296
|
Raises:
|
|
1312
1297
|
RuntimeError: If no short-term memory configured
|
|
1298
|
+
|
|
1313
1299
|
"""
|
|
1314
1300
|
if self.short_term_memory is None:
|
|
1315
1301
|
raise RuntimeError(
|
|
1316
1302
|
"No short-term memory configured. Pass short_term_memory to __init__ "
|
|
1317
|
-
"to enable pattern staging."
|
|
1303
|
+
"to enable pattern staging.",
|
|
1318
1304
|
)
|
|
1319
1305
|
return self.short_term_memory.list_staged_patterns(self.credentials)
|
|
1320
1306
|
|
|
@@ -1324,8 +1310,7 @@ class EmpathyOS:
|
|
|
1324
1310
|
data: dict,
|
|
1325
1311
|
target_agent: str | None = None,
|
|
1326
1312
|
) -> bool:
|
|
1327
|
-
"""
|
|
1328
|
-
Send a coordination signal to other agents.
|
|
1313
|
+
"""Send a coordination signal to other agents.
|
|
1329
1314
|
|
|
1330
1315
|
Use signals for real-time coordination:
|
|
1331
1316
|
- Notify completion of tasks
|
|
@@ -1352,11 +1337,12 @@ class EmpathyOS:
|
|
|
1352
1337
|
... )
|
|
1353
1338
|
>>> # Broadcast to all
|
|
1354
1339
|
>>> empathy.send_signal("status_update", {"phase": "testing"})
|
|
1340
|
+
|
|
1355
1341
|
"""
|
|
1356
1342
|
if self.short_term_memory is None:
|
|
1357
1343
|
raise RuntimeError(
|
|
1358
1344
|
"No short-term memory configured. Pass short_term_memory to __init__ "
|
|
1359
|
-
"to enable coordination signals."
|
|
1345
|
+
"to enable coordination signals.",
|
|
1360
1346
|
)
|
|
1361
1347
|
return self.short_term_memory.send_signal(
|
|
1362
1348
|
signal_type=signal_type,
|
|
@@ -1366,8 +1352,7 @@ class EmpathyOS:
|
|
|
1366
1352
|
)
|
|
1367
1353
|
|
|
1368
1354
|
def receive_signals(self, signal_type: str | None = None) -> list[dict]:
|
|
1369
|
-
"""
|
|
1370
|
-
Receive coordination signals from other agents.
|
|
1355
|
+
"""Receive coordination signals from other agents.
|
|
1371
1356
|
|
|
1372
1357
|
Returns signals targeted at this agent or broadcast signals.
|
|
1373
1358
|
Signals expire after 5 minutes (TTL).
|
|
@@ -1385,17 +1370,17 @@ class EmpathyOS:
|
|
|
1385
1370
|
>>> signals = empathy.receive_signals("analysis_complete")
|
|
1386
1371
|
>>> for sig in signals:
|
|
1387
1372
|
... print(f"From {sig['sender']}: {sig['data']}")
|
|
1373
|
+
|
|
1388
1374
|
"""
|
|
1389
1375
|
if self.short_term_memory is None:
|
|
1390
1376
|
raise RuntimeError(
|
|
1391
1377
|
"No short-term memory configured. Pass short_term_memory to __init__ "
|
|
1392
|
-
"to enable coordination signals."
|
|
1378
|
+
"to enable coordination signals.",
|
|
1393
1379
|
)
|
|
1394
1380
|
return self.short_term_memory.receive_signals(self.credentials, signal_type=signal_type)
|
|
1395
1381
|
|
|
1396
1382
|
def persist_collaboration_state(self) -> bool:
|
|
1397
|
-
"""
|
|
1398
|
-
Persist current collaboration state to short-term memory.
|
|
1383
|
+
"""Persist current collaboration state to short-term memory.
|
|
1399
1384
|
|
|
1400
1385
|
Call periodically to save state that can be recovered if the agent
|
|
1401
1386
|
restarts. State expires after 30 minutes by default.
|
|
@@ -1405,11 +1390,12 @@ class EmpathyOS:
|
|
|
1405
1390
|
|
|
1406
1391
|
Raises:
|
|
1407
1392
|
RuntimeError: If no short-term memory configured
|
|
1393
|
+
|
|
1408
1394
|
"""
|
|
1409
1395
|
if self.short_term_memory is None:
|
|
1410
1396
|
raise RuntimeError(
|
|
1411
1397
|
"No short-term memory configured. Pass short_term_memory to __init__ "
|
|
1412
|
-
"to enable state persistence."
|
|
1398
|
+
"to enable state persistence.",
|
|
1413
1399
|
)
|
|
1414
1400
|
|
|
1415
1401
|
state_data = {
|
|
@@ -1428,8 +1414,7 @@ class EmpathyOS:
|
|
|
1428
1414
|
)
|
|
1429
1415
|
|
|
1430
1416
|
def restore_collaboration_state(self, session_id: str | None = None) -> bool:
|
|
1431
|
-
"""
|
|
1432
|
-
Restore collaboration state from short-term memory.
|
|
1417
|
+
"""Restore collaboration state from short-term memory.
|
|
1433
1418
|
|
|
1434
1419
|
Use to recover state after agent restart or to continue a previous
|
|
1435
1420
|
session.
|
|
@@ -1442,11 +1427,12 @@ class EmpathyOS:
|
|
|
1442
1427
|
|
|
1443
1428
|
Raises:
|
|
1444
1429
|
RuntimeError: If no short-term memory configured
|
|
1430
|
+
|
|
1445
1431
|
"""
|
|
1446
1432
|
if self.short_term_memory is None:
|
|
1447
1433
|
raise RuntimeError(
|
|
1448
1434
|
"No short-term memory configured. Pass short_term_memory to __init__ "
|
|
1449
|
-
"to enable state persistence."
|
|
1435
|
+
"to enable state persistence.",
|
|
1450
1436
|
)
|
|
1451
1437
|
|
|
1452
1438
|
sid = session_id or self.session_id
|
|
@@ -1461,7 +1447,8 @@ class EmpathyOS:
|
|
|
1461
1447
|
# Restore state
|
|
1462
1448
|
self.collaboration_state.trust_level = state_data.get("trust_level", 0.5)
|
|
1463
1449
|
self.collaboration_state.successful_interventions = state_data.get(
|
|
1464
|
-
"successful_interventions",
|
|
1450
|
+
"successful_interventions",
|
|
1451
|
+
0,
|
|
1465
1452
|
)
|
|
1466
1453
|
self.collaboration_state.failed_interventions = state_data.get("failed_interventions", 0)
|
|
1467
1454
|
self.collaboration_state.total_interactions = state_data.get("total_interactions", 0)
|
|
@@ -1480,11 +1467,11 @@ class EmpathyOS:
|
|
|
1480
1467
|
return True
|
|
1481
1468
|
|
|
1482
1469
|
def get_memory_stats(self) -> dict | None:
|
|
1483
|
-
"""
|
|
1484
|
-
Get statistics about the short-term memory system.
|
|
1470
|
+
"""Get statistics about the short-term memory system.
|
|
1485
1471
|
|
|
1486
1472
|
Returns:
|
|
1487
1473
|
Dict with memory usage, key counts, mode, or None if not configured
|
|
1474
|
+
|
|
1488
1475
|
"""
|
|
1489
1476
|
if self.short_term_memory is None:
|
|
1490
1477
|
return None
|