File size: 8,365 Bytes
283b69e
b17bed0
8f174fa
283b69e
 
 
 
 
 
 
 
 
 
b17bed0
283b69e
 
 
8f174fa
283b69e
8f174fa
283b69e
8f174fa
283b69e
 
 
 
 
 
 
8f174fa
283b69e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
b17bed0
 
 
 
283b69e
 
 
 
b17bed0
283b69e
 
 
b17bed0
283b69e
b17bed0
 
 
 
283b69e
 
 
 
b17bed0
 
 
 
 
 
 
 
 
 
283b69e
 
 
 
b17bed0
 
 
 
283b69e
 
 
 
8f174fa
283b69e
 
b17bed0
283b69e
 
b17bed0
 
 
 
 
 
 
 
283b69e
 
 
 
b17bed0
283b69e
 
 
 
b17bed0
 
 
 
 
 
 
 
 
283b69e
 
 
 
b17bed0
 
 
 
 
 
 
 
 
283b69e
 
 
b17bed0
 
 
 
 
 
 
 
 
 
283b69e
b17bed0
 
283b69e
b17bed0
283b69e
 
b17bed0
283b69e
b17bed0
 
 
 
 
283b69e
 
 
 
 
b17bed0
 
 
 
 
 
 
 
 
 
283b69e
b17bed0
 
 
 
 
283b69e
 
b17bed0
283b69e
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
"""
Installation helper utilities for ARF Demo - FIXED VERSION
Updated to v3.3.9 (actual PyPI version) - SURGICAL FIX
"""
import subprocess
import sys
import logging
from typing import Dict, Any, List, Optional

logger = logging.getLogger(__name__)


