claude-mpm 3.1.3__py3-none-any.whl → 3.3.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.
- claude_mpm/__init__.py +3 -3
 - claude_mpm/__main__.py +0 -17
 - claude_mpm/agents/INSTRUCTIONS.md +149 -17
 - claude_mpm/agents/backups/INSTRUCTIONS.md +238 -0
 - claude_mpm/agents/base_agent.json +1 -1
 - claude_mpm/agents/templates/pm.json +25 -0
 - claude_mpm/agents/templates/research.json +2 -1
 - claude_mpm/cli/__init__.py +19 -23
 - claude_mpm/cli/commands/__init__.py +3 -1
 - claude_mpm/cli/commands/agents.py +7 -18
 - claude_mpm/cli/commands/info.py +5 -10
 - claude_mpm/cli/commands/memory.py +232 -0
 - claude_mpm/cli/commands/run.py +501 -28
 - claude_mpm/cli/commands/tickets.py +10 -17
 - claude_mpm/cli/commands/ui.py +15 -37
 - claude_mpm/cli/parser.py +91 -1
 - claude_mpm/cli/utils.py +9 -28
 - claude_mpm/config/socketio_config.py +256 -0
 - claude_mpm/constants.py +9 -0
 - claude_mpm/core/__init__.py +2 -2
 - claude_mpm/core/agent_registry.py +4 -4
 - claude_mpm/core/claude_runner.py +919 -0
 - claude_mpm/core/config.py +21 -1
 - claude_mpm/core/factories.py +1 -1
 - claude_mpm/core/hook_manager.py +196 -0
 - claude_mpm/core/pm_hook_interceptor.py +205 -0
 - claude_mpm/core/service_registry.py +1 -1
 - claude_mpm/core/simple_runner.py +323 -33
 - claude_mpm/core/socketio_pool.py +582 -0
 - claude_mpm/core/websocket_handler.py +233 -0
 - claude_mpm/deployment_paths.py +261 -0
 - claude_mpm/hooks/builtin/memory_hooks_example.py +67 -0
 - claude_mpm/hooks/claude_hooks/hook_handler.py +667 -679
 - claude_mpm/hooks/claude_hooks/hook_wrapper.sh +9 -4
 - claude_mpm/hooks/memory_integration_hook.py +312 -0
 - claude_mpm/models/__init__.py +9 -91
 - claude_mpm/orchestration/__init__.py +1 -1
 - claude_mpm/scripts/claude-mpm-socketio +32 -0
 - claude_mpm/scripts/claude_mpm_monitor.html +567 -0
 - claude_mpm/scripts/install_socketio_server.py +407 -0
 - claude_mpm/scripts/launch_monitor.py +132 -0
 - claude_mpm/scripts/launch_socketio_dashboard.py +261 -0
 - claude_mpm/scripts/manage_version.py +479 -0
 - claude_mpm/scripts/socketio_daemon.py +181 -0
 - claude_mpm/scripts/socketio_server_manager.py +428 -0
 - claude_mpm/services/__init__.py +5 -0
 - claude_mpm/services/agent_lifecycle_manager.py +76 -25
 - claude_mpm/services/agent_memory_manager.py +684 -0
 - claude_mpm/services/agent_modification_tracker.py +98 -17
 - claude_mpm/services/agent_persistence_service.py +33 -13
 - claude_mpm/services/agent_registry.py +82 -43
 - claude_mpm/services/hook_service.py +362 -0
 - claude_mpm/services/socketio_client_manager.py +474 -0
 - claude_mpm/services/socketio_server.py +922 -0
 - claude_mpm/services/standalone_socketio_server.py +631 -0
 - claude_mpm/services/ticket_manager.py +4 -5
 - claude_mpm/services/{ticket_manager_dependency_injection.py → ticket_manager_di.py} +12 -39
 - claude_mpm/services/{legacy_ticketing_service.py → ticketing_service_original.py} +9 -16
 - claude_mpm/services/version_control/semantic_versioning.py +9 -10
 - claude_mpm/services/websocket_server.py +376 -0
 - claude_mpm/utils/dependency_manager.py +211 -0
 - claude_mpm/utils/import_migration_example.py +80 -0
 - claude_mpm/utils/path_operations.py +0 -20
 - claude_mpm/web/open_dashboard.py +34 -0
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/METADATA +20 -9
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/RECORD +71 -50
 - claude_mpm-3.3.0.dist-info/entry_points.txt +7 -0
 - claude_mpm/cli_old.py +0 -728
 - claude_mpm/models/common.py +0 -41
 - claude_mpm/models/lifecycle.py +0 -97
 - claude_mpm/models/modification.py +0 -126
 - claude_mpm/models/persistence.py +0 -57
 - claude_mpm/models/registry.py +0 -91
 - claude_mpm/security/__init__.py +0 -8
 - claude_mpm/security/bash_validator.py +0 -393
 - claude_mpm-3.1.3.dist-info/entry_points.txt +0 -4
 - /claude_mpm/{cli_enhancements.py → experimental/cli_enhancements.py} +0 -0
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/WHEEL +0 -0
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/licenses/LICENSE +0 -0
 - {claude_mpm-3.1.3.dist-info → claude_mpm-3.3.0.dist-info}/top_level.txt +0 -0
 
    
        claude_mpm/models/common.py
    DELETED
    
    | 
         @@ -1,41 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #!/usr/bin/env python3
         
     | 
