gemini-computer-use 0.4.3 → 0.4.5

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.
package/core/version.py DELETED
@@ -1,31 +0,0 @@
1
- """core/version.py - the ONE place this node's version is declared.
2
-
3
- Every other place that needs the node version asks this module:
4
-
5
- * ``core/updater.py`` compares it against the newest GitHub release;
6
- * ``core/mcp_tools.py`` reports it from ``mesh_status`` and ``mesh_update``;
7
- * ``build-installer-exe.ps1`` refuses to build when ``package.json`` disagrees
8
- with it, so the npm package and the Python node can never ship as two
9
- different versions;
10
- * ``tests/test_version_single_source.py`` pins that agreement.
11
-
12
- The repository deliberately keeps no second literal: a version that lives in two
13
- files is a version that eventually disagrees with itself, and an updater that
14
- compares the wrong number either reinstalls forever or never updates at all.
15
-
16
- Format: ``MAJOR.MINOR.PATCH``, optionally followed by a pre-release suffix
17
- (``0.3.0-rc.1``). The suffix never changes the meaning of the three numbers; a
18
- pre-release is older than the release it precedes, which is what
19
- ``core.updater.is_newer`` implements.
20
- """
21
-
22
- #: The node version. Keep it in sync with ``package.json`` (the build enforces it).
23
- __version__ = "0.4.3"
24
-
25
- #: The repository that publishes the releases this node updates itself from.
26
- #: Declared here as well so a checkout says where it came from; ``package.json``
27
- #: carries the same slug under ``repository.url`` and a test pins the agreement.
28
- REPO_SLUG = "LevRa7/Computer-use-for-Gemini-App-Web"
29
-
30
- #: Anchored pattern for the only accepted spelling, used by the single-source test.
31
- VERSION_PATTERN = r"^\d+\.\d+\.\d+(?:-[0-9A-Za-z.\-]+)?$"
package/core/vitals.py DELETED
@@ -1,181 +0,0 @@
1
- import os
2
- import platform
3
- import shutil
4
- import socket
5
- import subprocess
6
- import time
7
- from typing import Dict, Any
8
-
9
-
10
- def _windows_cpu_usage_pct(sample_seconds: float = 0.1) -> float:
11
- """Measured CPU utilisation on Windows.
12
-
13
- Windows has no load average, so ``os.getloadavg`` does not exist and the
14
- previous code reported a hardcoded 0.0. ``GetSystemTimes`` gives idle and
15
- total processor time, and their delta over a short sample is the utilisation
16
- every other Windows tool reports.
17
- """
18
- try:
19
- import ctypes
20
- from ctypes import wintypes
21
-
22
- class FILETIME(ctypes.Structure):
23
- _fields_ = [
24
- ("dwLowDateTime", wintypes.DWORD),
25
- ("dwHighDateTime", wintypes.DWORD),
26
- ]
27
-
28
- def as_int(value: "FILETIME") -> int:
29
- return (value.dwHighDateTime << 32) | value.dwLowDateTime
30
-
31
- kernel32 = ctypes.windll.kernel32 # type: ignore[attr-defined]
32
-
33
- def sample():
34
- idle_c, kernel_c, user_c = FILETIME(), FILETIME(), FILETIME()
35
- ok = kernel32.GetSystemTimes(
36
- ctypes.byref(idle_c), ctypes.byref(kernel_c), ctypes.byref(user_c)
37
- )
38
- if not ok:
39
- return None
40
- return as_int(idle_c), as_int(kernel_c), as_int(user_c)
41
-
42
- first = sample()
43
- if first is None:
44
- return 0.0
45
- time.sleep(sample_seconds)
46
- second = sample()
47
- if second is None:
48
- return 0.0
49
-
50
- idle_delta = second[0] - first[0]
51
- total_delta = (second[1] - first[1]) + (second[2] - first[2])
52
- if total_delta <= 0:
53
- return 0.0
54
- usage = 100.0 * (total_delta - idle_delta) / total_delta
55
- return round(max(0.0, min(100.0, usage)), 1)
56
- except Exception:
57
- return 0.0
58
-
59
-
60
- def get_host_vitals() -> Dict[str, Any]:
61
- hostname = socket.gethostname()
62
- system = platform.system() # 'Linux', 'Darwin', 'Windows' - and 'Android' on a phone
63
-
64
- # Python on Android (Termux, 3.13+) answers platform.system() == "Android", not
65
- # "Linux", although it is Linux underneath and /proc is right there. Without this
66
- # a phone reported "0 MB of RAM" - verified on an OPPO PHY110 running Android 16
67
- # with Python 3.14, where the memory block came back as 0.0/0.0 MB. The file is
68
- # the honest signal, so it decides.
69
- linux_like = system == "Linux" or os.path.isfile("/proc/meminfo")
70
-
71
- # CPU load average (Unix)
72
- cpu_load = {"1m": 0.0, "5m": 0.0, "15m": 0.0}
73
- try:
74
- if hasattr(os, "getloadavg"):
75
- load = os.getloadavg()
76
- cpu_load = {
77
- "1m": round(load[0], 2),
78
- "5m": round(load[1], 2),
79
- "15m": round(load[2], 2),
80
- }
81
- elif system == "Windows":
82
- # No load average exists there: report the measured utilisation in all
83
- # three slots so no consumer reads a fabricated zero.
84
- usage = _windows_cpu_usage_pct()
85
- cpu_load = {"1m": usage, "5m": usage, "15m": usage}
86
- except Exception:
87
- pass
88
-
89
- # RAM metrics
90
- total_mb = 0.0
91
- free_mb = 0.0
92
-
93
- if linux_like:
94
- total_kb, avail_kb = 0, 0
95
- try:
96
- with open("/proc/meminfo", "r") as f:
97
- for line in f:
98
- parts = line.split(":")
99
- key = parts[0].strip()
100
- if key == "MemTotal":
101
- total_kb = int(parts[1].split()[0])
102
- elif key == "MemAvailable":
103
- avail_kb = int(parts[1].split()[0])
104
- except Exception:
105
- pass
106
- total_mb = round(total_kb / 1024, 1)
107
- free_mb = round(avail_kb / 1024, 1)
108
- elif system == "Darwin":
109
- # macOS
110
- try:
111
- mem_bytes = int(subprocess.check_output(["sysctl", "-n", "hw.memsize"], text=True).strip())
112
- total_mb = round(mem_bytes / (1024**2), 1)
113
- vm = subprocess.check_output(["vm_stat"], text=True)
114
- page_size = 4096
115
- free_pages = 0
116
- for line in vm.splitlines():
117
- if "page size of" in line:
118
- page_size = int(line.split()[-2])
119
- elif "Pages free:" in line or "Pages speculative:" in line:
120
- free_pages += int(line.split()[-1].replace(".", ""))
121
- free_mb = round((free_pages * page_size) / (1024**2), 1)
122
- except Exception:
123
- pass
124
- elif system == "Windows":
125
- try:
126
- import ctypes
127
- class MEMORYSTATUSEX(ctypes.Structure):
128
- _fields_ = [
129
- ("dwLength", ctypes.c_ulong),
130
- ("dwMemoryLoad", ctypes.c_ulong),
131
- ("ullTotalPhys", ctypes.c_ulonglong),
132
- ("ullAvailPhys", ctypes.c_ulonglong),
133
- ("ullTotalPageFile", ctypes.c_ulonglong),
134
- ("ullAvailPageFile", ctypes.c_ulonglong),
135
- ("ullTotalVirtual", ctypes.c_ulonglong),
136
- ("ullAvailVirtual", ctypes.c_ulonglong),
137
- ("sullAvailExtendedVirtual", ctypes.c_ulonglong),
138
- ]
139
- stat = MEMORYSTATUSEX()
140
- stat.dwLength = ctypes.sizeof(MEMORYSTATUSEX)
141
- ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(stat))
142
- total_mb = round(stat.ullTotalPhys / (1024**2), 1)
143
- free_mb = round(stat.ullAvailPhys / (1024**2), 1)
144
- except Exception:
145
- pass
146
-
147
- used_mb = max(0.0, round(total_mb - free_mb, 1))
148
- used_ram_pct = round((used_mb / total_mb) * 100.0, 1) if total_mb > 0 else 0.0
149
-
150
- ram = {
151
- "total_mb": total_mb,
152
- "used_mb": used_mb,
153
- "free_mb": free_mb,
154
- "used_pct": used_ram_pct,
155
- }
156
-
157
- # Disk metrics
158
- root_path = "C:\\" if system == "Windows" else "/"
159
- try:
160
- du = shutil.disk_usage(root_path)
161
- total_gb = round(du.total / (1024**3), 2)
162
- used_gb = round(du.used / (1024**3), 2)
163
- free_gb = round(du.free / (1024**3), 2)
164
- used_disk_pct = round((du.used / du.total) * 100.0, 1) if du.total > 0 else 0.0
165
- except Exception:
166
- total_gb, used_gb, free_gb, used_disk_pct = 0.0, 0.0, 0.0, 0.0
167
-
168
- disk = {
169
- "total_gb": total_gb,
170
- "used_gb": used_gb,
171
- "free_gb": free_gb,
172
- "used_pct": used_disk_pct,
173
- }
174
-
175
- return {
176
- "hostname": hostname,
177
- "os": system,
178
- "cpu_load": cpu_load,
179
- "ram": ram,
180
- "disk": disk,
181
- }