The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(desktop): retain native launcher and backend campaign probes
Teknium93fef377df8e
diff --git a/evals/desktop_bug_campaign/linux_launcher_probe.py b/evals/desktop_bug_campaign/linux_launcher_probe.pynew file mode 100644index 00000000000..afc8e9f7b77--- /dev/null+++ b/evals/desktop_bug_campaign/linux_launcher_probe.py@@ -0,0 +1,82 @@+"""Real Linux venv/XDG I/O probe; help-launch is NOT a native UI proof."""+import argparse+import json+import os+from pathlib import Path+import shlex+import subprocess+import sys+import tempfile+import venv+++def run(argv, env, cwd):+ result = subprocess.run(argv, env=env, cwd=cwd, stdin=subprocess.DEVNULL,+ capture_output=True, text=True, timeout=60)+ return {"argv": argv, "returncode": result.returncode,+ "stdout": result.stdout, "stderr": result.stderr}+++def main():+ parser = argparse.ArgumentParser()+ parser.add_argument("repo", type=Path)+ parser.add_argument("output", type=Path)+ parser.add_argument("--source-sha", help="Provenance for a git-archived checkout")+ args = parser.parse_args()+ repo = args.repo.resolve()+ args.output.mkdir(parents=True, exist_ok=True)+ root = Path(tempfile.mkdtemp(prefix="linux-launcher-", dir=args.output))+ env = {"PATH": "/usr/bin:/bin", "HOME": str(root / "home"),+ "HERMES_HOME": str(root / "home/.hermes"),+ "XDG_DATA_HOME": str(root / "xdg"), "LANG": "C.UTF-8",+ "HERMES_NONINTERACTIVE": "1"}+ Path(env["HERMES_HOME"]).mkdir(parents=True)+ venv_dir = root / "venv"+ venv.EnvBuilder(with_pip=False, symlinks=True).create(venv_dir)+ python = venv_dir / "bin/python"+ # Reuse dependencies read-only; put the tested checkout before its editable install.+ site = next(venv_dir.glob("lib/python*/site-packages"))+ dependencies = Path(sys.prefix) / f"lib/python{sys.version_info.major}.{sys.version_info.minor}/site-packages"+ (site / "probe.pth").write_text(str(repo) + "\n" + str(dependencies) + "\n")+ assert python.is_symlink() and python.resolve() != python+ install = (+ "import sys,json; from pathlib import Path; "+ "from hermes_cli.linux_desktop_entry import install_desktop_entry; "+ f"sys.argv[0]={str(repo / 'hermes')!r}; "+ f"p=install_desktop_entry(Path({str(repo)!r})); "+ "print(json.dumps({'path':str(p),'text':p.read_text(),'python':sys.executable}))"+ )+ rows: dict = {"source_sha": args.source_sha or subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=repo, text=True).strip(),+ "root": str(root), "lexical_python": str(python), "base_python": str(python.resolve())}+ rows["venv_import"] = run([str(python), "-I", "-c", "import yaml,hermes_cli.main; print(yaml.__version__)"], env, "/")+ rows["base_import_negative"] = run([str(python.resolve()), "-I", "-c", "import yaml,hermes_cli.main"], env, "/")+ rows["install"] = run([str(python), "-c", install], env, "/")+ assert rows["install"]["returncode"] == 0, rows["install"]+ installed = json.loads(rows["install"]["stdout"].splitlines()[-1])+ entry = Path(installed["path"])+ exec_line = next(x[5:] for x in installed["text"].splitlines() if x.startswith("Exec="))+ argv = shlex.split(exec_line)+ assert str(python.resolve()) not in argv+ # Exercise the generated command's real CLI imports without invoking npm/build.+ rows["generated_exec_help"] = run([*argv, "--help"], env, "/")+ original = entry.read_bytes()+ rows["second_install"] = run([str(python), "-c", install], env, "/")+ rows["stable_rewrite"] = entry.read_bytes() == original+ custom = original.replace(b"Name=Hermes\n", b"Name=Hermes custom\n").replace(b"Terminal=false", b"Terminal=true")+ entry.write_bytes(custom)+ config = Path(env["HERMES_HOME"]) / "config.yaml"+ config.write_text("desktop:\n manage_launcher_entry: false\n")+ rows["custom_install"] = run([str(python), "-c", install], env, "/")+ rows["custom_preserved"] = entry.read_bytes() == custom+ rows["generated_exec"] = exec_line+ rows["fidelity"] = "real venv, native Linux XDG installer, real generated argv --help; NOT Electron window/menu-click proof"+ (args.output / "probe.json").write_text(json.dumps(rows, indent=2))+ print(json.dumps(rows, indent=2))+ assert rows["venv_import"]["returncode"] == 0+ assert rows["base_import_negative"]["returncode"] != 0+ assert rows["generated_exec_help"]["returncode"] == 0+ assert rows["stable_rewrite"]+++if __name__ == "__main__":+ main()diff --git a/evals/desktop_bug_campaign/native_ready_probe.mjs b/evals/desktop_bug_campaign/native_ready_probe.mjsnew file mode 100644index 00000000000..3df4d2e75f2--- /dev/null+++ b/evals/desktop_bug_campaign/native_ready_probe.mjs@@ -0,0 +1,54 @@+// Real backend + production READY parser; no Electron renderer is exercised.+import { spawn } from 'node:child_process'+import { mkdtempSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { fileURLToPath } from 'node:url'+import { randomUUID } from 'node:crypto'+import { setTimeout as delay } from 'node:timers/promises'+import { waitForDashboardPortAnnouncement } from '../../apps/desktop/electron/backend-ready.ts'++const repo = fileURLToPath(new URL('../../', import.meta.url))+const home = mkdtempSync(join(tmpdir(), 'hermes-native-ready-'))+const token = randomUUID()+const env = {+ PATH: process.env.PATH, HOME: home, HERMES_HOME: home,+ LANG: 'C.UTF-8', PYTHONUNBUFFERED: '1', HERMES_NONINTERACTIVE: '1',+ HERMES_DASHBOARD_SESSION_TOKEN: token, HERMES_SERVE_HEADLESS: '1',+ HERMES_PARENT_PID: String(process.pid),+}+const child = spawn(process.argv[2] || join(repo, '.venv/bin/python'),+ ['-m', 'hermes_cli.main', 'serve', '--host', '127.0.0.1', '--port', '0', '--isolated'],+ { cwd: repo, env, stdio: ['ignore', 'pipe', 'pipe'] })+let tail = ''+for (const stream of [child.stdout, child.stderr]) {+ stream.on('data', chunk => { tail = (tail + chunk.toString()).slice(-32768) })+}+// Match production's synchronous attach-then-wait order, without synthetic output.+const announcement = waitForDashboardPortAnnouncement(child, { bufferedOutput: () => tail })+try {+ const port = await announcement+ console.log(JSON.stringify({ platform: process.platform, arch: process.arch, readyPort: port, home }))+ const ws = new WebSocket(`ws://127.0.0.1:${port}/api/ws?token=${token}`)+ await new Promise((resolve, reject) => {+ const timer = setTimeout(() => reject(new Error('WS open timeout')), 15000)+ ws.addEventListener('open', () => { clearTimeout(timer); resolve() }, { once: true })+ ws.addEventListener('error', () => { clearTimeout(timer); reject(new Error('WS rejected')) }, { once: true })+ })+ for (let i = 0; i < 20; i++) {+ for (const path of ['/api/status', '/api/profiles']) {+ const response = await fetch(`http://127.0.0.1:${port}${path}`, { headers: { 'X-Hermes-Session-Token': token } })+ if (!response.ok) throw new Error(`${path}: HTTP ${response.status}`)+ await response.json()+ }+ if (child.exitCode !== null || ws.readyState !== WebSocket.OPEN) throw new Error('Backend/session lost')+ await delay(5000)+ }+ ws.close()+ console.log('PASS: production READY parser + real backend HTTP/profiles and WS stayed healthy beyond 90s; not full Electron UI proof')+} catch (error) {+ console.error(tail)+ throw error+} finally {+ child.kill('SIGTERM')+}