| 
       2 
     | 
    
         
            -
            """
         
     | 
| 
       3 
     | 
    
         
            -
            Common Models
         
     | 
| 
       4 
     | 
    
         
            -
            =============
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            Shared enums and models used across multiple services.
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            WHY: This module contains enums and models that are used by multiple
         
     | 
| 
       9 
     | 
    
         
            -
            services but don't belong to any specific domain.
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            DESIGN DECISION: Creating a common module prevents:
         
     | 
| 
       12 
     | 
    
         
            -
            - Circular imports between specific model modules
         
     | 
| 
       13 
     | 
    
         
            -
            - Duplication of shared enums
         
     | 
| 
       14 
     | 
    
         
            -
            - Inconsistencies in shared constants
         
     | 
| 
       15 
     | 
    
         
            -
            """
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            from enum import Enum
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            # Note: We're not creating a unified TierType enum here because:
         
     | 
| 
       21 
     | 
    
         
            -
            # 1. ModificationTier uses PROJECT/USER/SYSTEM for modification tracking
         
     | 
| 
       22 
     | 
    
         
            -
            # 2. AgentTier uses USER/SYSTEM for registry discovery
         
     | 
| 
       23 
     | 
    
         
            -
            # 3. AgentType in agent_definition.py is for agent classification (CORE/PROJECT/CUSTOM/etc)
         
     | 
| 
       24 
     | 
    
         
            -
            # These serve different purposes and should remain separate.
         
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            # Common constants that might be shared across services
         
     | 
| 
       27 
     | 
    
         
            -
            AGENT_FILE_EXTENSIONS = {'.md', '.json', '.yaml', '.yml'}
         
     | 
| 
       28 
     | 
    
         
            -
            AGENT_IGNORE_PATTERNS = {'__pycache__', '.git', 'node_modules', '.pytest_cache'}
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
            # Core agent types used for classification
         
     | 
| 
       31 
     | 
    
         
            -
            CORE_AGENT_TYPES = {
         
     | 
| 
       32 
     | 
    
         
            -
                'engineer', 'architect', 'qa', 'security', 'documentation',
         
     | 
| 
       33 
     | 
    
         
            -
                'ops', 'data', 'research', 'version_control'
         
     | 
| 
       34 
     | 
    
         
            -
            }
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            SPECIALIZED_AGENT_TYPES = {
         
     | 
| 
       37 
     | 
    
         
            -
                'pm_orchestrator', 'frontend', 'backend', 'devops', 'ml',
         
     | 
| 
       38 
     | 
    
         
            -
                'database', 'api', 'mobile', 'cloud', 'testing'
         
     | 
| 
       39 
     | 
    
         
            -
            }
         
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
            ALL_AGENT_TYPES = CORE_AGENT_TYPES | SPECIALIZED_AGENT_TYPES
         
     | 
    
        claude_mpm/models/lifecycle.py
    DELETED
    
    | 
         @@ -1,97 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #!/usr/bin/env python3
         
     | 
| 
       2 
     | 
    
         
            -
            """
         
     | 
| 
       3 
     | 
    
         
            -
            Lifecycle Models
         
     | 
| 
       4 
     | 
    
         
            -
            ================
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            Data models for agent lifecycle management.
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            WHY: These models are extracted from agent_lifecycle_manager.py to centralize
         
     | 
| 
       9 
     | 
    
         
            -
            data definitions and reduce duplication across services.
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            DESIGN DECISION: Keeping lifecycle-specific models separate allows:
         
     | 
| 
       12 
     | 
    
         
            -
            - Clear separation of concerns
         
     | 
| 
       13 
     | 
    
         
            -
            - Easy reuse across different services
         
     | 
| 
       14 
     | 
    
         
            -
            - Independent evolution of data structures
         
     | 
| 
       15 
     | 
    
         
            -
            """
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            from dataclasses import dataclass, field
         
     | 
| 
       18 
     | 
    
         
            -
            from datetime import datetime
         
     | 
| 
       19 
     | 
    
         
            -
            from enum import Enum
         
     | 
