fleet-framework 0.1.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.
Files changed (85) hide show
  1. fleet/__init__.py +1 -0
  2. fleet/cli.py +290 -0
  3. fleet/core/__init__.py +69 -0
  4. fleet/core/automation.py +125 -0
  5. fleet/core/backend.py +736 -0
  6. fleet/core/config.py +38 -0
  7. fleet/core/context.py +102 -0
  8. fleet/core/contract.py +87 -0
  9. fleet/core/country_presets.py +50 -0
  10. fleet/core/events.py +55 -0
  11. fleet/core/logging.py +97 -0
  12. fleet/core/memory_backend.py +492 -0
  13. fleet/core/metrics.py +61 -0
  14. fleet/core/otel.py +97 -0
  15. fleet/core/primitives.py +310 -0
  16. fleet/core/protocol.py +171 -0
  17. fleet/core/proxy.py +166 -0
  18. fleet/core/reconcile.py +75 -0
  19. fleet/core/sqlite_backend.py +1117 -0
  20. fleet/core/store.py +104 -0
  21. fleet/master/__init__.py +3 -0
  22. fleet/master/api.py +324 -0
  23. fleet/master/app.py +105 -0
  24. fleet/master/auth.py +132 -0
  25. fleet/master/broadcaster.py +37 -0
  26. fleet/master/dashboard/__init__.py +4 -0
  27. fleet/master/dashboard/router.py +36 -0
  28. fleet/master/dashboard/static/style.css +97 -0
  29. fleet/master/dashboard/templates/index.html +372 -0
  30. fleet/master/metrics_route.py +141 -0
  31. fleet/master/ratelimit.py +55 -0
  32. fleet/master/ws_router.py +142 -0
  33. fleet/worker/__init__.py +3 -0
  34. fleet/worker/agent.py +173 -0
  35. fleet/worker/reconcile_loop.py +246 -0
  36. fleet/worker/slot_runner.py +256 -0
  37. fleet/worker/ws_client.py +164 -0
  38. fleet_browser/__init__.py +21 -0
  39. fleet_browser/browser.py +277 -0
  40. fleet_browser/cert.py +68 -0
  41. fleet_browser/fingerprint.py +327 -0
  42. fleet_browser/humanizer.py +157 -0
  43. fleet_browser/pool.py +241 -0
  44. fleet_browser/proxy_extension.py +122 -0
  45. fleet_browser/solver.py +51 -0
  46. fleet_browser/stealth.py +80 -0
  47. fleet_cloudflare/__init__.py +22 -0
  48. fleet_cloudflare/bypasser.py +168 -0
  49. fleet_cloudflare/harvest.py +266 -0
  50. fleet_cloudflare/replay.py +82 -0
  51. fleet_cloudflare/solver.py +28 -0
  52. fleet_content/__init__.py +24 -0
  53. fleet_content/automation.py +43 -0
  54. fleet_content/contracts.py +76 -0
  55. fleet_detect/__init__.py +26 -0
  56. fleet_detect/contracts.py +67 -0
  57. fleet_detect/detect.py +126 -0
  58. fleet_framework-0.1.0.dist-info/METADATA +160 -0
  59. fleet_framework-0.1.0.dist-info/RECORD +85 -0
  60. fleet_framework-0.1.0.dist-info/WHEEL +5 -0
  61. fleet_framework-0.1.0.dist-info/entry_points.txt +9 -0
  62. fleet_framework-0.1.0.dist-info/licenses/LICENSE +21 -0
  63. fleet_framework-0.1.0.dist-info/top_level.txt +14 -0
  64. fleet_headers/__init__.py +28 -0
  65. fleet_headers/profiles.py +131 -0
  66. fleet_jobs/__init__.py +28 -0
  67. fleet_jobs/automation.py +34 -0
  68. fleet_jobs/contracts.py +143 -0
  69. fleet_marketplace/__init__.py +33 -0
  70. fleet_marketplace/automation.py +32 -0
  71. fleet_marketplace/contracts.py +151 -0
  72. fleet_news/__init__.py +21 -0
  73. fleet_news/automation.py +51 -0
  74. fleet_news/contracts.py +59 -0
  75. fleet_place/__init__.py +33 -0
  76. fleet_place/automation.py +37 -0
  77. fleet_place/contracts.py +156 -0
  78. fleet_provider_dataimpulse/__init__.py +82 -0
  79. fleet_provider_evomi/__init__.py +76 -0
  80. fleet_serp/__init__.py +30 -0
  81. fleet_serp/automation.py +47 -0
  82. fleet_serp/contracts.py +100 -0
  83. fleet_social/__init__.py +34 -0
  84. fleet_social/automation.py +44 -0
  85. fleet_social/contracts.py +172 -0
