release: Mantoz — population-scale evaluation with simulated personas
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
FROM ubuntu:24.04
|
||||
|
||||
# computer-use runtime: Harbor computer-1 так же работает через Xvfb,
|
||||
# xdotool и screenshots. Ubuntu уже содержит bash для обёртки Harbor.
|
||||
# ponytail: XFCE/VNC не нужны для автопрогона; добавить для live-view.
|
||||
RUN apt-get update \
|
||||
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
fonts-dejavu-core python3 python3-tk scrot xauth xdotool xvfb \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
COPY desktop_app.py run_scenario.py /app/
|
||||
@@ -0,0 +1,52 @@
|
||||
"""Минимальное desktop-приложение: диалог разрешения уведомлений."""
|
||||
|
||||
import tkinter as tk
|
||||
|
||||
|
||||
class DecisionApp:
|
||||
def __init__(self) -> None:
|
||||
self.root = tk.Tk()
|
||||
self.root.title("Mantoz — уведомления")
|
||||
self.root.geometry("760x420+80+80")
|
||||
self.root.configure(bg="#f4f1ea")
|
||||
self.decision: str | None = None
|
||||
|
||||
tk.Label(
|
||||
self.root,
|
||||
text="Разрешить уведомления?",
|
||||
font=("DejaVu Sans", 22, "bold"),
|
||||
bg="#f4f1ea",
|
||||
).pack(pady=(70, 20))
|
||||
tk.Label(
|
||||
self.root,
|
||||
text="Приложение будет сообщать о важных событиях.",
|
||||
font=("DejaVu Sans", 13),
|
||||
bg="#f4f1ea",
|
||||
).pack(pady=(0, 45))
|
||||
|
||||
row = tk.Frame(self.root, bg="#f4f1ea")
|
||||
row.pack()
|
||||
self.buttons: dict[str, tk.Button] = {}
|
||||
for value, label in (
|
||||
("deny", "Запретить"),
|
||||
("later", "Позже"),
|
||||
("allow", "Разрешить"),
|
||||
):
|
||||
button = tk.Button(
|
||||
row,
|
||||
text=label,
|
||||
width=15,
|
||||
font=("DejaVu Sans", 12),
|
||||
command=lambda choice=value: self.choose(choice),
|
||||
)
|
||||
button.pack(side="left", padx=10)
|
||||
self.buttons[value] = button
|
||||
|
||||
self.status = tk.Label(
|
||||
self.root, text="", font=("DejaVu Sans", 13, "bold"), bg="#f4f1ea"
|
||||
)
|
||||
self.status.pack(pady=35)
|
||||
|
||||
def choose(self, decision: str) -> None:
|
||||
self.decision = decision
|
||||
self.status.configure(text=f"Решение: {decision}")
|
||||
@@ -0,0 +1,74 @@
|
||||
"""Проходит desktop-сценарий мышью и снимает виртуальный дисплей."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from desktop_app import DecisionApp
|
||||
|
||||
OPTIONS = ("allow", "later", "deny")
|
||||
SCREENSHOTS = Path("/app/screenshots")
|
||||
|
||||
|
||||
def command(*args: str) -> None:
|
||||
subprocess.run(
|
||||
args, check=True, env={**os.environ, "DISPLAY": os.environ["DISPLAY"]}
|
||||
)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
plan = json.loads(Path("/app/plan.json").read_text("utf-8"))
|
||||
target = plan.get("choose")
|
||||
if target not in OPTIONS:
|
||||
print(f"неизвестное решение: {target!r}", file=sys.stderr)
|
||||
return 1
|
||||
|
||||
SCREENSHOTS.mkdir(exist_ok=True)
|
||||
app = DecisionApp()
|
||||
actions = [{"type": "open", "target": "notification-dialog"}]
|
||||
failure: list[Exception] = []
|
||||
|
||||
def automate() -> None:
|
||||
try:
|
||||
command("scrot", "-o", str(SCREENSHOTS / "before.png"))
|
||||
actions.append({"type": "screenshot", "target": "before.png"})
|
||||
button = app.buttons[target]
|
||||
x = button.winfo_rootx() + button.winfo_width() // 2
|
||||
y = button.winfo_rooty() + button.winfo_height() // 2
|
||||
command("xdotool", "mousemove", "--sync", str(x), str(y), "click", "1")
|
||||
actions.append({"type": "click", "target": target, "x": x, "y": y})
|
||||
app.root.after(150, finish)
|
||||
except Exception as exc:
|
||||
failure.append(exc)
|
||||
app.root.quit()
|
||||
|
||||
def finish() -> None:
|
||||
try:
|
||||
app.root.update_idletasks()
|
||||
command("scrot", "-o", str(SCREENSHOTS / "after.png"))
|
||||
actions.append({"type": "screenshot", "target": "after.png"})
|
||||
except Exception as exc:
|
||||
failure.append(exc)
|
||||
finally:
|
||||
app.root.quit()
|
||||
|
||||
app.root.after(350, automate)
|
||||
app.root.mainloop()
|
||||
app.root.destroy()
|
||||
if failure:
|
||||
raise failure[0]
|
||||
if app.decision != target:
|
||||
print("клик не изменил состояние приложения", file=sys.stderr)
|
||||
return 1
|
||||
Path("/app/result.json").write_text(
|
||||
json.dumps({"actions": actions, "decision": app.decision}, ensure_ascii=False)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,5 @@
|
||||
Пройди desktop-сценарий в виртуальном дисплее командой
|
||||
`xvfb-run -a python3 /app/run_scenario.py`. Сценарий читает цель из
|
||||
`/app/plan.json`, сохраняет PNG до и после клика, а также
|
||||
`/app/result.json` со следом действий и решением `allow`, `later` или
|
||||
`deny`.
|
||||
@@ -0,0 +1,14 @@
|
||||
schema_version = "1.4"
|
||||
|
||||
[metadata]
|
||||
title = "app-decision"
|
||||
environment = "app"
|
||||
|
||||
[verifier]
|
||||
timeout_sec = 300.0
|
||||
|
||||
[agent]
|
||||
timeout_sec = 300.0
|
||||
|
||||
[environment]
|
||||
build_timeout_sec = 1800.0
|
||||
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
# Судит решение и доказательства настоящего computer-use прогона.
|
||||
mkdir -p /logs/verifier/screenshots
|
||||
cp /app/result.json /logs/verifier/result.json 2>/dev/null || true
|
||||
cp /app/screenshots/before.png /app/screenshots/after.png /logs/verifier/screenshots/ 2>/dev/null || true
|
||||
python3 - <<'PY'
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
OPTIONS = ("allow", "later", "deny")
|
||||
PNG = b"\x89PNG\r\n\x1a\n"
|
||||
|
||||
reward = 0
|
||||
try:
|
||||
result = json.loads(Path("/app/result.json").read_text("utf-8"))
|
||||
actions = result["actions"]
|
||||
decision = result["decision"]
|
||||
shots = [a.get("target") for a in actions if a.get("type") == "screenshot"]
|
||||
clicks = [a for a in actions if a.get("type") == "click"]
|
||||
images = [
|
||||
(Path("/app/screenshots") / name).read_bytes()
|
||||
for name in ("before.png", "after.png")
|
||||
]
|
||||
valid = (
|
||||
decision in OPTIONS
|
||||
and isinstance(actions, list)
|
||||
and len(actions) >= 4
|
||||
and actions[0] == {"type": "open", "target": "notification-dialog"}
|
||||
and clicks
|
||||
and clicks[-1].get("target") == decision
|
||||
and shots == ["before.png", "after.png"]
|
||||
and all(len(image) > 1000 and image.startswith(PNG) for image in images)
|
||||
and images[0] != images[1]
|
||||
)
|
||||
reward = int(valid)
|
||||
except Exception:
|
||||
reward = 0
|
||||
Path("/logs/verifier/reward.txt").write_text(str(reward))
|
||||
PY
|
||||
Reference in New Issue
Block a user