| 
       20 
     | 
    
         
            -
            from typing import Dict, List, Optional, Any
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            from claude_mpm.models.modification import ModificationTier
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
            class LifecycleOperation(Enum):
         
     | 
| 
       26 
     | 
    
         
            -
                """Agent lifecycle operations."""
         
     | 
| 
       27 
     | 
    
         
            -
                CREATE = "create"
         
     | 
| 
       28 
     | 
    
         
            -
                UPDATE = "update"
         
     | 
| 
       29 
     | 
    
         
            -
                DELETE = "delete"
         
     | 
| 
       30 
     | 
    
         
            -
                RESTORE = "restore"
         
     | 
| 
       31 
     | 
    
         
            -
                MIGRATE = "migrate"
         
     | 
| 
       32 
     | 
    
         
            -
                REPLICATE = "replicate"
         
     | 
| 
       33 
     | 
    
         
            -
                VALIDATE = "validate"
         
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
            class LifecycleState(Enum):
         
     | 
| 
       37 
     | 
    
         
            -
                """Agent lifecycle states."""
         
     | 
| 
       38 
     | 
    
         
            -
                ACTIVE = "active"
         
     | 
| 
       39 
     | 
    
         
            -
                MODIFIED = "modified"
         
     | 
| 
       40 
     | 
    
         
            -
                DELETED = "deleted"
         
     | 
| 
       41 
     | 
    
         
            -
                CONFLICTED = "conflicted"
         
     | 
| 
       42 
     | 
    
         
            -
                MIGRATING = "migrating"
         
     | 
| 
       43 
     | 
    
         
            -
                VALIDATING = "validating"
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
            @dataclass
         
     | 
| 
       47 
     | 
    
         
            -
            class AgentLifecycleRecord:
         
     | 
| 
       48 
     | 
    
         
            -
                """Complete lifecycle record for an agent.
         
     | 
| 
       49 
     | 
    
         
            -
                
         
     | 
| 
       50 
     | 
    
         
            -
                WHY: This model tracks the complete history and state of an agent
         
     | 
| 
       51 
     | 
    
         
            -
                throughout its lifecycle, enabling audit trails and state management.
         
     | 
| 
       52 
     | 
    
         
            -
                """
         
     | 
| 
       53 
     | 
    
         
            -
                
         
     | 
| 
       54 
     | 
    
         
            -
                agent_name: str
         
     | 
| 
       55 
     | 
    
         
            -
                current_state: LifecycleState
         
     | 
| 
       56 
     | 
    
         
            -
                tier: ModificationTier
         
     | 
| 
       57 
     | 
    
         
            -
                file_path: str
         
     | 
| 
       58 
     | 
    
         
            -
                created_at: float
         
     | 
| 
       59 
     | 
    
         
            -
                last_modified: float
         
     | 
| 
       60 
     | 
    
         
            -
                version: str
         
     | 
| 
       61 
     | 
    
         
            -
                modifications: List[str] = field(default_factory=list)  # Modification IDs
         
     | 
| 
       62 
     | 
    
         
            -
                persistence_operations: List[str] = field(default_factory=list)  # Operation IDs
         
     | 
| 
       63 
     | 
    
         
            -
                backup_paths: List[str] = field(default_factory=list)
         
     | 
| 
       64 
     | 
    
         
            -
                validation_status: str = "valid"
         
     | 
| 
       65 
     | 
    
         
            -
                validation_errors: List[str] = field(default_factory=list)
         
     | 
| 
       66 
     | 
    
         
            -
                metadata: Dict[str, Any] = field(default_factory=dict)
         
     | 
| 
       67 
     | 
    
         
            -
                
         
     | 
| 
       68 
     | 
    
         
            -
                @property
         
     | 
| 
       69 
     | 
    
         
            -
                def age_days(self) -> float:
         
     | 
| 
       70 
     | 
    
         
            -
                    """Get age in days."""
         
     | 
| 
       71 
     | 
    
         
            -
                    import time
         
     | 
| 
       72 
     | 
    
         
            -
                    return (time.time() - self.created_at) / (24 * 3600)
         
     | 
| 
       73 
     | 
    
         
            -
                
         
     | 
| 
       74 
     | 
    
         
            -
                @property
         
     | 
| 
       75 
     | 
    
         
            -
                def last_modified_datetime(self) -> datetime:
         
     | 
| 
       76 
     | 
    
         
            -
                    """Get last modified as datetime."""
         
     | 
| 
       77 
     | 
    
         
            -
                    return datetime.fromtimestamp(self.last_modified)
         
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
            @dataclass
         
     | 
| 
       81 
     | 
    
         
            -
            class LifecycleOperationResult:
         
     | 
