screen-controller-ai 0.1.1__tar.gz
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.
- screen_controller_ai-0.1.1/PKG-INFO +15 -0
- screen_controller_ai-0.1.1/controller.py +117 -0
- screen_controller_ai-0.1.1/pyproject.toml +27 -0
- screen_controller_ai-0.1.1/screen_controller_ai.egg-info/PKG-INFO +15 -0
- screen_controller_ai-0.1.1/screen_controller_ai.egg-info/SOURCES.txt +7 -0
- screen_controller_ai-0.1.1/screen_controller_ai.egg-info/dependency_links.txt +1 -0
- screen_controller_ai-0.1.1/screen_controller_ai.egg-info/requires.txt +3 -0
- screen_controller_ai-0.1.1/screen_controller_ai.egg-info/top_level.txt +1 -0
- screen_controller_ai-0.1.1/setup.cfg +4 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: screen-controller-ai
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A safe, dual-model agentic desktop controller with human-in-the-loop safety features
|
|
5
|
+
Author: Atharva
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/atharva/screen-controller
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: pynput
|
|
14
|
+
Requires-Dist: pillow
|
|
15
|
+
Requires-Dist: google-genai
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import time
|
|
2
|
+
import threading
|
|
3
|
+
import sys
|
|
4
|
+
from pynput import mouse, keyboard
|
|
5
|
+
from PIL import ImageGrab
|
|
6
|
+
|
|
7
|
+
class ScreenController:
|
|
8
|
+
def __init__(self):
|
|
9
|
+
self.url = None
|
|
10
|
+
self.api_key = None
|
|
11
|
+
self.task_target = None
|
|
12
|
+
self.screen_viewer_allowed = False
|
|
13
|
+
self.controller_allowed = False
|
|
14
|
+
self._stop_event = threading.Event()
|
|
15
|
+
|
|
16
|
+
self._mouse_listener = None
|
|
17
|
+
self._keyboard_listener = None
|
|
18
|
+
|
|
19
|
+
def allow_controller(self):
|
|
20
|
+
"""Enables the safety interrupt listener (mouse/keyboard tripwire)."""
|
|
21
|
+
self.controller_allowed = True
|
|
22
|
+
print("[Safety] Controller armed. Move your mouse or press any key to instantly abort.")
|
|
23
|
+
self._start_safety_listeners()
|
|
24
|
+
return self
|
|
25
|
+
|
|
26
|
+
def open(self, url):
|
|
27
|
+
"""Sets the target URL to open."""
|
|
28
|
+
self.url = url
|
|
29
|
+
print(f"[Action] Target URL configured: {self.url}")
|
|
30
|
+
return self
|
|
31
|
+
|
|
32
|
+
def key(self, api_key):
|
|
33
|
+
"""Sets the API key for the AI models."""
|
|
34
|
+
self.api_key = api_key
|
|
35
|
+
print("[Config] API Key loaded successfully.")
|
|
36
|
+
return self
|
|
37
|
+
|
|
38
|
+
def target(self, goal):
|
|
39
|
+
"""Defines what the AI agent must accomplish."""
|
|
40
|
+
self.task_target = goal
|
|
41
|
+
print(f"[Target] Goal defined: '{self.task_target}'")
|
|
42
|
+
return self
|
|
43
|
+
|
|
44
|
+
def allow_screen_viewer(self):
|
|
45
|
+
"""Grants permission for the model to capture screenshots."""
|
|
46
|
+
self.screen_viewer_allowed = True
|
|
47
|
+
print("[Permission] Screen viewer enabled.")
|
|
48
|
+
return self
|
|
49
|
+
|
|
50
|
+
def _trigger_abort(self, reason="User input detected"):
|
|
51
|
+
"""Instantly stops the execution loop."""
|
|
52
|
+
if not self._stop_event.is_set():
|
|
53
|
+
print(f"\n[ABORTED] Safety tripwire triggered ({reason}). Stopping controller immediately.")
|
|
54
|
+
self._stop_event.set()
|
|
55
|
+
self._stop_safety_listeners()
|
|
56
|
+
|
|
57
|
+
def _start_safety_listeners(self):
|
|
58
|
+
"""Starts background listeners to detect user mouse movement or key presses."""
|
|
59
|
+
def on_move(x, y):
|
|
60
|
+
self._trigger_abort("Mouse moved")
|
|
61
|
+
|
|
62
|
+
def on_click(x, y, button, pressed):
|
|
63
|
+
self._trigger_abort("Mouse clicked")
|
|
64
|
+
|
|
65
|
+
def on_press(key):
|
|
66
|
+
self._trigger_abort(f"Key pressed: {key}")
|
|
67
|
+
|
|
68
|
+
# Initialize non-blocking listeners
|
|
69
|
+
self._mouse_listener = mouse.Listener(on_move=on_move, on_click=on_click)
|
|
70
|
+
self._keyboard_listener = keyboard.Listener(on_press=on_press)
|
|
71
|
+
|
|
72
|
+
self._mouse_listener.start()
|
|
73
|
+
self._keyboard_listener.start()
|
|
74
|
+
|
|
75
|
+
def _stop_safety_listeners(self):
|
|
76
|
+
"""Cleanly stops the safety listeners."""
|
|
77
|
+
if self._mouse_listener:
|
|
78
|
+
self._mouse_listener.stop()
|
|
79
|
+
if self._keyboard_listener:
|
|
80
|
+
self._keyboard_listener.stop()
|
|
81
|
+
|
|
82
|
+
def start(self):
|
|
83
|
+
"""Executes the dual-model processing and action loop."""
|
|
84
|
+
if not self.controller_allowed or not self.screen_viewer_allowed:
|
|
85
|
+
raise PermissionError("You must allow controller and screen viewer before starting!")
|
|
86
|
+
|
|
87
|
+
if not self.api_key:
|
|
88
|
+
raise ValueError("API key is missing! Set it using x.key().")
|
|
89
|
+
|
|
90
|
+
print(f"\n[Running] Starting task: '{self.task_target}'")
|
|
91
|
+
print("[Model] Main execution model active.")
|
|
92
|
+
print("[Model] Background verification model active.")
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
while not self._stop_event.is_set():
|
|
96
|
+
# 1. Capture screen snapshot safely
|
|
97
|
+
if self.screen_viewer_allowed:
|
|
98
|
+
screenshot = ImageGrab.grab()
|
|
99
|
+
# (Here is where you would send the screenshot to Gemini Flash Lite)
|
|
100
|
+
|
|
101
|
+
# 2. Main Model execution step & Background Verifier check
|
|
102
|
+
print("[Looping] Analyzing screen state and verifying task progress...")
|
|
103
|
+
|
|
104
|
+
# Simulate a working interval (check every 2 seconds)
|
|
105
|
+
for _ in range(20):
|
|
106
|
+
if self._stop_event.is_set():
|
|
107
|
+
break
|
|
108
|
+
time.sleep(0.1)
|
|
109
|
+
|
|
110
|
+
# Break condition placeholder for testing
|
|
111
|
+
break
|
|
112
|
+
|
|
113
|
+
except Exception as e:
|
|
114
|
+
print(f"[Error] {e}")
|
|
115
|
+
finally:
|
|
116
|
+
self._stop_safety_listeners()
|
|
117
|
+
print("[Stopped] Screen controller session closed safely.")
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "screen-controller-ai"
|
|
7
|
+
version = "0.1.1"
|
|
8
|
+
description = "A safe, dual-model agentic desktop controller with human-in-the-loop safety features"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
authors = [
|
|
11
|
+
{ name = "Atharva" }
|
|
12
|
+
]
|
|
13
|
+
license = { text = "MIT" }
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Programming Language :: Python :: 3",
|
|
16
|
+
"License :: OSI Approved :: MIT License",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
]
|
|
19
|
+
requires-python = ">=3.8"
|
|
20
|
+
dependencies = [
|
|
21
|
+
"pynput",
|
|
22
|
+
"pillow",
|
|
23
|
+
"google-genai"
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://github.com/atharva/screen-controller"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: screen-controller-ai
|
|
3
|
+
Version: 0.1.1
|
|
4
|
+
Summary: A safe, dual-model agentic desktop controller with human-in-the-loop safety features
|
|
5
|
+
Author: Atharva
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/atharva/screen-controller
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.8
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: pynput
|
|
14
|
+
Requires-Dist: pillow
|
|
15
|
+
Requires-Dist: google-genai
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
controller
|