unrealon 1.1.5__py3-none-any.whl → 2.0.4__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.
- {unrealon-1.1.5.dist-info/licenses → unrealon-2.0.4.dist-info}/LICENSE +1 -1
- unrealon-2.0.4.dist-info/METADATA +491 -0
- unrealon-2.0.4.dist-info/RECORD +129 -0
- {unrealon-1.1.5.dist-info → unrealon-2.0.4.dist-info}/WHEEL +2 -1
- unrealon-2.0.4.dist-info/entry_points.txt +3 -0
- unrealon-2.0.4.dist-info/top_level.txt +3 -0
- unrealon_browser/__init__.py +5 -2
- unrealon_browser/cli/browser_cli.py +18 -9
- unrealon_browser/cli/interactive_mode.py +18 -7
- unrealon_browser/core/browser_manager.py +76 -13
- unrealon_browser/dto/__init__.py +21 -0
- unrealon_browser/dto/bot_detection.py +175 -0
- unrealon_browser/dto/models/config.py +14 -1
- unrealon_browser/managers/__init__.py +4 -1
- unrealon_browser/managers/logger_bridge.py +3 -6
- unrealon_browser/managers/page_wait_manager.py +198 -0
- unrealon_browser/stealth/__init__.py +27 -0
- unrealon_browser/stealth/bypass_techniques.pyc +0 -0
- unrealon_browser/stealth/manager.pyc +0 -0
- unrealon_browser/stealth/nodriver_stealth.pyc +0 -0
- unrealon_browser/stealth/playwright_stealth.pyc +0 -0
- unrealon_browser/stealth/scanner_tester.pyc +0 -0
- unrealon_browser/stealth/undetected_chrome.pyc +0 -0
- unrealon_core/__init__.py +160 -0
- unrealon_core/config/__init__.py +16 -0
- unrealon_core/config/environment.py +98 -0
- unrealon_core/config/urls.py +93 -0
- unrealon_core/enums/__init__.py +24 -0
- unrealon_core/enums/status.py +216 -0
- unrealon_core/enums/types.py +240 -0
- unrealon_core/error_handling/__init__.py +45 -0
- unrealon_core/error_handling/circuit_breaker.py +292 -0
- unrealon_core/error_handling/error_context.py +324 -0
- unrealon_core/error_handling/recovery.py +371 -0
- unrealon_core/error_handling/retry.py +268 -0
- unrealon_core/exceptions/__init__.py +46 -0
- unrealon_core/exceptions/base.py +292 -0
- unrealon_core/exceptions/communication.py +22 -0
- unrealon_core/exceptions/driver.py +11 -0
- unrealon_core/exceptions/proxy.py +11 -0
- unrealon_core/exceptions/task.py +12 -0
- unrealon_core/exceptions/validation.py +17 -0
- unrealon_core/models/__init__.py +98 -0
- unrealon_core/models/arq_context.py +252 -0
- unrealon_core/models/arq_responses.py +125 -0
- unrealon_core/models/base.py +291 -0
- unrealon_core/models/bridge_stats.py +58 -0
- unrealon_core/models/communication.py +39 -0
- unrealon_core/models/config.py +47 -0
- unrealon_core/models/connection_stats.py +47 -0
- unrealon_core/models/driver.py +30 -0
- unrealon_core/models/driver_details.py +98 -0
- unrealon_core/models/logging.py +28 -0
- unrealon_core/models/task.py +21 -0
- unrealon_core/models/typed_responses.py +210 -0
- unrealon_core/models/websocket/__init__.py +91 -0
- unrealon_core/models/websocket/base.py +49 -0
- unrealon_core/models/websocket/config.py +200 -0
- unrealon_core/models/websocket/driver.py +215 -0
- unrealon_core/models/websocket/errors.py +138 -0
- unrealon_core/models/websocket/heartbeat.py +100 -0
- unrealon_core/models/websocket/logging.py +261 -0
- unrealon_core/models/websocket/proxy.py +496 -0
- unrealon_core/models/websocket/tasks.py +275 -0
- unrealon_core/models/websocket/utils.py +153 -0
- unrealon_core/models/websocket_session.py +144 -0
- unrealon_core/monitoring/__init__.py +43 -0
- unrealon_core/monitoring/alerts.py +398 -0
- unrealon_core/monitoring/dashboard.py +307 -0
- unrealon_core/monitoring/health_check.py +354 -0
- unrealon_core/monitoring/metrics.py +352 -0
- unrealon_core/utils/__init__.py +11 -0
- unrealon_core/utils/time.py +61 -0
- unrealon_core/version.py +219 -0
- unrealon_driver/__init__.py +88 -50
- unrealon_driver/core_module/__init__.py +34 -0
- unrealon_driver/core_module/base.py +184 -0
- unrealon_driver/core_module/config.py +30 -0
- unrealon_driver/core_module/event_manager.py +127 -0
- unrealon_driver/core_module/protocols.py +98 -0
- unrealon_driver/core_module/registry.py +146 -0
- unrealon_driver/decorators/__init__.py +15 -0
- unrealon_driver/decorators/retry.py +117 -0
- unrealon_driver/decorators/schedule.py +137 -0
- unrealon_driver/decorators/task.py +61 -0
- unrealon_driver/decorators/timing.py +132 -0
- unrealon_driver/driver/__init__.py +20 -0
- unrealon_driver/driver/communication/__init__.py +10 -0
- unrealon_driver/driver/communication/session.py +203 -0
- unrealon_driver/driver/communication/websocket_client.py +197 -0
- unrealon_driver/driver/core/__init__.py +10 -0
- unrealon_driver/driver/core/config.py +85 -0
- unrealon_driver/driver/core/driver.py +221 -0
- unrealon_driver/driver/factory/__init__.py +9 -0
- unrealon_driver/driver/factory/manager_factory.py +130 -0
- unrealon_driver/driver/lifecycle/__init__.py +11 -0
- unrealon_driver/driver/lifecycle/daemon.py +76 -0
- unrealon_driver/driver/lifecycle/initialization.py +97 -0
- unrealon_driver/driver/lifecycle/shutdown.py +48 -0
- unrealon_driver/driver/monitoring/__init__.py +9 -0
- unrealon_driver/driver/monitoring/health.py +63 -0
- unrealon_driver/driver/utilities/__init__.py +10 -0
- unrealon_driver/driver/utilities/logging.py +51 -0
- unrealon_driver/driver/utilities/serialization.py +61 -0
- unrealon_driver/managers/__init__.py +32 -0
- unrealon_driver/managers/base.py +174 -0
- unrealon_driver/managers/browser.py +98 -0
- unrealon_driver/managers/cache.py +116 -0
- unrealon_driver/managers/http.py +107 -0
- unrealon_driver/managers/logger.py +286 -0
- unrealon_driver/managers/proxy.py +99 -0
- unrealon_driver/managers/registry.py +87 -0
- unrealon_driver/managers/threading.py +54 -0
- unrealon_driver/managers/update.py +107 -0
- unrealon_driver/utils/__init__.py +9 -0
- unrealon_driver/utils/time.py +10 -0
- unrealon/__init__.py +0 -40
- unrealon-1.1.5.dist-info/METADATA +0 -621
- unrealon-1.1.5.dist-info/RECORD +0 -54
- unrealon-1.1.5.dist-info/entry_points.txt +0 -9
- unrealon_browser/managers/stealth.py +0 -388
- unrealon_driver/exceptions.py +0 -33
- unrealon_driver/html_analyzer/__init__.py +0 -32
- unrealon_driver/html_analyzer/cleaner.py +0 -657
- unrealon_driver/html_analyzer/config.py +0 -64
- unrealon_driver/html_analyzer/manager.py +0 -247
- unrealon_driver/html_analyzer/models.py +0 -115
- unrealon_driver/html_analyzer/websocket_analyzer.py +0 -157
- unrealon_driver/models/__init__.py +0 -31
- unrealon_driver/models/websocket.py +0 -98
- unrealon_driver/parser/__init__.py +0 -36
- unrealon_driver/parser/cli_manager.py +0 -142
- unrealon_driver/parser/daemon_manager.py +0 -403
- unrealon_driver/parser/managers/__init__.py +0 -25
- unrealon_driver/parser/managers/config.py +0 -293
- unrealon_driver/parser/managers/error.py +0 -412
- unrealon_driver/parser/managers/result.py +0 -321
- unrealon_driver/parser/parser_manager.py +0 -458
- unrealon_driver/smart_logging/__init__.py +0 -24
- unrealon_driver/smart_logging/models.py +0 -44
- unrealon_driver/smart_logging/smart_logger.py +0 -406
- unrealon_driver/smart_logging/unified_logger.py +0 -525
- unrealon_driver/websocket/__init__.py +0 -31
- unrealon_driver/websocket/client.py +0 -249
- unrealon_driver/websocket/config.py +0 -188
- unrealon_driver/websocket/manager.py +0 -90
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Bridge Statistics Models
|
|
3
|
+
|
|
4
|
+
Strictly typed models for WebSocket bridge statistics.
|
|
5
|
+
Following critical requirements - no raw Dict[str, Any].
|
|
6
|
+
|
|
7
|
+
Phase 2: Core Systems - Bridge Statistics
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
from typing import Optional
|
|
12
|
+
from pydantic import BaseModel, Field, ConfigDict
|
|
13
|
+
|
|
14
|
+
from .base import UnrealOnBaseModel
|
|
15
|
+
from ..utils.time import utc_now
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class BridgeStatsData(UnrealOnBaseModel):
|
|
19
|
+
"""Internal bridge statistics data."""
|
|
20
|
+
|
|
21
|
+
model_config = ConfigDict(
|
|
22
|
+
validate_assignment=True,
|
|
23
|
+
extra="forbid"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
tasks_sent: int = Field(default=0, description="Number of tasks sent")
|
|
27
|
+
tasks_failed: int = Field(default=0, description="Number of tasks failed")
|
|
28
|
+
configs_sent: int = Field(default=0, description="Number of configurations sent")
|
|
29
|
+
configs_failed: int = Field(default=0, description="Number of configurations failed")
|
|
30
|
+
messages_processed: int = Field(default=0, description="Number of messages processed")
|
|
31
|
+
start_time: str = Field(description="Start time ISO string")
|
|
32
|
+
|
|
33
|
+
def increment_tasks_sent(self) -> None:
|
|
34
|
+
"""Increment tasks sent counter."""
|
|
35
|
+
self.tasks_sent += 1
|
|
36
|
+
|
|
37
|
+
def increment_tasks_failed(self) -> None:
|
|
38
|
+
"""Increment tasks failed counter."""
|
|
39
|
+
self.tasks_failed += 1
|
|
40
|
+
|
|
41
|
+
def increment_configs_sent(self) -> None:
|
|
42
|
+
"""Increment configs sent counter."""
|
|
43
|
+
self.configs_sent += 1
|
|
44
|
+
|
|
45
|
+
def increment_configs_failed(self) -> None:
|
|
46
|
+
"""Increment configs failed counter."""
|
|
47
|
+
self.configs_failed += 1
|
|
48
|
+
|
|
49
|
+
def increment_messages_processed(self) -> None:
|
|
50
|
+
"""Increment messages processed counter."""
|
|
51
|
+
self.messages_processed += 1
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def create_initial_bridge_stats() -> BridgeStatsData:
|
|
55
|
+
"""Create initial bridge statistics."""
|
|
56
|
+
return BridgeStatsData(
|
|
57
|
+
start_time=utc_now().isoformat()
|
|
58
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"""
|
|
2
|
+
WebSocket Communication Models for UnrealOn RPC.
|
|
3
|
+
|
|
4
|
+
CRITICAL REQUIREMENTS COMPLIANT:
|
|
5
|
+
- No raw Dict[str, Any] usage
|
|
6
|
+
- 100% Pydantic v2 validation
|
|
7
|
+
- Strict typing throughout
|
|
8
|
+
- Files under 500 lines
|
|
9
|
+
|
|
10
|
+
This file imports from strictly typed websocket models.
|
|
11
|
+
All raw dictionaries have been replaced with Pydantic models.
|
|
12
|
+
|
|
13
|
+
Phase 2: Core Systems - WebSocket Bridge
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
# Import all strictly typed models from websocket package
|
|
17
|
+
from .websocket import *
|
|
18
|
+
from .websocket.logging import LogContext
|
|
19
|
+
|
|
20
|
+
# Export commonly used data models for easy access
|
|
21
|
+
__all__ = [
|
|
22
|
+
# Message types and base
|
|
23
|
+
'MessageType', 'WebSocketMessage',
|
|
24
|
+
|
|
25
|
+
# Message classes
|
|
26
|
+
'DriverRegistrationMessage', 'RegistrationResponseMessage',
|
|
27
|
+
'TaskAssignmentMessage', 'TaskResultMessage',
|
|
28
|
+
'LogEntryMessage', 'LogBatchMessage',
|
|
29
|
+
'HeartbeatMessage', 'ConfigurationUpdateMessage',
|
|
30
|
+
'ErrorMessage', 'AckMessage',
|
|
31
|
+
|
|
32
|
+
# Data models for strict typing
|
|
33
|
+
'TaskAssignmentData', 'TaskResultData', 'TaskParameters',
|
|
34
|
+
'DriverRegistrationData', 'HeartbeatData', 'LogEntryData', 'LogContext',
|
|
35
|
+
|
|
36
|
+
# Utilities
|
|
37
|
+
'create_error_message', 'create_ack_message',
|
|
38
|
+
|
|
39
|
+
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Config models - Phase 2 update.
|
|
3
|
+
|
|
4
|
+
Import from strictly typed websocket models to avoid duplication.
|
|
5
|
+
Following critical requirements - no raw Dict[str, Any].
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Import strictly typed models from websocket package
|
|
9
|
+
from .websocket.config import (
|
|
10
|
+
DriverConfiguration,
|
|
11
|
+
LoggingConfiguration,
|
|
12
|
+
TaskConfiguration,
|
|
13
|
+
ProxyConfiguration
|
|
14
|
+
)
|
|
15
|
+
from .base import ConfigBaseModel
|
|
16
|
+
|
|
17
|
+
# System config that doesn't exist in websocket models yet
|
|
18
|
+
class SystemConfig(ConfigBaseModel):
|
|
19
|
+
"""System-wide configuration."""
|
|
20
|
+
|
|
21
|
+
redis_url: str = "redis://localhost:6379/0"
|
|
22
|
+
websocket_url: str = "ws://localhost:8000/ws"
|
|
23
|
+
max_workers: int = 10
|
|
24
|
+
debug: bool = False
|
|
25
|
+
|
|
26
|
+
# Legacy compatibility - map to new typed models
|
|
27
|
+
HttpConfig = TaskConfiguration # HTTP settings are part of task config
|
|
28
|
+
ProxyConfig = ProxyConfiguration
|
|
29
|
+
LoggingConfig = LoggingConfiguration
|
|
30
|
+
BrowserConfig = TaskConfiguration # Browser settings are part of task config
|
|
31
|
+
CacheConfig = SystemConfig # Cache settings are system-wide
|
|
32
|
+
ThreadConfig = TaskConfiguration # Thread settings are part of task config
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
'DriverConfiguration',
|
|
36
|
+
'LoggingConfiguration',
|
|
37
|
+
'TaskConfiguration',
|
|
38
|
+
'ProxyConfiguration',
|
|
39
|
+
'SystemConfig',
|
|
40
|
+
# Legacy names
|
|
41
|
+
'HttpConfig',
|
|
42
|
+
'ProxyConfig',
|
|
43
|
+
'LoggingConfig',
|
|
44
|
+
'BrowserConfig',
|
|
45
|
+
'CacheConfig',
|
|
46
|
+
'ThreadConfig'
|
|
47
|
+
]
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Connection Statistics Models
|
|
3
|
+
|
|
4
|
+
Strictly typed models for WebSocket connection statistics.
|
|
5
|
+
Following critical requirements - no raw Dict[str, Any].
|
|
6
|
+
|
|
7
|
+
Phase 2: Core Systems - Connection Statistics
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from pydantic import BaseModel, Field, ConfigDict
|
|
11
|
+
|
|
12
|
+
from .base import UnrealOnBaseModel
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class ConnectionStatsData(UnrealOnBaseModel):
|
|
16
|
+
"""Internal connection statistics data."""
|
|
17
|
+
|
|
18
|
+
model_config = ConfigDict(
|
|
19
|
+
validate_assignment=True,
|
|
20
|
+
extra="forbid"
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
total_connections: int = Field(default=0, description="Total connections made")
|
|
24
|
+
active_connections: int = Field(default=0, description="Currently active connections")
|
|
25
|
+
total_messages: int = Field(default=0, description="Total messages sent")
|
|
26
|
+
failed_messages: int = Field(default=0, description="Failed messages")
|
|
27
|
+
|
|
28
|
+
def increment_total_connections(self) -> None:
|
|
29
|
+
"""Increment total connections counter."""
|
|
30
|
+
self.total_connections += 1
|
|
31
|
+
|
|
32
|
+
def set_active_connections(self, count: int) -> None:
|
|
33
|
+
"""Set active connections count."""
|
|
34
|
+
self.active_connections = count
|
|
35
|
+
|
|
36
|
+
def increment_total_messages(self) -> None:
|
|
37
|
+
"""Increment total messages counter."""
|
|
38
|
+
self.total_messages += 1
|
|
39
|
+
|
|
40
|
+
def increment_failed_messages(self) -> None:
|
|
41
|
+
"""Increment failed messages counter."""
|
|
42
|
+
self.failed_messages += 1
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def create_initial_connection_stats() -> ConnectionStatsData:
|
|
46
|
+
"""Create initial connection statistics."""
|
|
47
|
+
return ConnectionStatsData()
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Driver models - Phase 2 update.
|
|
3
|
+
|
|
4
|
+
Import from strictly typed websocket models to avoid duplication.
|
|
5
|
+
Following critical requirements - no raw Dict[str, Any].
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Import strictly typed models from websocket package
|
|
9
|
+
from .websocket.driver import (
|
|
10
|
+
DriverRegistrationData,
|
|
11
|
+
DriverMetadata,
|
|
12
|
+
DriverConfiguration,
|
|
13
|
+
RegistrationResponseData
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
# Legacy compatibility
|
|
17
|
+
DriverInfo = DriverRegistrationData
|
|
18
|
+
DriverConfig = DriverConfiguration
|
|
19
|
+
DriverCapability = DriverMetadata
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
'DriverRegistrationData',
|
|
23
|
+
'DriverMetadata',
|
|
24
|
+
'DriverConfiguration',
|
|
25
|
+
'RegistrationResponseData',
|
|
26
|
+
# Legacy names
|
|
27
|
+
'DriverInfo',
|
|
28
|
+
'DriverConfig',
|
|
29
|
+
'DriverCapability'
|
|
30
|
+
]
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Driver Details Models
|
|
3
|
+
|
|
4
|
+
Strictly typed models for driver information and statistics.
|
|
5
|
+
Following critical requirements - no raw Dict[str, Any].
|
|
6
|
+
|
|
7
|
+
Phase 2: Core Systems - Driver Details
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
from typing import Optional, List
|
|
12
|
+
from pydantic import BaseModel, Field, ConfigDict
|
|
13
|
+
|
|
14
|
+
from .base import UnrealOnBaseModel
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class DriverDetails(UnrealOnBaseModel):
|
|
18
|
+
"""Complete driver details with statistics."""
|
|
19
|
+
|
|
20
|
+
model_config = ConfigDict(
|
|
21
|
+
validate_assignment=True,
|
|
22
|
+
extra="forbid"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
# Basic driver info
|
|
26
|
+
driver_id: str = Field(description="Driver ID")
|
|
27
|
+
driver_name: Optional[str] = Field(default=None, description="Driver name")
|
|
28
|
+
driver_type: str = Field(description="Driver type")
|
|
29
|
+
capabilities: List[str] = Field(default_factory=list, description="Driver capabilities")
|
|
30
|
+
version: Optional[str] = Field(default=None, description="Driver version")
|
|
31
|
+
|
|
32
|
+
# Connection info
|
|
33
|
+
connection_id: str = Field(description="WebSocket connection ID")
|
|
34
|
+
status: str = Field(description="Driver status")
|
|
35
|
+
connected_at: datetime = Field(description="Connection timestamp")
|
|
36
|
+
last_seen: datetime = Field(description="Last activity timestamp")
|
|
37
|
+
|
|
38
|
+
# Task statistics
|
|
39
|
+
active_tasks: int = Field(default=0, description="Number of active tasks")
|
|
40
|
+
completed_tasks: int = Field(default=0, description="Number of completed tasks")
|
|
41
|
+
failed_tasks: int = Field(default=0, description="Number of failed tasks")
|
|
42
|
+
|
|
43
|
+
# Performance metrics
|
|
44
|
+
uptime_seconds: float = Field(default=0.0, description="Uptime in seconds")
|
|
45
|
+
memory_usage_mb: Optional[float] = Field(default=None, description="Memory usage in MB")
|
|
46
|
+
cpu_usage_percent: Optional[float] = Field(default=None, description="CPU usage percentage")
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
class DriverInfo(UnrealOnBaseModel):
|
|
50
|
+
"""Basic driver information."""
|
|
51
|
+
|
|
52
|
+
model_config = ConfigDict(
|
|
53
|
+
validate_assignment=True,
|
|
54
|
+
extra="forbid"
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
driver_id: str = Field(description="Driver ID")
|
|
58
|
+
connection_id: str = Field(description="WebSocket connection ID")
|
|
59
|
+
status: str = Field(description="Driver status")
|
|
60
|
+
last_heartbeat: Optional[datetime] = Field(default=None, description="Last heartbeat timestamp")
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class DriverListResult(UnrealOnBaseModel):
|
|
64
|
+
"""Result of driver list query."""
|
|
65
|
+
|
|
66
|
+
model_config = ConfigDict(
|
|
67
|
+
validate_assignment=True,
|
|
68
|
+
extra="forbid"
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
drivers: List[DriverDetails] = Field(description="List of driver details")
|
|
72
|
+
total_count: int = Field(description="Total number of drivers")
|
|
73
|
+
filtered_count: int = Field(description="Number of drivers after filtering")
|
|
74
|
+
filter_applied: Optional[str] = Field(default=None, description="Filter that was applied")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def create_driver_details_from_session(
|
|
78
|
+
driver_info: DriverInfo,
|
|
79
|
+
session: "DriverSession"
|
|
80
|
+
) -> DriverDetails:
|
|
81
|
+
"""Create DriverDetails from DriverInfo and DriverSession."""
|
|
82
|
+
return DriverDetails(
|
|
83
|
+
driver_id=driver_info.driver_id,
|
|
84
|
+
driver_name=getattr(session, 'driver_name', None),
|
|
85
|
+
driver_type=session.driver_type,
|
|
86
|
+
capabilities=session.capabilities,
|
|
87
|
+
version=getattr(session, 'version', None),
|
|
88
|
+
connection_id=session.connection_id,
|
|
89
|
+
status=session.status,
|
|
90
|
+
connected_at=session.connected_at,
|
|
91
|
+
last_seen=session.last_seen,
|
|
92
|
+
active_tasks=session.active_tasks,
|
|
93
|
+
completed_tasks=getattr(session, 'completed_tasks', 0),
|
|
94
|
+
failed_tasks=getattr(session, 'failed_tasks', 0),
|
|
95
|
+
uptime_seconds=(utc_now() - session.connected_at).total_seconds(),
|
|
96
|
+
memory_usage_mb=getattr(session, 'memory_usage_mb', None),
|
|
97
|
+
cpu_usage_percent=getattr(session, 'cpu_usage_percent', None)
|
|
98
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Logging models - Phase 2 update.
|
|
3
|
+
|
|
4
|
+
Import from strictly typed websocket models to avoid duplication.
|
|
5
|
+
Following critical requirements - no raw Dict[str, Any].
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Import strictly typed models from websocket package
|
|
9
|
+
from .websocket.logging import (
|
|
10
|
+
LogEntryData,
|
|
11
|
+
LogBatchData,
|
|
12
|
+
LogContext
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
# Legacy compatibility
|
|
16
|
+
LogEntry = LogEntryData
|
|
17
|
+
LogQuery = LogContext
|
|
18
|
+
LogMetrics = LogBatchData
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
'LogEntryData',
|
|
22
|
+
'LogBatchData',
|
|
23
|
+
'LogContext',
|
|
24
|
+
# Legacy names
|
|
25
|
+
'LogEntry',
|
|
26
|
+
'LogQuery',
|
|
27
|
+
'LogMetrics'
|
|
28
|
+
]
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Task models - Phase 2 update.
|
|
3
|
+
|
|
4
|
+
Import from strictly typed websocket models to avoid duplication.
|
|
5
|
+
Following critical requirements - no raw Dict[str, Any].
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Import strictly typed models from websocket package
|
|
9
|
+
from .websocket.tasks import (
|
|
10
|
+
TaskAssignmentData,
|
|
11
|
+
TaskResultData,
|
|
12
|
+
TaskParameters,
|
|
13
|
+
TaskMetadata
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
'TaskAssignmentData',
|
|
18
|
+
'TaskResultData',
|
|
19
|
+
'TaskParameters',
|
|
20
|
+
'TaskMetadata',
|
|
21
|
+
]
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Typed Response Models
|
|
3
|
+
|
|
4
|
+
Strictly typed models to replace Dict[str, Any] usage.
|
|
5
|
+
Following critical requirements - no raw Dict[str, Any].
|
|
6
|
+
|
|
7
|
+
Phase 2: Core Systems - Typed Responses
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from datetime import datetime
|
|
11
|
+
from typing import Optional, List
|
|
12
|
+
from pydantic import BaseModel, Field, ConfigDict
|
|
13
|
+
|
|
14
|
+
from .base import UnrealOnBaseModel
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class HealthCheckDetails(UnrealOnBaseModel):
|
|
18
|
+
"""Health check details model."""
|
|
19
|
+
|
|
20
|
+
model_config = ConfigDict(
|
|
21
|
+
validate_assignment=True,
|
|
22
|
+
extra="forbid"
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
manager_status: str = Field(description="Manager status")
|
|
26
|
+
success_rate: float = Field(description="Success rate percentage")
|
|
27
|
+
total_operations: int = Field(description="Total operations count")
|
|
28
|
+
uptime_seconds: float = Field(description="Uptime in seconds")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class HealthCheckResult(UnrealOnBaseModel):
|
|
32
|
+
"""Health check result model."""
|
|
33
|
+
|
|
34
|
+
model_config = ConfigDict(
|
|
35
|
+
validate_assignment=True,
|
|
36
|
+
extra="forbid"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
status: str = Field(description="Health status")
|
|
40
|
+
message: str = Field(description="Health message")
|
|
41
|
+
details: HealthCheckDetails = Field(description="Health details")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class StatusInfo(UnrealOnBaseModel):
|
|
45
|
+
"""Status information model."""
|
|
46
|
+
|
|
47
|
+
model_config = ConfigDict(
|
|
48
|
+
validate_assignment=True,
|
|
49
|
+
extra="forbid"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
name: str = Field(description="Component name")
|
|
53
|
+
status: str = Field(description="Component status")
|
|
54
|
+
enabled: bool = Field(description="Whether component is enabled")
|
|
55
|
+
uptime_seconds: Optional[float] = Field(default=None, description="Uptime in seconds")
|
|
56
|
+
initialization_time: Optional[str] = Field(default=None, description="Initialization time ISO string")
|
|
57
|
+
shutdown_time: Optional[str] = Field(default=None, description="Shutdown time ISO string")
|
|
58
|
+
stats: "StatsModel" = Field(description="Component statistics")
|
|
59
|
+
config: "ConfigModel" = Field(description="Component configuration")
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class StatsModel(UnrealOnBaseModel):
|
|
63
|
+
"""Statistics model."""
|
|
64
|
+
|
|
65
|
+
model_config = ConfigDict(
|
|
66
|
+
validate_assignment=True,
|
|
67
|
+
extra="forbid"
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
operations_total: int = Field(default=0, description="Total operations")
|
|
71
|
+
operations_successful: int = Field(default=0, description="Successful operations")
|
|
72
|
+
operations_failed: int = Field(default=0, description="Failed operations")
|
|
73
|
+
last_operation_time: Optional[str] = Field(default=None, description="Last operation time ISO string")
|
|
74
|
+
average_operation_time: float = Field(default=0.0, description="Average operation time")
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class ConfigModel(UnrealOnBaseModel):
|
|
78
|
+
"""Configuration model."""
|
|
79
|
+
|
|
80
|
+
model_config = ConfigDict(
|
|
81
|
+
validate_assignment=True,
|
|
82
|
+
extra="forbid"
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
enabled: bool = Field(description="Whether enabled")
|
|
86
|
+
timeout_seconds: float = Field(description="Timeout in seconds")
|
|
87
|
+
retry_count: int = Field(description="Retry count")
|
|
88
|
+
log_level: str = Field(description="Log level")
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class SessionInfo(UnrealOnBaseModel):
|
|
92
|
+
"""HTTP session information model."""
|
|
93
|
+
|
|
94
|
+
model_config = ConfigDict(
|
|
95
|
+
validate_assignment=True,
|
|
96
|
+
extra="forbid"
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
cookies_count: int = Field(description="Number of cookies")
|
|
100
|
+
has_proxy_manager: bool = Field(description="Whether proxy manager is available")
|
|
101
|
+
use_proxy_manager: bool = Field(description="Whether using proxy manager")
|
|
102
|
+
max_connections: int = Field(description="Maximum connections")
|
|
103
|
+
default_timeout: float = Field(description="Default timeout")
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
class ProxyStats(UnrealOnBaseModel):
|
|
107
|
+
"""Proxy statistics model."""
|
|
108
|
+
|
|
109
|
+
model_config = ConfigDict(
|
|
110
|
+
validate_assignment=True,
|
|
111
|
+
extra="forbid"
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
total_proxies: int = Field(description="Total proxies")
|
|
115
|
+
healthy_proxies: int = Field(description="Healthy proxies")
|
|
116
|
+
banned_proxies: int = Field(description="Banned proxies")
|
|
117
|
+
average_success_rate: float = Field(description="Average success rate")
|
|
118
|
+
rotation_strategy: str = Field(description="Rotation strategy")
|
|
119
|
+
current_index: int = Field(description="Current rotation index")
|
|
120
|
+
has_rpc_client: bool = Field(description="Whether RPC client is available")
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
class ThreadStats(UnrealOnBaseModel):
|
|
124
|
+
"""Thread statistics model."""
|
|
125
|
+
|
|
126
|
+
model_config = ConfigDict(
|
|
127
|
+
validate_assignment=True,
|
|
128
|
+
extra="forbid"
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
thread_pools: "ThreadPoolsInfo" = Field(description="Thread pools information")
|
|
132
|
+
concurrency: "ConcurrencyInfo" = Field(description="Concurrency information")
|
|
133
|
+
active_task_names: List[str] = Field(description="Active task names")
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class ThreadPoolsInfo(UnrealOnBaseModel):
|
|
137
|
+
"""Thread pools information model."""
|
|
138
|
+
|
|
139
|
+
model_config = ConfigDict(
|
|
140
|
+
validate_assignment=True,
|
|
141
|
+
extra="forbid"
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
io_bound: "ThreadPoolInfo" = Field(description="I/O bound thread pool")
|
|
145
|
+
cpu_bound: "ThreadPoolInfo" = Field(description="CPU bound thread pool")
|
|
146
|
+
general: "ThreadPoolInfo" = Field(description="General thread pool")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class ThreadPoolInfo(UnrealOnBaseModel):
|
|
150
|
+
"""Thread pool information model."""
|
|
151
|
+
|
|
152
|
+
model_config = ConfigDict(
|
|
153
|
+
validate_assignment=True,
|
|
154
|
+
extra="forbid"
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
max_workers: int = Field(description="Maximum workers")
|
|
158
|
+
available: bool = Field(description="Whether available")
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
class ConcurrencyInfo(UnrealOnBaseModel):
|
|
162
|
+
"""Concurrency information model."""
|
|
163
|
+
|
|
164
|
+
model_config = ConfigDict(
|
|
165
|
+
validate_assignment=True,
|
|
166
|
+
extra="forbid"
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
max_concurrent_tasks: int = Field(description="Maximum concurrent tasks")
|
|
170
|
+
active_tasks: int = Field(description="Active tasks")
|
|
171
|
+
semaphore_available: int = Field(description="Available semaphore permits")
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class CacheStats(UnrealOnBaseModel):
|
|
175
|
+
"""Cache statistics model."""
|
|
176
|
+
|
|
177
|
+
model_config = ConfigDict(
|
|
178
|
+
validate_assignment=True,
|
|
179
|
+
extra="forbid"
|
|
180
|
+
)
|
|
181
|
+
|
|
182
|
+
entries: int = Field(description="Number of entries")
|
|
183
|
+
max_entries: int = Field(description="Maximum entries")
|
|
184
|
+
memory_usage_mb: float = Field(description="Memory usage in MB")
|
|
185
|
+
max_memory_mb: int = Field(description="Maximum memory in MB")
|
|
186
|
+
hits: int = Field(description="Cache hits")
|
|
187
|
+
misses: int = Field(description="Cache misses")
|
|
188
|
+
hit_rate_percent: float = Field(description="Hit rate percentage")
|
|
189
|
+
evictions: int = Field(description="Number of evictions")
|
|
190
|
+
eviction_strategy: str = Field(description="Eviction strategy")
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
class BatchStats(UnrealOnBaseModel):
|
|
194
|
+
"""Batch statistics model."""
|
|
195
|
+
|
|
196
|
+
model_config = ConfigDict(
|
|
197
|
+
validate_assignment=True,
|
|
198
|
+
extra="forbid"
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
current_batch_size: int = Field(description="Current batch size")
|
|
202
|
+
max_batch_size: int = Field(description="Maximum batch size")
|
|
203
|
+
batch_timeout: float = Field(description="Batch timeout")
|
|
204
|
+
has_rpc_client: bool = Field(description="Whether RPC client is available")
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
# Update forward references
|
|
208
|
+
StatusInfo.model_rebuild()
|
|
209
|
+
ThreadStats.model_rebuild()
|
|
210
|
+
ThreadPoolsInfo.model_rebuild()
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""
|
|
2
|
+
WebSocket Models Package.
|
|
3
|
+
|
|
4
|
+
Strictly typed WebSocket communication models following critical requirements:
|
|
5
|
+
- No raw Dict[str, Any] usage
|
|
6
|
+
- 100% Pydantic v2 validation
|
|
7
|
+
- Files under 500 lines each
|
|
8
|
+
- Complete type safety
|
|
9
|
+
|
|
10
|
+
Phase 2: Core Systems - WebSocket Bridge
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from .base import MessageType, WebSocketMessage
|
|
14
|
+
from .driver import (
|
|
15
|
+
DriverRegistrationData, DriverRegistrationMessage,
|
|
16
|
+
RegistrationResponseData, RegistrationResponseMessage
|
|
17
|
+
)
|
|
18
|
+
from .tasks import (
|
|
19
|
+
TaskAssignmentData, TaskAssignmentMessage,
|
|
20
|
+
TaskResultData, TaskResultMessage
|
|
21
|
+
)
|
|
22
|
+
from .logging import (
|
|
23
|
+
LogEntryData, LogEntryMessage,
|
|
24
|
+
LogBatchData, LogBatchMessage
|
|
25
|
+
)
|
|
26
|
+
from .heartbeat import HeartbeatData, HeartbeatMessage
|
|
27
|
+
from .config import ConfigurationUpdateData, ConfigurationUpdateMessage
|
|
28
|
+
from .errors import ErrorData, ErrorMessage, AckData, AckMessage
|
|
29
|
+
from .proxy import (
|
|
30
|
+
# Core models
|
|
31
|
+
ProxyType, ProxyHealthStatus, ProxyCredentials, ProxyInfo, ProxyAssignment,
|
|
32
|
+
# Data payloads
|
|
33
|
+
ProxyRequestData, ProxyResponseData, ProxyHealthReportData,
|
|
34
|
+
ProxyRotationRequestData, ProxyReleaseData,
|
|
35
|
+
# WebSocket messages
|
|
36
|
+
ProxyRequestMessage, ProxyResponseMessage, ProxyHealthReportMessage,
|
|
37
|
+
ProxyRotationRequestMessage, ProxyReleaseMessage
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
from .utils import create_error_message, create_ack_message
|
|
41
|
+
|
|
42
|
+
__all__ = [
|
|
43
|
+
# Base
|
|
44
|
+
'MessageType',
|
|
45
|
+
'WebSocketMessage',
|
|
46
|
+
|
|
47
|
+
# Driver messages
|
|
48
|
+
'DriverRegistrationData',
|
|
49
|
+
'DriverRegistrationMessage',
|
|
50
|
+
'RegistrationResponseData',
|
|
51
|
+
'RegistrationResponseMessage',
|
|
52
|
+
|
|
53
|
+
# Task messages
|
|
54
|
+
'TaskAssignmentData',
|
|
55
|
+
'TaskAssignmentMessage',
|
|
56
|
+
'TaskResultData',
|
|
57
|
+
'TaskResultMessage',
|
|
58
|
+
|
|
59
|
+
# Logging messages
|
|
60
|
+
'LogEntryData',
|
|
61
|
+
'LogEntryMessage',
|
|
62
|
+
'LogBatchData',
|
|
63
|
+
'LogBatchMessage',
|
|
64
|
+
|
|
65
|
+
# Heartbeat messages
|
|
66
|
+
'HeartbeatData',
|
|
67
|
+
'HeartbeatMessage',
|
|
68
|
+
|
|
69
|
+
# Configuration messages
|
|
70
|
+
'ConfigurationUpdateData',
|
|
71
|
+
'ConfigurationUpdateMessage',
|
|
72
|
+
|
|
73
|
+
# Error messages
|
|
74
|
+
'ErrorData',
|
|
75
|
+
'ErrorMessage',
|
|
76
|
+
'AckData',
|
|
77
|
+
'AckMessage',
|
|
78
|
+
|
|
79
|
+
# Proxy core models
|
|
80
|
+
'ProxyType', 'ProxyHealthStatus', 'ProxyCredentials', 'ProxyInfo', 'ProxyAssignment',
|
|
81
|
+
# Proxy data payloads
|
|
82
|
+
'ProxyRequestData', 'ProxyResponseData', 'ProxyHealthReportData',
|
|
83
|
+
'ProxyRotationRequestData', 'ProxyReleaseData',
|
|
84
|
+
# Proxy messages
|
|
85
|
+
'ProxyRequestMessage', 'ProxyResponseMessage', 'ProxyHealthReportMessage',
|
|
86
|
+
'ProxyRotationRequestMessage', 'ProxyReleaseMessage',
|
|
87
|
+
|
|
88
|
+
# Utilities
|
|
89
|
+
'create_error_message',
|
|
90
|
+
'create_ack_message'
|
|
91
|
+
]
|