| 
       82 
     | 
    
         
            -
                """Result of a lifecycle operation.
         
     | 
| 
       83 
     | 
    
         
            -
                
         
     | 
| 
       84 
     | 
    
         
            -
                WHY: Provides a consistent structure for operation results,
         
     | 
| 
       85 
     | 
    
         
            -
                making it easier to track success/failure and gather metrics.
         
     | 
| 
       86 
     | 
    
         
            -
                """
         
     | 
| 
       87 
     | 
    
         
            -
                
         
     | 
| 
       88 
     | 
    
         
            -
                operation: LifecycleOperation
         
     | 
| 
       89 
     | 
    
         
            -
                agent_name: str
         
     | 
| 
       90 
     | 
    
         
            -
                success: bool
         
     | 
| 
       91 
     | 
    
         
            -
                duration_ms: float
         
     | 
| 
       92 
     | 
    
         
            -
                error_message: Optional[str] = None
         
     | 
| 
       93 
     | 
    
         
            -
                modification_id: Optional[str] = None
         
     | 
| 
       94 
     | 
    
         
            -
                persistence_id: Optional[str] = None
         
     | 
| 
       95 
     | 
    
         
            -
                cache_invalidated: bool = False
         
     | 
| 
       96 
     | 
    
         
            -
                registry_updated: bool = False
         
     | 
| 
       97 
     | 
    
         
            -
                metadata: Dict[str, Any] = field(default_factory=dict)
         
     | 
| 
         @@ -1,126 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #!/usr/bin/env python3
         
     | 
| 
       2 
     | 
    
         
            -
            """
         
     | 
| 
       3 
     | 
    
         
            -
            Modification Models
         
     | 
| 
       4 
     | 
    
         
            -
            ===================
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            Data models for agent modification tracking.
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            WHY: These models are extracted from agent_modification_tracker.py to centralize
         
     | 
| 
       9 
     | 
    
         
            -
            data definitions and enable reuse across services.
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            DESIGN DECISION: Modification tracking models are kept separate because:
         
     | 
| 
       12 
     | 
    
         
            -
            - They represent a distinct domain (change tracking)
         
     | 
| 
       13 
     | 
    
         
            -
            - Multiple services need to work with modifications
         
     | 
| 
       14 
     | 
    
         
            -
            - The structure can evolve independently of other models
         
     | 
| 
       15 
     | 
    
         
            -
            """
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            from dataclasses import dataclass, field, asdict
         
     | 
| 
       18 
     | 
    
         
            -
            from datetime import datetime
         
     | 
| 
       19 
     | 
    
         
            -
            from enum import Enum
         
     | 
| 
       20 
     | 
    
         
            -
            from typing import Dict, List, Optional, Any
         
     | 
| 
       21 
     | 
    
         
            -
            import time
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            class ModificationType(Enum):
         
     | 
| 
       25 
     | 
    
         
            -
                """Types of agent modifications."""
         
     | 
| 
       26 
     | 
    
         
            -
                CREATE = "create"
         
     | 
| 
       27 
     | 
    
         
            -
                MODIFY = "modify"
         
     | 
| 
       28 
     | 
    
         
            -
                DELETE = "delete"
         
     | 
| 
       29 
     | 
    
         
            -
                MOVE = "move"
         
     | 
| 
       30 
     | 
    
         
            -
                RESTORE = "restore"
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
            class ModificationTier(Enum):
         
     | 
| 
       34 
     | 
    
         
            -
                """Agent hierarchy tiers for modification tracking.
         
     | 
| 
       35 
     | 
    
         
            -
                
         
     | 
| 
       36 
     | 
    
         
            -
                WHY: This enum is used across multiple services to ensure
         
     | 
| 
       37 
     | 
    
         
            -
                consistent tier classification throughout the system.
         
     | 
| 
       38 
     | 
    
         
            -
                """
         
     | 
| 
       39 
     | 
    
         
            -
                PROJECT = "project"
         
     | 
| 
       40 
     | 
    
         
            -
                USER = "user"
         
     | 
| 
       41 
     | 
    
         
            -
                SYSTEM = "system"
         
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
            @dataclass
         
     | 
| 
       45 
     | 
    
         
            -
            class AgentModification:
         
     | 
| 
       46 
     | 
    
         
            -
                """Agent modification record with comprehensive metadata.
         
     | 
| 
       47 
     | 
    
         
            -
                
         
     | 
| 
       48 
     | 
    
         
            -
                WHY: This model captures all relevant information about a single
         
     | 
| 
       49 
     | 
    
         
            -
                modification event, enabling detailed audit trails and rollback capabilities.
         
     | 
| 
       50 
     | 
    
         
            -
                """
         
     | 
