mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-23 10:42:00 +00:00
* feat(computer_use): disable cua-driver telemetry by default, add opt-in cua-driver ships anonymous PostHog usage telemetry ENABLED by default upstream (fires cua_driver_install / cua_driver_doctor events to eu.i.posthog.com). Hermes now disables it for our users unless they explicitly opt in. - New config key `computer_use.cua_telemetry` (default false) in DEFAULT_CONFIG. - `cua_backend.cua_driver_child_env()` injects `CUA_DRIVER_RS_TELEMETRY_ENABLED=0` into the child env when telemetry is disabled (the default); leaves the var untouched on opt-in so the driver uses its own default. Reads config fail-safe — any error defaults to telemetry off. - Routed every cua-driver spawn site through the policy: MCP backend (StdioServerParameters env), `cua_driver_update_check`, doctor's health_report Popen, the install.sh/install.ps1 runner, and the `--version` / status probes. - Docs: new Telemetry subsection in computer-use.md (EN). - Tests: tests/computer_use/test_cua_telemetry.py — default disables, explicit-false disables, opt-in leaves var untouched, config-failure fails safe, inherited-enabled is overridden off. Verified live on Linux against the real cua-driver-rs 0.6.0 binary: with the var=0 the driver reports "telemetry: disabled via CUA_DRIVER_RS_TELEMETRY_ENABLED" and sends no event; with it unset it logs "sending event: cua_driver_doctor". 213 computer_use + install tests green. * fix(dashboard): fold computer_use config category into agent tab The new computer_use.cua_telemetry key created a single-field dashboard config category, tripping test_no_single_field_categories (web_server's invariant that categories with <2 fields must be merged to avoid tab sprawl). Add computer_use -> agent to _CATEGORY_MERGE, matching the existing onboarding/telegram single-field folds.
80 lines
3.5 KiB
Python
80 lines
3.5 KiB
Python
"""Tests for the cua-driver telemetry opt-in policy.
|
|
|
|
cua-driver ships anonymous PostHog telemetry ENABLED by default upstream.
|
|
Hermes disables it unless the user opts in via
|
|
``computer_use.cua_telemetry: true``. The policy is applied by injecting
|
|
``CUA_DRIVER_RS_TELEMETRY_ENABLED=0`` into every cua-driver child env.
|
|
|
|
These assert the behavior contract (default disables, opt-in leaves the var
|
|
untouched, config failure fails safe toward disabled), not specific config
|
|
snapshots.
|
|
"""
|
|
|
|
from unittest.mock import patch
|
|
|
|
from tools.computer_use import cua_backend
|
|
|
|
|
|
_VAR = "CUA_DRIVER_RS_TELEMETRY_ENABLED"
|
|
|
|
|
|
class TestTelemetryDisabledFlag:
|
|
def test_default_config_disables(self):
|
|
# cua_telemetry absent / False => telemetry disabled.
|
|
with patch("hermes_cli.config.load_config", return_value={}):
|
|
assert cua_backend._cua_telemetry_disabled() is True
|
|
|
|
def test_explicit_false_disables(self):
|
|
with patch("hermes_cli.config.load_config",
|
|
return_value={"computer_use": {"cua_telemetry": False}}):
|
|
assert cua_backend._cua_telemetry_disabled() is True
|
|
|
|
def test_opt_in_true_does_not_disable(self):
|
|
with patch("hermes_cli.config.load_config",
|
|
return_value={"computer_use": {"cua_telemetry": True}}):
|
|
assert cua_backend._cua_telemetry_disabled() is False
|
|
|
|
def test_config_load_failure_fails_safe(self):
|
|
# Unreadable config => default to disabling telemetry (privacy-safe).
|
|
with patch("hermes_cli.config.load_config", side_effect=RuntimeError("boom")):
|
|
assert cua_backend._cua_telemetry_disabled() is True
|
|
|
|
def test_missing_section_disables(self):
|
|
with patch("hermes_cli.config.load_config", return_value={"other": {}}):
|
|
assert cua_backend._cua_telemetry_disabled() is True
|
|
|
|
|
|
class TestChildEnv:
|
|
def test_disabled_injects_var_zero(self):
|
|
with patch.object(cua_backend, "_cua_telemetry_disabled", return_value=True):
|
|
env = cua_backend.cua_driver_child_env({"PATH": "/usr/bin"})
|
|
assert env[_VAR] == "0"
|
|
# base env is preserved
|
|
assert env["PATH"] == "/usr/bin"
|
|
|
|
def test_opt_in_leaves_var_untouched(self):
|
|
# When the user opts in, we must NOT set the var — the driver uses its
|
|
# own default. If the base env already has a value, it is preserved.
|
|
with patch.object(cua_backend, "_cua_telemetry_disabled", return_value=False):
|
|
env = cua_backend.cua_driver_child_env({"PATH": "/usr/bin"})
|
|
assert _VAR not in env
|
|
|
|
def test_opt_in_preserves_user_set_var(self):
|
|
with patch.object(cua_backend, "_cua_telemetry_disabled", return_value=False):
|
|
env = cua_backend.cua_driver_child_env({_VAR: "1", "PATH": "/usr/bin"})
|
|
# user opted in and explicitly set it — don't clobber.
|
|
assert env[_VAR] == "1"
|
|
|
|
def test_disabled_overrides_inherited_enabled(self):
|
|
# Even if the parent process had telemetry enabled, the default policy
|
|
# forces it off in the child.
|
|
with patch.object(cua_backend, "_cua_telemetry_disabled", return_value=True):
|
|
env = cua_backend.cua_driver_child_env({_VAR: "1"})
|
|
assert env[_VAR] == "0"
|
|
|
|
def test_defaults_to_os_environ_when_no_base(self):
|
|
with patch.object(cua_backend, "_cua_telemetry_disabled", return_value=True), \
|
|
patch.dict("os.environ", {"SOME_MARKER": "yes"}, clear=False):
|
|
env = cua_backend.cua_driver_child_env()
|
|
assert env.get("SOME_MARKER") == "yes"
|
|
assert env[_VAR] == "0"
|