attune-ai 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- attune/__init__.py +358 -0
- attune/adaptive/__init__.py +13 -0
- attune/adaptive/task_complexity.py +127 -0
- attune/agent_monitoring.py +414 -0
- attune/cache/__init__.py +117 -0
- attune/cache/base.py +166 -0
- attune/cache/dependency_manager.py +256 -0
- attune/cache/hash_only.py +251 -0
- attune/cache/hybrid.py +457 -0
- attune/cache/storage.py +285 -0
- attune/cache_monitor.py +356 -0
- attune/cache_stats.py +298 -0
- attune/cli/__init__.py +152 -0
- attune/cli/__main__.py +12 -0
- attune/cli/commands/__init__.py +1 -0
- attune/cli/commands/batch.py +264 -0
- attune/cli/commands/cache.py +248 -0
- attune/cli/commands/help.py +331 -0
- attune/cli/commands/info.py +140 -0
- attune/cli/commands/inspect.py +436 -0
- attune/cli/commands/inspection.py +57 -0
- attune/cli/commands/memory.py +48 -0
- attune/cli/commands/metrics.py +92 -0
- attune/cli/commands/orchestrate.py +184 -0
- attune/cli/commands/patterns.py +207 -0
- attune/cli/commands/profiling.py +202 -0
- attune/cli/commands/provider.py +98 -0
- attune/cli/commands/routing.py +285 -0
- attune/cli/commands/setup.py +96 -0
- attune/cli/commands/status.py +235 -0
- attune/cli/commands/sync.py +166 -0
- attune/cli/commands/tier.py +121 -0
- attune/cli/commands/utilities.py +114 -0
- attune/cli/commands/workflow.py +579 -0
- attune/cli/core.py +32 -0
- attune/cli/parsers/__init__.py +68 -0
- attune/cli/parsers/batch.py +118 -0
- attune/cli/parsers/cache.py +65 -0
- attune/cli/parsers/help.py +41 -0
- attune/cli/parsers/info.py +26 -0
- attune/cli/parsers/inspect.py +66 -0
- attune/cli/parsers/metrics.py +42 -0
- attune/cli/parsers/orchestrate.py +61 -0
- attune/cli/parsers/patterns.py +54 -0
- attune/cli/parsers/provider.py +40 -0
- attune/cli/parsers/routing.py +110 -0
- attune/cli/parsers/setup.py +42 -0
- attune/cli/parsers/status.py +47 -0
- attune/cli/parsers/sync.py +31 -0
- attune/cli/parsers/tier.py +33 -0
- attune/cli/parsers/workflow.py +77 -0
- attune/cli/utils/__init__.py +1 -0
- attune/cli/utils/data.py +242 -0
- attune/cli/utils/helpers.py +68 -0
- attune/cli_legacy.py +3957 -0
- attune/cli_minimal.py +1159 -0
- attune/cli_router.py +437 -0
- attune/cli_unified.py +814 -0
- attune/config/__init__.py +66 -0
- attune/config/xml_config.py +286 -0
- attune/config.py +545 -0
- attune/coordination.py +870 -0
- attune/core.py +1511 -0
- attune/core_modules/__init__.py +15 -0
- attune/cost_tracker.py +626 -0
- attune/dashboard/__init__.py +41 -0
- attune/dashboard/app.py +512 -0
- attune/dashboard/simple_server.py +435 -0
- attune/dashboard/standalone_server.py +547 -0
- attune/discovery.py +306 -0
- attune/emergence.py +306 -0
- attune/exceptions.py +123 -0
- attune/feedback_loops.py +373 -0
- attune/hot_reload/README.md +473 -0
- attune/hot_reload/__init__.py +62 -0
- attune/hot_reload/config.py +83 -0
- attune/hot_reload/integration.py +229 -0
- attune/hot_reload/reloader.py +298 -0
- attune/hot_reload/watcher.py +183 -0
- attune/hot_reload/websocket.py +177 -0
- attune/levels.py +577 -0
- attune/leverage_points.py +441 -0
- attune/logging_config.py +261 -0
- attune/mcp/__init__.py +10 -0
- attune/mcp/server.py +506 -0
- attune/memory/__init__.py +237 -0
- attune/memory/claude_memory.py +469 -0
- attune/memory/config.py +224 -0
- attune/memory/control_panel.py +1290 -0
- attune/memory/control_panel_support.py +145 -0
- attune/memory/cross_session.py +845 -0
- attune/memory/edges.py +179 -0
- attune/memory/encryption.py +159 -0
- attune/memory/file_session.py +770 -0
- attune/memory/graph.py +570 -0
- attune/memory/long_term.py +913 -0
- attune/memory/long_term_types.py +99 -0
- attune/memory/mixins/__init__.py +25 -0
- attune/memory/mixins/backend_init_mixin.py +249 -0
- attune/memory/mixins/capabilities_mixin.py +208 -0
- attune/memory/mixins/handoff_mixin.py +208 -0
- attune/memory/mixins/lifecycle_mixin.py +49 -0
- attune/memory/mixins/long_term_mixin.py +352 -0
- attune/memory/mixins/promotion_mixin.py +109 -0
- attune/memory/mixins/short_term_mixin.py +182 -0
- attune/memory/nodes.py +179 -0
- attune/memory/redis_bootstrap.py +540 -0
- attune/memory/security/__init__.py +31 -0
- attune/memory/security/audit_logger.py +932 -0
- attune/memory/security/pii_scrubber.py +640 -0
- attune/memory/security/secrets_detector.py +678 -0
- attune/memory/short_term.py +2192 -0
- attune/memory/simple_storage.py +302 -0
- attune/memory/storage/__init__.py +15 -0
- attune/memory/storage_backend.py +167 -0
- attune/memory/summary_index.py +583 -0
- attune/memory/types.py +446 -0
- attune/memory/unified.py +182 -0
- attune/meta_workflows/__init__.py +74 -0
- attune/meta_workflows/agent_creator.py +248 -0
- attune/meta_workflows/builtin_templates.py +567 -0
- attune/meta_workflows/cli_commands/__init__.py +56 -0
- attune/meta_workflows/cli_commands/agent_commands.py +321 -0
- attune/meta_workflows/cli_commands/analytics_commands.py +442 -0
- attune/meta_workflows/cli_commands/config_commands.py +232 -0
- attune/meta_workflows/cli_commands/memory_commands.py +182 -0
- attune/meta_workflows/cli_commands/template_commands.py +354 -0
- attune/meta_workflows/cli_commands/workflow_commands.py +382 -0
- attune/meta_workflows/cli_meta_workflows.py +59 -0
- attune/meta_workflows/form_engine.py +292 -0
- attune/meta_workflows/intent_detector.py +409 -0
- attune/meta_workflows/models.py +569 -0
- attune/meta_workflows/pattern_learner.py +738 -0
- attune/meta_workflows/plan_generator.py +384 -0
- attune/meta_workflows/session_context.py +397 -0
- attune/meta_workflows/template_registry.py +229 -0
- attune/meta_workflows/workflow.py +984 -0
- attune/metrics/__init__.py +12 -0
- attune/metrics/collector.py +31 -0
- attune/metrics/prompt_metrics.py +194 -0
- attune/models/__init__.py +172 -0
- attune/models/__main__.py +13 -0
- attune/models/adaptive_routing.py +437 -0
- attune/models/auth_cli.py +444 -0
- attune/models/auth_strategy.py +450 -0
- attune/models/cli.py +655 -0
- attune/models/empathy_executor.py +354 -0
- attune/models/executor.py +257 -0
- attune/models/fallback.py +762 -0
- attune/models/provider_config.py +282 -0
- attune/models/registry.py +472 -0
- attune/models/tasks.py +359 -0
- attune/models/telemetry/__init__.py +71 -0
- attune/models/telemetry/analytics.py +594 -0
- attune/models/telemetry/backend.py +196 -0
- attune/models/telemetry/data_models.py +431 -0
- attune/models/telemetry/storage.py +489 -0
- attune/models/token_estimator.py +420 -0
- attune/models/validation.py +280 -0
- attune/monitoring/__init__.py +52 -0
- attune/monitoring/alerts.py +946 -0
- attune/monitoring/alerts_cli.py +448 -0
- attune/monitoring/multi_backend.py +271 -0
- attune/monitoring/otel_backend.py +362 -0
- attune/optimization/__init__.py +19 -0
- attune/optimization/context_optimizer.py +272 -0
- attune/orchestration/__init__.py +67 -0
- attune/orchestration/agent_templates.py +707 -0
- attune/orchestration/config_store.py +499 -0
- attune/orchestration/execution_strategies.py +2111 -0
- attune/orchestration/meta_orchestrator.py +1168 -0
- attune/orchestration/pattern_learner.py +696 -0
- attune/orchestration/real_tools.py +931 -0
- attune/pattern_cache.py +187 -0
- attune/pattern_library.py +542 -0
- attune/patterns/debugging/all_patterns.json +81 -0
- attune/patterns/debugging/workflow_20260107_1770825e.json +77 -0
- attune/patterns/refactoring_memory.json +89 -0
- attune/persistence.py +564 -0
- attune/platform_utils.py +265 -0
- attune/plugins/__init__.py +28 -0
- attune/plugins/base.py +361 -0
- attune/plugins/registry.py +268 -0
- attune/project_index/__init__.py +32 -0
- attune/project_index/cli.py +335 -0
- attune/project_index/index.py +667 -0
- attune/project_index/models.py +504 -0
- attune/project_index/reports.py +474 -0
- attune/project_index/scanner.py +777 -0
- attune/project_index/scanner_parallel.py +291 -0
- attune/prompts/__init__.py +61 -0
- attune/prompts/config.py +77 -0
- attune/prompts/context.py +177 -0
- attune/prompts/parser.py +285 -0
- attune/prompts/registry.py +313 -0
- attune/prompts/templates.py +208 -0
- attune/redis_config.py +302 -0
- attune/redis_memory.py +799 -0
- attune/resilience/__init__.py +56 -0
- attune/resilience/circuit_breaker.py +256 -0
- attune/resilience/fallback.py +179 -0
- attune/resilience/health.py +300 -0
- attune/resilience/retry.py +209 -0
- attune/resilience/timeout.py +135 -0
- attune/routing/__init__.py +43 -0
- attune/routing/chain_executor.py +433 -0
- attune/routing/classifier.py +217 -0
- attune/routing/smart_router.py +234 -0
- attune/routing/workflow_registry.py +343 -0
- attune/scaffolding/README.md +589 -0
- attune/scaffolding/__init__.py +35 -0
- attune/scaffolding/__main__.py +14 -0
- attune/scaffolding/cli.py +240 -0
- attune/scaffolding/templates/base_wizard.py.jinja2 +121 -0
- attune/scaffolding/templates/coach_wizard.py.jinja2 +321 -0
- attune/scaffolding/templates/domain_wizard.py.jinja2 +408 -0
- attune/scaffolding/templates/linear_flow_wizard.py.jinja2 +203 -0
- attune/socratic/__init__.py +256 -0
- attune/socratic/ab_testing.py +958 -0
- attune/socratic/blueprint.py +533 -0
- attune/socratic/cli.py +703 -0
- attune/socratic/collaboration.py +1114 -0
- attune/socratic/domain_templates.py +924 -0
- attune/socratic/embeddings.py +738 -0
- attune/socratic/engine.py +794 -0
- attune/socratic/explainer.py +682 -0
- attune/socratic/feedback.py +772 -0
- attune/socratic/forms.py +629 -0
- attune/socratic/generator.py +732 -0
- attune/socratic/llm_analyzer.py +637 -0
- attune/socratic/mcp_server.py +702 -0
- attune/socratic/session.py +312 -0
- attune/socratic/storage.py +667 -0
- attune/socratic/success.py +730 -0
- attune/socratic/visual_editor.py +860 -0
- attune/socratic/web_ui.py +958 -0
- attune/telemetry/__init__.py +39 -0
- attune/telemetry/agent_coordination.py +475 -0
- attune/telemetry/agent_tracking.py +367 -0
- attune/telemetry/approval_gates.py +545 -0
- attune/telemetry/cli.py +1231 -0
- attune/telemetry/commands/__init__.py +14 -0
- attune/telemetry/commands/dashboard_commands.py +696 -0
- attune/telemetry/event_streaming.py +409 -0
- attune/telemetry/feedback_loop.py +567 -0
- attune/telemetry/usage_tracker.py +591 -0
- attune/templates.py +754 -0
- attune/test_generator/__init__.py +38 -0
- attune/test_generator/__main__.py +14 -0
- attune/test_generator/cli.py +234 -0
- attune/test_generator/generator.py +355 -0
- attune/test_generator/risk_analyzer.py +216 -0
- attune/test_generator/templates/unit_test.py.jinja2 +272 -0
- attune/tier_recommender.py +384 -0
- attune/tools.py +183 -0
- attune/trust/__init__.py +28 -0
- attune/trust/circuit_breaker.py +579 -0
- attune/trust_building.py +527 -0
- attune/validation/__init__.py +19 -0
- attune/validation/xml_validator.py +281 -0
- attune/vscode_bridge.py +173 -0
- attune/workflow_commands.py +780 -0
- attune/workflow_patterns/__init__.py +33 -0
- attune/workflow_patterns/behavior.py +249 -0
- attune/workflow_patterns/core.py +76 -0
- attune/workflow_patterns/output.py +99 -0
- attune/workflow_patterns/registry.py +255 -0
- attune/workflow_patterns/structural.py +288 -0
- attune/workflows/__init__.py +539 -0
- attune/workflows/autonomous_test_gen.py +1268 -0
- attune/workflows/base.py +2667 -0
- attune/workflows/batch_processing.py +342 -0
- attune/workflows/bug_predict.py +1084 -0
- attune/workflows/builder.py +273 -0
- attune/workflows/caching.py +253 -0
- attune/workflows/code_review.py +1048 -0
- attune/workflows/code_review_adapters.py +312 -0
- attune/workflows/code_review_pipeline.py +722 -0
- attune/workflows/config.py +645 -0
- attune/workflows/dependency_check.py +644 -0
- attune/workflows/document_gen/__init__.py +25 -0
- attune/workflows/document_gen/config.py +30 -0
- attune/workflows/document_gen/report_formatter.py +162 -0
- attune/workflows/document_gen/workflow.py +1426 -0
- attune/workflows/document_manager.py +216 -0
- attune/workflows/document_manager_README.md +134 -0
- attune/workflows/documentation_orchestrator.py +1205 -0
- attune/workflows/history.py +510 -0
- attune/workflows/keyboard_shortcuts/__init__.py +39 -0
- attune/workflows/keyboard_shortcuts/generators.py +391 -0
- attune/workflows/keyboard_shortcuts/parsers.py +416 -0
- attune/workflows/keyboard_shortcuts/prompts.py +295 -0
- attune/workflows/keyboard_shortcuts/schema.py +193 -0
- attune/workflows/keyboard_shortcuts/workflow.py +509 -0
- attune/workflows/llm_base.py +363 -0
- attune/workflows/manage_docs.py +87 -0
- attune/workflows/manage_docs_README.md +134 -0
- attune/workflows/manage_documentation.py +821 -0
- attune/workflows/new_sample_workflow1.py +149 -0
- attune/workflows/new_sample_workflow1_README.md +150 -0
- attune/workflows/orchestrated_health_check.py +849 -0
- attune/workflows/orchestrated_release_prep.py +600 -0
- attune/workflows/output.py +413 -0
- attune/workflows/perf_audit.py +863 -0
- attune/workflows/pr_review.py +762 -0
- attune/workflows/progress.py +785 -0
- attune/workflows/progress_server.py +322 -0
- attune/workflows/progressive/README 2.md +454 -0
- attune/workflows/progressive/README.md +454 -0
- attune/workflows/progressive/__init__.py +82 -0
- attune/workflows/progressive/cli.py +219 -0
- attune/workflows/progressive/core.py +488 -0
- attune/workflows/progressive/orchestrator.py +723 -0
- attune/workflows/progressive/reports.py +520 -0
- attune/workflows/progressive/telemetry.py +274 -0
- attune/workflows/progressive/test_gen.py +495 -0
- attune/workflows/progressive/workflow.py +589 -0
- attune/workflows/refactor_plan.py +694 -0
- attune/workflows/release_prep.py +895 -0
- attune/workflows/release_prep_crew.py +969 -0
- attune/workflows/research_synthesis.py +404 -0
- attune/workflows/routing.py +168 -0
- attune/workflows/secure_release.py +593 -0
- attune/workflows/security_adapters.py +297 -0
- attune/workflows/security_audit.py +1329 -0
- attune/workflows/security_audit_phase3.py +355 -0
- attune/workflows/seo_optimization.py +633 -0
- attune/workflows/step_config.py +234 -0
- attune/workflows/telemetry_mixin.py +269 -0
- attune/workflows/test5.py +125 -0
- attune/workflows/test5_README.md +158 -0
- attune/workflows/test_coverage_boost_crew.py +849 -0
- attune/workflows/test_gen/__init__.py +52 -0
- attune/workflows/test_gen/ast_analyzer.py +249 -0
- attune/workflows/test_gen/config.py +88 -0
- attune/workflows/test_gen/data_models.py +38 -0
- attune/workflows/test_gen/report_formatter.py +289 -0
- attune/workflows/test_gen/test_templates.py +381 -0
- attune/workflows/test_gen/workflow.py +655 -0
- attune/workflows/test_gen.py +54 -0
- attune/workflows/test_gen_behavioral.py +477 -0
- attune/workflows/test_gen_parallel.py +341 -0
- attune/workflows/test_lifecycle.py +526 -0
- attune/workflows/test_maintenance.py +627 -0
- attune/workflows/test_maintenance_cli.py +590 -0
- attune/workflows/test_maintenance_crew.py +840 -0
- attune/workflows/test_runner.py +622 -0
- attune/workflows/tier_tracking.py +531 -0
- attune/workflows/xml_enhanced_crew.py +285 -0
- attune_ai-2.0.0.dist-info/METADATA +1026 -0
- attune_ai-2.0.0.dist-info/RECORD +457 -0
- attune_ai-2.0.0.dist-info/WHEEL +5 -0
- attune_ai-2.0.0.dist-info/entry_points.txt +26 -0
- attune_ai-2.0.0.dist-info/licenses/LICENSE +201 -0
- attune_ai-2.0.0.dist-info/licenses/LICENSE_CHANGE_ANNOUNCEMENT.md +101 -0
- attune_ai-2.0.0.dist-info/top_level.txt +5 -0
- attune_healthcare/__init__.py +13 -0
- attune_healthcare/monitors/__init__.py +9 -0
- attune_healthcare/monitors/clinical_protocol_monitor.py +315 -0
- attune_healthcare/monitors/monitoring/__init__.py +44 -0
- attune_healthcare/monitors/monitoring/protocol_checker.py +300 -0
- attune_healthcare/monitors/monitoring/protocol_loader.py +214 -0
- attune_healthcare/monitors/monitoring/sensor_parsers.py +306 -0
- attune_healthcare/monitors/monitoring/trajectory_analyzer.py +389 -0
- attune_llm/README.md +553 -0
- attune_llm/__init__.py +28 -0
- attune_llm/agent_factory/__init__.py +53 -0
- attune_llm/agent_factory/adapters/__init__.py +85 -0
- attune_llm/agent_factory/adapters/autogen_adapter.py +312 -0
- attune_llm/agent_factory/adapters/crewai_adapter.py +483 -0
- attune_llm/agent_factory/adapters/haystack_adapter.py +298 -0
- attune_llm/agent_factory/adapters/langchain_adapter.py +362 -0
- attune_llm/agent_factory/adapters/langgraph_adapter.py +333 -0
- attune_llm/agent_factory/adapters/native.py +228 -0
- attune_llm/agent_factory/adapters/wizard_adapter.py +423 -0
- attune_llm/agent_factory/base.py +305 -0
- attune_llm/agent_factory/crews/__init__.py +67 -0
- attune_llm/agent_factory/crews/code_review.py +1113 -0
- attune_llm/agent_factory/crews/health_check.py +1262 -0
- attune_llm/agent_factory/crews/refactoring.py +1128 -0
- attune_llm/agent_factory/crews/security_audit.py +1018 -0
- attune_llm/agent_factory/decorators.py +287 -0
- attune_llm/agent_factory/factory.py +558 -0
- attune_llm/agent_factory/framework.py +193 -0
- attune_llm/agent_factory/memory_integration.py +328 -0
- attune_llm/agent_factory/resilient.py +320 -0
- attune_llm/agents_md/__init__.py +22 -0
- attune_llm/agents_md/loader.py +218 -0
- attune_llm/agents_md/parser.py +271 -0
- attune_llm/agents_md/registry.py +307 -0
- attune_llm/claude_memory.py +466 -0
- attune_llm/cli/__init__.py +8 -0
- attune_llm/cli/sync_claude.py +487 -0
- attune_llm/code_health.py +1313 -0
- attune_llm/commands/__init__.py +51 -0
- attune_llm/commands/context.py +375 -0
- attune_llm/commands/loader.py +301 -0
- attune_llm/commands/models.py +231 -0
- attune_llm/commands/parser.py +371 -0
- attune_llm/commands/registry.py +429 -0
- attune_llm/config/__init__.py +29 -0
- attune_llm/config/unified.py +291 -0
- attune_llm/context/__init__.py +22 -0
- attune_llm/context/compaction.py +455 -0
- attune_llm/context/manager.py +434 -0
- attune_llm/contextual_patterns.py +361 -0
- attune_llm/core.py +907 -0
- attune_llm/git_pattern_extractor.py +435 -0
- attune_llm/hooks/__init__.py +24 -0
- attune_llm/hooks/config.py +306 -0
- attune_llm/hooks/executor.py +289 -0
- attune_llm/hooks/registry.py +302 -0
- attune_llm/hooks/scripts/__init__.py +39 -0
- attune_llm/hooks/scripts/evaluate_session.py +201 -0
- attune_llm/hooks/scripts/first_time_init.py +285 -0
- attune_llm/hooks/scripts/pre_compact.py +207 -0
- attune_llm/hooks/scripts/session_end.py +183 -0
- attune_llm/hooks/scripts/session_start.py +163 -0
- attune_llm/hooks/scripts/suggest_compact.py +225 -0
- attune_llm/learning/__init__.py +30 -0
- attune_llm/learning/evaluator.py +438 -0
- attune_llm/learning/extractor.py +514 -0
- attune_llm/learning/storage.py +560 -0
- attune_llm/levels.py +227 -0
- attune_llm/pattern_confidence.py +414 -0
- attune_llm/pattern_resolver.py +272 -0
- attune_llm/pattern_summary.py +350 -0
- attune_llm/providers.py +967 -0
- attune_llm/routing/__init__.py +32 -0
- attune_llm/routing/model_router.py +362 -0
- attune_llm/security/IMPLEMENTATION_SUMMARY.md +413 -0
- attune_llm/security/PHASE2_COMPLETE.md +384 -0
- attune_llm/security/PHASE2_SECRETS_DETECTOR_COMPLETE.md +271 -0
- attune_llm/security/QUICK_REFERENCE.md +316 -0
- attune_llm/security/README.md +262 -0
- attune_llm/security/__init__.py +62 -0
- attune_llm/security/audit_logger.py +929 -0
- attune_llm/security/audit_logger_example.py +152 -0
- attune_llm/security/pii_scrubber.py +640 -0
- attune_llm/security/secrets_detector.py +678 -0
- attune_llm/security/secrets_detector_example.py +304 -0
- attune_llm/security/secure_memdocs.py +1192 -0
- attune_llm/security/secure_memdocs_example.py +278 -0
- attune_llm/session_status.py +745 -0
- attune_llm/state.py +246 -0
- attune_llm/utils/__init__.py +5 -0
- attune_llm/utils/tokens.py +349 -0
- attune_software/SOFTWARE_PLUGIN_README.md +57 -0
- attune_software/__init__.py +13 -0
- attune_software/cli/__init__.py +120 -0
- attune_software/cli/inspect.py +362 -0
- attune_software/cli.py +574 -0
- attune_software/plugin.py +188 -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
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Deep Study AI, LLC
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# Empathy Framework is Now Fully Open Source (Apache 2.0)
|
|
2
|
+
|
|
3
|
+
**Date:** January 28, 2026
|
|
4
|
+
|
|
5
|
+
We're excited to announce that **Empathy Framework is now fully open source** under the Apache License 2.0!
|
|
6
|
+
|
|
7
|
+
## What Changed?
|
|
8
|
+
|
|
9
|
+
- **Before:** Fair Source License 0.9 (free for small teams, paid for larger organizations)
|
|
10
|
+
- **After:** Apache License 2.0 (free and open source for everyone)
|
|
11
|
+
|
|
12
|
+
## Why Apache 2.0?
|
|
13
|
+
|
|
14
|
+
Empathy Framework helps developers save 70-85% on LLM costs through:
|
|
15
|
+
- Progressive tier escalation (cheap models for simple tasks)
|
|
16
|
+
- Intelligent caching (85% hit rates)
|
|
17
|
+
- Batch processing (50% cost reduction)
|
|
18
|
+
- Multi-agent orchestration
|
|
19
|
+
|
|
20
|
+
**But we realized the license was limiting adoption**, the restrictions made developers hesitant to try the framework.
|
|
21
|
+
|
|
22
|
+
**Open source first. Revenue later.** The path to sustainable business is:
|
|
23
|
+
1. **Adoption** - Get the framework into developers' hands
|
|
24
|
+
2. **Community** - Build contributors and advocates
|
|
25
|
+
3. **Value Creation** - Prove the technology works at scale
|
|
26
|
+
4. **Monetization** - Offer hosted services, enterprise features, support
|
|
27
|
+
|
|
28
|
+
We were trying to skip to step 4. That doesn't work.
|
|
29
|
+
|
|
30
|
+
## What This Means for You
|
|
31
|
+
|
|
32
|
+
### If you're a developer:
|
|
33
|
+
- ✅ **Use it freely** - Personal projects, commercial products, anything
|
|
34
|
+
- ✅ **Fork and modify** - Build on top of it however you want
|
|
35
|
+
- ✅ **Contribute** - PRs welcome, no CLA required
|
|
36
|
+
- ✅ **No restrictions** - No employee limits, no usage limits
|
|
37
|
+
|
|
38
|
+
### If you're a company:
|
|
39
|
+
- ✅ **No commercial license needed** - Use in production freely
|
|
40
|
+
- ✅ **Enterprise-friendly** - Apache 2.0 is approved by most legal teams
|
|
41
|
+
- ✅ **Patent protection** - Apache 2.0 includes patent grants
|
|
42
|
+
- ✅ **Clear terms** - Well-understood OSI-approved license
|
|
43
|
+
|
|
44
|
+
## What Hasn't Changed
|
|
45
|
+
|
|
46
|
+
- **Same great features** - All the cost optimization, caching, orchestration
|
|
47
|
+
- **Same innovation** - We're still building the best AI framework
|
|
48
|
+
- **Same commitment** - Active development, responsive maintainers
|
|
49
|
+
- **Same quality** - 7,168 tests passing (99.9%)
|
|
50
|
+
|
|
51
|
+
## Our Commitment Going Forward
|
|
52
|
+
|
|
53
|
+
We're doubling down on making Empathy Framework the best AI orchestration tool:
|
|
54
|
+
|
|
55
|
+
1. **Claude-native focus** - Leveraging prompt caching, 200K context, extended thinking
|
|
56
|
+
2. **Performance** - 18x faster than v4.8 (already shipped in v4.9)
|
|
57
|
+
3. **Cost optimization** - Batch API, caching, adaptive routing (shipped in v5.0.2)
|
|
58
|
+
4. **Developer experience** - Better docs, more examples, easier onboarding
|
|
59
|
+
|
|
60
|
+
## How You Can Help
|
|
61
|
+
|
|
62
|
+
Now that we're fully open source, we need **adoption and feedback**:
|
|
63
|
+
|
|
64
|
+
- ⭐ **Star the repo** - https://github.com/Smart-AI-Memory/attune-ai
|
|
65
|
+
- 🐛 **Report bugs** - Help us improve quality
|
|
66
|
+
- 💡 **Share ideas** - Feature requests welcome
|
|
67
|
+
- 📝 **Write tutorials** - Show others how to use it
|
|
68
|
+
- 🤝 **Contribute code** - PRs appreciated
|
|
69
|
+
|
|
70
|
+
## Future Monetization
|
|
71
|
+
|
|
72
|
+
Going open source doesn't mean we won't build a business. We plan to offer:
|
|
73
|
+
|
|
74
|
+
- **Empathy Cloud** - Hosted/managed version (like Vercel for Next.js)
|
|
75
|
+
- **Enterprise Edition** - Advanced features (SSO, audit logs, team management)
|
|
76
|
+
- **Support Contracts** - SLAs, dedicated help, custom integrations
|
|
77
|
+
- **Consulting** - Help teams implement AI orchestration
|
|
78
|
+
|
|
79
|
+
But **first, we need adoption**. And that means being fully open source.
|
|
80
|
+
|
|
81
|
+
## Get Started
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install attune-ai[developer]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Read the docs: https://smartaimemory.com/framework-docs/
|
|
88
|
+
|
|
89
|
+
Join the community: https://github.com/Smart-AI-Memory/attune-ai/discussions
|
|
90
|
+
|
|
91
|
+
## Thank You
|
|
92
|
+
|
|
93
|
+
To everyone who believed in Empathy Framework under Fair Source - thank you. This change makes the project accessible to everyone, not just a select few.
|
|
94
|
+
|
|
95
|
+
Let's build the future of AI orchestration together.
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
**Questions?** Open an issue or discussion on GitHub.
|
|
100
|
+
|
|
101
|
+
**Built by [Deep Study AI, LLC](https://smartaimemory.com)** · Licensed under [Apache 2.0](LICENSE)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"""Empathy Healthcare Plugin
|
|
2
|
+
|
|
3
|
+
Clinical protocol monitoring using the empathy framework.
|
|
4
|
+
|
|
5
|
+
Copyright 2025 Smart AI Memory, LLC
|
|
6
|
+
Licensed under Fair Source 0.9
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__version__ = "1.0.0"
|
|
10
|
+
|
|
11
|
+
from .monitors.clinical_protocol_monitor import ClinicalProtocolMonitor
|
|
12
|
+
|
|
13
|
+
__all__ = ["ClinicalProtocolMonitor"]
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
"""Clinical Protocol Monitor (Level 4)
|
|
2
|
+
|
|
3
|
+
Main monitoring system that combines protocol checking and trajectory analysis.
|
|
4
|
+
|
|
5
|
+
This is the healthcare equivalent of the Advanced Debugging Wizard.
|
|
6
|
+
|
|
7
|
+
Copyright 2025 Smart AI Memory, LLC
|
|
8
|
+
Licensed under Fair Source 0.9
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import logging
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
from .monitoring.protocol_checker import ProtocolChecker, ProtocolCheckResult
|
|
16
|
+
from .monitoring.protocol_loader import ClinicalProtocol, ProtocolLoader
|
|
17
|
+
from .monitoring.sensor_parsers import normalize_vitals, parse_sensor_data
|
|
18
|
+
from .monitoring.trajectory_analyzer import TrajectoryAnalyzer, TrajectoryPrediction
|
|
19
|
+
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class ClinicalProtocolMonitor:
|
|
24
|
+
"""Clinical Protocol Monitoring System.
|
|
25
|
+
|
|
26
|
+
Monitors patient sensor data against clinical protocols using
|
|
27
|
+
the same systematic approach as linting configuration:
|
|
28
|
+
|
|
29
|
+
1. Load protocol (the "config")
|
|
30
|
+
2. Parse sensor data (the "code state")
|
|
31
|
+
3. Check compliance (run the "linter")
|
|
32
|
+
4. Predict trajectory (Level 4 - anticipatory)
|
|
33
|
+
5. Generate alerts and documentation
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def __init__(self, protocol_directory: str | None = None):
|
|
37
|
+
self.protocol_loader = ProtocolLoader(protocol_directory)
|
|
38
|
+
self.protocol_checker = ProtocolChecker()
|
|
39
|
+
self.trajectory_analyzer = TrajectoryAnalyzer()
|
|
40
|
+
|
|
41
|
+
# Active protocols per patient
|
|
42
|
+
self.active_protocols: dict[str, ClinicalProtocol] = {}
|
|
43
|
+
|
|
44
|
+
# Historical data per patient
|
|
45
|
+
self.patient_history: dict[str, list[dict[str, Any]]] = {}
|
|
46
|
+
|
|
47
|
+
def load_protocol(
|
|
48
|
+
self,
|
|
49
|
+
patient_id: str,
|
|
50
|
+
protocol_name: str,
|
|
51
|
+
patient_context: dict[str, Any] | None = None,
|
|
52
|
+
) -> ClinicalProtocol:
|
|
53
|
+
"""Load and activate protocol for patient.
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
patient_id: Patient identifier
|
|
57
|
+
protocol_name: Name of protocol to load
|
|
58
|
+
patient_context: Additional patient context
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
Loaded protocol
|
|
62
|
+
|
|
63
|
+
Example:
|
|
64
|
+
>>> monitor = ClinicalProtocolMonitor()
|
|
65
|
+
>>> protocol = monitor.load_protocol(
|
|
66
|
+
... patient_id="12345",
|
|
67
|
+
... protocol_name="sepsis",
|
|
68
|
+
... patient_context={"age": 65, "post_op_day": 2}
|
|
69
|
+
... )
|
|
70
|
+
|
|
71
|
+
"""
|
|
72
|
+
protocol = self.protocol_loader.load_protocol(protocol_name)
|
|
73
|
+
self.active_protocols[patient_id] = protocol
|
|
74
|
+
|
|
75
|
+
logger.info(f"Loaded {protocol.name} v{protocol.version} for patient {patient_id}")
|
|
76
|
+
|
|
77
|
+
return protocol
|
|
78
|
+
|
|
79
|
+
async def analyze(self, context: dict[str, Any]) -> dict[str, Any]:
|
|
80
|
+
"""Main analysis method - unified interface.
|
|
81
|
+
|
|
82
|
+
Context expects:
|
|
83
|
+
- patient_id: Patient identifier
|
|
84
|
+
- sensor_data: Current sensor readings (JSON string or dict)
|
|
85
|
+
- sensor_format: "simple_json" or "fhir" (default: simple_json)
|
|
86
|
+
- protocol_name: Protocol to check (optional if already loaded)
|
|
87
|
+
- intervention_status: Status of interventions (optional)
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Comprehensive analysis with alerts, predictions, recommendations
|
|
91
|
+
|
|
92
|
+
"""
|
|
93
|
+
patient_id = context.get("patient_id")
|
|
94
|
+
sensor_data = context.get("sensor_data")
|
|
95
|
+
sensor_format = context.get("sensor_format", "simple_json")
|
|
96
|
+
protocol_name = context.get("protocol_name")
|
|
97
|
+
intervention_status = context.get("intervention_status", {})
|
|
98
|
+
|
|
99
|
+
if not patient_id:
|
|
100
|
+
return {"error": "patient_id required"}
|
|
101
|
+
|
|
102
|
+
if not sensor_data:
|
|
103
|
+
return {"error": "sensor_data required"}
|
|
104
|
+
|
|
105
|
+
# Load protocol if not already active
|
|
106
|
+
if patient_id not in self.active_protocols and protocol_name:
|
|
107
|
+
self.load_protocol(patient_id, protocol_name)
|
|
108
|
+
|
|
109
|
+
if patient_id not in self.active_protocols:
|
|
110
|
+
return {"error": f"No active protocol for patient {patient_id}"}
|
|
111
|
+
|
|
112
|
+
protocol = self.active_protocols[patient_id]
|
|
113
|
+
|
|
114
|
+
# Parse sensor data
|
|
115
|
+
if isinstance(sensor_data, str):
|
|
116
|
+
readings = parse_sensor_data(sensor_data, sensor_format)
|
|
117
|
+
normalized_data = normalize_vitals(readings)
|
|
118
|
+
else:
|
|
119
|
+
normalized_data = sensor_data
|
|
120
|
+
|
|
121
|
+
# Store in history
|
|
122
|
+
if patient_id not in self.patient_history:
|
|
123
|
+
self.patient_history[patient_id] = []
|
|
124
|
+
|
|
125
|
+
historical_entry = {"timestamp": datetime.now().isoformat(), **normalized_data}
|
|
126
|
+
self.patient_history[patient_id].append(historical_entry)
|
|
127
|
+
|
|
128
|
+
# Keep last 24 hours only
|
|
129
|
+
if len(self.patient_history[patient_id]) > 144: # 24hrs at 10min intervals
|
|
130
|
+
self.patient_history[patient_id] = self.patient_history[patient_id][-144:]
|
|
131
|
+
|
|
132
|
+
# Phase 1: Check protocol compliance
|
|
133
|
+
compliance_result = self.protocol_checker.check_compliance(
|
|
134
|
+
protocol,
|
|
135
|
+
normalized_data,
|
|
136
|
+
intervention_status,
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
# Phase 2: Analyze trajectory (Level 4)
|
|
140
|
+
trajectory_prediction = self.trajectory_analyzer.analyze_trajectory(
|
|
141
|
+
normalized_data,
|
|
142
|
+
self.patient_history[patient_id][:-1], # Exclude current reading
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
# Phase 3: Generate alerts
|
|
146
|
+
alerts = self._generate_alerts(compliance_result, trajectory_prediction)
|
|
147
|
+
|
|
148
|
+
# Phase 4: Generate recommendations
|
|
149
|
+
recommendations = self._generate_recommendations(
|
|
150
|
+
compliance_result,
|
|
151
|
+
trajectory_prediction,
|
|
152
|
+
protocol,
|
|
153
|
+
)
|
|
154
|
+
|
|
155
|
+
# Phase 5: Generate predictions (Level 4)
|
|
156
|
+
predictions = self._generate_predictions(trajectory_prediction, compliance_result)
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
"patient_id": patient_id,
|
|
160
|
+
"protocol": {"name": protocol.name, "version": protocol.version},
|
|
161
|
+
"current_vitals": normalized_data,
|
|
162
|
+
# Protocol compliance (like linter output)
|
|
163
|
+
"protocol_compliance": {
|
|
164
|
+
"activated": compliance_result.protocol_activated,
|
|
165
|
+
"score": compliance_result.activation_score,
|
|
166
|
+
"threshold": compliance_result.threshold,
|
|
167
|
+
"alert_level": compliance_result.alert_level,
|
|
168
|
+
"deviations": [
|
|
169
|
+
{
|
|
170
|
+
"action": d.intervention.action,
|
|
171
|
+
"status": d.status.value,
|
|
172
|
+
"due": d.intervention.timing,
|
|
173
|
+
"reasoning": d.reasoning,
|
|
174
|
+
}
|
|
175
|
+
for d in compliance_result.deviations
|
|
176
|
+
],
|
|
177
|
+
"compliant": compliance_result.compliant_items,
|
|
178
|
+
},
|
|
179
|
+
# Trajectory analysis (Level 4)
|
|
180
|
+
"trajectory": {
|
|
181
|
+
"state": trajectory_prediction.trajectory_state,
|
|
182
|
+
"estimated_time_to_critical": trajectory_prediction.estimated_time_to_critical,
|
|
183
|
+
"trends": [
|
|
184
|
+
{
|
|
185
|
+
"parameter": t.parameter,
|
|
186
|
+
"current": t.current_value,
|
|
187
|
+
"change": t.change,
|
|
188
|
+
"direction": t.direction,
|
|
189
|
+
"concerning": t.concerning,
|
|
190
|
+
"reasoning": t.reasoning,
|
|
191
|
+
}
|
|
192
|
+
for t in trajectory_prediction.vital_trends
|
|
193
|
+
],
|
|
194
|
+
"assessment": trajectory_prediction.overall_assessment,
|
|
195
|
+
"confidence": trajectory_prediction.confidence,
|
|
196
|
+
},
|
|
197
|
+
# Alerts
|
|
198
|
+
"alerts": alerts,
|
|
199
|
+
# Standard wizard outputs
|
|
200
|
+
"predictions": predictions,
|
|
201
|
+
"recommendations": recommendations,
|
|
202
|
+
"confidence": trajectory_prediction.confidence,
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
def _generate_alerts(
|
|
206
|
+
self,
|
|
207
|
+
compliance: ProtocolCheckResult,
|
|
208
|
+
trajectory: TrajectoryPrediction,
|
|
209
|
+
) -> list[dict[str, Any]]:
|
|
210
|
+
"""Generate alerts based on compliance and trajectory"""
|
|
211
|
+
alerts = []
|
|
212
|
+
|
|
213
|
+
# Protocol activation alert
|
|
214
|
+
if compliance.protocol_activated:
|
|
215
|
+
alerts.append(
|
|
216
|
+
{
|
|
217
|
+
"type": "protocol_activated",
|
|
218
|
+
"severity": "high",
|
|
219
|
+
"message": compliance.recommendation,
|
|
220
|
+
},
|
|
221
|
+
)
|
|
222
|
+
|
|
223
|
+
# Overdue intervention alerts
|
|
224
|
+
overdue = [d for d in compliance.deviations if d.status.value == "overdue"]
|
|
225
|
+
if overdue:
|
|
226
|
+
alerts.append(
|
|
227
|
+
{
|
|
228
|
+
"type": "intervention_overdue",
|
|
229
|
+
"severity": "critical",
|
|
230
|
+
"message": f"{len(overdue)} interventions overdue",
|
|
231
|
+
"details": [d.intervention.action for d in overdue],
|
|
232
|
+
},
|
|
233
|
+
)
|
|
234
|
+
|
|
235
|
+
# Trajectory alerts (Level 4 - early warning)
|
|
236
|
+
if trajectory.trajectory_state == "critical":
|
|
237
|
+
alerts.append(
|
|
238
|
+
{
|
|
239
|
+
"type": "trajectory_critical",
|
|
240
|
+
"severity": "critical",
|
|
241
|
+
"message": trajectory.overall_assessment,
|
|
242
|
+
},
|
|
243
|
+
)
|
|
244
|
+
elif trajectory.trajectory_state == "concerning":
|
|
245
|
+
alerts.append(
|
|
246
|
+
{
|
|
247
|
+
"type": "trajectory_concerning",
|
|
248
|
+
"severity": "warning",
|
|
249
|
+
"message": trajectory.overall_assessment,
|
|
250
|
+
"time_to_critical": trajectory.estimated_time_to_critical,
|
|
251
|
+
},
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
return alerts
|
|
255
|
+
|
|
256
|
+
def _generate_recommendations(
|
|
257
|
+
self,
|
|
258
|
+
compliance: ProtocolCheckResult,
|
|
259
|
+
trajectory: TrajectoryPrediction,
|
|
260
|
+
protocol: ClinicalProtocol,
|
|
261
|
+
) -> list[str]:
|
|
262
|
+
"""Generate actionable recommendations"""
|
|
263
|
+
recommendations = []
|
|
264
|
+
|
|
265
|
+
# From protocol compliance
|
|
266
|
+
if compliance.recommendation:
|
|
267
|
+
recommendations.append(compliance.recommendation)
|
|
268
|
+
|
|
269
|
+
# From trajectory analysis
|
|
270
|
+
recommendations.extend(trajectory.recommendations)
|
|
271
|
+
|
|
272
|
+
# From protocol-specific guidance
|
|
273
|
+
if compliance.protocol_activated:
|
|
274
|
+
recommendations.append(
|
|
275
|
+
f"Follow {protocol.name} monitoring frequency: {protocol.monitoring_frequency}",
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
return list(dict.fromkeys(recommendations)) # Deduplicate (preserves order)
|
|
279
|
+
|
|
280
|
+
def _generate_predictions(
|
|
281
|
+
self,
|
|
282
|
+
trajectory: TrajectoryPrediction,
|
|
283
|
+
compliance: ProtocolCheckResult,
|
|
284
|
+
) -> list[dict[str, Any]]:
|
|
285
|
+
"""Generate Level 4 predictions"""
|
|
286
|
+
predictions = []
|
|
287
|
+
|
|
288
|
+
# Trajectory-based predictions
|
|
289
|
+
if trajectory.trajectory_state in ["concerning", "critical"]:
|
|
290
|
+
predictions.append(
|
|
291
|
+
{
|
|
292
|
+
"type": "patient_deterioration",
|
|
293
|
+
"severity": "high" if trajectory.trajectory_state == "critical" else "medium",
|
|
294
|
+
"description": trajectory.overall_assessment,
|
|
295
|
+
"time_horizon": trajectory.estimated_time_to_critical,
|
|
296
|
+
"confidence": trajectory.confidence,
|
|
297
|
+
"prevention_steps": trajectory.recommendations,
|
|
298
|
+
},
|
|
299
|
+
)
|
|
300
|
+
|
|
301
|
+
# Compliance-based predictions
|
|
302
|
+
if compliance.protocol_activated and compliance.deviations:
|
|
303
|
+
predictions.append(
|
|
304
|
+
{
|
|
305
|
+
"type": "protocol_deviation_risk",
|
|
306
|
+
"severity": "high",
|
|
307
|
+
"description": "In our experience, protocol deviations correlate with adverse outcomes",
|
|
308
|
+
"prevention_steps": [
|
|
309
|
+
"Complete pending interventions",
|
|
310
|
+
"Document deviations and rationale",
|
|
311
|
+
],
|
|
312
|
+
},
|
|
313
|
+
)
|
|
314
|
+
|
|
315
|
+
return predictions
|