| 
       51 
     | 
    
         
            -
                
         
     | 
| 
       52 
     | 
    
         
            -
                modification_id: str
         
     | 
| 
       53 
     | 
    
         
            -
                agent_name: str
         
     | 
| 
       54 
     | 
    
         
            -
                modification_type: ModificationType
         
     | 
| 
       55 
     | 
    
         
            -
                tier: ModificationTier
         
     | 
| 
       56 
     | 
    
         
            -
                file_path: str
         
     | 
| 
       57 
     | 
    
         
            -
                timestamp: float
         
     | 
| 
       58 
     | 
    
         
            -
                user_id: Optional[str] = None
         
     | 
| 
       59 
     | 
    
         
            -
                modification_details: Dict[str, Any] = field(default_factory=dict)
         
     | 
| 
       60 
     | 
    
         
            -
                file_hash_before: Optional[str] = None
         
     | 
| 
       61 
     | 
    
         
            -
                file_hash_after: Optional[str] = None
         
     | 
| 
       62 
     | 
    
         
            -
                file_size_before: Optional[int] = None
         
     | 
| 
       63 
     | 
    
         
            -
                file_size_after: Optional[int] = None
         
     | 
| 
       64 
     | 
    
         
            -
                backup_path: Optional[str] = None
         
     | 
| 
       65 
     | 
    
         
            -
                validation_status: str = "pending"
         
     | 
| 
       66 
     | 
    
         
            -
                validation_errors: List[str] = field(default_factory=list)
         
     | 
| 
       67 
     | 
    
         
            -
                related_modifications: List[str] = field(default_factory=list)
         
     | 
| 
       68 
     | 
    
         
            -
                metadata: Dict[str, Any] = field(default_factory=dict)
         
     | 
| 
       69 
     | 
    
         
            -
                
         
     | 
| 
       70 
     | 
    
         
            -
                @property
         
     | 
| 
       71 
     | 
    
         
            -
                def modification_datetime(self) -> datetime:
         
     | 
| 
       72 
     | 
    
         
            -
                    """Get modification timestamp as datetime."""
         
     | 
| 
       73 
     | 
    
         
            -
                    return datetime.fromtimestamp(self.timestamp)
         
     | 
| 
       74 
     | 
    
         
            -
                
         
     | 
| 
       75 
     | 
    
         
            -
                @property
         
     | 
| 
       76 
     | 
    
         
            -
                def age_seconds(self) -> float:
         
     | 
| 
       77 
     | 
    
         
            -
                    """Get age of modification in seconds."""
         
     | 
| 
       78 
     | 
    
         
            -
                    return time.time() - self.timestamp
         
     | 
| 
       79 
     | 
    
         
            -
                
         
     | 
| 
       80 
     | 
    
         
            -
                def to_dict(self) -> Dict[str, Any]:
         
     | 
| 
       81 
     | 
    
         
            -
                    """Convert to dictionary for serialization."""
         
     | 
| 
       82 
     | 
    
         
            -
                    data = asdict(self)
         
     | 
| 
       83 
     | 
    
         
            -
                    data['modification_type'] = self.modification_type.value
         
     | 
| 
       84 
     | 
    
         
            -
                    data['tier'] = self.tier.value
         
     | 
| 
       85 
     | 
    
         
            -
                    return data
         
     | 
| 
       86 
     | 
    
         
            -
                
         
     | 
| 
       87 
     | 
    
         
            -
                @classmethod
         
     | 
| 
       88 
     | 
    
         
            -
                def from_dict(cls, data: Dict[str, Any]) -> 'AgentModification':
         
     | 
| 
       89 
     | 
    
         
            -
                    """Create from dictionary."""
         
     | 
| 
       90 
     | 
    
         
            -
                    data['modification_type'] = ModificationType(data['modification_type'])
         
     | 
| 
       91 
     | 
    
         
            -
                    data['tier'] = ModificationTier(data['tier'])
         
     | 
| 
       92 
     | 
    
         
            -
                    return cls(**data)
         
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
            @dataclass
         
     | 
| 
       96 
     | 
    
         
            -
            class ModificationHistory:
         
     | 
| 
       97 
     | 
    
         
            -
                """Complete modification history for an agent.
         
     | 
| 
       98 
     | 
    
         
            -
                
         
     | 
| 
       99 
     | 
    
         
            -
                WHY: Aggregates all modifications for a single agent, providing
         
     | 
| 
       100 
     | 
    
         
            -
                a complete change history for analysis and rollback.
         
     | 
| 
       101 
     | 
    
         
            -
                """
         
     | 
| 
       102 
     | 
    
         
            -
                
         
     | 
| 
       103 
     | 
    
         
            -
                agent_name: str
         
     | 
