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
|
@@ -1,891 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Trust-Building Behaviors for Level 4 Anticipatory Agents
|
|
3
|
-
|
|
4
|
-
Implements team dynamics that build trust through anticipatory actions:
|
|
5
|
-
- Pre-format data for handoffs (reduce cognitive load for next person)
|
|
6
|
-
- Clarify confusing instructions before execution (prevent wasted effort)
|
|
7
|
-
- Volunteer structure during stress (not pep talks, actual scaffolding)
|
|
8
|
-
- Proactively offer help when teammates are struggling
|
|
9
|
-
|
|
10
|
-
These behaviors demonstrate Level 4 Anticipatory Empathy by:
|
|
11
|
-
1. Predicting friction points (handoffs, confusion, stress, overload)
|
|
12
|
-
2. Acting without being asked (but without overstepping)
|
|
13
|
-
3. Providing structural relief (not just emotional support)
|
|
14
|
-
4. Building trust through consistent, helpful actions
|
|
15
|
-
|
|
16
|
-
Copyright 2025 Smart AI Memory, LLC
|
|
17
|
-
Licensed under Fair Source 0.9
|
|
18
|
-
"""
|
|
19
|
-
|
|
20
|
-
import logging
|
|
21
|
-
from datetime import datetime
|
|
22
|
-
|
|
23
|
-
logger = logging.getLogger(__name__)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
class TrustBuildingBehaviors:
|
|
27
|
-
"""
|
|
28
|
-
Level 4 Anticipatory trust-building behaviors
|
|
29
|
-
|
|
30
|
-
Philosophy: Trust is earned through consistent, helpful actions that
|
|
31
|
-
demonstrate understanding of team dynamics and proactive problem-solving.
|
|
32
|
-
"""
|
|
33
|
-
|
|
34
|
-
@staticmethod
|
|
35
|
-
def pre_format_for_handoff(data: dict, next_person_role: str, context: str) -> dict:
|
|
36
|
-
"""
|
|
37
|
-
Scenario: Handoff Risk
|
|
38
|
-
Anticipatory Response: Pre-format the data so next person doesn't waste time
|
|
39
|
-
|
|
40
|
-
Example:
|
|
41
|
-
- Raw compliance data → Formatted summary for charge nurse
|
|
42
|
-
- Gap list → Prioritized action items with assignments
|
|
43
|
-
- Assessment results → Executive dashboard for manager
|
|
44
|
-
|
|
45
|
-
Trust Built:
|
|
46
|
-
- "This AI understands my workflow"
|
|
47
|
-
- "I don't have to translate data myself"
|
|
48
|
-
- "My time is valued"
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
logger.info(f"Pre-formatting data for handoff to {next_person_role}")
|
|
52
|
-
|
|
53
|
-
# Determine format based on recipient role
|
|
54
|
-
if next_person_role == "charge_nurse":
|
|
55
|
-
# Charge nurses need: Quick scan, action items, patient IDs
|
|
56
|
-
formatted = {
|
|
57
|
-
"format": "action_oriented",
|
|
58
|
-
"summary": {
|
|
59
|
-
"critical_actions": [
|
|
60
|
-
item
|
|
61
|
-
for item in data.get("action_items", [])
|
|
62
|
-
if item.get("severity") == "critical"
|
|
63
|
-
],
|
|
64
|
-
"high_priority_actions": [
|
|
65
|
-
item
|
|
66
|
-
for item in data.get("action_items", [])
|
|
67
|
-
if item.get("severity") == "high"
|
|
68
|
-
],
|
|
69
|
-
"patient_ids_affected": list(
|
|
70
|
-
{
|
|
71
|
-
pid
|
|
72
|
-
for gap in data.get("compliance_gaps", [])
|
|
73
|
-
for pid in gap.get("patient_ids", [])
|
|
74
|
-
}
|
|
75
|
-
),
|
|
76
|
-
"estimated_total_time": sum(
|
|
77
|
-
int(item.get("estimated_time", "0 minutes").split()[0])
|
|
78
|
-
for item in data.get("action_items", [])
|
|
79
|
-
if item.get("estimated_time", "").split()[0].isdigit()
|
|
80
|
-
),
|
|
81
|
-
},
|
|
82
|
-
"quick_scan_view": {
|
|
83
|
-
"red_flags": [
|
|
84
|
-
gap
|
|
85
|
-
for gap in data.get("compliance_gaps", [])
|
|
86
|
-
if gap.get("severity") in ["critical", "high"]
|
|
87
|
-
],
|
|
88
|
-
"compliance_percentage": data.get("compliance_percentage", 0),
|
|
89
|
-
"days_until_audit": data.get("days_until_audit", 0),
|
|
90
|
-
},
|
|
91
|
-
"reasoning": (
|
|
92
|
-
"Pre-formatted for charge nurse workflow: "
|
|
93
|
-
"critical items first, patient IDs for chart review, "
|
|
94
|
-
"time estimate for shift planning"
|
|
95
|
-
),
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
elif next_person_role == "nurse_manager":
|
|
99
|
-
# Managers need: Trends, resource allocation, escalation path
|
|
100
|
-
formatted = {
|
|
101
|
-
"format": "strategic_overview",
|
|
102
|
-
"summary": {
|
|
103
|
-
"compliance_trend": data.get("compliance_trend", "unknown"),
|
|
104
|
-
"category_performance": data.get("category_scores", {}),
|
|
105
|
-
"resource_needs": {
|
|
106
|
-
"staff_time_required": f"{data.get('estimated_total_time', 0)} minutes",
|
|
107
|
-
"external_resources": [
|
|
108
|
-
(
|
|
109
|
-
"Provider orders"
|
|
110
|
-
if any(
|
|
111
|
-
"provider" in item.get("assignee", "")
|
|
112
|
-
for item in data.get("action_items", [])
|
|
113
|
-
)
|
|
114
|
-
else None
|
|
115
|
-
)
|
|
116
|
-
],
|
|
117
|
-
},
|
|
118
|
-
"escalation_needed": len(
|
|
119
|
-
[
|
|
120
|
-
g
|
|
121
|
-
for g in data.get("compliance_gaps", [])
|
|
122
|
-
if g.get("severity") == "critical"
|
|
123
|
-
]
|
|
124
|
-
)
|
|
125
|
-
> 2,
|
|
126
|
-
},
|
|
127
|
-
"reasoning": (
|
|
128
|
-
"Pre-formatted for manager workflow: "
|
|
129
|
-
"strategic view, resource allocation, escalation triggers"
|
|
130
|
-
),
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
elif next_person_role == "cno":
|
|
134
|
-
# CNO needs: Executive summary, risk assessment, board reporting
|
|
135
|
-
formatted = {
|
|
136
|
-
"format": "executive_summary",
|
|
137
|
-
"summary": {
|
|
138
|
-
"audit_readiness_score": data.get("audit_readiness_score", 0),
|
|
139
|
-
"risk_level": calculate_risk_level(data),
|
|
140
|
-
"board_talking_points": [
|
|
141
|
-
f"Overall compliance: {data.get('compliance_percentage', 0):.1f}%",
|
|
142
|
-
f"Audit in {data.get('days_until_audit', 0)} days",
|
|
143
|
-
f"{len(data.get('compliance_gaps', []))} gaps identified proactively",
|
|
144
|
-
"Remediation plan in place (target: 2 weeks before audit)",
|
|
145
|
-
],
|
|
146
|
-
"legal_risk_summary": {
|
|
147
|
-
"high_risk_items": len(
|
|
148
|
-
[
|
|
149
|
-
g
|
|
150
|
-
for g in data.get("compliance_gaps", [])
|
|
151
|
-
if g.get("legal_risk") == "high"
|
|
152
|
-
]
|
|
153
|
-
),
|
|
154
|
-
"can_fix_before_audit": all(
|
|
155
|
-
g.get("can_fix_retroactively", True)
|
|
156
|
-
for g in data.get("compliance_gaps", [])
|
|
157
|
-
),
|
|
158
|
-
},
|
|
159
|
-
},
|
|
160
|
-
"reasoning": (
|
|
161
|
-
"Pre-formatted for executive workflow: "
|
|
162
|
-
"board-ready summary, legal risk assessment, organizational impact"
|
|
163
|
-
),
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
else:
|
|
167
|
-
# Default: Structured but general format
|
|
168
|
-
formatted = {
|
|
169
|
-
"format": "general_structured",
|
|
170
|
-
"summary": data,
|
|
171
|
-
"reasoning": "General structured format (no role-specific optimization)",
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
# Add metadata
|
|
175
|
-
formatted["handoff_metadata"] = {
|
|
176
|
-
"formatted_for": next_person_role,
|
|
177
|
-
"formatted_at": datetime.now().isoformat(),
|
|
178
|
-
"context": context,
|
|
179
|
-
"trust_building_behavior": "pre_format_for_handoff",
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
logger.info(f"Data formatted in {formatted['format']} style for {next_person_role}")
|
|
183
|
-
|
|
184
|
-
return formatted
|
|
185
|
-
|
|
186
|
-
@staticmethod
|
|
187
|
-
def clarify_before_execution(
|
|
188
|
-
instruction: str, context: dict, confidence_threshold: float = 0.8
|
|
189
|
-
) -> dict:
|
|
190
|
-
"""
|
|
191
|
-
Scenario: Confusing Instructions
|
|
192
|
-
Anticipatory Response: Clarify and summarize before execution
|
|
193
|
-
|
|
194
|
-
Example:
|
|
195
|
-
- Vague request → Ask calibrated questions (Voss's tactical empathy)
|
|
196
|
-
- Ambiguous scope → Propose interpretation, request confirmation
|
|
197
|
-
- Missing context → Surface assumptions, verify before proceeding
|
|
198
|
-
|
|
199
|
-
Trust Built:
|
|
200
|
-
- "This AI doesn't waste my time on wrong implementations"
|
|
201
|
-
- "It's safe to give rough instructions"
|
|
202
|
-
- "We're collaborating, not just transacting"
|
|
203
|
-
"""
|
|
204
|
-
|
|
205
|
-
logger.info(f"Analyzing instruction clarity: '{instruction[:50]}...'")
|
|
206
|
-
|
|
207
|
-
# Analyze instruction for ambiguity
|
|
208
|
-
ambiguity_signals = detect_ambiguity(instruction, context)
|
|
209
|
-
|
|
210
|
-
if ambiguity_signals["clarity_score"] >= confidence_threshold:
|
|
211
|
-
# Clear instruction, proceed
|
|
212
|
-
return {
|
|
213
|
-
"action": "proceed",
|
|
214
|
-
"clarification_needed": False,
|
|
215
|
-
"interpretation": instruction,
|
|
216
|
-
"confidence": ambiguity_signals["clarity_score"],
|
|
217
|
-
"reasoning": "Instruction is clear, proceeding with execution",
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
else:
|
|
221
|
-
# Ambiguous instruction, clarify first
|
|
222
|
-
return {
|
|
223
|
-
"action": "clarify_first",
|
|
224
|
-
"clarification_needed": True,
|
|
225
|
-
"ambiguities_detected": ambiguity_signals["ambiguities"],
|
|
226
|
-
"proposed_interpretation": ambiguity_signals["best_guess"],
|
|
227
|
-
"clarifying_questions": ambiguity_signals["questions"],
|
|
228
|
-
"confidence": ambiguity_signals["clarity_score"],
|
|
229
|
-
"reasoning": (
|
|
230
|
-
f"Instruction clarity score: {ambiguity_signals['clarity_score']:.0%} "
|
|
231
|
-
f"(threshold: {confidence_threshold:.0%}). "
|
|
232
|
-
"Clarifying before execution to prevent wasted effort."
|
|
233
|
-
),
|
|
234
|
-
"message_to_user": compose_clarification_request(instruction, ambiguity_signals),
|
|
235
|
-
"trust_building_behavior": "clarify_before_execution",
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
@staticmethod
|
|
239
|
-
def volunteer_structure_during_stress(team_state: dict, stress_indicators: dict) -> dict | None:
|
|
240
|
-
"""
|
|
241
|
-
Scenario: Team Stress Rising
|
|
242
|
-
Anticipatory Response: Volunteer structure, not pep talks
|
|
243
|
-
|
|
244
|
-
Example:
|
|
245
|
-
- Audit in 2 weeks, multiple critical gaps → Propose prioritized timeline
|
|
246
|
-
- Overlapping deadlines → Suggest task delegation framework
|
|
247
|
-
- Information overload → Create structured dashboard/checklist
|
|
248
|
-
|
|
249
|
-
Trust Built:
|
|
250
|
-
- "This AI understands real problems"
|
|
251
|
-
- "Structure relieves stress more than encouragement"
|
|
252
|
-
- "Practical help, not performative support"
|
|
253
|
-
"""
|
|
254
|
-
|
|
255
|
-
logger.info("Analyzing team stress indicators")
|
|
256
|
-
|
|
257
|
-
# Detect stress level
|
|
258
|
-
stress_level = calculate_stress_level(stress_indicators)
|
|
259
|
-
|
|
260
|
-
if stress_level < 0.6:
|
|
261
|
-
# No significant stress, no intervention needed
|
|
262
|
-
return None
|
|
263
|
-
|
|
264
|
-
# Identify stress source
|
|
265
|
-
stress_sources = identify_stress_sources(team_state, stress_indicators)
|
|
266
|
-
|
|
267
|
-
# Design structural intervention (not emotional support)
|
|
268
|
-
structural_interventions = []
|
|
269
|
-
|
|
270
|
-
for source in stress_sources:
|
|
271
|
-
if source["type"] == "time_pressure":
|
|
272
|
-
# Volunteer: Prioritized timeline
|
|
273
|
-
structural_interventions.append(
|
|
274
|
-
{
|
|
275
|
-
"intervention_type": "timeline_structure",
|
|
276
|
-
"structure": create_prioritized_timeline(team_state, source),
|
|
277
|
-
"benefit": "Clarifies what must be done when → reduces decision paralysis",
|
|
278
|
-
"not_this": "⛔ Pep talk: 'You can do this! Stay positive!'",
|
|
279
|
-
}
|
|
280
|
-
)
|
|
281
|
-
|
|
282
|
-
elif source["type"] == "task_overload":
|
|
283
|
-
# Volunteer: Task delegation framework
|
|
284
|
-
structural_interventions.append(
|
|
285
|
-
{
|
|
286
|
-
"intervention_type": "delegation_framework",
|
|
287
|
-
"structure": create_delegation_framework(team_state, source),
|
|
288
|
-
"benefit": "Distributes workload clearly → prevents burnout",
|
|
289
|
-
"not_this": "⛔ Pep talk: 'Just push through!'",
|
|
290
|
-
}
|
|
291
|
-
)
|
|
292
|
-
|
|
293
|
-
elif source["type"] == "information_overload":
|
|
294
|
-
# Volunteer: Structured dashboard
|
|
295
|
-
structural_interventions.append(
|
|
296
|
-
{
|
|
297
|
-
"intervention_type": "information_structure",
|
|
298
|
-
"structure": create_decision_dashboard(team_state, source),
|
|
299
|
-
"benefit": "Surfaces critical info only → reduces cognitive load",
|
|
300
|
-
"not_this": "⛔ Pep talk: 'Focus on what matters!'",
|
|
301
|
-
}
|
|
302
|
-
)
|
|
303
|
-
|
|
304
|
-
elif source["type"] == "unclear_priorities":
|
|
305
|
-
# Volunteer: Decision matrix
|
|
306
|
-
structural_interventions.append(
|
|
307
|
-
{
|
|
308
|
-
"intervention_type": "priority_matrix",
|
|
309
|
-
"structure": create_priority_matrix(team_state, source),
|
|
310
|
-
"benefit": "Makes trade-offs explicit → enables confident decisions",
|
|
311
|
-
"not_this": "⛔ Pep talk: 'Trust your gut!'",
|
|
312
|
-
}
|
|
313
|
-
)
|
|
314
|
-
|
|
315
|
-
if not structural_interventions:
|
|
316
|
-
return None
|
|
317
|
-
|
|
318
|
-
return {
|
|
319
|
-
"stress_level": stress_level,
|
|
320
|
-
"stress_sources": stress_sources,
|
|
321
|
-
"structural_interventions": structural_interventions,
|
|
322
|
-
"reasoning": (
|
|
323
|
-
f"Detected stress level: {stress_level:.0%}. "
|
|
324
|
-
f"Volunteering {len(structural_interventions)} structural interventions "
|
|
325
|
-
"(not emotional support - structure relieves stress more effectively)."
|
|
326
|
-
),
|
|
327
|
-
"message_to_team": compose_structure_offer(stress_level, structural_interventions),
|
|
328
|
-
"trust_building_behavior": "volunteer_structure_during_stress",
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
@staticmethod
|
|
332
|
-
def offer_help_to_struggling_teammate(
|
|
333
|
-
teammate_state: dict, my_bandwidth: float = 0.7
|
|
334
|
-
) -> dict | None:
|
|
335
|
-
"""
|
|
336
|
-
Scenario: Silent Teammate Struggling
|
|
337
|
-
Anticipatory Response: "I've got bandwidth—want me to take a slice of this?"
|
|
338
|
-
|
|
339
|
-
Example:
|
|
340
|
-
- Charge nurse with 12 action items → Offer to take 5 low-priority items
|
|
341
|
-
- Manager preparing audit docs → Offer to generate first draft
|
|
342
|
-
- Team member stuck on complex gap → Offer to research solutions
|
|
343
|
-
|
|
344
|
-
Trust Built:
|
|
345
|
-
- "This AI notices when I'm underwater"
|
|
346
|
-
- "Offers concrete help, not vague support"
|
|
347
|
-
- "Respects my autonomy (asks, doesn't assume)"
|
|
348
|
-
"""
|
|
349
|
-
|
|
350
|
-
logger.info(f"Checking if teammate needs help (my bandwidth: {my_bandwidth:.0%})")
|
|
351
|
-
|
|
352
|
-
# Detect if teammate is struggling
|
|
353
|
-
struggle_indicators = detect_struggle(teammate_state)
|
|
354
|
-
|
|
355
|
-
if struggle_indicators["struggle_score"] < 0.5:
|
|
356
|
-
# Not struggling, no offer needed
|
|
357
|
-
return None
|
|
358
|
-
|
|
359
|
-
if my_bandwidth < 0.3:
|
|
360
|
-
# I'm also overloaded, can't help right now
|
|
361
|
-
return None
|
|
362
|
-
|
|
363
|
-
# Identify specific tasks I could take
|
|
364
|
-
tasks_i_can_help_with = []
|
|
365
|
-
|
|
366
|
-
for task in teammate_state.get("tasks", []):
|
|
367
|
-
if can_i_help_with_task(task, my_bandwidth):
|
|
368
|
-
tasks_i_can_help_with.append(
|
|
369
|
-
{
|
|
370
|
-
"task_id": task["id"],
|
|
371
|
-
"description": task["description"],
|
|
372
|
-
"estimated_time": task["estimated_time"],
|
|
373
|
-
"why_i_can_help": determine_help_rationale(task),
|
|
374
|
-
"impact_on_teammate": estimate_relief(task, teammate_state),
|
|
375
|
-
}
|
|
376
|
-
)
|
|
377
|
-
|
|
378
|
-
if not tasks_i_can_help_with:
|
|
379
|
-
return None
|
|
380
|
-
|
|
381
|
-
# Compose specific offer (not vague "let me know if you need help")
|
|
382
|
-
return {
|
|
383
|
-
"teammate_struggling": True,
|
|
384
|
-
"struggle_score": struggle_indicators["struggle_score"],
|
|
385
|
-
"struggle_indicators": struggle_indicators["indicators"],
|
|
386
|
-
"my_available_bandwidth": my_bandwidth,
|
|
387
|
-
"specific_help_offers": tasks_i_can_help_with,
|
|
388
|
-
"reasoning": (
|
|
389
|
-
f"Detected teammate struggle score: {struggle_indicators['struggle_score']:.0%}. "
|
|
390
|
-
f"I have {my_bandwidth:.0%} bandwidth available. "
|
|
391
|
-
f"Offering to take {len(tasks_i_can_help_with)} specific tasks."
|
|
392
|
-
),
|
|
393
|
-
"message_to_teammate": compose_help_offer(
|
|
394
|
-
tasks_i_can_help_with, my_bandwidth, struggle_indicators
|
|
395
|
-
),
|
|
396
|
-
"trust_building_behavior": "offer_help_to_struggling_teammate",
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
# =============================================================================
|
|
401
|
-
# Helper Functions
|
|
402
|
-
# =============================================================================
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
def calculate_risk_level(data: dict) -> str:
|
|
406
|
-
"""Calculate overall risk level (low, medium, high, critical)"""
|
|
407
|
-
compliance_pct = data.get("compliance_percentage", 100)
|
|
408
|
-
critical_gaps = len(
|
|
409
|
-
[g for g in data.get("compliance_gaps", []) if g.get("severity") == "critical"]
|
|
410
|
-
)
|
|
411
|
-
days_until = data.get("days_until_audit", 999)
|
|
412
|
-
|
|
413
|
-
if critical_gaps > 0 or compliance_pct < 85:
|
|
414
|
-
return "high"
|
|
415
|
-
elif compliance_pct < 90 or days_until < 30:
|
|
416
|
-
return "medium"
|
|
417
|
-
else:
|
|
418
|
-
return "low"
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
def detect_ambiguity(instruction: str, context: dict) -> dict:
|
|
422
|
-
"""
|
|
423
|
-
Detect ambiguity in instruction
|
|
424
|
-
|
|
425
|
-
Returns:
|
|
426
|
-
clarity_score: 0.0-1.0 (1.0 = perfectly clear)
|
|
427
|
-
ambiguities: List of detected ambiguities
|
|
428
|
-
questions: Calibrated questions to clarify
|
|
429
|
-
best_guess: Best interpretation if proceeding anyway
|
|
430
|
-
"""
|
|
431
|
-
|
|
432
|
-
# Simple heuristic-based ambiguity detection
|
|
433
|
-
# In production, could use NLP / LLM analysis
|
|
434
|
-
|
|
435
|
-
ambiguities = []
|
|
436
|
-
questions = []
|
|
437
|
-
|
|
438
|
-
# Check for vague quantifiers
|
|
439
|
-
vague_words = ["some", "a few", "several", "many", "most", "soon", "quickly"]
|
|
440
|
-
for word in vague_words:
|
|
441
|
-
if word in instruction.lower():
|
|
442
|
-
ambiguities.append(f"Vague quantifier: '{word}'")
|
|
443
|
-
if word in ["some", "a few", "several", "many"]:
|
|
444
|
-
questions.append(f"How many specifically? (You said '{word}')")
|
|
445
|
-
else:
|
|
446
|
-
questions.append(f"What timeframe for '{word}'?")
|
|
447
|
-
|
|
448
|
-
# Check for missing scope
|
|
449
|
-
if "all" in instruction.lower() and "items" in instruction.lower():
|
|
450
|
-
if not context.get("items_defined"):
|
|
451
|
-
ambiguities.append("Scope unclear: 'all items' - which items?")
|
|
452
|
-
questions.append("Which items specifically? (compliance gaps, action items, patients?)")
|
|
453
|
-
|
|
454
|
-
# Check for missing context
|
|
455
|
-
if "update" in instruction.lower() or "fix" in instruction.lower():
|
|
456
|
-
if not context.get("target_defined"):
|
|
457
|
-
ambiguities.append("Target unclear: what should be updated/fixed?")
|
|
458
|
-
questions.append("What specifically should be updated/fixed?")
|
|
459
|
-
|
|
460
|
-
# Calculate clarity score
|
|
461
|
-
clarity_score = max(0.0, 1.0 - (len(ambiguities) * 0.2))
|
|
462
|
-
|
|
463
|
-
return {
|
|
464
|
-
"clarity_score": clarity_score,
|
|
465
|
-
"ambiguities": ambiguities,
|
|
466
|
-
"questions": questions,
|
|
467
|
-
"best_guess": instruction, # In production, generate interpretation
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
def compose_clarification_request(instruction: str, ambiguity_signals: dict) -> str:
|
|
472
|
-
"""Compose user-friendly clarification request"""
|
|
473
|
-
|
|
474
|
-
ambiguities_text = "\n".join(f"• {amb}" for amb in ambiguity_signals["ambiguities"])
|
|
475
|
-
questions_text = "\n".join(
|
|
476
|
-
f"{i + 1}. {q}" for i, q in enumerate(ambiguity_signals["questions"])
|
|
477
|
-
)
|
|
478
|
-
|
|
479
|
-
return f"""
|
|
480
|
-
🤔 **Clarification Needed (to prevent wasted effort)**
|
|
481
|
-
|
|
482
|
-
Your instruction: "{instruction}"
|
|
483
|
-
|
|
484
|
-
I want to make sure I understand correctly. I detected {len(ambiguity_signals["ambiguities"])} potential ambiguities:
|
|
485
|
-
|
|
486
|
-
{ambiguities_text}
|
|
487
|
-
|
|
488
|
-
**Could you clarify:**
|
|
489
|
-
{questions_text}
|
|
490
|
-
|
|
491
|
-
**My best guess:**
|
|
492
|
-
{ambiguity_signals["best_guess"]}
|
|
493
|
-
|
|
494
|
-
Is this what you meant? If so, I'll proceed. If not, please clarify and I'll adjust.
|
|
495
|
-
|
|
496
|
-
_(This AI clarifies before executing to build trust through accurate work)_
|
|
497
|
-
""".strip()
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
def calculate_stress_level(stress_indicators: dict) -> float:
|
|
501
|
-
"""
|
|
502
|
-
Calculate team stress level (0.0-1.0)
|
|
503
|
-
|
|
504
|
-
Indicators:
|
|
505
|
-
- Time pressure (days until deadline)
|
|
506
|
-
- Task overload (tasks per person)
|
|
507
|
-
- Complexity (critical items)
|
|
508
|
-
- Uncertainty (missing information)
|
|
509
|
-
"""
|
|
510
|
-
|
|
511
|
-
stress_factors = []
|
|
512
|
-
|
|
513
|
-
# Time pressure
|
|
514
|
-
days_until_deadline = stress_indicators.get("days_until_deadline", 999)
|
|
515
|
-
if days_until_deadline < 30:
|
|
516
|
-
time_stress = 1.0 - (days_until_deadline / 30)
|
|
517
|
-
stress_factors.append(time_stress)
|
|
518
|
-
|
|
519
|
-
# Task overload
|
|
520
|
-
tasks_per_person = stress_indicators.get("tasks_per_person", 0)
|
|
521
|
-
if tasks_per_person > 5:
|
|
522
|
-
overload_stress = min(1.0, (tasks_per_person - 5) / 10)
|
|
523
|
-
stress_factors.append(overload_stress)
|
|
524
|
-
|
|
525
|
-
# Complexity
|
|
526
|
-
critical_tasks = stress_indicators.get("critical_tasks", 0)
|
|
527
|
-
if critical_tasks > 0:
|
|
528
|
-
complexity_stress = min(1.0, critical_tasks / 5)
|
|
529
|
-
stress_factors.append(complexity_stress)
|
|
530
|
-
|
|
531
|
-
# Uncertainty
|
|
532
|
-
missing_info_count = stress_indicators.get("missing_information", 0)
|
|
533
|
-
if missing_info_count > 0:
|
|
534
|
-
uncertainty_stress = min(1.0, missing_info_count / 5)
|
|
535
|
-
stress_factors.append(uncertainty_stress)
|
|
536
|
-
|
|
537
|
-
# Average stress level
|
|
538
|
-
return sum(stress_factors) / len(stress_factors) if stress_factors else 0.0
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
def identify_stress_sources(team_state: dict, stress_indicators: dict) -> list[dict]:
|
|
542
|
-
"""Identify specific sources of stress"""
|
|
543
|
-
|
|
544
|
-
sources = []
|
|
545
|
-
|
|
546
|
-
if stress_indicators.get("days_until_deadline", 999) < 30:
|
|
547
|
-
sources.append(
|
|
548
|
-
{
|
|
549
|
-
"type": "time_pressure",
|
|
550
|
-
"description": f"Only {stress_indicators['days_until_deadline']} days until deadline",
|
|
551
|
-
"severity": ("high" if stress_indicators["days_until_deadline"] < 14 else "medium"),
|
|
552
|
-
}
|
|
553
|
-
)
|
|
554
|
-
|
|
555
|
-
if stress_indicators.get("tasks_per_person", 0) > 5:
|
|
556
|
-
sources.append(
|
|
557
|
-
{
|
|
558
|
-
"type": "task_overload",
|
|
559
|
-
"description": f"{stress_indicators['tasks_per_person']} tasks per person",
|
|
560
|
-
"severity": ("high" if stress_indicators["tasks_per_person"] > 10 else "medium"),
|
|
561
|
-
}
|
|
562
|
-
)
|
|
563
|
-
|
|
564
|
-
if len(team_state.get("compliance_gaps", [])) > 10:
|
|
565
|
-
sources.append(
|
|
566
|
-
{
|
|
567
|
-
"type": "information_overload",
|
|
568
|
-
"description": f"{len(team_state['compliance_gaps'])} gaps to process",
|
|
569
|
-
"severity": "medium",
|
|
570
|
-
}
|
|
571
|
-
)
|
|
572
|
-
|
|
573
|
-
return sources
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
def create_prioritized_timeline(team_state: dict, stress_source: dict) -> dict:
|
|
577
|
-
"""Create structured timeline to relieve time pressure"""
|
|
578
|
-
|
|
579
|
-
return {
|
|
580
|
-
"structure_type": "timeline",
|
|
581
|
-
"phases": [
|
|
582
|
-
{
|
|
583
|
-
"phase": "CRITICAL (Days 1-3)",
|
|
584
|
-
"focus": "Critical gaps only",
|
|
585
|
-
"tasks": [
|
|
586
|
-
t for t in team_state.get("action_items", []) if t.get("severity") == "critical"
|
|
587
|
-
],
|
|
588
|
-
},
|
|
589
|
-
{
|
|
590
|
-
"phase": "HIGH PRIORITY (Days 4-7)",
|
|
591
|
-
"focus": "High-severity gaps",
|
|
592
|
-
"tasks": [
|
|
593
|
-
t for t in team_state.get("action_items", []) if t.get("severity") == "high"
|
|
594
|
-
],
|
|
595
|
-
},
|
|
596
|
-
{
|
|
597
|
-
"phase": "MEDIUM (Days 8-14)",
|
|
598
|
-
"focus": "Medium-severity gaps",
|
|
599
|
-
"tasks": [
|
|
600
|
-
t for t in team_state.get("action_items", []) if t.get("severity") == "medium"
|
|
601
|
-
],
|
|
602
|
-
},
|
|
603
|
-
],
|
|
604
|
-
"reasoning": "Phased approach prevents overwhelm by clarifying daily priorities",
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
def create_delegation_framework(team_state: dict, stress_source: dict) -> dict:
|
|
609
|
-
"""Create task delegation structure"""
|
|
610
|
-
|
|
611
|
-
return {
|
|
612
|
-
"structure_type": "delegation_matrix",
|
|
613
|
-
"assignments": {
|
|
614
|
-
"charge_nurse": {
|
|
615
|
-
"tasks": [
|
|
616
|
-
t
|
|
617
|
-
for t in team_state.get("action_items", [])
|
|
618
|
-
if t.get("assignee") == "charge_nurse"
|
|
619
|
-
],
|
|
620
|
-
"estimated_time": "X hours",
|
|
621
|
-
"can_delegate_to": ["staff_nurses"],
|
|
622
|
-
},
|
|
623
|
-
"nurse_manager": {
|
|
624
|
-
"tasks": [
|
|
625
|
-
t
|
|
626
|
-
for t in team_state.get("action_items", [])
|
|
627
|
-
if t.get("assignee") == "nurse_manager"
|
|
628
|
-
],
|
|
629
|
-
"estimated_time": "Y hours",
|
|
630
|
-
"can_delegate_to": ["charge_nurse"],
|
|
631
|
-
},
|
|
632
|
-
},
|
|
633
|
-
"reasoning": "Clear delegation prevents duplicate/missed work",
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
def create_decision_dashboard(team_state: dict, stress_source: dict) -> dict:
|
|
638
|
-
"""Create structured information dashboard"""
|
|
639
|
-
|
|
640
|
-
return {
|
|
641
|
-
"structure_type": "decision_dashboard",
|
|
642
|
-
"critical_only_view": {
|
|
643
|
-
"red_flags": [
|
|
644
|
-
g for g in team_state.get("compliance_gaps", []) if g.get("severity") == "critical"
|
|
645
|
-
],
|
|
646
|
-
"blocking_issues": [],
|
|
647
|
-
"requires_immediate_action": [],
|
|
648
|
-
},
|
|
649
|
-
"reasoning": "Filters noise, surfaces only decision-critical information",
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
def create_priority_matrix(team_state: dict, stress_source: dict) -> dict:
|
|
654
|
-
"""Create priority decision matrix"""
|
|
655
|
-
|
|
656
|
-
return {
|
|
657
|
-
"structure_type": "priority_matrix",
|
|
658
|
-
"dimensions": {
|
|
659
|
-
"urgency": "Days until audit",
|
|
660
|
-
"importance": "Legal risk + severity",
|
|
661
|
-
"effort": "Time to fix",
|
|
662
|
-
},
|
|
663
|
-
"quadrants": {
|
|
664
|
-
"do_first": "High urgency + High importance",
|
|
665
|
-
"schedule": "Low urgency + High importance",
|
|
666
|
-
"delegate": "High urgency + Low importance",
|
|
667
|
-
"drop": "Low urgency + Low importance",
|
|
668
|
-
},
|
|
669
|
-
"reasoning": "Makes trade-offs explicit for confident prioritization",
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
def compose_structure_offer(stress_level: float, interventions: list[dict]) -> str:
|
|
674
|
-
"""Compose offer of structural help"""
|
|
675
|
-
|
|
676
|
-
intervention_text = "\n".join(
|
|
677
|
-
f"{i + 1}. **{interv['intervention_type'].replace('_', ' ').title()}**\n"
|
|
678
|
-
f" → Benefit: {interv['benefit']}\n"
|
|
679
|
-
f" → {interv['not_this']}"
|
|
680
|
-
for i, interv in enumerate(interventions)
|
|
681
|
-
)
|
|
682
|
-
|
|
683
|
-
return f"""
|
|
684
|
-
💡 **Structural Support Available**
|
|
685
|
-
|
|
686
|
-
I noticed team stress indicators ({stress_level:.0%}). Rather than pep talks, I've prepared {len(interventions)} structural interventions that might help:
|
|
687
|
-
|
|
688
|
-
{intervention_text}
|
|
689
|
-
|
|
690
|
-
**Would any of these structures be helpful?**
|
|
691
|
-
(I'm volunteering structure, not advice—you decide if/how to use)
|
|
692
|
-
|
|
693
|
-
_(Level 4 Anticipatory Empathy: Structure relieves stress more than encouragement)_
|
|
694
|
-
""".strip()
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
def detect_struggle(teammate_state: dict) -> dict:
|
|
698
|
-
"""Detect if teammate is struggling"""
|
|
699
|
-
|
|
700
|
-
struggle_indicators = []
|
|
701
|
-
struggle_score = 0.0
|
|
702
|
-
|
|
703
|
-
# High task count
|
|
704
|
-
task_count = len(teammate_state.get("tasks", []))
|
|
705
|
-
if task_count > 10:
|
|
706
|
-
struggle_indicators.append(f"High task count: {task_count} tasks")
|
|
707
|
-
struggle_score += 0.3
|
|
708
|
-
|
|
709
|
-
# Many critical tasks
|
|
710
|
-
critical_count = len(
|
|
711
|
-
[t for t in teammate_state.get("tasks", []) if t.get("severity") == "critical"]
|
|
712
|
-
)
|
|
713
|
-
if critical_count > 2:
|
|
714
|
-
struggle_indicators.append(f"Multiple critical tasks: {critical_count}")
|
|
715
|
-
struggle_score += 0.4
|
|
716
|
-
|
|
717
|
-
# Tight deadlines
|
|
718
|
-
urgent_deadlines = len(
|
|
719
|
-
[t for t in teammate_state.get("tasks", []) if t.get("deadline_days", 999) < 3]
|
|
720
|
-
)
|
|
721
|
-
if urgent_deadlines > 0:
|
|
722
|
-
struggle_indicators.append(f"Urgent deadlines: {urgent_deadlines} tasks due <3 days")
|
|
723
|
-
struggle_score += 0.3
|
|
724
|
-
|
|
725
|
-
return {
|
|
726
|
-
"struggle_score": min(1.0, struggle_score),
|
|
727
|
-
"indicators": struggle_indicators,
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
def can_i_help_with_task(task: dict, my_bandwidth: float) -> bool:
|
|
732
|
-
"""Determine if I can help with this task"""
|
|
733
|
-
|
|
734
|
-
# I can help if:
|
|
735
|
-
# 1. Task is not too complex (medium/low priority)
|
|
736
|
-
# 2. Task doesn't require human judgment (can be automated)
|
|
737
|
-
# 3. I have enough bandwidth
|
|
738
|
-
|
|
739
|
-
if task.get("severity") == "critical":
|
|
740
|
-
return False # Critical tasks need human oversight
|
|
741
|
-
|
|
742
|
-
if task.get("requires_human_judgment", False):
|
|
743
|
-
return False
|
|
744
|
-
|
|
745
|
-
task_effort = estimate_task_effort(task)
|
|
746
|
-
if task_effort > my_bandwidth:
|
|
747
|
-
return False
|
|
748
|
-
|
|
749
|
-
return True
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
def estimate_task_effort(task: dict) -> float:
|
|
753
|
-
"""Estimate effort required for task (0.0-1.0 of bandwidth)"""
|
|
754
|
-
|
|
755
|
-
estimated_time = task.get("estimated_time", "0 minutes")
|
|
756
|
-
minutes = int(estimated_time.split()[0]) if estimated_time.split()[0].isdigit() else 0
|
|
757
|
-
|
|
758
|
-
# Map minutes to bandwidth fraction
|
|
759
|
-
if minutes < 15:
|
|
760
|
-
return 0.1
|
|
761
|
-
elif minutes < 30:
|
|
762
|
-
return 0.2
|
|
763
|
-
elif minutes < 60:
|
|
764
|
-
return 0.3
|
|
765
|
-
else:
|
|
766
|
-
return 0.5
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
def determine_help_rationale(task: dict) -> str:
|
|
770
|
-
"""Explain why I can help with this task"""
|
|
771
|
-
|
|
772
|
-
if task.get("type") == "documentation":
|
|
773
|
-
return "I can auto-generate documentation drafts"
|
|
774
|
-
elif task.get("type") == "data_gathering":
|
|
775
|
-
return "I can collect and format data quickly"
|
|
776
|
-
elif task.get("type") == "analysis":
|
|
777
|
-
return "I can run analysis and summarize results"
|
|
778
|
-
else:
|
|
779
|
-
return "I can automate repetitive parts of this task"
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
def estimate_relief(task: dict, teammate_state: dict) -> str:
|
|
783
|
-
"""Estimate impact on teammate if I take this task"""
|
|
784
|
-
|
|
785
|
-
task_time = estimate_task_effort(task)
|
|
786
|
-
total_load = len(teammate_state.get("tasks", []))
|
|
787
|
-
|
|
788
|
-
if total_load > 10:
|
|
789
|
-
return f"Reduces your load by {(task_time / total_load * 100):.0f}% (meaningful relief)"
|
|
790
|
-
else:
|
|
791
|
-
return "Modest relief but every bit helps"
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
def compose_help_offer(tasks: list[dict], bandwidth: float, struggle: dict) -> str:
|
|
795
|
-
"""Compose specific help offer to struggling teammate"""
|
|
796
|
-
|
|
797
|
-
indicators_text = "\n".join(f"• {ind}" for ind in struggle["indicators"])
|
|
798
|
-
|
|
799
|
-
tasks_text = "\n".join(
|
|
800
|
-
f"{i + 1}. {task['description']}\n"
|
|
801
|
-
f" → Why I can help: {task['why_i_can_help']}\n"
|
|
802
|
-
f" → Impact: {task['impact_on_teammate']}\n"
|
|
803
|
-
f" → Time: {task['estimated_time']}"
|
|
804
|
-
for i, task in enumerate(tasks[:3])
|
|
805
|
-
)
|
|
806
|
-
|
|
807
|
-
more_tasks = f"... and {len(tasks) - 3} more tasks" if len(tasks) > 3 else ""
|
|
808
|
-
|
|
809
|
-
return f"""
|
|
810
|
-
🤝 **I've Got Bandwidth—Want Me to Take a Slice?**
|
|
811
|
-
|
|
812
|
-
I noticed you have {len(struggle["indicators"])} stress indicators:
|
|
813
|
-
{indicators_text}
|
|
814
|
-
|
|
815
|
-
I have {bandwidth:.0%} bandwidth available and could take these {len(tasks)} tasks off your plate:
|
|
816
|
-
|
|
817
|
-
{tasks_text}
|
|
818
|
-
|
|
819
|
-
{more_tasks}
|
|
820
|
-
|
|
821
|
-
**Want me to take any of these?** (Your call—just offering concrete help)
|
|
822
|
-
|
|
823
|
-
_(Level 4 Anticipatory Empathy: Specific offers, not vague "let me know if you need anything")_
|
|
824
|
-
""".strip()
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
# =============================================================================
|
|
828
|
-
# Example Usage
|
|
829
|
-
# =============================================================================
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
if __name__ == "__main__":
|
|
833
|
-
# Example 1: Pre-format for handoff
|
|
834
|
-
raw_data = {
|
|
835
|
-
"compliance_percentage": 88.5,
|
|
836
|
-
"compliance_gaps": [
|
|
837
|
-
{
|
|
838
|
-
"severity": "critical",
|
|
839
|
-
"description": "2 missing double-checks",
|
|
840
|
-
"patient_ids": ["P123", "P456"],
|
|
841
|
-
},
|
|
842
|
-
{
|
|
843
|
-
"severity": "high",
|
|
844
|
-
"description": "5 missing signatures",
|
|
845
|
-
"patient_ids": ["P789", "P101", "P112"],
|
|
846
|
-
},
|
|
847
|
-
],
|
|
848
|
-
"action_items": [
|
|
849
|
-
{"severity": "critical", "estimated_time": "20 minutes"},
|
|
850
|
-
{"severity": "high", "estimated_time": "15 minutes"},
|
|
851
|
-
],
|
|
852
|
-
"days_until_audit": 45,
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
trust_builder = TrustBuildingBehaviors()
|
|
856
|
-
|
|
857
|
-
formatted = trust_builder.pre_format_for_handoff(
|
|
858
|
-
data=raw_data, next_person_role="charge_nurse", context="audit_preparation"
|
|
859
|
-
)
|
|
860
|
-
|
|
861
|
-
print("=" * 80)
|
|
862
|
-
print("EXAMPLE 1: Pre-Format for Handoff")
|
|
863
|
-
print("=" * 80)
|
|
864
|
-
print(f"Format: {formatted['format']}")
|
|
865
|
-
print(f"Reasoning: {formatted['reasoning']}")
|
|
866
|
-
print(f"Quick scan view: {formatted['summary']['quick_scan_view']}")
|
|
867
|
-
print()
|
|
868
|
-
|
|
869
|
-
# Example 2: Volunteer structure during stress
|
|
870
|
-
team_state = {
|
|
871
|
-
"compliance_gaps": [{"severity": "critical"}] * 3,
|
|
872
|
-
"action_items": [{"severity": "critical"}] * 8,
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
stress_indicators = {
|
|
876
|
-
"days_until_deadline": 14,
|
|
877
|
-
"tasks_per_person": 8,
|
|
878
|
-
"critical_tasks": 3,
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
structure_offer = trust_builder.volunteer_structure_during_stress(
|
|
882
|
-
team_state=team_state, stress_indicators=stress_indicators
|
|
883
|
-
)
|
|
884
|
-
|
|
885
|
-
if structure_offer:
|
|
886
|
-
print("=" * 80)
|
|
887
|
-
print("EXAMPLE 2: Volunteer Structure During Stress")
|
|
888
|
-
print("=" * 80)
|
|
889
|
-
print(f"Stress Level: {structure_offer['stress_level']:.0%}")
|
|
890
|
-
print(f"Interventions: {len(structure_offer['structural_interventions'])}")
|
|
891
|
-
print(structure_offer["message_to_team"])
|