unrealon 1.0.9__py3-none-any.whl → 1.1.1__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.
Files changed (302) hide show
  1. unrealon/__init__.py +23 -21
  2. unrealon-1.1.1.dist-info/METADATA +722 -0
  3. unrealon-1.1.1.dist-info/RECORD +82 -0
  4. {unrealon-1.0.9.dist-info → unrealon-1.1.1.dist-info}/WHEEL +1 -1
  5. unrealon-1.1.1.dist-info/entry_points.txt +9 -0
  6. {unrealon-1.0.9.dist-info → unrealon-1.1.1.dist-info/licenses}/LICENSE +1 -1
  7. unrealon_bridge/__init__.py +114 -0
  8. unrealon_bridge/cli.py +316 -0
  9. unrealon_bridge/client/__init__.py +93 -0
  10. unrealon_bridge/client/base.py +78 -0
  11. unrealon_bridge/client/commands.py +89 -0
  12. unrealon_bridge/client/connection.py +90 -0
  13. unrealon_bridge/client/events.py +65 -0
  14. unrealon_bridge/client/health.py +38 -0
  15. unrealon_bridge/client/html_parser.py +146 -0
  16. unrealon_bridge/client/logging.py +139 -0
  17. unrealon_bridge/client/proxy.py +70 -0
  18. unrealon_bridge/client/scheduler.py +450 -0
  19. unrealon_bridge/client/session.py +70 -0
  20. unrealon_bridge/configs/__init__.py +14 -0
  21. unrealon_bridge/configs/bridge_config.py +212 -0
  22. unrealon_bridge/configs/bridge_config.yaml +39 -0
  23. unrealon_bridge/models/__init__.py +138 -0
  24. unrealon_bridge/models/base.py +28 -0
  25. unrealon_bridge/models/command.py +41 -0
  26. unrealon_bridge/models/events.py +40 -0
  27. unrealon_bridge/models/html_parser.py +79 -0
  28. unrealon_bridge/models/logging.py +55 -0
  29. unrealon_bridge/models/parser.py +63 -0
  30. unrealon_bridge/models/proxy.py +41 -0
  31. unrealon_bridge/models/requests.py +95 -0
  32. unrealon_bridge/models/responses.py +88 -0
  33. unrealon_bridge/models/scheduler.py +592 -0
  34. unrealon_bridge/models/session.py +28 -0
  35. unrealon_bridge/server/__init__.py +91 -0
  36. unrealon_bridge/server/base.py +171 -0
  37. unrealon_bridge/server/handlers/__init__.py +23 -0
  38. unrealon_bridge/server/handlers/command.py +110 -0
  39. unrealon_bridge/server/handlers/html_parser.py +139 -0
  40. unrealon_bridge/server/handlers/logging.py +95 -0
  41. unrealon_bridge/server/handlers/parser.py +95 -0
  42. unrealon_bridge/server/handlers/proxy.py +75 -0
  43. unrealon_bridge/server/handlers/scheduler.py +545 -0
  44. unrealon_bridge/server/handlers/session.py +66 -0
  45. unrealon_browser/__init__.py +61 -18
  46. unrealon_browser/{src/cli → cli}/browser_cli.py +6 -13
  47. unrealon_browser/{src/cli → cli}/cookies_cli.py +5 -1
  48. unrealon_browser/{src/core → core}/browser_manager.py +2 -2
  49. unrealon_browser/{src/managers → managers}/captcha.py +1 -1
  50. unrealon_browser/{src/managers → managers}/cookies.py +1 -1
  51. unrealon_browser/managers/logger_bridge.py +231 -0
  52. unrealon_browser/{src/managers → managers}/profile.py +1 -1
  53. unrealon_driver/__init__.py +73 -19
  54. unrealon_driver/browser/__init__.py +8 -0
  55. unrealon_driver/browser/config.py +74 -0
  56. unrealon_driver/browser/manager.py +416 -0
  57. unrealon_driver/exceptions.py +28 -0
  58. unrealon_driver/parser/__init__.py +55 -0
  59. unrealon_driver/parser/cli_manager.py +141 -0
  60. unrealon_driver/parser/daemon_manager.py +227 -0
  61. unrealon_driver/parser/managers/__init__.py +46 -0
  62. unrealon_driver/parser/managers/browser.py +51 -0
  63. unrealon_driver/parser/managers/config.py +281 -0
  64. unrealon_driver/parser/managers/error.py +412 -0
  65. unrealon_driver/parser/managers/html.py +732 -0
  66. unrealon_driver/parser/managers/logging.py +609 -0
  67. unrealon_driver/parser/managers/result.py +321 -0
  68. unrealon_driver/parser/parser_manager.py +628 -0
  69. unrealon/sdk_config.py +0 -88
  70. unrealon-1.0.9.dist-info/METADATA +0 -810
  71. unrealon-1.0.9.dist-info/RECORD +0 -246
  72. unrealon_browser/pyproject.toml +0 -182
  73. unrealon_browser/src/__init__.py +0 -62
  74. unrealon_browser/src/managers/logger_bridge.py +0 -395
  75. unrealon_driver/README.md +0 -204
  76. unrealon_driver/pyproject.toml +0 -187
  77. unrealon_driver/src/__init__.py +0 -90
  78. unrealon_driver/src/cli/__init__.py +0 -10
  79. unrealon_driver/src/cli/main.py +0 -66
  80. unrealon_driver/src/cli/simple.py +0 -510
  81. unrealon_driver/src/config/__init__.py +0 -11
  82. unrealon_driver/src/config/auto_config.py +0 -478
  83. unrealon_driver/src/core/__init__.py +0 -18
  84. unrealon_driver/src/core/exceptions.py +0 -289
  85. unrealon_driver/src/core/parser.py +0 -638
  86. unrealon_driver/src/dto/__init__.py +0 -66
  87. unrealon_driver/src/dto/cli.py +0 -119
  88. unrealon_driver/src/dto/config.py +0 -18
  89. unrealon_driver/src/dto/events.py +0 -237
  90. unrealon_driver/src/dto/execution.py +0 -313
  91. unrealon_driver/src/dto/services.py +0 -311
  92. unrealon_driver/src/execution/__init__.py +0 -23
  93. unrealon_driver/src/execution/daemon_mode.py +0 -317
  94. unrealon_driver/src/execution/interactive_mode.py +0 -88
  95. unrealon_driver/src/execution/modes.py +0 -45
  96. unrealon_driver/src/execution/scheduled_mode.py +0 -209
  97. unrealon_driver/src/execution/test_mode.py +0 -250
  98. unrealon_driver/src/logging/__init__.py +0 -24
  99. unrealon_driver/src/logging/driver_logger.py +0 -512
  100. unrealon_driver/src/services/__init__.py +0 -24
  101. unrealon_driver/src/services/browser_service.py +0 -726
  102. unrealon_driver/src/services/llm/__init__.py +0 -15
  103. unrealon_driver/src/services/llm/browser_llm_service.py +0 -363
  104. unrealon_driver/src/services/llm/llm.py +0 -195
  105. unrealon_driver/src/services/logger_service.py +0 -232
  106. unrealon_driver/src/services/metrics_service.py +0 -185
  107. unrealon_driver/src/services/scheduler_service.py +0 -489
  108. unrealon_driver/src/services/websocket_service.py +0 -362
  109. unrealon_driver/src/utils/__init__.py +0 -16
  110. unrealon_driver/src/utils/service_factory.py +0 -317
  111. unrealon_driver/src/utils/time_formatter.py +0 -338
  112. unrealon_llm/README.md +0 -44
  113. unrealon_llm/__init__.py +0 -26
  114. unrealon_llm/pyproject.toml +0 -154
  115. unrealon_llm/src/__init__.py +0 -228
  116. unrealon_llm/src/cli/__init__.py +0 -0
  117. unrealon_llm/src/core/__init__.py +0 -11
  118. unrealon_llm/src/core/smart_client.py +0 -438
  119. unrealon_llm/src/dto/__init__.py +0 -155
  120. unrealon_llm/src/dto/models/__init__.py +0 -0
  121. unrealon_llm/src/dto/models/config.py +0 -343
  122. unrealon_llm/src/dto/models/core.py +0 -328
  123. unrealon_llm/src/dto/models/enums.py +0 -123
  124. unrealon_llm/src/dto/models/html_analysis.py +0 -345
  125. unrealon_llm/src/dto/models/statistics.py +0 -473
  126. unrealon_llm/src/dto/models/translation.py +0 -383
  127. unrealon_llm/src/dto/models/type_conversion.py +0 -462
  128. unrealon_llm/src/dto/schemas/__init__.py +0 -0
  129. unrealon_llm/src/exceptions.py +0 -392
  130. unrealon_llm/src/llm_config/__init__.py +0 -20
  131. unrealon_llm/src/llm_config/logging_config.py +0 -178
  132. unrealon_llm/src/llm_logging/__init__.py +0 -42
  133. unrealon_llm/src/llm_logging/llm_events.py +0 -107
  134. unrealon_llm/src/llm_logging/llm_logger.py +0 -466
  135. unrealon_llm/src/managers/__init__.py +0 -15
  136. unrealon_llm/src/managers/cache_manager.py +0 -67
  137. unrealon_llm/src/managers/cost_manager.py +0 -107
  138. unrealon_llm/src/managers/request_manager.py +0 -298
  139. unrealon_llm/src/modules/__init__.py +0 -0
  140. unrealon_llm/src/modules/html_processor/__init__.py +0 -25
  141. unrealon_llm/src/modules/html_processor/base_processor.py +0 -415
  142. unrealon_llm/src/modules/html_processor/details_processor.py +0 -85
  143. unrealon_llm/src/modules/html_processor/listing_processor.py +0 -91
  144. unrealon_llm/src/modules/html_processor/models/__init__.py +0 -20
  145. unrealon_llm/src/modules/html_processor/models/processing_models.py +0 -40
  146. unrealon_llm/src/modules/html_processor/models/universal_model.py +0 -56
  147. unrealon_llm/src/modules/html_processor/processor.py +0 -102
  148. unrealon_llm/src/modules/llm/__init__.py +0 -0
  149. unrealon_llm/src/modules/translator/__init__.py +0 -0
  150. unrealon_llm/src/provider.py +0 -116
  151. unrealon_llm/src/utils/__init__.py +0 -95
  152. unrealon_llm/src/utils/common.py +0 -64
  153. unrealon_llm/src/utils/data_extractor.py +0 -188
  154. unrealon_llm/src/utils/html_cleaner.py +0 -767
  155. unrealon_llm/src/utils/language_detector.py +0 -308
  156. unrealon_llm/src/utils/models_cache.py +0 -592
  157. unrealon_llm/src/utils/smart_counter.py +0 -229
  158. unrealon_llm/src/utils/token_counter.py +0 -189
  159. unrealon_sdk/README.md +0 -25
  160. unrealon_sdk/__init__.py +0 -30
  161. unrealon_sdk/pyproject.toml +0 -231
  162. unrealon_sdk/src/__init__.py +0 -150
  163. unrealon_sdk/src/cli/__init__.py +0 -12
  164. unrealon_sdk/src/cli/commands/__init__.py +0 -22
  165. unrealon_sdk/src/cli/commands/benchmark.py +0 -42
  166. unrealon_sdk/src/cli/commands/diagnostics.py +0 -573
  167. unrealon_sdk/src/cli/commands/health.py +0 -46
  168. unrealon_sdk/src/cli/commands/integration.py +0 -498
  169. unrealon_sdk/src/cli/commands/reports.py +0 -43
  170. unrealon_sdk/src/cli/commands/security.py +0 -36
  171. unrealon_sdk/src/cli/commands/server.py +0 -483
  172. unrealon_sdk/src/cli/commands/servers.py +0 -56
  173. unrealon_sdk/src/cli/commands/tests.py +0 -55
  174. unrealon_sdk/src/cli/main.py +0 -126
  175. unrealon_sdk/src/cli/utils/reporter.py +0 -519
  176. unrealon_sdk/src/clients/openapi.yaml +0 -3347
  177. unrealon_sdk/src/clients/python_http/__init__.py +0 -3
  178. unrealon_sdk/src/clients/python_http/api_config.py +0 -228
  179. unrealon_sdk/src/clients/python_http/models/BaseModel.py +0 -12
  180. unrealon_sdk/src/clients/python_http/models/BroadcastDeliveryStats.py +0 -33
  181. unrealon_sdk/src/clients/python_http/models/BroadcastMessage.py +0 -17
  182. unrealon_sdk/src/clients/python_http/models/BroadcastMessageRequest.py +0 -35
  183. unrealon_sdk/src/clients/python_http/models/BroadcastPriority.py +0 -10
  184. unrealon_sdk/src/clients/python_http/models/BroadcastResponse.py +0 -21
  185. unrealon_sdk/src/clients/python_http/models/BroadcastResultResponse.py +0 -33
  186. unrealon_sdk/src/clients/python_http/models/BroadcastTarget.py +0 -11
  187. unrealon_sdk/src/clients/python_http/models/ConnectionStats.py +0 -27
  188. unrealon_sdk/src/clients/python_http/models/ConnectionsResponse.py +0 -21
  189. unrealon_sdk/src/clients/python_http/models/DeveloperMessageResponse.py +0 -23
  190. unrealon_sdk/src/clients/python_http/models/ErrorResponse.py +0 -25
  191. unrealon_sdk/src/clients/python_http/models/HTTPValidationError.py +0 -16
  192. unrealon_sdk/src/clients/python_http/models/HealthResponse.py +0 -23
  193. unrealon_sdk/src/clients/python_http/models/HealthStatus.py +0 -33
  194. unrealon_sdk/src/clients/python_http/models/LogLevel.py +0 -10
  195. unrealon_sdk/src/clients/python_http/models/LoggingRequest.py +0 -27
  196. unrealon_sdk/src/clients/python_http/models/LoggingResponse.py +0 -23
  197. unrealon_sdk/src/clients/python_http/models/MaintenanceMode.py +0 -9
  198. unrealon_sdk/src/clients/python_http/models/MaintenanceModeRequest.py +0 -33
  199. unrealon_sdk/src/clients/python_http/models/MaintenanceStatusResponse.py +0 -39
  200. unrealon_sdk/src/clients/python_http/models/ParserCommandRequest.py +0 -25
  201. unrealon_sdk/src/clients/python_http/models/ParserMessageResponse.py +0 -21
  202. unrealon_sdk/src/clients/python_http/models/ParserRegistrationRequest.py +0 -28
  203. unrealon_sdk/src/clients/python_http/models/ParserRegistrationResponse.py +0 -25
  204. unrealon_sdk/src/clients/python_http/models/ParserType.py +0 -10
  205. unrealon_sdk/src/clients/python_http/models/ProxyBlockRequest.py +0 -19
  206. unrealon_sdk/src/clients/python_http/models/ProxyEndpointResponse.py +0 -20
  207. unrealon_sdk/src/clients/python_http/models/ProxyListResponse.py +0 -19
  208. unrealon_sdk/src/clients/python_http/models/ProxyProvider.py +0 -10
  209. unrealon_sdk/src/clients/python_http/models/ProxyPurchaseRequest.py +0 -25
  210. unrealon_sdk/src/clients/python_http/models/ProxyResponse.py +0 -47
  211. unrealon_sdk/src/clients/python_http/models/ProxyRotationRequest.py +0 -23
  212. unrealon_sdk/src/clients/python_http/models/ProxyStatus.py +0 -10
  213. unrealon_sdk/src/clients/python_http/models/ProxyUsageRequest.py +0 -19
  214. unrealon_sdk/src/clients/python_http/models/ProxyUsageStatsResponse.py +0 -26
  215. unrealon_sdk/src/clients/python_http/models/ServiceRegistrationDto.py +0 -23
  216. unrealon_sdk/src/clients/python_http/models/ServiceStatsResponse.py +0 -31
  217. unrealon_sdk/src/clients/python_http/models/SessionStartRequest.py +0 -23
  218. unrealon_sdk/src/clients/python_http/models/SuccessResponse.py +0 -25
  219. unrealon_sdk/src/clients/python_http/models/SystemNotificationResponse.py +0 -23
  220. unrealon_sdk/src/clients/python_http/models/ValidationError.py +0 -18
  221. unrealon_sdk/src/clients/python_http/models/ValidationErrorResponse.py +0 -21
  222. unrealon_sdk/src/clients/python_http/models/WebSocketMetrics.py +0 -21
  223. unrealon_sdk/src/clients/python_http/models/__init__.py +0 -44
  224. unrealon_sdk/src/clients/python_http/services/None_service.py +0 -35
  225. unrealon_sdk/src/clients/python_http/services/ParserManagement_service.py +0 -190
  226. unrealon_sdk/src/clients/python_http/services/ProxyManagement_service.py +0 -289
  227. unrealon_sdk/src/clients/python_http/services/SocketLogging_service.py +0 -187
  228. unrealon_sdk/src/clients/python_http/services/SystemHealth_service.py +0 -119
  229. unrealon_sdk/src/clients/python_http/services/WebSocketAPI_service.py +0 -198
  230. unrealon_sdk/src/clients/python_http/services/__init__.py +0 -0
  231. unrealon_sdk/src/clients/python_http/services/admin_service.py +0 -125
  232. unrealon_sdk/src/clients/python_http/services/async_None_service.py +0 -35
  233. unrealon_sdk/src/clients/python_http/services/async_ParserManagement_service.py +0 -190
  234. unrealon_sdk/src/clients/python_http/services/async_ProxyManagement_service.py +0 -289
  235. unrealon_sdk/src/clients/python_http/services/async_SocketLogging_service.py +0 -189
  236. unrealon_sdk/src/clients/python_http/services/async_SystemHealth_service.py +0 -123
  237. unrealon_sdk/src/clients/python_http/services/async_WebSocketAPI_service.py +0 -200
  238. unrealon_sdk/src/clients/python_http/services/async_admin_service.py +0 -125
  239. unrealon_sdk/src/clients/python_websocket/__init__.py +0 -28
  240. unrealon_sdk/src/clients/python_websocket/client.py +0 -490
  241. unrealon_sdk/src/clients/python_websocket/events.py +0 -732
  242. unrealon_sdk/src/clients/python_websocket/example.py +0 -136
  243. unrealon_sdk/src/clients/python_websocket/types.py +0 -871
  244. unrealon_sdk/src/core/__init__.py +0 -64
  245. unrealon_sdk/src/core/client.py +0 -556
  246. unrealon_sdk/src/core/config.py +0 -465
  247. unrealon_sdk/src/core/exceptions.py +0 -239
  248. unrealon_sdk/src/core/metadata.py +0 -191
  249. unrealon_sdk/src/core/models.py +0 -142
  250. unrealon_sdk/src/core/types.py +0 -68
  251. unrealon_sdk/src/dto/__init__.py +0 -268
  252. unrealon_sdk/src/dto/authentication.py +0 -108
  253. unrealon_sdk/src/dto/cache.py +0 -208
  254. unrealon_sdk/src/dto/common.py +0 -19
  255. unrealon_sdk/src/dto/concurrency.py +0 -393
  256. unrealon_sdk/src/dto/events.py +0 -108
  257. unrealon_sdk/src/dto/health.py +0 -339
  258. unrealon_sdk/src/dto/load_balancing.py +0 -336
  259. unrealon_sdk/src/dto/logging.py +0 -230
  260. unrealon_sdk/src/dto/performance.py +0 -165
  261. unrealon_sdk/src/dto/rate_limiting.py +0 -295
  262. unrealon_sdk/src/dto/resource_pooling.py +0 -128
  263. unrealon_sdk/src/dto/structured_logging.py +0 -112
  264. unrealon_sdk/src/dto/task_scheduling.py +0 -121
  265. unrealon_sdk/src/dto/websocket.py +0 -55
  266. unrealon_sdk/src/enterprise/__init__.py +0 -59
  267. unrealon_sdk/src/enterprise/authentication.py +0 -401
  268. unrealon_sdk/src/enterprise/cache_manager.py +0 -578
  269. unrealon_sdk/src/enterprise/error_recovery.py +0 -494
  270. unrealon_sdk/src/enterprise/event_system.py +0 -549
  271. unrealon_sdk/src/enterprise/health_monitor.py +0 -747
  272. unrealon_sdk/src/enterprise/load_balancer.py +0 -964
  273. unrealon_sdk/src/enterprise/logging/__init__.py +0 -68
  274. unrealon_sdk/src/enterprise/logging/cleanup.py +0 -156
  275. unrealon_sdk/src/enterprise/logging/development.py +0 -744
  276. unrealon_sdk/src/enterprise/logging/service.py +0 -410
  277. unrealon_sdk/src/enterprise/multithreading_manager.py +0 -853
  278. unrealon_sdk/src/enterprise/performance_monitor.py +0 -539
  279. unrealon_sdk/src/enterprise/proxy_manager.py +0 -696
  280. unrealon_sdk/src/enterprise/rate_limiter.py +0 -652
  281. unrealon_sdk/src/enterprise/resource_pool.py +0 -763
  282. unrealon_sdk/src/enterprise/task_scheduler.py +0 -709
  283. unrealon_sdk/src/internal/__init__.py +0 -10
  284. unrealon_sdk/src/internal/command_router.py +0 -497
  285. unrealon_sdk/src/internal/connection_manager.py +0 -397
  286. unrealon_sdk/src/internal/http_client.py +0 -446
  287. unrealon_sdk/src/internal/websocket_client.py +0 -420
  288. unrealon_sdk/src/provider.py +0 -471
  289. unrealon_sdk/src/utils.py +0 -234
  290. /unrealon_browser/{src/cli → cli}/__init__.py +0 -0
  291. /unrealon_browser/{src/cli → cli}/interactive_mode.py +0 -0
  292. /unrealon_browser/{src/cli → cli}/main.py +0 -0
  293. /unrealon_browser/{src/core → core}/__init__.py +0 -0
  294. /unrealon_browser/{src/dto → dto}/__init__.py +0 -0
  295. /unrealon_browser/{src/dto → dto}/models/config.py +0 -0
  296. /unrealon_browser/{src/dto → dto}/models/core.py +0 -0
  297. /unrealon_browser/{src/dto → dto}/models/dataclasses.py +0 -0
  298. /unrealon_browser/{src/dto → dto}/models/detection.py +0 -0
  299. /unrealon_browser/{src/dto → dto}/models/enums.py +0 -0
  300. /unrealon_browser/{src/dto → dto}/models/statistics.py +0 -0
  301. /unrealon_browser/{src/managers → managers}/__init__.py +0 -0
  302. /unrealon_browser/{src/managers → managers}/stealth.py +0 -0