| 
       104 
     | 
    
         
            -
                modifications: List[AgentModification] = field(default_factory=list)
         
     | 
| 
       105 
     | 
    
         
            -
                current_version: Optional[str] = None
         
     | 
| 
       106 
     | 
    
         
            -
                total_modifications: int = 0
         
     | 
| 
       107 
     | 
    
         
            -
                first_seen: Optional[float] = None
         
     | 
| 
       108 
     | 
    
         
            -
                last_modified: Optional[float] = None
         
     | 
| 
       109 
     | 
    
         
            -
                
         
     | 
| 
       110 
     | 
    
         
            -
                def add_modification(self, modification: AgentModification) -> None:
         
     | 
| 
       111 
     | 
    
         
            -
                    """Add a modification to history."""
         
     | 
| 
       112 
     | 
    
         
            -
                    self.modifications.append(modification)
         
     | 
| 
       113 
     | 
    
         
            -
                    self.total_modifications += 1
         
     | 
| 
       114 
     | 
    
         
            -
                    self.last_modified = modification.timestamp
         
     | 
| 
       115 
     | 
    
         
            -
                    
         
     | 
| 
       116 
     | 
    
         
            -
                    if self.first_seen is None:
         
     | 
| 
       117 
     | 
    
         
            -
                        self.first_seen = modification.timestamp
         
     | 
| 
       118 
     | 
    
         
            -
                
         
     | 
| 
       119 
     | 
    
         
            -
                def get_recent_modifications(self, hours: int = 24) -> List[AgentModification]:
         
     | 
| 
       120 
     | 
    
         
            -
                    """Get modifications within specified hours."""
         
     | 
| 
       121 
     | 
    
         
            -
                    cutoff = time.time() - (hours * 3600)
         
     | 
| 
       122 
     | 
    
         
            -
                    return [mod for mod in self.modifications if mod.timestamp >= cutoff]
         
     | 
| 
       123 
     | 
    
         
            -
                
         
     | 
| 
       124 
     | 
    
         
            -
                def get_modifications_by_type(self, mod_type: ModificationType) -> List[AgentModification]:
         
     | 
| 
       125 
     | 
    
         
            -
                    """Get modifications by type."""
         
     | 
| 
       126 
     | 
    
         
            -
                    return [mod for mod in self.modifications if mod.modification_type == mod_type]
         
     | 
    
        claude_mpm/models/persistence.py
    DELETED
    
    | 
         @@ -1,57 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #!/usr/bin/env python3
         
     | 
| 
       2 
     | 
    
         
            -
            """
         
     | 
| 
       3 
     | 
    
         
            -
            Persistence Models
         
     | 
| 
       4 
     | 
    
         
            -
            ==================
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            Data models for agent persistence operations.
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            WHY: These models are extracted from agent_persistence_service.py to centralize
         
     | 
| 
       9 
     | 
    
         
            -
            data definitions and maintain consistency across services.
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            DESIGN DECISION: Persistence models are minimal because actual persistence
         
     | 
| 
       12 
     | 
    
         
            -
            is now handled by AgentManager, but we maintain these for API compatibility.
         
     | 
| 
       13 
     | 
    
         
            -
            """
         
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            from dataclasses import dataclass, field
         
     | 
| 
       16 
     | 
    
         
            -
            from enum import Enum
         
     | 
| 
       17 
     | 
    
         
            -
            from typing import Optional, Any, Dict
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
            class PersistenceStrategy(Enum):
         
     | 
| 
       21 
     | 
    
         
            -
                """Agent persistence strategies.
         
     | 
| 
       22 
     | 
    
         
            -
                
         
     | 
| 
       23 
     | 
    
         
            -
                WHY: Different strategies allow flexibility in how agents are persisted
         
     | 
| 
       24 
     | 
    
         
            -
                based on their tier and use case.
         
     | 
| 
       25 
     | 
    
         
            -
                """
         
     | 
| 
       26 
     | 
    
         
            -
                USER_OVERRIDE = "user_override"
         
     | 
| 
       27 
     | 
    
         
            -
                PROJECT_SPECIFIC = "project_specific"
         
     | 
| 
       28 
     | 
    
         
            -
                SYSTEM_DEFAULT = "system_default"
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
            class PersistenceOperation(Enum):
         
     | 
| 
       32 
     | 
    
         
            -
                """Persistence operation types."""
         
     | 
| 
       33 
     | 
    
         
            -
                CREATE = "create"
         
     | 
| 
       34 
     | 
    
         
            -
                UPDATE = "update"
         
     | 
| 
       35 
     | 
    
         
            -
                DELETE = "delete"
         
     | 
| 
       36 
     | 
    
         
            -
                BACKUP = "backup"
         
     | 
