seeu-computeruse 1.9.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.
- seeu/VERSION +1 -0
- seeu/__init__.py +73 -0
- seeu/__main__.py +415 -0
- seeu/act.py +4116 -0
- seeu/ax.py +760 -0
- seeu/bgclick.py +1108 -0
- seeu/bgkey.py +358 -0
- seeu/cdp.py +999 -0
- seeu/deps.py +393 -0
- seeu/doctor.py +409 -0
- seeu/entry.py +21 -0
- seeu/evidence.py +199 -0
- seeu/hints.py +50 -0
- seeu/i18n.py +272 -0
- seeu/install.py +787 -0
- seeu/isee.py +675 -0
- seeu/launcher/AppIcon.icns +0 -0
- seeu/launcher/AppIcon.svg +23 -0
- seeu/launcher/build.sh +27 -0
- seeu/launcher/seeu_launcher.c +34 -0
- seeu/linux/__init__.py +72 -0
- seeu/linux/act.py +1330 -0
- seeu/linux/atspi.py +417 -0
- seeu/linux/distro.py +68 -0
- seeu/linux/doctor.py +170 -0
- seeu/linux/ext/seeu@seeu-computeruse/cursor.js +402 -0
- seeu/linux/ext/seeu@seeu-computeruse/extension.js +295 -0
- seeu/linux/ext/seeu@seeu-computeruse/float.js +489 -0
- seeu/linux/ext/seeu@seeu-computeruse/metadata.json +16 -0
- seeu/linux/floatwin.py +931 -0
- seeu/linux/install.py +245 -0
- seeu/linux/lang.py +178 -0
- seeu/linux/mcp_server.py +1108 -0
- seeu/linux/ocr.py +46 -0
- seeu/linux/openapp.py +193 -0
- seeu/linux/probe.py +202 -0
- seeu/linux/real.py +840 -0
- seeu/linux/safety.py +386 -0
- seeu/linux/shell.py +483 -0
- seeu/linux/shot.py +224 -0
- seeu/linux/skill/SKILL.md +66 -0
- seeu/linux/web.py +465 -0
- seeu/linux/window.py +209 -0
- seeu/mcp_server.py +1016 -0
- seeu/newline.py +36 -0
- seeu/openapp.py +296 -0
- seeu/probe.py +226 -0
- seeu/reason_en.py +569 -0
- seeu/safety.py +561 -0
- seeu/sched.py +1240 -0
- seeu/skill/SKILL.md +94 -0
- seeu/stealth.py +692 -0
- seeu/upcheck.py +236 -0
- seeu/update.py +404 -0
- seeu/version.py +38 -0
- seeu/web/__init__.py +1099 -0
- seeu/web/aejs.py +666 -0
- seeu/web/extension/background.js +480 -0
- seeu/web/extension/icon128.png +0 -0
- seeu/web/extension/icon16.png +0 -0
- seeu/web/extension/icon32.png +0 -0
- seeu/web/extension/icon48.png +0 -0
- seeu/web/extension/manifest.json +36 -0
- seeu/web/extension/popup.html +38 -0
- seeu/web/extension/popup.js +100 -0
- seeu/web/extension/privacy.html +45 -0
- seeu/web/host.py +236 -0
- seeu/web/host.sh +2 -0
- seeu/web/install.py +126 -0
- seeu/where.py +81 -0
- seeu/win/__init__.py +6 -0
- seeu/win/act.py +1837 -0
- seeu/win/api.py +110 -0
- seeu/win/cursor.py +940 -0
- seeu/win/doctor.py +141 -0
- seeu/win/evidence.py +247 -0
- seeu/win/floatwin.py +2309 -0
- seeu/win/inputs.py +411 -0
- seeu/win/install.py +1314 -0
- seeu/win/lang.py +34 -0
- seeu/win/mcp_server.py +1108 -0
- seeu/win/ocr.ps1 +49 -0
- seeu/win/ocr.py +98 -0
- seeu/win/openapp.py +344 -0
- seeu/win/probe.py +179 -0
- seeu/win/real.py +405 -0
- seeu/win/safety.py +507 -0
- seeu/win/skill/SKILL.md +54 -0
- seeu/win/uia.py +495 -0
- seeu/win/web.py +519 -0
- seeu/win/window.py +537 -0
- seeu//350/256/276/347/275/256.json +11 -0
- seeu_computeruse-1.9.0.dist-info/METADATA +347 -0
- seeu_computeruse-1.9.0.dist-info/RECORD +110 -0
- seeu_computeruse-1.9.0.dist-info/WHEEL +5 -0
- seeu_computeruse-1.9.0.dist-info/entry_points.txt +3 -0
- seeu_computeruse-1.9.0.dist-info/licenses/LICENSE +21 -0
- seeu_computeruse-1.9.0.dist-info/top_level.txt +2 -0
- seeu_lib/__init__.py +8 -0
- seeu_lib/appname.py +182 -0
- seeu_lib/cursor_overlay.py +1023 -0
- seeu_lib/desktop_lock.py +193 -0
- seeu_lib/input_guard.py +730 -0
- seeu_lib/mac_input.py +280 -0
- seeu_lib/match.py +77 -0
- seeu_lib/ocr.py +134 -0
- seeu_lib/sck_capture.py +399 -0
- seeu_lib/wait.py +216 -0
- seeu_lib/watch_island.py +881 -0
- seeu_lib/watch_window.py +3410 -0
seeu/VERSION
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
1.9.0
|
seeu/__init__.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""SeeU —— 我们自己的 Computer Use(名字取「CU」的谐音,别处一律只叫 SeeU)。说明见同目录 README.md。"""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
# 只支持 macOS。别的系统一进来就说清楚,别等到缺 pyobjc 报一大段英文。
|
|
7
|
+
# 还没加载设置、认不了语言,中英文一起写。python3 -m seeu 直接退出;被别的程序 import 就抛 ImportError 带这段话。
|
|
8
|
+
MAC_ONLY = ("SeeU 目前支持 macOS、Windows 和 Linux(GNOME 桌面),当前设备({os})暂时用不了,欢迎关注后续版本!\n"
|
|
9
|
+
"SeeU currently supports macOS, Windows and Linux (GNOME desktop); it can't run on this device ({os}) yet. Stay tuned!")
|
|
10
|
+
# Windows 预览版,实现在 seeu/win/(Mac 版代码不动)。包里没有 win/ 时(以前的开源导出)Windows 上照旧给「只支持 macOS」的话
|
|
11
|
+
WINDOWS = sys.platform == "win32" and os.path.isdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), "win"))
|
|
12
|
+
# Linux 预览版(第 1 段,只支持 GNOME + Wayland),实现在 seeu/linux/。包里没有 linux/ 时照旧给「只支持 macOS」的话
|
|
13
|
+
LINUX = sys.platform.startswith("linux") and os.path.isdir(os.path.join(os.path.dirname(os.path.abspath(__file__)), "linux"))
|
|
14
|
+
if sys.platform != "darwin" and not WINDOWS and not LINUX:
|
|
15
|
+
import platform as _pf
|
|
16
|
+
_msg = MAC_ONLY.format(os=_pf.system() or sys.platform)
|
|
17
|
+
# PyPI 装的命令入口(seeu / seeu-computeruse)启动时也直接说清楚,不抛一大段 ImportError
|
|
18
|
+
if sys.argv[:1] == ["-m"] or os.path.basename(sys.argv[0] if sys.argv else "").lower().startswith("seeu"):
|
|
19
|
+
print(_msg, file=sys.stderr)
|
|
20
|
+
sys.exit(1)
|
|
21
|
+
raise ImportError(_msg)
|
|
22
|
+
|
|
23
|
+
# "每次点击小火箭都跳一次":bgclick.focus_without_raise(SLPSPostEventRecordTo)会把调用它的
|
|
24
|
+
# Python 登记成前台应用,Dock 冒图标。凡是 import seeu 的进程先标成后台程序(lsappinfo 出生即 BackgroundOnly,
|
|
25
|
+
# 聚焦照常成功)。要在任何 AppKit/SkyLight 调用之前设,所以放包入口。
|
|
26
|
+
try:
|
|
27
|
+
from Foundation import NSBundle
|
|
28
|
+
NSBundle.mainBundle().infoDictionary()["LSBackgroundOnly"] = "1"
|
|
29
|
+
except Exception:
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# 动作统一挂在包上(import seeu; seeu.tap(...)),实现在 seeu/act.py。
|
|
34
|
+
# 用到才加载:bgclick 等子模块 import seeu 时不连带拉起 act(act 反过来要 import 它们,提前拉会循环导入)。
|
|
35
|
+
ACTIONS = ("see", "tap", "type", "scroll", "press", "menu", "drag", "long_press", "describe",
|
|
36
|
+
"mirror_home", "mirror_open_app", "mirror_baseline")
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
SUBMODULES = ("web", "stealth", "cdp", "isee", "safety", "act") # Skill 里写 seeu.web.type(...),用到再加载
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
WIN_ACTIONS = ("see", "tap", "type", "scroll", "press", "describe")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
LINUX_ACTIONS = ("see", "tap", "type", "scroll", "press", "describe")
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def __getattr__(name):
|
|
49
|
+
if LINUX:
|
|
50
|
+
if name in LINUX_ACTIONS:
|
|
51
|
+
from seeu.linux import act as _lact
|
|
52
|
+
return getattr(_lact, name)
|
|
53
|
+
mods = {"linux": "seeu.linux", "act": "seeu.linux.act", "safety": "seeu.linux.safety"}
|
|
54
|
+
if name in mods:
|
|
55
|
+
import importlib
|
|
56
|
+
return importlib.import_module(mods[name])
|
|
57
|
+
raise AttributeError(f"module 'seeu' has no attribute {name!r}(Linux 预览版还没有这一项)")
|
|
58
|
+
if WINDOWS:
|
|
59
|
+
if name in WIN_ACTIONS:
|
|
60
|
+
from seeu.win import act as _wact
|
|
61
|
+
return getattr(_wact, name)
|
|
62
|
+
mods = {"win": "seeu.win", "act": "seeu.win.act", "safety": "seeu.win.safety"}
|
|
63
|
+
if name in mods:
|
|
64
|
+
import importlib
|
|
65
|
+
return importlib.import_module(mods[name])
|
|
66
|
+
raise AttributeError(f"module 'seeu' has no attribute {name!r}(Windows 预览版还没有这一项)")
|
|
67
|
+
if name in ACTIONS:
|
|
68
|
+
from seeu import act
|
|
69
|
+
return getattr(act, name)
|
|
70
|
+
if name in SUBMODULES:
|
|
71
|
+
import importlib
|
|
72
|
+
return importlib.import_module(f"seeu.{name}")
|
|
73
|
+
raise AttributeError(f"module 'seeu' has no attribute {name!r}")
|
seeu/__main__.py
ADDED
|
@@ -0,0 +1,415 @@
|
|
|
1
|
+
"""动作:python3 -m seeu see|tap|type|scroll|press|menu|base|home|open <App> ...
|
|
2
|
+
例:python3 -m seeu see TextEdit · python3 -m seeu tap TextEdit 加粗 · python3 -m seeu type TextEdit "你好" --enter
|
|
3
|
+
管理:python3 -m seeu isee on|off|status|report · python3 -m seeu allow|disallow 网址 · python3 -m seeu allowed
|
|
4
|
+
python3 -m seeu 取证 [--shot] 出事时(被抢键盘、打字跑错地方)一键记下现场
|
|
5
|
+
python3 -m seeu 检查 [--open] 看本机缺哪些授权/开关,缺的逐项写怎么开
|
|
6
|
+
python3 -m seeu mcp 以 MCP 服务方式运行(给 Codex 等 AI 客户端接,见 mcp_server.py)
|
|
7
|
+
python3 -m seeu 接入 [claude|codex|cursor|trae|vscode|kilo|千问|raycast|自动] [--本项目] 一键接入 MCP + Skill;python3 -m seeu 移除 <同上>
|
|
8
|
+
python3 -m seeu 更新 [--check] 更新到 GitHub 上的新版(git clone 装的才行)
|
|
9
|
+
python3 -m seeu 探一下 <App> 看这个 App 能不能用 SeeU 自动化、会走哪条路(只读)
|
|
10
|
+
python3 -m seeu 设置 [借用鼠标 开|问我|关 | 自动检查更新 开|关] 看 / 改设置
|
|
11
|
+
python3 -m seeu 版本 看装的是哪一版(英文 --version)"""
|
|
12
|
+
import sys
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def _ai_gate(args, what):
|
|
16
|
+
"""加名单、改借用鼠标这两条命令,AI 客户端自己就能跑(只有 isee on 拦了),等于绕开 MCP 那边的「先问用户」。
|
|
17
|
+
现在跟 MCP 一样:AI 在跑就要带 --user-said "本人原话",并弹提示条留痕。人自己在终端敲的不受影响。
|
|
18
|
+
what:拿去掉 --user-said 之后的参数拼出「要做的事」的函数。返回 (去掉 --user-said 的参数, 能不能继续)。"""
|
|
19
|
+
args = list(args)
|
|
20
|
+
said = ""
|
|
21
|
+
if "--user-said" in args:
|
|
22
|
+
i = args.index("--user-said")
|
|
23
|
+
said = (args[i + 1] if i + 1 < len(args) else "").strip()
|
|
24
|
+
del args[i:i + 2]
|
|
25
|
+
from seeu import isee
|
|
26
|
+
if not isee.from_ai():
|
|
27
|
+
return args, True
|
|
28
|
+
try:
|
|
29
|
+
from seeu.i18n import lang
|
|
30
|
+
en = lang() == "en"
|
|
31
|
+
except Exception:
|
|
32
|
+
en = False
|
|
33
|
+
what = what(args)
|
|
34
|
+
if not said:
|
|
35
|
+
if en:
|
|
36
|
+
print(f"Not done: this command is being run by an AI client. \"{what}\" needs the user's OK first: ask in the chat, "
|
|
37
|
+
"then re-run with --user-said \"their reply\" (use the seeu_allow_site / seeu_manage tools if you have them).")
|
|
38
|
+
else:
|
|
39
|
+
print(f"没做:这条命令是 AI 客户端在跑。「{what}」要先在对话里问用户,答应了再带上 --user-said \"用户的原话\" 重跑"
|
|
40
|
+
"(有 seeu_allow_site / seeu_manage 工具的直接用工具)。")
|
|
41
|
+
return args, False
|
|
42
|
+
try:
|
|
43
|
+
from seeu_lib import cursor_overlay as co
|
|
44
|
+
co.toast("SeeU", (f"The AI did this for you: {what}" if en else f"AI 帮你做了:{what}"), 8)
|
|
45
|
+
except Exception:
|
|
46
|
+
pass
|
|
47
|
+
return args, True
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def _win_stdio():
|
|
51
|
+
"""输出被接走(AI 客户端、管道、重定向)时 Windows 按系统代码页编码,✅ ⛔ 和中文在英文系统(cp1252)上
|
|
52
|
+
一打印就崩。接走时统一用 UTF-8;在真终端里只保证打不出的字不崩。"""
|
|
53
|
+
for s in (sys.stdout, sys.stderr):
|
|
54
|
+
try:
|
|
55
|
+
if s.isatty():
|
|
56
|
+
s.reconfigure(errors="replace")
|
|
57
|
+
else:
|
|
58
|
+
s.reconfigure(encoding="utf-8", errors="replace")
|
|
59
|
+
except Exception:
|
|
60
|
+
pass
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def _win_by_person():
|
|
64
|
+
"""这条命令是不是人自己在终端里敲的。没有终端 = 程序 / AI 调的;有终端但带着 AI 客户端的环境变量
|
|
65
|
+
(在客户端自带的终端里跑)也算 AI 调的。"""
|
|
66
|
+
import os
|
|
67
|
+
if os.environ.get("CLAUDECODE") or os.environ.get("CODEX_SANDBOX") or os.environ.get("CURSOR_TRACE_ID"):
|
|
68
|
+
return False
|
|
69
|
+
# 🔴 不能用 sys.stdin.isatty():输入接到空设备(< NUL)时它也说是终端。
|
|
70
|
+
# 问系统「这是不是真的控制台」,而且输入、输出都得是(输出被接走的多半是程序在跑)。
|
|
71
|
+
try:
|
|
72
|
+
import ctypes
|
|
73
|
+
import msvcrt
|
|
74
|
+
k = ctypes.windll.kernel32
|
|
75
|
+
k.GetConsoleMode.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint32)]
|
|
76
|
+
|
|
77
|
+
def con(fd):
|
|
78
|
+
m = ctypes.c_uint32()
|
|
79
|
+
return bool(k.GetConsoleMode(msvcrt.get_osfhandle(fd), ctypes.byref(m)))
|
|
80
|
+
return con(0) and con(1)
|
|
81
|
+
except Exception:
|
|
82
|
+
return False
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _win_isee_ai():
|
|
86
|
+
"""isee on 专用、比 _win_by_person 再严一层:编辑器 / AI 客户端的内置终端在 Windows 上是伪控制台,
|
|
87
|
+
_win_by_person 会当成人。这里再看①编辑器、AI 命令行留下的环境变量 ②父进程链里有没有 AI 客户端 / 编辑器。
|
|
88
|
+
查不了进程表就当是 AI(宁可拦错,用户可以点浮标上的 I See 按钮)。"""
|
|
89
|
+
import os
|
|
90
|
+
env = os.environ
|
|
91
|
+
if env.get("TERM_PROGRAM", "").lower() == "vscode" or any(
|
|
92
|
+
env.get(k) for k in ("VSCODE_PID", "VSCODE_IPC_HOOK_CLI", "VSCODE_INJECTION", "GEMINI_CLI")):
|
|
93
|
+
return True
|
|
94
|
+
try:
|
|
95
|
+
from seeu import isee
|
|
96
|
+
from seeu.win import safety
|
|
97
|
+
names = tuple(isee.AI_PROCS) + ("code.exe", "code - insiders.exe", "qianwen", "chatgpt", "windsurf")
|
|
98
|
+
table = safety._process_table()
|
|
99
|
+
cur, seen = os.getpid(), set()
|
|
100
|
+
while cur and cur not in seen and cur in table:
|
|
101
|
+
seen.add(cur)
|
|
102
|
+
parent, name = table[cur]
|
|
103
|
+
n = name.lower()
|
|
104
|
+
if n in safety._STOP:
|
|
105
|
+
break
|
|
106
|
+
if any(k in n for k in names):
|
|
107
|
+
return True
|
|
108
|
+
cur = parent
|
|
109
|
+
return False
|
|
110
|
+
except Exception: # noqa: BLE001
|
|
111
|
+
return True
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _win_key_confirm(lg, secs=60):
|
|
115
|
+
"""isee on 的现场确认:随机一个字母,要人在这个控制台的键盘上按。读的是控制台键盘(msvcrt),不是 stdin,
|
|
116
|
+
AI 在新开的窗口里跑这条命令也答不上来。最多等 secs 秒,超时算取消(别让藏着的窗口一直挂着)。"""
|
|
117
|
+
import msvcrt
|
|
118
|
+
import random
|
|
119
|
+
import time
|
|
120
|
+
ch = random.choice("ABCDEFGHJKLMNPQRSTUVWXYZ")
|
|
121
|
+
while msvcrt.kbhit(): # 先清掉之前积在键盘缓冲里的键
|
|
122
|
+
msvcrt.getwch()
|
|
123
|
+
print(lg.L(f"要打开 I See(我知风险),请在键盘上按字母 {ch} 确认,按别的键取消({secs} 秒内):",
|
|
124
|
+
f"To turn on I See (I know the risks), press the letter {ch} to confirm, any other key cancels (within {secs} s):"),
|
|
125
|
+
end=" ", flush=True)
|
|
126
|
+
t0 = time.time()
|
|
127
|
+
while time.time() - t0 < secs:
|
|
128
|
+
if msvcrt.kbhit():
|
|
129
|
+
k = msvcrt.getwch()
|
|
130
|
+
print(k)
|
|
131
|
+
return k.upper() == ch
|
|
132
|
+
time.sleep(0.05)
|
|
133
|
+
print()
|
|
134
|
+
return False
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def _win_gate_log(what, said):
|
|
138
|
+
"""带着 --user-said 放行的,记一行(跟 MCP 那边记在同一个文件),事后查得到。记不上不影响命令。"""
|
|
139
|
+
try:
|
|
140
|
+
import os
|
|
141
|
+
import time
|
|
142
|
+
from seeu_lib import home
|
|
143
|
+
p = home("seeu_mcp.log")
|
|
144
|
+
os.makedirs(os.path.dirname(p), exist_ok=True)
|
|
145
|
+
with open(p, "a", encoding="utf-8") as f:
|
|
146
|
+
f.write(f"{time.strftime('%Y-%m-%d %H:%M:%S')} cli {what} user_said={said[:200]!r}\n")
|
|
147
|
+
except Exception:
|
|
148
|
+
pass
|
|
149
|
+
try: # 屏幕上留痕(同 Mac 的 _ai_gate):AI 代你做了什么
|
|
150
|
+
from seeu.win import cursor, lang
|
|
151
|
+
cursor.toast("SeeU", lang.L(f"AI 帮你做了:{what}", f"The AI did this for you: {what}"), 8)
|
|
152
|
+
except Exception:
|
|
153
|
+
pass
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
if __name__ == "__main__":
|
|
157
|
+
args = sys.argv[1:]
|
|
158
|
+
# Linux 预览版要系统自带的 python3(GNOME 的 gi 库在系统里),PyPI / uvx 的独立环境看不到 → 说清楚,别让每个工具都报缺 gi
|
|
159
|
+
if sys.platform.startswith("linux"):
|
|
160
|
+
try:
|
|
161
|
+
from seeu.where import as_pip as _lpip
|
|
162
|
+
_linux_pip = _lpip()
|
|
163
|
+
except Exception: # noqa: BLE001
|
|
164
|
+
_linux_pip = False
|
|
165
|
+
if _linux_pip:
|
|
166
|
+
print("SeeU 的 Linux 预览版要用系统自带的 python3,不能从 PyPI / uvx 装:请照 README 用 git clone 安装。\n"
|
|
167
|
+
"SeeU's Linux preview needs the system python3 and can't run from PyPI / uvx: install it with git clone (see README).",
|
|
168
|
+
file=sys.stderr)
|
|
169
|
+
sys.exit(1)
|
|
170
|
+
cmd = args[0] if args else ""
|
|
171
|
+
# 插件版已经由 Claude Code / Codex 接好了,再「接入」会多出一份同样的工具 → 说清楚、不做(「看接了没有」照常)
|
|
172
|
+
if cmd in ("接入", "install") and len(args) > 1:
|
|
173
|
+
try:
|
|
174
|
+
from seeu.where import as_plugin as _asp, as_pip as _aspip
|
|
175
|
+
_plugin, _pip = _asp(), _aspip()
|
|
176
|
+
except Exception: # noqa: BLE001
|
|
177
|
+
_plugin = _pip = False
|
|
178
|
+
if _pip: # PyPI 装的没有固定的代码位置,接法统一是 uvx seeu-computeruse
|
|
179
|
+
from seeu.i18n import T as _T
|
|
180
|
+
print(_T("inst.pip"))
|
|
181
|
+
sys.exit(1)
|
|
182
|
+
if _plugin:
|
|
183
|
+
from seeu.i18n import T as _T
|
|
184
|
+
print(_T("inst.plugin"))
|
|
185
|
+
sys.exit(1)
|
|
186
|
+
if sys.platform.startswith("linux"): # Linux 预览版(第 1 段),命令都在 seeu/linux/
|
|
187
|
+
import seeu as _seeu # 包里没有 linux/ 时,这一行会给「只支持 macOS」的话
|
|
188
|
+
if cmd == "mcp": # 第 2 段
|
|
189
|
+
from seeu.linux import mcp_server as _lmcp
|
|
190
|
+
_lmcp.main()
|
|
191
|
+
sys.exit(0)
|
|
192
|
+
if cmd in ("设置", "settings", "set"):
|
|
193
|
+
args, ok = _ai_gate(args, lambda a: "改设置:" + " ".join(a[1:])) if len(args) > 1 else (args, True)
|
|
194
|
+
if not ok:
|
|
195
|
+
sys.exit(3)
|
|
196
|
+
from seeu.linux import real as _lreal
|
|
197
|
+
sys.exit(_lreal.settings_cmd(args[1:]))
|
|
198
|
+
if cmd in ("接入", "install", "移除", "uninstall", "remove"):
|
|
199
|
+
from seeu.linux import install as _linst
|
|
200
|
+
sys.exit(_linst.main(cmd, args[1:]))
|
|
201
|
+
if cmd in ("allow", "disallow", "allowed"):
|
|
202
|
+
from seeu.web import aejs as _aejs
|
|
203
|
+
if cmd == "allowed":
|
|
204
|
+
print("\n".join(_aejs.allowed_list()) or "(允许名单是空的)")
|
|
205
|
+
sys.exit(0)
|
|
206
|
+
args, ok = _ai_gate(args, lambda a: ("把 " if cmd == "allow" else "从允许名单拿掉 ") + " ".join(a[1:])
|
|
207
|
+
+ (" 加进允许名单" if cmd == "allow" else ""))
|
|
208
|
+
if not ok:
|
|
209
|
+
sys.exit(3)
|
|
210
|
+
for u in args[1:]:
|
|
211
|
+
_aejs.allow(u, on=(cmd == "allow"))
|
|
212
|
+
print(("已加进允许名单:" if cmd == "allow" else "已从允许名单拿掉:") + u)
|
|
213
|
+
sys.exit(0)
|
|
214
|
+
if cmd in ("更新", "update"):
|
|
215
|
+
from seeu import update as _upd
|
|
216
|
+
sys.exit(_upd.main(args[1:]))
|
|
217
|
+
if cmd in ("检查", "check", "doctor"):
|
|
218
|
+
from seeu.linux import doctor as _ldoc
|
|
219
|
+
sys.exit(_ldoc.main(args[1:]))
|
|
220
|
+
if cmd in ("版本", "version", "--version", "-v"):
|
|
221
|
+
from seeu import version
|
|
222
|
+
print("SeeU v" + version.current() + " (Linux preview)")
|
|
223
|
+
sys.exit(0)
|
|
224
|
+
from seeu.linux import act as _lact
|
|
225
|
+
sys.exit(_lact.main(args))
|
|
226
|
+
if sys.platform == "win32": # Windows 预览版,命令都在 seeu/win/
|
|
227
|
+
if cmd == "mcp":
|
|
228
|
+
from seeu.win import mcp_server as _wmcp
|
|
229
|
+
_wmcp.main()
|
|
230
|
+
sys.exit(0)
|
|
231
|
+
_win_stdio()
|
|
232
|
+
if cmd in ("接入", "install", "移除", "uninstall", "remove"):
|
|
233
|
+
from seeu.win import install as _winst
|
|
234
|
+
sys.exit(_winst.main(cmd, args[1:]))
|
|
235
|
+
if cmd in ("版本", "version", "--version", "-v"):
|
|
236
|
+
from seeu import version
|
|
237
|
+
print("SeeU v" + version.current() + " (Windows preview)")
|
|
238
|
+
sys.exit(0)
|
|
239
|
+
if cmd in ("allow", "disallow", "allowed"):
|
|
240
|
+
from seeu.web import aejs
|
|
241
|
+
from seeu.win import lang as _lg
|
|
242
|
+
if cmd == "allowed":
|
|
243
|
+
print(_lg.L("允许名单:", "Allow list:"), aejs.allowed_list())
|
|
244
|
+
sys.exit(0)
|
|
245
|
+
rest = list(args[1:])
|
|
246
|
+
said = ""
|
|
247
|
+
if "--user-said" in rest:
|
|
248
|
+
i = rest.index("--user-said")
|
|
249
|
+
said = (rest[i + 1] if i + 1 < len(rest) else "").strip()
|
|
250
|
+
del rest[i:i + 2]
|
|
251
|
+
# 人在终端里敲的(有终端)直接做;程序 / AI 调的(没有终端)要带本人原话(跟 Mac 版 _ai_gate 一个意思)
|
|
252
|
+
# 编辑器 / AI 客户端的内置终端是伪控制台,_win_by_person 会当成人 → 跟 isee on 一样再查父进程链
|
|
253
|
+
if cmd == "allow" and not said and (not _win_by_person() or _win_isee_ai()):
|
|
254
|
+
print(_lg.L("没做:这条命令不是人在终端里敲的。要先问用户,答应了带上 --user-said \"用户的原话\" 重跑"
|
|
255
|
+
"(有 seeu_allow_site 工具就用工具)。就是你本人的话:在 cmd / PowerShell 窗口里直接运行,别把输出接走。",
|
|
256
|
+
"Not done: this command wasn't typed by a person in a terminal. Ask the user first, then re-run with "
|
|
257
|
+
"--user-said \"their reply\" (use the seeu_allow_site tool if you have it). If this is you: run it directly "
|
|
258
|
+
"in a cmd / PowerShell window, without redirecting the output."), file=sys.stderr)
|
|
259
|
+
sys.exit(3)
|
|
260
|
+
if not rest:
|
|
261
|
+
print(_lg.L("用法:python -m seeu allow|disallow 网址", "Usage: python -m seeu allow|disallow <site>"))
|
|
262
|
+
sys.exit(2)
|
|
263
|
+
if cmd == "allow" and said:
|
|
264
|
+
_win_gate_log("allow " + rest[0], said)
|
|
265
|
+
print(_lg.L("允许名单:", "Allow list:"), aejs.allow(rest[0], on=cmd == "allow"))
|
|
266
|
+
sys.exit(0)
|
|
267
|
+
if cmd == "isee": # 照 Mac 版 isee on|off|status|report
|
|
268
|
+
from seeu import isee
|
|
269
|
+
from seeu.win import lang as _lg
|
|
270
|
+
sub = args[1] if len(args) > 1 else "status"
|
|
271
|
+
if sub == "on":
|
|
272
|
+
# 🔴 只让人自己开:Mac 的 isee.from_ai 靠 ps 查父进程,Windows 上没有 ps 会一律当「不是 AI」放行,
|
|
273
|
+
# 所以这里用 _win_by_person(真控制台 + 没有 AI 客户端的环境变量)+ _win_isee_ai(编辑器终端、父进程链)
|
|
274
|
+
# + 现场按键确认(防 AI 新开一个控制台窗口来跑)。不收 --user-said(AI 永远不能替人开)。
|
|
275
|
+
if not _win_by_person() or _win_isee_ai():
|
|
276
|
+
print(_lg.L("I See 只能你自己开:点 SeeU 悬浮窗上的「I See」按钮(网页任务时才有),"
|
|
277
|
+
"或者在系统的 cmd / PowerShell 窗口里直接运行这条命令(编辑器、AI 客户端自带的终端不算,别把输出接走)。AI 不能替你开。",
|
|
278
|
+
"Only you can turn on I See: click the I See button on the SeeU floating window (it shows during web tasks), "
|
|
279
|
+
"or run this command directly in a Windows cmd / PowerShell window (not a terminal inside an editor or AI app, "
|
|
280
|
+
"and without redirecting the output). The AI can't turn it on for you."), file=sys.stderr)
|
|
281
|
+
sys.exit(3)
|
|
282
|
+
try:
|
|
283
|
+
hours = float(args[2]) if len(args) > 2 else isee.DEFAULT_HOURS
|
|
284
|
+
if not (hours == 0 or 1 / 60 <= hours <= 24 * 365):
|
|
285
|
+
raise ValueError
|
|
286
|
+
except ValueError:
|
|
287
|
+
print(_lg.L("用法:python -m seeu isee on [小时](0 = 不自动关;最短 1 分钟,最长一年)",
|
|
288
|
+
"Usage: python -m seeu isee on [hours] (0 = never turns off by itself; 1 minute to 1 year)"), file=sys.stderr)
|
|
289
|
+
sys.exit(2)
|
|
290
|
+
try:
|
|
291
|
+
isee.on(hours, by="console") # 三道门(含现场按键)在 isee.on 里自己再查,不信这里
|
|
292
|
+
st = isee.status()
|
|
293
|
+
except PermissionError:
|
|
294
|
+
print(_lg.L("没开:没有按对确认键(或不是在 cmd / PowerShell 窗口里直接运行)。",
|
|
295
|
+
"Not turned on: the confirmation key wasn't pressed (or this isn't a cmd / PowerShell window)."), file=sys.stderr)
|
|
296
|
+
sys.exit(3)
|
|
297
|
+
except Exception as ex: # noqa: BLE001 设置文件坏了 / 写不进
|
|
298
|
+
print(_lg.L(f"没开成:{ex}", f"Couldn't turn it on: {ex}"), file=sys.stderr)
|
|
299
|
+
sys.exit(1)
|
|
300
|
+
if not st.get("on"):
|
|
301
|
+
print(_lg.L("没开成:写进去了但读回来是关着(看一下设置文件)。", "Didn't take: it reads back as off (check the settings file)."),
|
|
302
|
+
file=sys.stderr)
|
|
303
|
+
sys.exit(1)
|
|
304
|
+
print(_lg.L("I See 开了", "I See is on") + (_lg.L(f",到 {st['until']} 自动关", f", turns off at {st['until']}")
|
|
305
|
+
if st.get("until") else _lg.L("(不自动关)", " (won't turn off by itself)")))
|
|
306
|
+
elif sub == "off":
|
|
307
|
+
try:
|
|
308
|
+
isee.off()
|
|
309
|
+
except Exception as ex: # noqa: BLE001
|
|
310
|
+
print(_lg.L(f"没关成:{ex}", f"Couldn't turn it off: {ex}"), file=sys.stderr)
|
|
311
|
+
sys.exit(1)
|
|
312
|
+
st = isee.status()
|
|
313
|
+
print(_lg.L("I See 关了", "I See is off"))
|
|
314
|
+
elif sub == "report":
|
|
315
|
+
print(isee.report())
|
|
316
|
+
elif sub == "status":
|
|
317
|
+
st = isee.status()
|
|
318
|
+
src = _lg.L("环境变量 SEEU_ISEE", "the SEEU_ISEE environment variable") if st.get("source") == "环境变量" else _lg.L("设置文件", "settings file")
|
|
319
|
+
print(_lg.L("开着" if st["on"] else "关着", "on" if st["on"] else "off")
|
|
320
|
+
+ (_lg.L(f",到 {st['until']}", f", until {st['until']}") if st.get("on") and st.get("until") else "")
|
|
321
|
+
+ _lg.L(f"(来源:{src})", f" (from {src})")
|
|
322
|
+
+ (_lg.L(";设置里写着开,但不是你用按钮 / 命令开的(或是升级前开的),按关算;要用请重新开一次",
|
|
323
|
+
"; the settings file says on, but it wasn't turned on with the button / command (or was turned on before "
|
|
324
|
+
"an update), so it counts as off; turn it on again if you need it") if st.get("forged") else ""))
|
|
325
|
+
else:
|
|
326
|
+
print(_lg.L("用法:python -m seeu isee on [小时] | off | status | report",
|
|
327
|
+
"Usage: python -m seeu isee on [hours] | off | status | report"), file=sys.stderr)
|
|
328
|
+
sys.exit(2)
|
|
329
|
+
sys.exit(0)
|
|
330
|
+
if cmd in ("探一下", "probe"):
|
|
331
|
+
from seeu.win import probe as _wprobe
|
|
332
|
+
sys.exit(_wprobe.main(args[1:]))
|
|
333
|
+
# 检查 / 设置 / 更新 / 取证(照 Mac 版)
|
|
334
|
+
if cmd in ("检查", "check", "doctor"):
|
|
335
|
+
from seeu.win import doctor as _wdoc
|
|
336
|
+
sys.exit(_wdoc.main(args[1:]))
|
|
337
|
+
if cmd in ("设置", "set", "settings"):
|
|
338
|
+
rest = list(args[1:])
|
|
339
|
+
said = ""
|
|
340
|
+
if "--user-said" in rest:
|
|
341
|
+
i = rest.index("--user-said")
|
|
342
|
+
said = (rest[i + 1] if i + 1 < len(rest) else "").strip()
|
|
343
|
+
del rest[i:i + 2]
|
|
344
|
+
# 改设置跟加名单一个规矩:人在终端里敲的直接做;程序 / AI 调的要带本人原话。只看不改不用
|
|
345
|
+
if rest and not said and (not _win_by_person() or _win_isee_ai()): # 同 allow
|
|
346
|
+
from seeu.win import lang as _lg
|
|
347
|
+
print(_lg.L("没做:这条命令不是人在终端里敲的。改设置要先问用户,答应了带上 --user-said \"用户的原话\" 重跑。"
|
|
348
|
+
"就是你本人的话:在 cmd / PowerShell 窗口里直接运行,别把输出接走。",
|
|
349
|
+
"Not done: this command wasn't typed by a person in a terminal. Changing a setting needs the user's OK first: "
|
|
350
|
+
"ask them, then re-run with --user-said \"their reply\". If this is you: run it directly in a cmd / PowerShell window, "
|
|
351
|
+
"without redirecting the output."), file=sys.stderr)
|
|
352
|
+
sys.exit(3)
|
|
353
|
+
if rest and said:
|
|
354
|
+
_win_gate_log("set " + " ".join(rest[:2]), said)
|
|
355
|
+
from seeu.win import act as _wact
|
|
356
|
+
sys.exit(_wact.settings_cmd(rest))
|
|
357
|
+
if cmd in ("更新", "update"):
|
|
358
|
+
from seeu import update as _upd
|
|
359
|
+
sys.exit(_upd.main(args[1:]))
|
|
360
|
+
if cmd in ("取证", "evidence"):
|
|
361
|
+
from seeu.win import evidence as _wev
|
|
362
|
+
sys.exit(_wev.main(args[1:]))
|
|
363
|
+
from seeu.win import act as _wact
|
|
364
|
+
sys.exit(_wact.main(args))
|
|
365
|
+
if cmd in ("see", "tap", "type", "scroll", "press", "menu", "base", "home", "open"):
|
|
366
|
+
from seeu import act
|
|
367
|
+
sys.exit(act.main(args))
|
|
368
|
+
elif cmd == "isee":
|
|
369
|
+
from seeu import isee
|
|
370
|
+
isee.main(args[1:])
|
|
371
|
+
elif cmd in ("allow", "disallow") and len(args) > 1:
|
|
372
|
+
if cmd == "allow":
|
|
373
|
+
args, ok = _ai_gate(args, lambda a: "allow " + (a[1] if len(a) > 1 else ""))
|
|
374
|
+
if not ok:
|
|
375
|
+
sys.exit(3)
|
|
376
|
+
if len(args) < 2: # 只给了 --user-said、没给网址
|
|
377
|
+
print(__doc__)
|
|
378
|
+
sys.exit(2)
|
|
379
|
+
from seeu.web import aejs
|
|
380
|
+
print("允许名单(Safari 开关、Chrome 插件共用一份):", aejs.allow(args[1], on=cmd == "allow"))
|
|
381
|
+
if cmd == "allow":
|
|
382
|
+
print("用 Chrome 插件的话,还要在这个网页上点浏览器右上角的 SeeU 图标、选「允许这个网站」一次(Chrome 规定要你亲手点)")
|
|
383
|
+
elif cmd in ("取证", "evidence"):
|
|
384
|
+
from seeu import evidence
|
|
385
|
+
evidence.main(args[1:])
|
|
386
|
+
elif cmd in ("检查", "check", "doctor"):
|
|
387
|
+
from seeu import doctor
|
|
388
|
+
sys.exit(doctor.main(args[1:]))
|
|
389
|
+
elif cmd in ("接入", "install", "移除", "uninstall", "remove"):
|
|
390
|
+
from seeu import install
|
|
391
|
+
sys.exit(install.main(cmd, args[1:]))
|
|
392
|
+
elif cmd in ("设置", "set", "settings"):
|
|
393
|
+
if len(args) > 2:
|
|
394
|
+
args, ok = _ai_gate(args, lambda a: "set " + " ".join(a[1:3]))
|
|
395
|
+
if not ok:
|
|
396
|
+
sys.exit(3)
|
|
397
|
+
from seeu import act
|
|
398
|
+
sys.exit(act.settings_cmd(args[1:]))
|
|
399
|
+
elif cmd in ("探一下", "probe"):
|
|
400
|
+
from seeu import probe
|
|
401
|
+
sys.exit(probe.main(args[1:]))
|
|
402
|
+
elif cmd in ("更新", "update"):
|
|
403
|
+
from seeu import update
|
|
404
|
+
sys.exit(update.main(args[1:]))
|
|
405
|
+
elif cmd in ("版本", "version", "--version", "-v"):
|
|
406
|
+
from seeu import version
|
|
407
|
+
print("SeeU v" + version.current())
|
|
408
|
+
elif cmd == "mcp":
|
|
409
|
+
from seeu import mcp_server
|
|
410
|
+
mcp_server.main()
|
|
411
|
+
elif cmd == "allowed":
|
|
412
|
+
from seeu.web import aejs
|
|
413
|
+
print("允许名单(Safari 开关、Chrome 插件共用一份):", aejs.allowed_list())
|
|
414
|
+
else:
|
|
415
|
+
print(__doc__)
|