class InstallationHelper:
    """Helper class for ARF package installation - FIXED: No attempt to import non-existent packages"""
    
    @staticmethod
    def install_arf_oss() -> Dict[str, Any]:
        """Install ARF OSS package - FIXED: Updated to v3.3.9"""
        try:
            logger.info("Installing ARF OSS v3.3.9...")  # FIXED: v3.3.7 β†’ v3.3.9
            result = subprocess.run(
                [sys.executable, "-m", "pip", "install", "agentic-reliability-framework==3.3.9"],  # FIXED: v3.3.9
                capture_output=True,
                text=True,
                check=True
            )
            
            return {
                "success": True,
                "message": "βœ… ARF OSS v3.3.9 installed successfully",  # FIXED: v3.3.9
                "output": result.stdout
            }
            
        except subprocess.CalledProcessError as e:
            return {
                "success": False,
                "message": "❌ Failed to install ARF OSS",
                "error": e.stderr
            }
        except Exception as e:
            return {
                "success": False,
                "message": f"❌ Installation error: {str(e)}",
                "error": str(e)
            }
    
    @staticmethod
    def check_installation() -> Dict[str, Any]:
        """
        FIXED: Check ARF package installation - no attempt to import non-existent arf_enterprise
        Enterprise is always simulated in this demo
        """
        try:
            import agentic_reliability_framework as arf_oss
            oss_version = getattr(arf_oss, '__version__', 'unknown')
            oss_installed = True
            logger.info(f"βœ… ARF OSS v{oss_version} detected")
        except ImportError:
            oss_installed = False
            oss_version = None
            logger.info("⚠️ ARF OSS not installed - using mock mode")
        
        # FIXED: Enterprise is ALWAYS simulated - package doesn't exist
        enterprise_installed = False
        enterprise_version = "simulated"
        logger.info("⚠️ ARF Enterprise not installed - using simulation")
        
        return {
            "oss_installed": oss_installed,
            "oss_version": oss_version,
            "enterprise_installed": enterprise_installed,  # Always false
            "enterprise_version": enterprise_version,  # Always "simulated"
            "recommendations": InstallationHelper.get_recommendations(oss_installed, enterprise_installed),
            "boundaries": {
                "oss_can": ["advisory_analysis", "rag_search", "healing_intent"],
                "oss_cannot": ["execute", "modify_infra", "autonomous_healing"],
                "enterprise_simulated": True,
                "enterprise_requires_license": True,
                "architecture": "OSS advises β†’ Enterprise simulates"
            }
        }
    
    @staticmethod
    def get_recommendations(oss_installed: bool, enterprise_installed: bool) -> List[str]:
        """
        FIXED: Get realistic installation recommendations
        Enterprise package doesn't exist publicly
        """
        recommendations = []
        
        if not oss_installed:
            recommendations.append(
                "Install ARF OSS: `pip install agentic-reliability-framework==3.3.9`"  # FIXED: v3.3.9
            )
            recommendations.append(
                "πŸ’‘ Without OSS, demo runs in mock mode with simulated analysis"
            )
        
        # FIXED: Enterprise is simulated, not installable
        recommendations.append(
            "πŸ”’ ARF Enterprise requires commercial license - simulated in this demo"
        )
        recommendations.append(
            "🏒 Contact sales@arf.dev for Enterprise trial access"
        )
        
        return recommendations
    
    @staticmethod
    def get_installation_html() -> str:
        """Get HTML for installation status display - FIXED to show clear boundaries"""
        status = InstallationHelper.check_installation()
        
        if status["oss_installed"]:
            oss_html = f"""
            <div style="padding: 10px; background: linear-gradient(135deg, #10b981 0%, #0ca678 100%); 
                       color: white; border-radius: 8px; margin: 5px 0; border: 1px solid #0da271;">
                <div style="display: flex; align-items: center; gap: 8px;">
                    <span style="font-size: 16px;">βœ…</span>
                    <div>
                        <div style="font-weight: 600;">ARF OSS v{status['oss_version']}</div>
                        <div style="font-size: 12px; opacity: 0.9;">Apache 2.0 β€’ Advisory Intelligence</div>
                    </div>
                </div>
            </div>
            """
        else:
            oss_html = """
            <div style="padding: 10px; background: linear-gradient(135deg, #f59e0b 0%, #e0950a 100%); 
                       color: white; border-radius: 8px; margin: 5px 0; border: 1px solid #d98a09;">
                <div style="display: flex; align-items: center; gap: 8px;">
                    <span style="font-size: 16px;">⚠️</span>
                    <div>
                        <div style="font-weight: 600;">Mock ARF</div>
                        <div style="font-size: 12px; opacity: 0.9;">Simulated analysis only</div>
                    </div>
                </div>
            </div>
            """
        
        # FIXED: Enterprise is always simulated
        enterprise_html = f"""
        <div style="padding: 10px; background: linear-gradient(135deg, #64748b 0%, #4b5563 100%); 
                   color: white; border-radius: 8px; margin: 5px 0; border: 1px dashed #9ca3af;">
            <div style="display: flex; align-items: center; gap: 8px;">
                <span style="font-size: 16px;">πŸ”’</span>
                <div>
                    <div style="font-weight: 600;">Enterprise Simulation</div>
                    <div style="font-size: 12px; opacity: 0.9;">v{status['enterprise_version']} β€’ Commercial License Required</div>
                </div>
            </div>
        </div>
        """
        
        # FIXED: Realistic recommendations
        recommendations_html = ""
        if status["recommendations"]:
            rec_list = "\n".join([f"<li style='margin-bottom: 5px;'>{rec}</li>" for rec in status["recommendations"][:3]])
            recommendations_html = f"""
            <div style="margin-top: 15px; padding: 12px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0;">
                <div style="font-weight: 600; color: #475569; margin-bottom: 8px; display: flex; align-items: center; gap: 6px;">
                    <span>πŸ’‘</span> <span>Architecture & Recommendations</span>
                </div>
                <ul style="margin: 5px 0 0 0; padding-left: 20px; color: #64748b; font-size: 13px;">
                    {rec_list}
                </ul>
            </div>
            """
        
        # FIXED: Add boundary context
        boundary_html = """
        <div style="margin-top: 10px; padding: 8px; background: #f0fdf4; border-radius: 6px; border: 1px solid #d1fae5;">
            <div style="font-size: 12px; color: #059669; display: flex; align-items: center; gap: 6px;">
                <span style="display: inline-block; width: 8px; height: 8px; background: #10b981; border-radius: 50%;"></span>
                <span>Boundary: OSS advises β†’ Enterprise simulates</span>
            </div>
        </div>
        """
        
        return f"""
        <div style="border: 2px solid #e2e8f0; border-radius: 12px; padding: 15px; background: white; 
                   box-shadow: 0 1px 3px rgba(0,0,0,0.05);">
            <h4 style="margin: 0 0 12px 0; color: #1e293b; font-size: 16px; font-weight: 600;">
                πŸ“¦ ARF Installation & Boundaries
            </h4>
            {oss_html}
            {enterprise_html}
            {boundary_html}
            {recommendations_html}
        </div>
        """


# Export singleton
installation_helper = InstallationHelper()