| 
       37 
     | 
    
         
            -
                RESTORE = "restore"
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
            @dataclass
         
     | 
| 
       41 
     | 
    
         
            -
            class PersistenceRecord:
         
     | 
| 
       42 
     | 
    
         
            -
                """Record of a persistence operation.
         
     | 
| 
       43 
     | 
    
         
            -
                
         
     | 
| 
       44 
     | 
    
         
            -
                WHY: Tracks persistence operations for audit trails and debugging,
         
     | 
| 
       45 
     | 
    
         
            -
                even though actual persistence is delegated to AgentManager.
         
     | 
| 
       46 
     | 
    
         
            -
                """
         
     | 
| 
       47 
     | 
    
         
            -
                operation_id: str
         
     | 
| 
       48 
     | 
    
         
            -
                operation_type: PersistenceOperation
         
     | 
| 
       49 
     | 
    
         
            -
                agent_name: str
         
     | 
| 
       50 
     | 
    
         
            -
                source_tier: Any  # Can be ModificationTier or string
         
     | 
| 
       51 
     | 
    
         
            -
                target_tier: Optional[Any] = None
         
     | 
| 
       52 
     | 
    
         
            -
                strategy: Optional[PersistenceStrategy] = None
         
     | 
| 
       53 
     | 
    
         
            -
                success: bool = True
         
     | 
| 
       54 
     | 
    
         
            -
                timestamp: float = 0.0
         
     | 
| 
       55 
     | 
    
         
            -
                file_path: Optional[str] = None
         
     | 
| 
       56 
     | 
    
         
            -
                error_message: Optional[str] = None
         
     | 
| 
       57 
     | 
    
         
            -
                metadata: Dict[str, Any] = field(default_factory=dict)
         
     | 
    
        claude_mpm/models/registry.py
    DELETED
    
    | 
         @@ -1,91 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #!/usr/bin/env python3
         
     | 
| 
       2 
     | 
    
         
            -
            """
         
     | 
| 
       3 
     | 
    
         
            -
            Registry Models
         
     | 
| 
       4 
     | 
    
         
            -
            ===============
         
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
            Data models for agent registry and discovery.
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            WHY: These models are extracted from agent_registry.py to centralize
         
     | 
| 
       9 
     | 
    
         
            -
            data definitions and avoid duplication with agent_definition.py models.
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            DESIGN DECISION: Registry models are kept separate from agent definitions
         
     | 
| 
       12 
     | 
    
         
            -
            because they serve different purposes:
         
     | 
| 
       13 
     | 
    
         
            -
            - Registry models are for discovery and management
         
     | 
| 
       14 
     | 
    
         
            -
            - Agent definitions are for execution and behavior
         
     | 
| 
       15 
     | 
    
         
            -
            """
         
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
            from dataclasses import dataclass, field, asdict
         
     | 
| 
       18 
     | 
    
         
            -
            from enum import Enum
         
     | 
| 
       19 
     | 
    
         
            -
            from typing import Dict, List, Any, Optional
         
     | 
| 
       20 
     | 
    
         
            -
            import time
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
            class AgentTier(Enum):
         
     | 
| 
       24 
     | 
    
         
            -
                """Agent hierarchy tiers for registry.
         
     | 
| 
       25 
     | 
    
         
            -
                
         
     | 
| 
       26 
     | 
    
         
            -
                WHY: Different from ModificationTier because registry uses a
         
     | 
| 
       27 
     | 
    
         
            -
                simpler two-tier system (user/system) for discovery.
         
     | 
| 
       28 
     | 
    
         
            -
                """
         
     | 
| 
       29 
     | 
    
         
            -
                USER = "user"
         
     | 
| 
       30 
     | 
    
         
            -
                SYSTEM = "system"
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
            @dataclass
         
     | 
| 
       34 
     | 
    
         
            -
            class AgentRegistryMetadata:
         
     | 
| 
       35 
     | 
    
         
            -
                """Registry-specific metadata for discovered agents.
         
     | 
| 
       36 
     | 
    
         
            -
                
         
     | 
| 
       37 
     | 
    
         
            -
                WHY: This is different from AgentMetadata in agent_definition.py because:
         
     | 
| 
       38 
     | 
    
         
            -
                - Registry needs discovery-specific information (path, checksum, etc.)
         
     | 
| 
       39 
     | 
    
         
            -
                - Agent definitions need behavior-specific information
         
     | 
| 
       40 
     | 
    
         
            -
                - Keeping them separate avoids coupling discovery to execution
         
     | 
| 
       41 
     | 
    
         
            -
                
         
     | 
| 
       42 
     | 
    
         
            -
                NOTE: This replaces the AgentMetadata class in agent_registry.py to avoid
         
     | 
| 
       43 
     | 
    
         
            -
                conflicts with the one in agent_definition.py
         
     | 
| 
       44 
     | 
    
         
            -
                """
         
     | 
