dsh-quay-bot 0.7.4 → 1.0.0

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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +105 -28
  3. package/bin/doctor.mjs +148 -0
  4. package/botscreen/requirements-offline.txt +11 -0
  5. package/client.js +1 -2
  6. package/cordis.patch.yml +1 -1
  7. package/host/api.js +0 -4
  8. package/host/remote.js +2 -140
  9. package/host/screen.js +85 -21
  10. package/market/index.json +41 -0
  11. package/package.json +32 -13
  12. package/vendor/wheels/any/annotated_doc-0.0.7-py3-none-any.whl +0 -0
  13. package/vendor/wheels/any/annotated_types-0.8.0-py3-none-any.whl +0 -0
  14. package/vendor/wheels/any/anyio-4.16.0-py3-none-any.whl +0 -0
  15. package/vendor/wheels/any/certifi-2026.11.20-py3-none-any.whl +0 -0
  16. package/vendor/wheels/any/click-8.5.1-py3-none-any.whl +0 -0
  17. package/vendor/wheels/any/fastapi-0.165.0-py3-none-any.whl +0 -0
  18. package/vendor/wheels/any/h11-0.16.0-py3-none-any.whl +0 -0
  19. package/vendor/wheels/any/httpcore-1.0.9-py3-none-any.whl +0 -0
  20. package/vendor/wheels/any/httpx-0.29.0-py3-none-any.whl +0 -0
  21. package/vendor/wheels/any/idna-3.20-py3-none-any.whl +0 -0
  22. package/vendor/wheels/any/mss-10.2.0-py3-none-any.whl +0 -0
  23. package/vendor/wheels/any/opentelemetry_api-1.45.2-py3-none-any.whl +0 -0
  24. package/vendor/wheels/any/pydantic-2.14.4-py3-none-any.whl +0 -0
  25. package/vendor/wheels/any/python_multipart-0.0.34-py3-none-any.whl +0 -0
  26. package/vendor/wheels/any/python_xlib-0.33-py2.py3-none-any.whl +0 -0
  27. package/vendor/wheels/any/six-1.17.0-py2.py3-none-any.whl +0 -0
  28. package/vendor/wheels/any/starlette-1.10.0-py3-none-any.whl +0 -0
  29. package/vendor/wheels/any/typing_extensions-4.16.0-py3-none-any.whl +0 -0
  30. package/vendor/wheels/any/typing_inspection-0.4.5-py3-none-any.whl +0 -0
  31. package/vendor/wheels/any/uvicorn-0.54.0-py3-none-any.whl +0 -0
  32. package/vendor/wheels/linux-aarch64/pillow-12.2.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl +0 -0
  33. package/vendor/wheels/linux-aarch64/pydantic_core-2.50.5-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.whl +0 -0
  34. package/vendor/wheels/linux-aarch64/websockets-17.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl +0 -0
  35. package/vendor/wheels/linux-x86_64/pillow-12.2.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl +0 -0
  36. package/vendor/wheels/linux-x86_64/pydantic_core-2.50.5-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl +0 -0
  37. package/vendor/wheels/linux-x86_64/websockets-17.4-cp312-cp312-manylinux1_x86_64.manylinux_2_28_x86_64.manylinux_2_5_x86_64.whl +0 -0
  38. package/botscreen/botscreen/__init__.py +0 -2
  39. package/botscreen/botscreen/__main__.py +0 -5
  40. package/botscreen/botscreen/artifacts.py +0 -388
  41. package/botscreen/botscreen/audit.py +0 -94
  42. package/botscreen/botscreen/cgroup.py +0 -293
  43. package/botscreen/botscreen/config.py +0 -320
  44. package/botscreen/botscreen/desktop/assets/chrome.png +0 -0
  45. package/botscreen/botscreen/desktop/assets/codex.png +0 -0
  46. package/botscreen/botscreen/desktop/assets/drive.png +0 -0
  47. package/botscreen/botscreen/desktop/assets/folder.png +0 -0
  48. package/botscreen/botscreen/desktop/assets/search.png +0 -0
  49. package/botscreen/botscreen/desktop/assets/terminal.png +0 -0
  50. package/botscreen/botscreen/desktop/assets/trash.png +0 -0
  51. package/botscreen/botscreen/desktop/assets/wallpaper.png +0 -0
  52. package/botscreen/botscreen/desktop.py +0 -244
  53. package/botscreen/botscreen/driver.py +0 -832
  54. package/botscreen/botscreen/gateway.py +0 -2089
  55. package/botscreen/botscreen/iconlayer.py +0 -841
  56. package/botscreen/botscreen/mcp_server.py +0 -435
  57. package/botscreen/botscreen/resources.py +0 -494
  58. package/botscreen/botscreen/screen.py +0 -1282
  59. package/botscreen/botscreen/session.py +0 -706
  60. package/botscreen/botscreen/state.py +0 -330
  61. package/botscreen/botscreen/streamer.py +0 -388
  62. package/remote/bin/dsh-remote.mjs +0 -418
  63. package/remote/package.json +0 -27
  64. package/remote/src/config.mjs +0 -183
  65. package/remote/src/crypto.mjs +0 -220
  66. package/remote/src/keys.mjs +0 -226
  67. package/remote/src/proxy.mjs +0 -1028
  68. package/remote/src/sessions.mjs +0 -163
  69. package/remote/src/shim.js +0 -838
  70. package/remote/src/supervisor.mjs +0 -207
  71. package/remote/src/tunnel.mjs +0 -489
  72. package/remote/src/upstream.mjs +0 -372
  73. package/remote/src/util.mjs +0 -139
  74. package/remote/src/ws.mjs +0 -313
  75. package/requirements.txt +0 -8