@@ -0,0 +1,75 @@
1
+ from __future__ import annotations
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Any, Literal
5
+
6
+ from fleet.core.config import BaseConfig
7
+
8
+ # pure-functional diff between observed and desired config. no I/O.
9
+ # applied by fleet.worker.reconcile_loop.
10
+
11
+ ActionKind = Literal[
12
+ "stop_all",
13
+ "cold_start",
14
+ "restart",
15
+ "scale_up",
16
+ "scale_down",
17
+ "restart_pages",
18
+ "noop",
19
+ ]
20
+
21
+
22
+ @dataclass(frozen=True)
23
+ class Action:
24
+ kind: ActionKind
25
+ detail: dict[str, Any] = field(default_factory=dict, hash=False, compare=True)
26
+
27
+
28
+ _BASE_REBOOT = frozenset() # populated per-config-class via BaseConfig.reboot_fields()
29
+ _BASE_RESTART = frozenset({"proxy_url"})
30
+
31
+
32
+ def _diff_fields(observed: BaseConfig, desired: BaseConfig, names: frozenset[str]) -> list[str]:
33
+ return [f for f in names if getattr(observed, f) != getattr(desired, f)]
34
+
35
+
36
+ def diff(observed: BaseConfig, desired: BaseConfig) -> list[Action]:
37
+ # rule 1: disabled wins.
38
+ if not desired.enabled:
39
+ return [Action(kind="stop_all", detail={})]
40
+
41
+ # rule 2: cold start.
42
+ if not observed.enabled:
43
+ return [Action(kind="cold_start", detail={"desired": desired})]
44
+
45
+ cls = type(desired)
46
+ reboot_fields = _BASE_REBOOT | cls.reboot_fields()
47
+ restart_fields = _BASE_RESTART | cls.restart_fields()
48
+
49
+ # rule 3: reboot-class change → full cold restart of the worker (token server etc).
50
+ reboot_changes = _diff_fields(observed, desired, reboot_fields)
51
+ if reboot_changes:
52
+ return [Action(kind="restart", detail={"desired": desired, "changed": reboot_changes})]
53
+
54
+ # rule 4 / 5: scale by slot delta.
55
+ delta = desired.slots - observed.slots
56
+ if delta > 0:
57
+ return [Action(kind="scale_up", detail={"delta": delta})]
58
+ if delta < 0:
59
+ return [Action(kind="scale_down", detail={"delta": -delta})]
60
+
61
+ # rule 6: restart-class (page-level) change → recycle each slot.
62
+ restart_changes = _diff_fields(observed, desired, restart_fields)
63
+ if restart_changes:
64
+ return [
65
+ Action(kind="restart_pages", detail={"desired": desired, "changed": restart_changes})
66
+ ]
67
+
68
+ return [Action(kind="noop", detail={})]
69
+
70
+
71
+ def is_noop(plan: list[Action]) -> bool:
72
+ return len(plan) == 1 and plan[0].kind == "noop"
73
+
74
+
75
+ __all__ = ["Action", "ActionKind", "diff", "is_noop"]