| 
       45 
     | 
    
         
            -
                name: str
         
     | 
| 
       46 
     | 
    
         
            -
                path: str
         
     | 
| 
       47 
     | 
    
         
            -
                tier: AgentTier
         
     | 
| 
       48 
     | 
    
         
            -
                agent_type: str  # Using string instead of AgentType enum to avoid conflicts
         
     | 
| 
       49 
     | 
    
         
            -
                description: str = ""
         
     | 
| 
       50 
     | 
    
         
            -
                version: str = "0.0.0"
         
     | 
| 
       51 
     | 
    
         
            -
                dependencies: List[str] = field(default_factory=list)
         
     | 
| 
       52 
     | 
    
         
            -
                capabilities: List[str] = field(default_factory=list)
         
     | 
| 
       53 
     | 
    
         
            -
                created_at: float = field(default_factory=time.time)
         
     | 
| 
       54 
     | 
    
         
            -
                last_modified: float = field(default_factory=time.time)
         
     | 
| 
       55 
     | 
    
         
            -
                file_size: int = 0
         
     | 
| 
       56 
     | 
    
         
            -
                checksum: str = ""
         
     | 
| 
       57 
     | 
    
         
            -
                is_valid: bool = True
         
     | 
| 
       58 
     | 
    
         
            -
                validation_errors: List[str] = field(default_factory=list)
         
     | 
| 
       59 
     | 
    
         
            -
                metadata: Dict[str, Any] = field(default_factory=dict)
         
     | 
| 
       60 
     | 
    
         
            -
                
         
     | 
| 
       61 
     | 
    
         
            -
                # Compatibility properties for existing code
         
     | 
| 
       62 
     | 
    
         
            -
                @property
         
     | 
| 
       63 
     | 
    
         
            -
                def type(self) -> str:
         
     | 
| 
       64 
     | 
    
         
            -
                    """Compatibility property for existing code expecting 'type' attribute."""
         
     | 
| 
       65 
     | 
    
         
            -
                    return self.agent_type
         
     | 
| 
       66 
     | 
    
         
            -
                
         
     | 
| 
       67 
     | 
    
         
            -
                @property
         
     | 
| 
       68 
     | 
    
         
            -
                def validated(self) -> bool:
         
     | 
| 
       69 
     | 
    
         
            -
                    """Compatibility property for existing code expecting 'validated' attribute."""
         
     | 
| 
       70 
     | 
    
         
            -
                    return self.is_valid
         
     | 
| 
       71 
     | 
    
         
            -
                
         
     | 
| 
       72 
     | 
    
         
            -
                def to_dict(self) -> Dict[str, Any]:
         
     | 
| 
       73 
     | 
    
         
            -
                    """Convert to dictionary for serialization."""
         
     | 
| 
       74 
     | 
    
         
            -
                    data = asdict(self)
         
     | 
| 
       75 
     | 
    
         
            -
                    data['tier'] = self.tier.value
         
     | 
| 
       76 
     | 
    
         
            -
                    # Include compatibility fields
         
     | 
| 
       77 
     | 
    
         
            -
                    data['type'] = self.agent_type
         
     | 
| 
       78 
     | 
    
         
            -
                    data['validated'] = self.is_valid
         
     | 
| 
       79 
     | 
    
         
            -
                    return data
         
     | 
| 
       80 
     | 
    
         
            -
                
         
     | 
| 
       81 
     | 
    
         
            -
                @classmethod
         
     | 
| 
       82 
     | 
    
         
            -
                def from_dict(cls, data: Dict[str, Any]) -> 'AgentRegistryMetadata':
         
     | 
| 
       83 
     | 
    
         
            -
                    """Create from dictionary."""
         
     | 
| 
       84 
     | 
    
         
            -
                    # Handle compatibility fields
         
     | 
| 
       85 
     | 
    
         
            -
                    if 'type' in data and 'agent_type' not in data:
         
     | 
| 
       86 
     | 
    
         
            -
                        data['agent_type'] = data['type']
         
     | 
| 
       87 
     | 
    
         
            -
                    if 'validated' in data and 'is_valid' not in data:
         
     | 
| 
       88 
     | 
    
         
            -
                        data['is_valid'] = data['validated']
         
     | 
| 
       89 
     | 
    
         
            -
                    
         
     | 
| 
       90 
     | 
    
         
            -
                    data['tier'] = AgentTier(data['tier'])
         
     | 
| 
       91 
     | 
    
         
            -
                    return cls(**data)
         
     | 
    
        claude_mpm/security/__init__.py
    DELETED