cuaboss 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.
- cuaboss/__init__.py +1 -0
- cuaboss/cli.py +163 -0
- cuaboss/desktop.py +77 -0
- cuaboss/server.py +154 -0
- cuaboss/tools.py +52 -0
- cuaboss/tunnel.py +43 -0
- cuaboss-0.1.0.dist-info/METADATA +159 -0
- cuaboss-0.1.0.dist-info/RECORD +12 -0
- cuaboss-0.1.0.dist-info/WHEEL +5 -0
- cuaboss-0.1.0.dist-info/entry_points.txt +2 -0
- cuaboss-0.1.0.dist-info/licenses/LICENSE +21 -0
- cuaboss-0.1.0.dist-info/top_level.txt +1 -0
cuaboss/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
cuaboss/cli.py
ADDED
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import ctypes
|
|
3
|
+
import os
|
|
4
|
+
import secrets
|
|
5
|
+
import shutil
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
from . import tunnel
|
|
10
|
+
from .desktop import Desktop
|
|
11
|
+
from .server import serve
|
|
12
|
+
|
|
13
|
+
CONF = Path.home() / ".cuaboss" / "secret"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class _Style:
|
|
17
|
+
"""Small ANSI styling helper with a clean plain-text fallback."""
|
|
18
|
+
|
|
19
|
+
def __init__(self, enabled):
|
|
20
|
+
self.enabled = enabled
|
|
21
|
+
|
|
22
|
+
def __call__(self, text, code):
|
|
23
|
+
return f"\033[{code}m{text}\033[0m" if self.enabled else text
|
|
24
|
+
|
|
25
|
+
def bold(self, text):
|
|
26
|
+
return self(text, "1")
|
|
27
|
+
|
|
28
|
+
def cyan(self, text):
|
|
29
|
+
return self(text, "1;36")
|
|
30
|
+
|
|
31
|
+
def green(self, text):
|
|
32
|
+
return self(text, "1;32")
|
|
33
|
+
|
|
34
|
+
def yellow(self, text):
|
|
35
|
+
return self(text, "1;33")
|
|
36
|
+
|
|
37
|
+
def dim(self, text):
|
|
38
|
+
return self(text, "2")
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _enable_color():
|
|
42
|
+
if os.environ.get("NO_COLOR") is not None or not sys.stdout.isatty():
|
|
43
|
+
return False
|
|
44
|
+
if not sys.platform.startswith("win"):
|
|
45
|
+
return os.environ.get("TERM") != "dumb"
|
|
46
|
+
try:
|
|
47
|
+
kernel32 = ctypes.windll.kernel32
|
|
48
|
+
handle = kernel32.GetStdHandle(-11) # STD_OUTPUT_HANDLE
|
|
49
|
+
mode = ctypes.c_ulong()
|
|
50
|
+
if not kernel32.GetConsoleMode(handle, ctypes.byref(mode)):
|
|
51
|
+
return False
|
|
52
|
+
return bool(kernel32.SetConsoleMode(handle, mode.value | 0x0004))
|
|
53
|
+
except (AttributeError, OSError):
|
|
54
|
+
return False
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def startup_text(screen, mcp_url, *, public, tunnel_failed=False, color=None, width=None):
|
|
58
|
+
"""Render the startup card. Kept separate so it stays easy to snapshot-test."""
|
|
59
|
+
style = _Style(_enable_color() if color is None else color)
|
|
60
|
+
columns = width or shutil.get_terminal_size((100, 24)).columns
|
|
61
|
+
rule_width = max(36, min(columns - 4, 112))
|
|
62
|
+
rule = "=" * rule_width
|
|
63
|
+
soft_rule = "-" * rule_width
|
|
64
|
+
size = f"{screen['width']} x {screen['height']}"
|
|
65
|
+
scope = "PUBLIC HTTPS" if public else "LOCAL ONLY"
|
|
66
|
+
|
|
67
|
+
lines = [
|
|
68
|
+
"",
|
|
69
|
+
f" {style.cyan('CUABOSS')} {style.dim('One bridge. Three assistants. Your desktop.')}",
|
|
70
|
+
f" {rule}",
|
|
71
|
+
f" {style.green('[ LIVE ]')} Screen {style.bold(size)} | {style.bold(scope)}",
|
|
72
|
+
f" {rule}",
|
|
73
|
+
"",
|
|
74
|
+
f" {style.bold('MCP ENDPOINT')}",
|
|
75
|
+
f" {style.dim('Use this one URL for ChatGPT, Claude, and Gemini.')}",
|
|
76
|
+
f" {style.cyan(mcp_url)}",
|
|
77
|
+
"",
|
|
78
|
+
f" {style.bold('CONNECT')}",
|
|
79
|
+
f" {soft_rule}",
|
|
80
|
+
f" {style.bold('[1] ChatGPT')} Plugins > + > Add custom MCP server",
|
|
81
|
+
" Paste the endpoint above | Authentication: None",
|
|
82
|
+
"",
|
|
83
|
+
f" {style.bold('[2] Claude')} Settings > Connectors > Add custom connector",
|
|
84
|
+
" Paste the endpoint above",
|
|
85
|
+
"",
|
|
86
|
+
f" {style.bold('[3] Gemini')} Run in Gemini CLI:",
|
|
87
|
+
' gemini mcp add --transport http cuaboss "<endpoint above>"',
|
|
88
|
+
f" {soft_rule}",
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
if not public:
|
|
92
|
+
if tunnel_failed:
|
|
93
|
+
lines.extend([
|
|
94
|
+
"",
|
|
95
|
+
f" {style.yellow('[ TUNNEL NOT FOUND ]')} Install cloudflared or ngrok, then rerun.",
|
|
96
|
+
" Or keep this server local and connect it through Secure MCP Tunnel.",
|
|
97
|
+
])
|
|
98
|
+
else:
|
|
99
|
+
lines.extend([
|
|
100
|
+
"",
|
|
101
|
+
f" {style.yellow('[ LOCAL MODE ]')} Web assistants need your own HTTPS or Secure MCP Tunnel.",
|
|
102
|
+
])
|
|
103
|
+
|
|
104
|
+
lines.extend([
|
|
105
|
+
"",
|
|
106
|
+
f" {style.yellow('[ SECURITY ]')} This endpoint is a password. Anyone with it controls this machine.",
|
|
107
|
+
" Move the mouse into a screen corner to abort. Press Ctrl+C to stop.",
|
|
108
|
+
"",
|
|
109
|
+
])
|
|
110
|
+
return "\n".join(lines)
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
def get_secret(rotate=False):
|
|
114
|
+
if os.environ.get("CUABOSS_SECRET"):
|
|
115
|
+
return os.environ["CUABOSS_SECRET"]
|
|
116
|
+
if CONF.exists() and not rotate:
|
|
117
|
+
return CONF.read_text().strip()
|
|
118
|
+
s = secrets.token_urlsafe(24)
|
|
119
|
+
CONF.parent.mkdir(parents=True, exist_ok=True)
|
|
120
|
+
CONF.write_text(s)
|
|
121
|
+
try:
|
|
122
|
+
CONF.chmod(0o600)
|
|
123
|
+
except OSError:
|
|
124
|
+
pass
|
|
125
|
+
return s
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def main(argv=None):
|
|
129
|
+
ap = argparse.ArgumentParser(prog="cuaboss", description="Let ChatGPT, Claude and Gemini use this desktop.")
|
|
130
|
+
ap.add_argument("--port", type=int, default=8765)
|
|
131
|
+
ap.add_argument("--no-tunnel", action="store_true", help="local only, bring your own tunnel")
|
|
132
|
+
ap.add_argument("--rotate-secret", action="store_true", help="new secret URL")
|
|
133
|
+
a = ap.parse_args(argv)
|
|
134
|
+
|
|
135
|
+
secret = get_secret(a.rotate_secret)
|
|
136
|
+
desk = Desktop()
|
|
137
|
+
srv = serve(desk, secret, a.port)
|
|
138
|
+
local = f"http://127.0.0.1:{a.port}/{secret}"
|
|
139
|
+
base, proc = (None, None) if a.no_tunnel else tunnel.start(a.port)
|
|
140
|
+
|
|
141
|
+
if base:
|
|
142
|
+
pub = f"{base}/{secret}"
|
|
143
|
+
output = startup_text(desk.screen_size(), f"{pub}/mcp", public=True)
|
|
144
|
+
else:
|
|
145
|
+
output = startup_text(
|
|
146
|
+
desk.screen_size(),
|
|
147
|
+
f"{local}/mcp",
|
|
148
|
+
public=False,
|
|
149
|
+
tunnel_failed=not a.no_tunnel,
|
|
150
|
+
)
|
|
151
|
+
print(output)
|
|
152
|
+
try:
|
|
153
|
+
srv.serve_forever()
|
|
154
|
+
except KeyboardInterrupt:
|
|
155
|
+
pass
|
|
156
|
+
finally:
|
|
157
|
+
if proc:
|
|
158
|
+
proc.terminate()
|
|
159
|
+
return 0
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if __name__ == "__main__":
|
|
163
|
+
sys.exit(main())
|
cuaboss/desktop.py
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"""Desktop backend: screenshot + mouse + keyboard. Coordinates are in screenshot space."""
|
|
2
|
+
import base64
|
|
3
|
+
import io
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
MAX_W = 1280
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Desktop:
|
|
10
|
+
def __init__(self):
|
|
11
|
+
import pyautogui # imported lazily so the server can start headless for tests
|
|
12
|
+
|
|
13
|
+
pyautogui.FAILSAFE = True # slam mouse into a screen corner to abort
|
|
14
|
+
pyautogui.PAUSE = 0.05
|
|
15
|
+
self.pg = pyautogui
|
|
16
|
+
self.real_w, self.real_h = pyautogui.size()
|
|
17
|
+
self.scale = min(1.0, MAX_W / self.real_w)
|
|
18
|
+
self.w, self.h = int(self.real_w * self.scale), int(self.real_h * self.scale)
|
|
19
|
+
|
|
20
|
+
def _xy(self, x, y):
|
|
21
|
+
return int(x / self.scale), int(y / self.scale)
|
|
22
|
+
|
|
23
|
+
def screenshot_png(self) -> bytes:
|
|
24
|
+
img = self.pg.screenshot().convert("RGB")
|
|
25
|
+
if self.scale < 1.0:
|
|
26
|
+
img = img.resize((self.w, self.h))
|
|
27
|
+
buf = io.BytesIO()
|
|
28
|
+
img.save(buf, "PNG", optimize=True)
|
|
29
|
+
return buf.getvalue()
|
|
30
|
+
|
|
31
|
+
def screenshot_b64(self) -> str:
|
|
32
|
+
return base64.b64encode(self.screenshot_png()).decode()
|
|
33
|
+
|
|
34
|
+
def screen_size(self):
|
|
35
|
+
return {"width": self.w, "height": self.h}
|
|
36
|
+
|
|
37
|
+
def click(self, x, y, button="left", double=False):
|
|
38
|
+
rx, ry = self._xy(x, y)
|
|
39
|
+
self.pg.click(rx, ry, clicks=2 if double else 1, button=button)
|
|
40
|
+
|
|
41
|
+
def move(self, x, y):
|
|
42
|
+
self.pg.moveTo(*self._xy(x, y), duration=0.15)
|
|
43
|
+
|
|
44
|
+
def drag(self, x1, y1, x2, y2):
|
|
45
|
+
self.pg.moveTo(*self._xy(x1, y1))
|
|
46
|
+
self.pg.dragTo(*self._xy(x2, y2), duration=0.4, button="left")
|
|
47
|
+
|
|
48
|
+
def type_text(self, text):
|
|
49
|
+
# pyautogui.write drops non-ASCII; fall back to clipboard paste for those
|
|
50
|
+
if text.isascii():
|
|
51
|
+
self.pg.write(text, interval=0.01)
|
|
52
|
+
else:
|
|
53
|
+
import subprocess, sys
|
|
54
|
+
if sys.platform == "darwin":
|
|
55
|
+
subprocess.run(["pbcopy"], input=text.encode(), check=True)
|
|
56
|
+
self.pg.hotkey("command", "v")
|
|
57
|
+
elif sys.platform.startswith("win"):
|
|
58
|
+
subprocess.run(["clip"], input=text.encode("utf-16"), check=True)
|
|
59
|
+
self.pg.hotkey("ctrl", "v")
|
|
60
|
+
else:
|
|
61
|
+
subprocess.run(["xclip", "-selection", "clipboard"], input=text.encode(), check=True)
|
|
62
|
+
self.pg.hotkey("ctrl", "v")
|
|
63
|
+
|
|
64
|
+
def key(self, combo):
|
|
65
|
+
keys = [k.strip().lower() for k in combo.split("+") if k.strip()]
|
|
66
|
+
if len(keys) == 1:
|
|
67
|
+
self.pg.press(keys[0])
|
|
68
|
+
else:
|
|
69
|
+
self.pg.hotkey(*keys)
|
|
70
|
+
|
|
71
|
+
def scroll(self, amount, x=None, y=None):
|
|
72
|
+
if x is not None and y is not None:
|
|
73
|
+
self.pg.moveTo(*self._xy(x, y))
|
|
74
|
+
self.pg.scroll(int(amount))
|
|
75
|
+
|
|
76
|
+
def wait(self, seconds):
|
|
77
|
+
time.sleep(min(float(seconds), 10))
|
cuaboss/server.py
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"""One HTTP server, three front doors:
|
|
2
|
+
/<secret>/mcp MCP (Streamable HTTP, stateless) -> ChatGPT connector, Claude connector, Gemini CLI
|
|
3
|
+
/<secret>/openapi.json + /<secret>/tools/<name> -> Gemini function calling / any OpenAPI client
|
|
4
|
+
/<secret>/screenshot.png -> quick sanity check in a browser
|
|
5
|
+
The secret in the path is the auth. Treat the URL like a password.
|
|
6
|
+
"""
|
|
7
|
+
import json
|
|
8
|
+
import threading
|
|
9
|
+
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
|
|
10
|
+
|
|
11
|
+
from . import __version__
|
|
12
|
+
from .tools import TOOLS, call
|
|
13
|
+
|
|
14
|
+
PROTOCOL = "2025-03-26"
|
|
15
|
+
_lock = threading.Lock() # one human desktop, one action at a time
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _tool_list():
|
|
19
|
+
return [{"name": n, "description": d, "inputSchema": s} for n, (d, s) in TOOLS.items()]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def handle_rpc(desktop, msg):
|
|
23
|
+
"""Handle one JSON-RPC message. Returns a response dict or None for notifications."""
|
|
24
|
+
mid, method = msg.get("id"), msg.get("method")
|
|
25
|
+
params = msg.get("params") or {}
|
|
26
|
+
if mid is None:
|
|
27
|
+
return None # notification
|
|
28
|
+
|
|
29
|
+
def ok(result):
|
|
30
|
+
return {"jsonrpc": "2.0", "id": mid, "result": result}
|
|
31
|
+
|
|
32
|
+
def err(code, text):
|
|
33
|
+
return {"jsonrpc": "2.0", "id": mid, "error": {"code": code, "message": text}}
|
|
34
|
+
|
|
35
|
+
if method == "initialize":
|
|
36
|
+
return ok({"protocolVersion": params.get("protocolVersion", PROTOCOL),
|
|
37
|
+
"capabilities": {"tools": {"listChanged": False}},
|
|
38
|
+
"serverInfo": {"name": "cuaboss", "version": __version__}})
|
|
39
|
+
if method == "ping":
|
|
40
|
+
return ok({})
|
|
41
|
+
if method == "tools/list":
|
|
42
|
+
return ok({"tools": _tool_list()})
|
|
43
|
+
if method == "tools/call":
|
|
44
|
+
name, args = params.get("name"), params.get("arguments") or {}
|
|
45
|
+
try:
|
|
46
|
+
with _lock:
|
|
47
|
+
text, png = call(desktop, name, args)
|
|
48
|
+
except KeyError:
|
|
49
|
+
return err(-32602, f"unknown tool {name}")
|
|
50
|
+
except Exception as e: # surface desktop errors to the model
|
|
51
|
+
return ok({"isError": True, "content": [{"type": "text", "text": f"{type(e).__name__}: {e}"}]})
|
|
52
|
+
content = [{"type": "text", "text": text}]
|
|
53
|
+
if png:
|
|
54
|
+
content.append({"type": "image", "data": png, "mimeType": "image/png"})
|
|
55
|
+
return ok({"content": content})
|
|
56
|
+
return err(-32601, f"method not found: {method}")
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def openapi(base):
|
|
60
|
+
paths = {}
|
|
61
|
+
for n, (d, s) in TOOLS.items():
|
|
62
|
+
paths[f"/tools/{n}"] = {"post": {"operationId": n, "summary": d,
|
|
63
|
+
"requestBody": {"required": True, "content": {"application/json": {"schema": s}}},
|
|
64
|
+
"responses": {"200": {"description": "text result plus base64 PNG screenshot",
|
|
65
|
+
"content": {"application/json": {"schema": {"type": "object", "properties": {
|
|
66
|
+
"text": {"type": "string"}, "image_png_base64": {"type": "string"}}}}}}}}}
|
|
67
|
+
return {"openapi": "3.1.0", "info": {"title": "cuaboss", "version": __version__,
|
|
68
|
+
"description": "Control the user's desktop: screenshot, click, type, keys, scroll."},
|
|
69
|
+
"servers": [{"url": base}], "paths": paths}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
def make_handler(desktop, secret):
|
|
73
|
+
prefix = f"/{secret}"
|
|
74
|
+
|
|
75
|
+
class H(BaseHTTPRequestHandler):
|
|
76
|
+
server_version = "cuaboss"
|
|
77
|
+
|
|
78
|
+
def log_message(self, fmt, *a):
|
|
79
|
+
line = fmt % a
|
|
80
|
+
print("[cuaboss]", line.replace(secret, "***"))
|
|
81
|
+
|
|
82
|
+
def _send(self, code, body, ctype="application/json", extra=None):
|
|
83
|
+
data = body if isinstance(body, bytes) else json.dumps(body).encode()
|
|
84
|
+
self.send_response(code)
|
|
85
|
+
self.send_header("Content-Type", ctype)
|
|
86
|
+
self.send_header("Content-Length", str(len(data)))
|
|
87
|
+
self.send_header("Access-Control-Allow-Origin", "*")
|
|
88
|
+
for k, v in (extra or {}).items():
|
|
89
|
+
self.send_header(k, v)
|
|
90
|
+
self.end_headers()
|
|
91
|
+
self.wfile.write(data)
|
|
92
|
+
|
|
93
|
+
def _path(self):
|
|
94
|
+
p = self.path.split("?")[0]
|
|
95
|
+
if not p.startswith(prefix + "/") and p != prefix:
|
|
96
|
+
return None
|
|
97
|
+
return p[len(prefix):] or "/"
|
|
98
|
+
|
|
99
|
+
def do_OPTIONS(self):
|
|
100
|
+
self._send(204, b"", extra={"Access-Control-Allow-Headers": "*", "Access-Control-Allow-Methods": "GET,POST,DELETE,OPTIONS"})
|
|
101
|
+
|
|
102
|
+
def do_GET(self):
|
|
103
|
+
p = self._path()
|
|
104
|
+
if p is None:
|
|
105
|
+
return self._send(404, {"error": "not found"})
|
|
106
|
+
if p == "/":
|
|
107
|
+
return self._send(200, {"name": "cuaboss", "version": __version__, "mcp": f"{prefix}/mcp"})
|
|
108
|
+
if p == "/screenshot.png":
|
|
109
|
+
with _lock:
|
|
110
|
+
return self._send(200, desktop.screenshot_png(), "image/png")
|
|
111
|
+
if p == "/openapi.json":
|
|
112
|
+
host = self.headers.get("X-Forwarded-Host") or self.headers.get("Host")
|
|
113
|
+
proto = self.headers.get("X-Forwarded-Proto", "http")
|
|
114
|
+
return self._send(200, openapi(f"{proto}://{host}{prefix}"))
|
|
115
|
+
if p == "/mcp":
|
|
116
|
+
return self._send(405, {"error": "use POST"})
|
|
117
|
+
self._send(404, {"error": "not found"})
|
|
118
|
+
|
|
119
|
+
def do_DELETE(self):
|
|
120
|
+
self._send(200, {})
|
|
121
|
+
|
|
122
|
+
def do_POST(self):
|
|
123
|
+
p = self._path()
|
|
124
|
+
if p is None:
|
|
125
|
+
return self._send(404, {"error": "not found"})
|
|
126
|
+
n = int(self.headers.get("Content-Length") or 0)
|
|
127
|
+
try:
|
|
128
|
+
body = json.loads(self.rfile.read(n) or b"{}")
|
|
129
|
+
except ValueError:
|
|
130
|
+
return self._send(400, {"error": "bad json"})
|
|
131
|
+
if p == "/mcp":
|
|
132
|
+
if isinstance(body, list):
|
|
133
|
+
out = [r for r in (handle_rpc(desktop, m) for m in body) if r]
|
|
134
|
+
return self._send(200, out) if out else self._send(202, b"")
|
|
135
|
+
r = handle_rpc(desktop, body)
|
|
136
|
+
return self._send(200, r) if r else self._send(202, b"")
|
|
137
|
+
if p.startswith("/tools/"):
|
|
138
|
+
name = p[len("/tools/"):]
|
|
139
|
+
try:
|
|
140
|
+
with _lock:
|
|
141
|
+
text, png = call(desktop, name, body)
|
|
142
|
+
except KeyError:
|
|
143
|
+
return self._send(404, {"error": f"unknown tool {name}"})
|
|
144
|
+
except Exception as e:
|
|
145
|
+
return self._send(500, {"error": f"{type(e).__name__}: {e}"})
|
|
146
|
+
return self._send(200, {"text": text, "image_png_base64": png})
|
|
147
|
+
self._send(404, {"error": "not found"})
|
|
148
|
+
|
|
149
|
+
return H
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
def serve(desktop, secret, port):
|
|
153
|
+
srv = ThreadingHTTPServer(("127.0.0.1", port), make_handler(desktop, secret))
|
|
154
|
+
return srv
|
cuaboss/tools.py
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"""Tool registry shared by the MCP endpoint and the REST/OpenAPI endpoint."""
|
|
2
|
+
|
|
3
|
+
def _obj(props, required=()):
|
|
4
|
+
return {"type": "object", "properties": props, "required": list(required)}
|
|
5
|
+
|
|
6
|
+
_N = {"type": "integer"}
|
|
7
|
+
_S = {"type": "string"}
|
|
8
|
+
|
|
9
|
+
TOOLS = {
|
|
10
|
+
"screenshot": ("Take a screenshot of the desktop. Coordinates for every other tool refer to this image.", _obj({})),
|
|
11
|
+
"screen_size": ("Width and height of the screenshot coordinate space.", _obj({})),
|
|
12
|
+
"click": ("Click at x,y. button: left|right|middle. Set double=true for a double click.",
|
|
13
|
+
_obj({"x": _N, "y": _N, "button": {"type": "string", "enum": ["left", "right", "middle"]}, "double": {"type": "boolean"}}, ["x", "y"])),
|
|
14
|
+
"move": ("Move the mouse to x,y.", _obj({"x": _N, "y": _N}, ["x", "y"])),
|
|
15
|
+
"drag": ("Press at x1,y1 and drag to x2,y2.", _obj({"x1": _N, "y1": _N, "x2": _N, "y2": _N}, ["x1", "y1", "x2", "y2"])),
|
|
16
|
+
"type": ("Type text at the current focus.", _obj({"text": _S}, ["text"])),
|
|
17
|
+
"key": ("Press a key or combo, e.g. 'enter', 'ctrl+l', 'command+space'.", _obj({"combo": _S}, ["combo"])),
|
|
18
|
+
"scroll": ("Scroll by amount (positive up, negative down), optionally at x,y.", _obj({"amount": _N, "x": _N, "y": _N}, ["amount"])),
|
|
19
|
+
"wait": ("Wait up to 10 seconds.", _obj({"seconds": {"type": "number"}}, ["seconds"])),
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
SAYS = {
|
|
23
|
+
"click": "clicked", "move": "moved", "drag": "dragged", "type": "typed",
|
|
24
|
+
"key": "pressed", "scroll": "scrolled", "wait": "waited",
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def call(desktop, name, args):
|
|
29
|
+
"""Returns (text, png_b64_or_None). Actions return a fresh screenshot so the model sees the result."""
|
|
30
|
+
if name not in TOOLS:
|
|
31
|
+
raise KeyError(name)
|
|
32
|
+
if name == "screenshot":
|
|
33
|
+
return "ok", desktop.screenshot_b64()
|
|
34
|
+
if name == "screen_size":
|
|
35
|
+
s = desktop.screen_size()
|
|
36
|
+
return f"{s['width']}x{s['height']}", None
|
|
37
|
+
if name == "click":
|
|
38
|
+
desktop.click(args["x"], args["y"], args.get("button", "left"), bool(args.get("double", False)))
|
|
39
|
+
elif name == "move":
|
|
40
|
+
desktop.move(args["x"], args["y"])
|
|
41
|
+
elif name == "drag":
|
|
42
|
+
desktop.drag(args["x1"], args["y1"], args["x2"], args["y2"])
|
|
43
|
+
elif name == "type":
|
|
44
|
+
desktop.type_text(args["text"])
|
|
45
|
+
elif name == "key":
|
|
46
|
+
desktop.key(args["combo"])
|
|
47
|
+
elif name == "scroll":
|
|
48
|
+
desktop.scroll(args["amount"], args.get("x"), args.get("y"))
|
|
49
|
+
elif name == "wait":
|
|
50
|
+
desktop.wait(args["seconds"])
|
|
51
|
+
desktop.wait(0.4)
|
|
52
|
+
return SAYS[name], desktop.screenshot_b64()
|
cuaboss/tunnel.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Open a public HTTPS tunnel to the local server. Tries cloudflared (no account), then ngrok."""
|
|
2
|
+
import re
|
|
3
|
+
import shutil
|
|
4
|
+
import subprocess
|
|
5
|
+
import threading
|
|
6
|
+
import time
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def start(port, timeout=40):
|
|
10
|
+
"""Returns (public_https_url, process) or (None, None)."""
|
|
11
|
+
if shutil.which("cloudflared"):
|
|
12
|
+
p = subprocess.Popen(["cloudflared", "tunnel", "--no-autoupdate", "--url", f"http://127.0.0.1:{port}"],
|
|
13
|
+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)
|
|
14
|
+
found = []
|
|
15
|
+
|
|
16
|
+
def pump():
|
|
17
|
+
for line in p.stdout:
|
|
18
|
+
m = re.search(r"https://[a-z0-9-]+\.trycloudflare\.com", line)
|
|
19
|
+
if m and not found:
|
|
20
|
+
found.append(m.group(0))
|
|
21
|
+
threading.Thread(target=pump, daemon=True).start()
|
|
22
|
+
end = time.time() + timeout
|
|
23
|
+
while time.time() < end and not found and p.poll() is None:
|
|
24
|
+
time.sleep(0.3)
|
|
25
|
+
if found:
|
|
26
|
+
return found[0], p
|
|
27
|
+
p.terminate()
|
|
28
|
+
if shutil.which("ngrok"):
|
|
29
|
+
p = subprocess.Popen(["ngrok", "http", str(port), "--log=stdout", "--log-format=json"],
|
|
30
|
+
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
|
31
|
+
import json
|
|
32
|
+
import urllib.request
|
|
33
|
+
end = time.time() + timeout
|
|
34
|
+
while time.time() < end:
|
|
35
|
+
try:
|
|
36
|
+
with urllib.request.urlopen("http://127.0.0.1:4040/api/tunnels", timeout=2) as r:
|
|
37
|
+
for t in json.load(r)["tunnels"]:
|
|
38
|
+
if t["public_url"].startswith("https://"):
|
|
39
|
+
return t["public_url"], p
|
|
40
|
+
except Exception:
|
|
41
|
+
time.sleep(0.5)
|
|
42
|
+
p.terminate()
|
|
43
|
+
return None, None
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: cuaboss
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: One server, three assistants: let ChatGPT, Claude and Gemini use your desktop.
|
|
5
|
+
Author: Rajarshi Datta
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/rajarshidattapy/cuaboss
|
|
8
|
+
Project-URL: Repository, https://github.com/rajarshidattapy/cuaboss
|
|
9
|
+
Project-URL: Issues, https://github.com/rajarshidattapy/cuaboss/issues
|
|
10
|
+
Keywords: mcp,computer-use,desktop-automation,chatgpt,claude,gemini
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Desktop Environment
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: pyautogui>=0.9.54
|
|
27
|
+
Requires-Dist: pillow>=10
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
30
|
+
Provides-Extra: release
|
|
31
|
+
Requires-Dist: build>=1.2; extra == "release"
|
|
32
|
+
Requires-Dist: twine>=5; extra == "release"
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# cuaboss
|
|
36
|
+
|
|
37
|
+
**One bridge. Three assistants. Your desktop.**
|
|
38
|
+
|
|
39
|
+
<img width="2172" height="724" alt="Cuaboss Blue Pixel Puzzle Banner" src="https://github.com/user-attachments/assets/e76bf9bf-48dd-4cd2-8b1e-a902c7cb2f3a" />
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
- PyPi link:
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
ChatGPT, Claude and Gemini live in the browser. Your computer doesn't. cuaboss closes the gap: a tiny local server that gives any of them computer use (screenshot, click, type, keys, scroll) on *your* machine, through a single tunnel.
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
ChatGPT web ─┐
|
|
51
|
+
Claude ─┼─► public HTTPS tunnel ─► cuaboss (localhost) ─► your desktop
|
|
52
|
+
Gemini ─┘ secret URL MCP + OpenAPI
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Why
|
|
56
|
+
|
|
57
|
+
Every assistant has its own plugin format. cuaboss speaks the one they all converge on, MCP, and adds an OpenAPI door for the rest. Build the desktop tools once, plug in all three.
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
| Assistant | How it connects |
|
|
61
|
+
| --------- | ---------------------------------------------------------------- |
|
|
62
|
+
| ChatGPT | Developer mode connector, MCP URL |
|
|
63
|
+
| Claude | Custom connector, same MCP URL |
|
|
64
|
+
| Gemini | Gemini CLI via `gemini mcp add`, or OpenAPI for function calling |
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## Run it
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install cuaboss
|
|
71
|
+
winget install cloudflared # or: winget install cloudflared / apt install cloudflared. ngrok also works
|
|
72
|
+
cuaboss
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
It prints one shared MCP endpoint and shows where to paste it for each assistant. macOS: grant your terminal Screen Recording and Accessibility. Linux: X11 session (plus `xclip` for non-ASCII typing).
|
|
76
|
+
|
|
77
|
+
Then, in ChatGPT: *Plugins > + > Add custom MCP server*, paste `https://<tunnel>/<secret>/mcp`, auth none. Ask: "take a screenshot and open my browser."
|
|
78
|
+
|
|
79
|
+
## Tools
|
|
80
|
+
|
|
81
|
+
`screenshot` `click` `move` `drag` `type` `key` `scroll` `wait` `screen_size`
|
|
82
|
+
|
|
83
|
+
Every action returns a fresh screenshot so the model sees what happened. Coordinates live in the screenshot's space and are scaled to your real screen.
|
|
84
|
+
|
|
85
|
+
## Safety (read this)
|
|
86
|
+
|
|
87
|
+
- The secret in the URL is the only auth. Anyone with it controls your machine. `cuaboss --rotate-secret` makes a new one.
|
|
88
|
+
- Fail-safe: slam the mouse into a screen corner to abort.
|
|
89
|
+
- Stop the process and the tunnel dies with it.
|
|
90
|
+
- MVP: no allowlists, no per-action approval yet.
|
|
91
|
+
|
|
92
|
+
## Roadmap
|
|
93
|
+
|
|
94
|
+
- OAuth instead of a path secret
|
|
95
|
+
- Per-action approval prompt and app allowlist
|
|
96
|
+
- Named tunnel for a stable URL
|
|
97
|
+
- Window-level capture, not just full screen
|
|
98
|
+
|
|
99
|
+
## Development and releases
|
|
100
|
+
|
|
101
|
+
Install the development dependencies and run the tests:
|
|
102
|
+
|
|
103
|
+
```powershell
|
|
104
|
+
python -m pip install -e ".[dev]"
|
|
105
|
+
python -m pytest -q
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Build and validate the wheel and source distribution:
|
|
109
|
+
|
|
110
|
+
```powershell
|
|
111
|
+
.\scripts\build.ps1
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
For releases after `0.1.0`, update both version declarations together:
|
|
115
|
+
|
|
116
|
+
```powershell
|
|
117
|
+
.\scripts\set-version.ps1 -Version 0.1.1
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Publishing uses GitHub Actions and PyPI Trusted Publishing, so the repository does not store a PyPI API token. Configure these publishers once:
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
| Index | Project | Owner | Repository | Workflow | Environment |
|
|
124
|
+
| -------- | --------- | ----------------- | ---------- | -------------- | ----------- |
|
|
125
|
+
| PyPI | `cuaboss` | `rajarshidattapy` | `cuaboss` | `release.yml` | `pypi` |
|
|
126
|
+
| TestPyPI | `cuaboss` | `rajarshidattapy` | `cuaboss` | `testpypi.yml` | `testpypi` |
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
Create matching `pypi` and `testpypi` environments under the GitHub repository's **Settings > Environments** page. Configure the publishers in the [PyPI](https://pypi.org/manage/account/publishing/) and [TestPyPI](https://test.pypi.org/manage/account/publishing/) account settings.
|
|
130
|
+
|
|
131
|
+
After committing and pushing the release changes, test the package on TestPyPI:
|
|
132
|
+
|
|
133
|
+
```powershell
|
|
134
|
+
.\scripts\publish-testpypi.ps1 -Watch
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Validate a production release without publishing anything:
|
|
138
|
+
|
|
139
|
+
```powershell
|
|
140
|
+
.\scripts\release.ps1 -Version 0.1.0
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
When ready, create the GitHub Release and trigger the production PyPI workflow:
|
|
144
|
+
|
|
145
|
+
```powershell
|
|
146
|
+
.\scripts\release.ps1 -Version 0.1.0 -Publish
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
Alternatively, publish directly from PowerShell with a PyPI API token. The script prompts privately for it (or reads `PYPI_TOKEN` from the current process), never commits or prints it:
|
|
150
|
+
|
|
151
|
+
```powershell
|
|
152
|
+
.\scripts\publish-pypi.ps1 -Publish
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Use a project-scoped token for `cuaboss` after the project exists. For the very first upload, an account-scoped token is required; create it in [PyPI API token settings](https://pypi.org/manage/account/token/). Do not paste the token into chat, source code, or a `.env` file.
|
|
156
|
+
|
|
157
|
+
The publishing scripts require the authenticated [GitHub CLI](https://cli.github.com/). Every new release must use a version that has never previously been uploaded to that package index; keep `pyproject.toml` and `cuaboss/__init__.py` in sync.
|
|
158
|
+
|
|
159
|
+
MIT
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
cuaboss/__init__.py,sha256=QTYqXqSTHFRkM9TEgpDFcHvwLbvqHDqvqfQ9EiXkcAM,23
|
|
2
|
+
cuaboss/cli.py,sha256=LC5z_UjxmOm4Dbqt0UnDz4jM61PZTIHESLqx8NwHGHA,5345
|
|
3
|
+
cuaboss/desktop.py,sha256=Ueji5FQUIpula5LiEdP6IgtIxN_jNWoqWUe_9Twt1uc,2792
|
|
4
|
+
cuaboss/server.py,sha256=0iSXQQpAn5arfXyE_DGswgtJY6StRPlfyOF88ofRAYc,6730
|
|
5
|
+
cuaboss/tools.py,sha256=E0n8qxzK9V1jVlMQNXEZjXfzsd-Oz4NUmoNu5a1nV7I,2558
|
|
6
|
+
cuaboss/tunnel.py,sha256=Kh1dcN699qzLyz_zuRxA2TgwkdJeLxVMzCQ_NT1ivB0,1764
|
|
7
|
+
cuaboss-0.1.0.dist-info/licenses/LICENSE,sha256=pJ9mn-O9czeNE26gyqxvmjajWxIe_xtFyKadbdVPtZ4,1092
|
|
8
|
+
cuaboss-0.1.0.dist-info/METADATA,sha256=_nEcJsRuC-YSe414Rx6h7HnISHEupdr4GkDHBtvuTV8,6378
|
|
9
|
+
cuaboss-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
10
|
+
cuaboss-0.1.0.dist-info/entry_points.txt,sha256=UN6mfCoQU_kIDzLBm4EBW4ytAkhqlR8eTO8HNaADZWQ,45
|
|
11
|
+
cuaboss-0.1.0.dist-info/top_level.txt,sha256=V7qAwgRfNx96BQvlhdt_Y9a35FLVpme6hjDihFwJPj8,8
|
|
12
|
+
cuaboss-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rajarshi Datta
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
cuaboss
|