@@ -1,465 +0,0 @@
1
- """
2
- Configuration management for UnrealOn SDK v1.0
3
-
4
- Provides enterprise-grade configuration with:
5
- - Minimal configuration philosophy (10 lines replaces 200+)
6
- - Environment-specific settings
7
- - Type-safe validation with Pydantic v2
8
- - Feature toggles for enterprise capabilities
9
- - Performance tuning options
10
- """
11
-
12
- import os
13
- import json
14
- import yaml
15
- from typing import Dict, Optional, List, Union
16
- from datetime import timedelta
17
- from pathlib import Path
18
-
19
- from pydantic import BaseModel, Field, field_validator, ConfigDict
20
- from pydantic_settings import BaseSettings, SettingsConfigDict
21
-
22
- from unrealon_sdk.src.clients.python_http.models import LogLevel, ParserType
23
-
24
-
25
- class EnvironmentDefaults(BaseModel):
26
- """
27
- Type-safe environment-specific default values.
28
-
29
- Replaces Dict[str, Any] usage with properly typed configuration model.
30
- """
31
-
32
- model_config = ConfigDict(validate_assignment=True, extra="forbid")
33
-
34
- enable_monitoring: bool = Field(default=True, description="Enable monitoring")
35
- enable_logging: bool = Field(default=True, description="Enable logging")
36
- enable_error_recovery: bool = Field(default=True, description="Enable error recovery")
37
- request_timeout_ms: int = Field(default=30000, description="Request timeout in ms")
38
- max_retries: int = Field(default=3, description="Maximum retry attempts")
39
- connection_pool_size: int = Field(default=50, description="Connection pool size")
40
- debug_mode: bool = Field(default=False, description="Enable debug mode")
41
- verbose_logging: bool = Field(default=False, description="Enable verbose logging")
42
-
43
-
44
- class ProxyConfig(BaseModel):
45
- """Proxy management configuration."""
46
-
47
- model_config = ConfigDict(
48
- validate_assignment=True,
49
- extra="allow", # Allow extra fields for backward compatibility
50
- frozen=False, # Allow modifications for testing
51
- )
52
-
53
- rotation_strategy: str = Field(
54
- default="success_rate",
55
- description="Proxy rotation strategy",
56
- pattern=r"^(round_robin|success_rate|weighted_random|least_failures|least_used)$",
57
- )
58
- health_check_interval: int = Field(
59
- default=30, description="Health check interval in seconds", ge=10, le=300
60
- )
61
- failover_threshold: int = Field(
62
- default=3, description="Failures before proxy replacement", ge=1, le=10
63
- )
64
- session_persistence: bool = Field(
65
- default=True, description="Maintain proxy sessions across requests"
66
- )
67
- geographic_distribution: Optional[Dict[str, float]] = Field(
68
- default=None, description="Geographic proxy distribution weights"
69
- )
70
-
71
- # Legacy field names (for backward compatibility)
72
- enabled: Optional[bool] = Field(default=None, description="Legacy: Enable proxy management")
73
- providers: Optional[List[str]] = Field(
74
- default=None, description="Legacy: List of proxy providers"
75
- )
76
- max_failures_before_rotation: Optional[int] = Field(
77
- default=None, description="Legacy: Max failures before rotation"
78
- )
79
-
80
- @field_validator("geographic_distribution")
81
- @classmethod
82
- def validate_distribution(cls, v: Optional[Dict[str, float]]) -> Optional[Dict[str, float]]:
83
- if v is not None:
84
- total = sum(v.values())
85
- if not (0.95 <= total <= 1.05): # Allow small floating point errors
86
- raise ValueError("Geographic distribution weights must sum to 1.0")
87
- return v
88
-
89
-
90
- class MultithreadingConfig(BaseModel):
91
- """Multithreading and concurrency configuration."""
92
-
93
- model_config = ConfigDict(validate_assignment=True, extra="forbid", frozen=True)
94
-
95
- max_workers: int = Field(default=10, description="Maximum concurrent workers", ge=1, le=100)
96
- distribution_strategy: str = Field(
97
- default="LOAD_BALANCING",
98
- description="Task distribution strategy",
99
- pattern=r"^(SEQUENTIAL|ROUND_ROBIN|LOAD_BALANCING|CUSTOM)$",
100
- )
101
- task_timeout: int = Field(default=300, description="Task timeout in seconds", ge=30, le=3600)
102
- queue_size: int = Field(default=1000, description="Task queue size", ge=10, le=10000)
103
-
104
-
105
- class LoggingConfig(BaseModel):
106
- """Logging configuration for multi-destination logging."""
107
-
108
- model_config = ConfigDict(
109
- validate_assignment=True,
110
- extra="allow", # Allow extra fields for backward compatibility
111
- frozen=False, # Allow modifications for testing
112
- )
113
-
114
- # New field names (preferred)
115
- log_level: LogLevel = Field(default=LogLevel.INFO, description="Minimum log level")
116
- enable_file_logging: bool = Field(default=True, description="Enable file logging")
117
- enable_server_logging: bool = Field(
118
- default=True, description="Enable server logging via WebSocket"
119
- )
120
- enable_audit_logging: bool = Field(default=False, description="Enable audit trail logging")
121
- log_file_path: Optional[str] = Field(default=None, description="Custom log file path")
122
-
123
- # Legacy field names (for backward compatibility)
124
- level: Optional[LogLevel] = Field(default=None, description="Legacy: Minimum log level")
125
- console_enabled: Optional[bool] = Field(
126
- default=None, description="Legacy: Enable console logging"
127
- )
128
- file_enabled: Optional[bool] = Field(default=None, description="Legacy: Enable file logging")
129
- file_path: Optional[str] = Field(default=None, description="Legacy: Log file path")
130
- server_enabled: Optional[bool] = Field(
131
- default=None, description="Legacy: Enable server logging"
132
- )
133
- structured: Optional[bool] = Field(
134
- default=None, description="Legacy: Enable structured logging"
135
- )
136
- server_batch_size: Optional[int] = Field(default=None, description="Legacy: Server batch size")
137
- log_rotation_size_mb: int = Field(
138
- default=50, description="Log file rotation size in MB", ge=1, le=1000
139
- )
140
- log_rotation_count: int = Field(
141
- default=10, description="Number of rotated log files to keep", ge=1, le=100
142
- )
143
- structured_logging: bool = Field(default=True, description="Use structured JSON logging")
144
-
145
- # New enterprise fields for LoggingService
146
- enabled: bool = Field(default=True, description="Enable logging service")
147
- buffer_size: int = Field(
148
- default=100, description="Buffer size for batching logs", ge=10, le=10000
149
- )
150
- flush_interval_seconds: float = Field(
151
- default=5.0, description="Auto-flush interval in seconds", ge=0.1, le=60.0
152
- )
153
- destinations: List[str] = Field(
154
- default_factory=lambda: ["console", "websocket"], description="Log destinations"
155
- )
156
-
157
-
158
- class MonitoringConfig(BaseModel):
159
- """Monitoring and analytics configuration."""
160
-
161
- model_config = ConfigDict(
162
- validate_assignment=True,
163
- extra="allow", # Allow extra fields for backward compatibility
164
- frozen=False, # Allow modifications for testing
165
- )
166
-
167
- # New field names (preferred)
168
- metrics_interval: int = Field(
169
- default=15, description="Metrics collection interval in seconds", ge=5, le=300
170
- )
171
- enable_health_checks: bool = Field(default=True, description="Enable health monitoring")
172
- enable_performance_profiling: bool = Field(
173
- default=False, description="Enable performance profiling"
174
- )
175
- enable_business_metrics: bool = Field(default=True, description="Enable business KPI tracking")
176
- enable_cost_tracking: bool = Field(
177
- default=True, description="Enable cost optimization tracking"
178
- )
179
- alert_thresholds: Dict[str, float] = Field(
180
- default_factory=lambda: {
181
- "error_rate": 0.05,
182
- "response_time_ms": 5000,
183
- "memory_usage_percent": 0.85,
184
- "success_rate": 0.95,
185
- },
186
- description="Alert threshold values",
187
- )
188
-
189
- # Legacy field names (for backward compatibility)
190
- enabled: Optional[bool] = Field(default=None, description="Legacy: Enable monitoring")
191
- health_check_interval: Optional[int] = Field(
192
- default=None, description="Legacy: Health check interval"
193
- )
194
- track_response_times: Optional[bool] = Field(
195
- default=None, description="Legacy: Track response times"
196
- )
197
- track_memory_usage: Optional[bool] = Field(
198
- default=None, description="Legacy: Track memory usage"
199
- )
200
- enable_alerts: Optional[bool] = Field(default=None, description="Legacy: Enable alerts")
201
-
202
-
203
- class AdapterConfig(BaseSettings):
204
- """
205
- Main configuration class for UnrealOn Adapter Client.
206
-
207
- Minimal configuration philosophy - most settings have intelligent defaults.
208
-
209
- Example:
210
- config = AdapterConfig(
211
- api_key="up_dev_your_api_key",
212
- parser_id="my_parser",
213
- parser_name="My Parser",
214
- enable_proxy_rotation=True,
215
- enable_monitoring=True,
216
- enable_logging=True
217
- )
218
- """
219
-
220
- model_config = SettingsConfigDict(
221
- env_prefix="UNREALON_",
222
- env_file=".env",
223
- env_file_encoding="utf-8",
224
- case_sensitive=False,
225
- validate_assignment=True,
226
- extra="allow", # Allow extra fields for backward compatibility
227
- )
228
-
229
- # Core connection settings
230
- server_url: str = Field(
231
- default="wss://api.unrealon.com", description="UnrealOn server WebSocket URL"
232
- )
233
- api_key: str = Field(
234
- ...,
235
- description="Developer API key",
236
- min_length=20,
237
- pattern=r"^up_(dev|prod)_[a-zA-Z0-9_]{16,}$",
238
- )
239
- parser_id: str = Field(
240
- ...,
241
- description="Unique parser identifier",
242
- min_length=3,
243
- max_length=100,
244
- pattern=r"^[a-zA-Z0-9_-]+$",
245
- )
246
- parser_name: str = Field(
247
- ..., description="Human-readable parser name", min_length=1, max_length=200
248
- )
249
- parser_type: ParserType = Field(default=ParserType.CUSTOM, description="Type of parser")
250
-
251
- # Environment and deployment
252
- environment: str = Field(
253
- default="development",
254
- description="Deployment environment",
255
- pattern=r"^(development|staging|production)$",
256
- )
257
-
258
- # Enterprise feature toggles
259
- enable_proxy_rotation: bool = Field(
260
- default=False, description="Enable intelligent proxy management"
261
- )
262
- enable_monitoring: bool = Field(default=True, description="Enable real-time monitoring")
263
- enable_logging: bool = Field(default=True, description="Enable multi-destination logging")
264
- enable_error_recovery: bool = Field(
265
- default=True, description="Enable production error handling"
266
- )
267
- enable_auto_scaling: bool = Field(
268
- default=False, description="Enable dynamic resource allocation"
269
- )
270
-
271
- # Performance and reliability settings
272
- request_timeout_ms: int = Field(
273
- default=30000, description="Request timeout in milliseconds", ge=5000, le=300000
274
- )
275
- max_retries: int = Field(default=3, description="Maximum retry attempts", ge=0, le=10)
276
- memory_limit_mb: Optional[int] = Field(
277
- default=None, description="Memory limit in MB", ge=128, le=32768
278
- )
279
- cpu_limit_percent: float = Field(
280
- default=0.8, description="CPU usage limit (0.0-1.0)", ge=0.1, le=1.0
281
- )
282
- connection_pool_size: int = Field(
283
- default=50, description="HTTP connection pool size", ge=1, le=1000
284
- )
285
-
286
- # Advanced configuration objects
287
- proxy_config: Optional[ProxyConfig] = Field(
288
- default=None, description="Proxy management configuration"
289
- )
290
- multithreading_config: Optional[MultithreadingConfig] = Field(
291
- default=None, description="Multithreading configuration"
292
- )
293
- logging_config: Optional[LoggingConfig] = Field(
294
- default=None, description="Logging configuration"
295
- )
296
- monitoring_config: Optional[MonitoringConfig] = Field(
297
- default=None, description="Monitoring configuration"
298
- )
299
-
300
- # Debug and development options
301
- debug_mode: bool = Field(default=False, description="Enable debug mode")
302
- verbose_logging: bool = Field(default=False, description="Enable verbose logging")
303
-
304
- def __init__(self, **data) -> None:
305
- """Initialize configuration with intelligent defaults."""
306
- super().__init__(**data)
307
-
308
- # Auto-create sub-configurations if features are enabled
309
- if self.enable_proxy_rotation and self.proxy_config is None:
310
- self.proxy_config = ProxyConfig()
311
-
312
- if self.enable_monitoring and self.monitoring_config is None:
313
- self.monitoring_config = MonitoringConfig()
314
-
315
- if self.enable_logging and self.logging_config is None:
316
- self.logging_config = LoggingConfig()
317
-
318
- # Set multithreading config for production
319
- if self.environment == "production" and self.multithreading_config is None:
320
- self.multithreading_config = MultithreadingConfig(
321
- max_workers=20, distribution_strategy="LOAD_BALANCING"
322
- )
323
-
324
- @field_validator("api_key")
325
- @classmethod
326
- def validate_api_key(cls, v: str) -> str:
327
- """Validate API key format and environment consistency."""
328
- if v.startswith("up_dev_"):
329
- # Development API key
330
- pass
331
- elif v.startswith("up_prod_"):
332
- # Production API key
333
- pass
334
- else:
335
- raise ValueError("API key must start with 'up_dev_' or 'up_prod_'")
336
- return v
337
-
338
- @field_validator("server_url")
339
- @classmethod
340
- def validate_server_url(cls, v: str) -> str:
341
- """Validate server URL format."""
342
- if not (v.startswith("ws://") or v.startswith("wss://")):
343
- raise ValueError("Server URL must be a WebSocket URL (ws:// or wss://)")
344
- return v
345
-
346
- def get_environment_specific_defaults(self) -> EnvironmentDefaults:
347
- """Get environment-specific default values."""
348
- if self.environment == "production":
349
- return EnvironmentDefaults(
350
- enable_monitoring=True,
351
- enable_logging=True,
352
- enable_error_recovery=True,
353
- request_timeout_ms=45000,
354
- max_retries=5,
355
- connection_pool_size=100,
356
- debug_mode=False,
357
- verbose_logging=False,
358
- )
359
- elif self.environment == "staging":
360
- return EnvironmentDefaults(
361
- enable_monitoring=True,
362
- enable_logging=True,
363
- enable_error_recovery=True,
364
- debug_mode=True,
365
- verbose_logging=False,
366
- )
367
- else: # development
368
- return EnvironmentDefaults(
369
- enable_monitoring=True,
370
- enable_logging=True,
371
- enable_error_recovery=True,
372
- debug_mode=True,
373
- verbose_logging=True,
374
- )
375
-
376
- def to_dict(self) -> Dict[str, Union[str, int, bool, float, None]]:
377
- """Convert configuration to dictionary with type-safe values."""
378
- return self.model_dump()
379
-
380
- def to_json(self) -> str:
381
- """Convert configuration to JSON string."""
382
- return self.model_dump_json(indent=2)
383
-
384
- @classmethod
385
- def from_env(cls) -> "AdapterConfig":
386
- """Create configuration from environment variables."""
387
- return cls()
388
-
389
- @classmethod
390
- def from_file(cls, file_path: Union[str, Path]) -> "AdapterConfig":
391
- """Load configuration from file."""
392
- file_path = Path(file_path)
393
-
394
- if not file_path.exists():
395
- from .exceptions import ConfigurationError
396
-
397
- raise ConfigurationError(f"Configuration file not found: {file_path}")
398
-
399
- if file_path.suffix == ".json":
400
- with file_path.open() as f:
401
- data = json.load(f)
402
- elif file_path.suffix in (".yaml", ".yml"):
403
- with file_path.open() as f:
404
- data = yaml.safe_load(f)
405
- else:
406
- from .exceptions import ConfigurationError
407
-
408
- raise ConfigurationError(f"Unsupported configuration file format: {file_path.suffix}")
409
-
410
- return cls(**data)
411
-
412
- def validate_for_environment(self) -> List[str]:
413
- """Validate configuration for current environment."""
414
- warnings = []
415
-
416
- if self.environment == "production":
417
- if not self.enable_monitoring:
418
- warnings.append("Monitoring should be enabled in production")
419
- if not self.enable_error_recovery:
420
- warnings.append("Error recovery should be enabled in production")
421
- if self.debug_mode:
422
- warnings.append("Debug mode should be disabled in production")
423
- if self.api_key.startswith("up_dev_"):
424
- warnings.append("Using development API key in production")
425
-
426
- return warnings
427
-
428
-
429
- def create_development_config(
430
- api_key: str, parser_id: str, parser_name: str, **kwargs
431
- ) -> AdapterConfig:
432
- """Create a development configuration with sensible defaults."""
433
- return AdapterConfig(
434
- api_key=api_key,
435
- parser_id=parser_id,
436
- parser_name=parser_name,
437
- environment="development",
438
- debug_mode=True,
439
- verbose_logging=True,
440
- enable_monitoring=True,
441
- enable_logging=True,
442
- **kwargs,
443
- )
444
-
445
-
446
- def create_production_config(
447
- api_key: str, parser_id: str, parser_name: str, **kwargs
448
- ) -> AdapterConfig:
449
- """Create a production configuration with enterprise features."""
450
- return AdapterConfig(
451
- api_key=api_key,
452
- parser_id=parser_id,
453
- parser_name=parser_name,
454
- environment="production",
455
- enable_proxy_rotation=True,
456
- enable_monitoring=True,
457
- enable_logging=True,
458
- enable_error_recovery=True,
459
- enable_auto_scaling=True,
460
- debug_mode=False,
461
- request_timeout_ms=45000,
462
- max_retries=5,
463
- connection_pool_size=100,
464
- **kwargs,
465
- )
@@ -1,239 +0,0 @@
1
- """
2
- Exception hierarchy for UnrealOn SDK v1.0
3
-
4
- Provides comprehensive error handling with structured exception types
5
- for different categories of errors that can occur in the SDK.
6
- """
7
-
8
- from typing import Optional, Any
9
-
10
-
11
- class UnrealOnError(Exception):
12
- """
13
- Base exception for all UnrealOn SDK errors.
14
-
15
- All SDK exceptions inherit from this base class to allow
16
- for comprehensive error handling.
17
- """
18
-
19
- def __init__(
20
- self,
21
- message: str,
22
- error_code: Optional[str] = None,
23
- details: Optional[Any] = None,
24
- ):
25
- super().__init__(message)
26
- self.message = message
27
- self.error_code = error_code or "UNREALON_ERROR"
28
- self.details = details or {}
29
-
30
- def __str__(self) -> str:
31
- if self.error_code:
32
- return f"[{self.error_code}] {self.message}"
33
- return self.message
34
-
35
-
36
- class ConnectionError(UnrealOnError):
37
- """
38
- Raised when connection-related errors occur.
39
-
40
- This includes WebSocket connection failures, HTTP connection issues,
41
- network timeouts, and connection state errors.
42
- """
43
-
44
- def __init__(
45
- self,
46
- message: str,
47
- error_code: Optional[str] = None,
48
- details: Optional[Any] = None,
49
- ):
50
- super().__init__(message, error_code or "CONNECTION_ERROR", details)
51
-
52
-
53
- class AuthenticationError(UnrealOnError):
54
- """
55
- Raised when authentication fails.
56
-
57
- This includes invalid API keys, expired tokens,
58
- permission denied, and other auth-related issues.
59
- """
60
-
61
- def __init__(
62
- self,
63
- message: str,
64
- error_code: Optional[str] = None,
65
- details: Optional[Any] = None,
66
- ):
67
- super().__init__(message, error_code or "AUTH_ERROR", details)
68
-
69
-
70
- class ConfigurationError(UnrealOnError):
71
- """
72
- Raised when configuration is invalid or incomplete.
73
-
74
- This includes missing required fields, invalid values,
75
- incompatible settings, and configuration validation errors.
76
- """
77
-
78
- def __init__(
79
- self,
80
- message: str,
81
- error_code: Optional[str] = None,
82
- details: Optional[Any] = None,
83
- ):
84
- super().__init__(message, error_code or "CONFIG_ERROR", details)
85
-
86
-
87
- class CommandError(UnrealOnError):
88
- """
89
- Raised when command processing fails.
90
-
91
- This includes unknown command types, command execution failures,
92
- timeout errors, and command validation issues.
93
- """
94
-
95
- def __init__(
96
- self,
97
- message: str,
98
- error_code: Optional[str] = None,
99
- details: Optional[Any] = None,
100
- ):
101
- super().__init__(message, error_code or "COMMAND_ERROR", details)
102
-
103
-
104
- class ProxyError(UnrealOnError):
105
- """
106
- Raised when proxy-related errors occur.
107
-
108
- This includes proxy connection failures, proxy rotation issues,
109
- proxy authentication problems, and proxy health check failures.
110
- """
111
-
112
- def __init__(
113
- self,
114
- message: str,
115
- error_code: Optional[str] = None,
116
- details: Optional[Any] = None,
117
- ):
118
- super().__init__(message, error_code or "PROXY_ERROR", details)
119
-
120
-
121
- class TimeoutError(UnrealOnError):
122
- """
123
- Raised when operations exceed their timeout limits.
124
-
125
- This includes command timeouts, connection timeouts,
126
- response timeouts, and other time-based failures.
127
- """
128
-
129
- def __init__(
130
- self,
131
- message: str,
132
- error_code: Optional[str] = None,
133
- details: Optional[Any] = None,
134
- ):
135
- super().__init__(message, error_code or "TIMEOUT_ERROR", details)
136
-
137
-
138
- class ValidationError(UnrealOnError):
139
- """
140
- Raised when data validation fails.
141
-
142
- This includes Pydantic validation errors, schema validation,
143
- data format errors, and type validation issues.
144
- """
145
-
146
- def __init__(
147
- self,
148
- message: str,
149
- error_code: Optional[str] = None,
150
- details: Optional[Any] = None,
151
- ):
152
- super().__init__(message, error_code or "VALIDATION_ERROR", details)
153
-
154
-
155
- class RegistrationError(UnrealOnError):
156
- """
157
- Raised when parser registration fails.
158
-
159
- This includes registration validation errors, duplicate parser IDs,
160
- service registration issues, and registration timeout errors.
161
- """
162
-
163
- def __init__(
164
- self,
165
- message: str,
166
- error_code: Optional[str] = None,
167
- details: Optional[Any] = None,
168
- ):
169
- super().__init__(message, error_code or "REGISTRATION_ERROR", details)
170
-
171
-
172
- class WebSocketError(UnrealOnError):
173
- """
174
- Raised when WebSocket-specific errors occur.
175
-
176
- This includes WebSocket protocol errors, message format issues,
177
- event handling errors, and WebSocket state problems.
178
- """
179
-
180
- def __init__(
181
- self,
182
- message: str,
183
- error_code: Optional[str] = None,
184
- details: Optional[Any] = None,
185
- ):
186
- super().__init__(message, error_code or "WEBSOCKET_ERROR", details)
187
-
188
-
189
- class MonitoringError(UnrealOnError):
190
- """
191
- Raised when monitoring system errors occur.
192
-
193
- This includes metrics collection failures, health check errors,
194
- monitoring configuration issues, and performance tracking problems.
195
- """
196
-
197
- def __init__(
198
- self,
199
- message: str,
200
- error_code: Optional[str] = None,
201
- details: Optional[Any] = None,
202
- ):
203
- super().__init__(message, error_code or "MONITORING_ERROR", details)
204
-
205
-
206
- class LoggingError(UnrealOnError):
207
- """
208
- Raised when logging system errors occur.
209
-
210
- This includes log transmission failures, log format errors,
211
- logging configuration issues, and log destination problems.
212
- """
213
-
214
- def __init__(
215
- self,
216
- message: str,
217
- error_code: Optional[str] = None,
218
- details: Optional[Any] = None,
219
- ):
220
- super().__init__(message, error_code or "LOGGING_ERROR", details)
221
-
222
-
223
- class RateLimitError(UnrealOnError):
224
- """
225
- Raised when rate limits are exceeded.
226
-
227
- This includes API rate limiting, command throttling,
228
- resource usage limits, and quota exceeded errors.
229
- """
230
-
231
- def __init__(
232
- self,
233
- message: str,
234
- error_code: Optional[str] = None,
235
- details: Optional[Any] = None,
236
- retry_after: Optional[int] = None,
237
- ):
238
- super().__init__(message, error_code or "RATE_LIMIT_ERROR", details)
239
- self.retry_after = retry_after