@@ -1,244 +0,0 @@
1
- """统一轻量桌面壳:托管单一 `botscreen.iconlayer`(壁纸 + 桌面图标 + 顶部导航/任务栏)。
2
-
3
- 所有 Bot 虚拟屏均采用完全一致的桌面壳架构:
4
- * 不依赖宿主机可选包(tint2 / xfdesktop / xfce4-panel / picom / gvfs),彻底消除不同 Bot
5
- 新建桌面规格不一致、顶部导航栏错位或缺失的问题;
6
- * 单进程 ~20MB 内存,0.2 秒就绪,支持按需启停与崩溃自愈。
7
- """
8
- from __future__ import annotations
9
-
10
- import os
11
- import shutil
12
- import signal
13
- import subprocess
14
- import sys
15
- import time
16
- from typing import List, Optional
17
-
18
- from .config import SHARED_XAUTHORITY, BotPaths
19
-
20
- ASSETS = (
21
- "wallpaper.png",
22
- "drive.png",
23
- "folder.png",
24
- "codex.png",
25
- "chrome.png",
26
- "trash.png",
27
- "search.png",
28
- "terminal.png",
29
- )
30
-
31
- SEARCH_HTML = """<!DOCTYPE html><html lang="zh-CN"><head><meta charset="utf-8">
32
- <title>搜索</title><style>
33
- html,body{margin:0;height:100%;background:#0d1013;color:#d7dee4;
34
- font-family:-apple-system,"PingFang SC","Noto Sans CJK SC",sans-serif;display:flex;
35
- align-items:center;justify-content:center}
36
- form{width:min(680px,86vw);text-align:center}
37
- h1{font:600 15px ui-monospace;letter-spacing:.16em;color:#46b39d;margin:0 0 26px}
38
- input{width:100%;box-sizing:border-box;font-size:20px;padding:16px 20px;border-radius:12px;
39
- border:1px solid #2a333d;background:#15191d;color:#e6edf3;outline:none}
40
- input:focus{border-color:#46b39d;box-shadow:0 0 0 3px #46b39d22}
41
- p{margin:18px 0 0;color:#63707a;font-size:12.5px}
42
- </style></head><body><form onsubmit="go(event)">
43
- <h1>SEARCH</h1>
44
- <input id=q placeholder="搜索网页,回车用 Bing" autofocus>
45
- <p>输入后回车 · 也可以直接粘一个 URL</p></form>
46
- <script>
47
- function go(e){e.preventDefault();var q=document.getElementById('q').value.trim();
48
- if(!q)return;location.href=/^(https?:\\/\\/|file:)/.test(q)?q:('https://www.bing.com/search?q='+encodeURIComponent(q));}
49
- </script></body></html>
50
- """
51
-
52
-
53
- class DesktopShell:
54
- """给一张虚拟屏铺统一轻量桌面。所有进程均交由调用方纳管进 cgroup。"""
55
-
56
- def __init__(self, bot_id: str, paths: BotPaths, assets_pkg: str, display: int) -> None:
57
- self.bot_id = bot_id
58
- self.paths = paths
59
- self.display = display
60
- self.assets_pkg = assets_pkg
61
- self.assets_dir = os.path.join(os.path.dirname(paths.root), "_assets")
62
- self.procs: List[dict] = []
63
- self._started = False
64
-
65
- def _ensure_assets(self) -> None:
66
- os.makedirs(self.assets_dir, exist_ok=True)
67
- for name in ASSETS:
68
- src = os.path.join(self.assets_pkg, name)
69
- dst = os.path.join(self.assets_dir, name)
70
- if os.path.exists(src) and (
71
- not os.path.exists(dst) or os.path.getmtime(src) > os.path.getmtime(dst)
72
- ):
73
- shutil.copy2(src, dst)
74
- with open(os.path.join(self.assets_dir, "search.html"), "w", encoding="utf-8") as fh:
75
- fh.write(SEARCH_HTML)
76
-
77
- def prepare_files(self) -> None:
78
- self._ensure_assets()
79
- os.makedirs(os.path.join(self.paths.home, "Desktop"), exist_ok=True)
80
-
81
- def env(self, extra: Optional[dict] = None) -> dict:
82
- env = dict(os.environ)
83
- env.update(
84
- DISPLAY=f":{self.display}",
85
- XAUTHORITY=SHARED_XAUTHORITY,
86
- HOME=self.paths.home,
87
- XDG_CONFIG_HOME=os.path.join(self.paths.home, ".config"),
88
- XDG_DATA_HOME=os.path.join(self.paths.home, ".local", "share"),
89
- XDG_CACHE_HOME=os.path.join(self.paths.home, ".cache"),
90
- XDG_RUNTIME_DIR=self.paths.runtime,
91
- XDG_SESSION_TYPE="x11",
92
- )
93
- for d in (env["XDG_CONFIG_HOME"], env["XDG_DATA_HOME"], env["XDG_CACHE_HOME"], env["XDG_RUNTIME_DIR"]):
94
- os.makedirs(d, exist_ok=True)
95
- if extra:
96
- env.update(extra)
97
- return env
98
-
99
- def _spawn(
100
- self,
101
- argv: List[str],
102
- log_name: str,
103
- env: Optional[dict] = None,
104
- cgroup_hook=None,
105
- name: Optional[str] = None,
106
- ) -> Optional[subprocess.Popen]:
107
- if not shutil.which(argv[0]) and not os.path.exists(argv[0]):
108
- return None
109
- log_path = os.path.join(self.paths.runtime, log_name)
110
- log = open(log_path, "ab", buffering=0)
111
- proc = subprocess.Popen(
112
- argv,
113
- env=env or self.env(),
114
- stdout=log,
115
- stderr=subprocess.STDOUT,
116
- start_new_session=True,
117
- )
118
- self.procs.append(
119
- {
120
- "name": name or os.path.basename(argv[0]),
121
- "argv": list(argv),
122
- "log": log_path,
123
- "env": env,
124
- "proc": proc,
125
- }
126
- )
127
- if cgroup_hook:
128
- try:
129
- cgroup_hook(proc.pid)
130
- except Exception: # noqa: BLE001
131
- pass
132
- return proc
133
-
134
- def ensure_running(self, cgroup_hook=None) -> List[str]:
135
- """补齐已退出的桌面组件进程。"""
136
- if not self._started:
137
- return []
138
- revived: List[str] = []
139
- for item in list(self.procs):
140
- proc = item["proc"]
141
- if proc.poll() is None:
142
- continue
143
- try:
144
- log = open(item["log"], "ab", buffering=0)
145
- new_proc = subprocess.Popen(
146
- item["argv"],
147
- env=item.get("env") or self.env(),
148
- stdout=log,
149
- stderr=subprocess.STDOUT,
150
- start_new_session=True,
151
- )
152
- if cgroup_hook:
153
- try:
154
- cgroup_hook(new_proc.pid)
155
- except Exception: # noqa: BLE001
156
- pass
157
- item["proc"] = new_proc
158
- revived.append(item["name"])
159
- except OSError:
160
- continue
161
- return revived
162
-
163
- def start(self, cgroup_hook=None) -> bool:
164
- if self._started:
165
- return True
166
- self._kill_stale()
167
- self.prepare_files()
168
- disp = f":{self.display}" if not str(self.display).startswith(":") else str(self.display)
169
- self._spawn(
170
- [
171
- sys.executable,
172
- "-m",
173
- "botscreen.iconlayer",
174
- "--display",
175
- disp,
176
- "--home",
177
- self.paths.home,
178
- "--assets",
179
- self.assets_dir,
180
- ],
181
- "iconlayer.log",
182
- cgroup_hook=cgroup_hook,
183
- name="iconlayer",
184
- )
185
- time.sleep(0.25)
186
- self._started = True
187
- return True
188
-
189
- def _kill_stale(self) -> None:
190
- """精确清理本 display 上残留的桌面组件进程(包含旧版 xfdesktop/tint2/picom/xfce4-panel/iconlayer)。"""
191
- targets = {"xfdesktop", "pcmanfm", "tint2", "picom", "xfce4-panel"}
192
- display_tag = f"DISPLAY=:{self.display}".encode()
193
- iconlayer_arg = f":{self.display}"
194
- killed = False
195
- for entry in os.listdir("/proc"):
196
- if not entry.isdigit():
197
- continue
198
- pid = int(entry)
199
- if pid == os.getpid():
200
- continue
201
- try:
202
- with open(f"/proc/{pid}/comm", "rb") as fh:
203
- comm = fh.read().strip().decode(errors="ignore")
204
- match = False
205
- if comm in targets:
206
- with open(f"/proc/{pid}/environ", "rb") as fh:
207
- if display_tag in fh.read().split(b"\x00"):
208
- match = True
209
- elif "python" in comm:
210
- with open(f"/proc/{pid}/cmdline", "rb") as fh:
211
- args = [a.decode(errors="ignore") for a in fh.read().split(b"\x00") if a]
212
- if "botscreen.iconlayer" in args and iconlayer_arg in args:
213
- match = True
214
- if match:
215
- os.kill(pid, signal.SIGTERM)
216
- killed = True
217
- except OSError:
218
- continue
219
- if killed:
220
- time.sleep(0.25)
221
-
222
- def stop(self) -> None:
223
- for item in reversed(self.procs):
224
- proc = item["proc"]
225
- try:
226
- if proc.poll() is None:
227
- proc.terminate()
228
- proc.wait(timeout=3)
229
- except (subprocess.TimeoutExpired, OSError):
230
- try:
231
- proc.kill()
232
- except OSError:
233
- pass
234
- self.procs.clear()
235
- self._kill_stale()
236
- self._started = False
237
-
238
- def snapshot(self) -> dict:
239
- return {
240
- "started": self._started,
241
- "assets": self.assets_dir,
242
- "procs": [i["proc"].pid for i in self.procs if i["proc"].poll() is None],
243
- "dead": [i["name"] for i in self.procs if i["proc"].poll() is not None],
244
- }