"""Mind2Web -> labelled System One requests shaped exactly like jev-ultrafast's per-step request. One Mind2Web action step becomes one request: state {page: {url, title, text}, elements: [...], recent_actions: [...]} questions operation (CLICK | TYPE_TEXT | SELECT | SCROLL_* | WAIT | DONE | BLOCKED) + the gold operation's target labels {"operation": , "_target": } Splits are by website, so dev/test measure transfer to sites never seen in training. Mind2Web's official test sets are distributed separately to prevent leakage and are not used here. Known gap: Mind2Web has no DONE / WAIT / SCROLL / BLOCKED steps. They are offered as options, as in real requests, but a model trained only on this data never sees them as the answer. """ import argparse import hashlib import json import random import re from bisect import bisect_left from collections import Counter from pathlib import Path from lxml import etree from .prompts import (CONTROL_LABELS, HISTORY_STEPS, NEXT_ACTION, OPERATION_LABELS, PAGE_TEXT_CHARS, TARGET, TERMINAL_LABELS) OP_MAP = {"CLICK": "CLICK", "HOVER": "CLICK", "ENTER": "CLICK", "TYPE": "TYPE_TEXT", "SELECT": "SELECT"} KIND = {"CLICK": "click", "TYPE_TEXT": "fill", "SELECT": "select"} INTERACTIVE_TAGS = {"a", "button", "input", "select", "textarea", "option", "label", "summary"} INTERACTIVE_ROLES = {"button", "link", "textbox", "searchbox", "combobox", "checkbox", "radio", "option", "tab", "menuitem", "switch"} TEXT_INPUT_TYPES = {"", "text", "search", "email", "tel", "url", "number", "password", "date", "datetime-local", "month", "week", "time"} ROLE_BY_TAG = {"a": "link", "button": "button", "select": "combobox", "textarea": "textbox", "option": "option", "img": "img", "svg": "img", "summary": "button", "label": "label"} LABEL_CHARS = 100 MAX_SELECT_OPTIONS = 60 # the API caps a question at 255 options; some Mind2Web dropdowns have over 1,000 REPR = re.compile(r"^\[(?P[^\]]*)\]\s*(?P