mirror of
https://github.com/vercel-labs/agent-browser.git
synced 2026-11-24 03:35:59 +08:00
* fix(interaction): refuse fill, type, check, uncheck and select on preconditions fill, type, check, uncheck and select reported success without checking the target. The target's own properties now decide, before anything changes: - Refuse with stable codes: not_editable, read_only, disabled, not_checkable, option_not_found, ambiguous, malformed_value. - fill sets date, time, color and range inputs directly and rejects values the input would sanitize away. - check and uncheck return when the state already matches, refuse non-toggle elements, a checked radio and disabled controls, and retry with a DOM click for native inputs only. - select takes a unique exact label, then a unique exact value, otherwise ambiguous; options sharing a value are one choice; several values on a non-multiple select are refused first; multiselect shares the checks. - Whether the page ended up as requested is a warning shown in text and JSON output, not an error. - type with only newline, carriage return and tab keeps the key dispatch. Text insertion and clearing are unchanged. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): narrow refusals to never-text elements, tolerate failed reads, select --by - fill and type refuse only elements that can never take text (select, button, checkbox, radio, file, submit and reset inputs, and color, range and date-type inputs for type); where text lands for everything else is unchanged. A label stands for its control. - A failed read after the action (context destroyed, page navigated) is a warning, not an error, and a probe that cannot inspect the element lets the action proceed. - select: a string that matches exactly one option by value or exact label selects it; matching options with different values, across kinds or by shared label, is ambiguous. --by value|label (and a by field in MCP) restricts matching so every option is reachable. Several values on a single select are not_multiple. - Option and treeitem state comes from aria-selected, role tokens are parsed, line endings are normalized before comparing, and the form warning is carried in its own data key. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): snap range values to the step, point type at fill - fill on a range input inside its bounds sets the value the browser snaps to and warns with the requested and held values; unparsable and out-of-range values stay malformed_value. - The refusal hint for type on color, range and date-type inputs says to use fill to set the value of the input. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): select takes dash-leading values, buttons behave as before - select treats only --by <v>, --by=<v> and a leading -- as special; values such as "-- Select --" or "-none-" are data, as in the type parser. A repeated --by is rejected. - fill and type no longer refuse button, submit, reset and button inputs: whether text reaches a field through them depends on focus. - A read that fails because the page navigated reports "page navigated after the action; result not verified". - The ambiguous error advises the by field over MCP and the --by flag in the listbox path; the select synopsis in the docs lists --by. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): type no longer refuses readonly inputs type does not clear the field, so a readonly input is left to the page as before (a trigger may forward focus to another field); fill still refuses it because it would empty the value. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): form warnings never echo field values; option labels are the browser's labels - A fill whose value the page rewrote reports the change by length (length 10 -> 14) or as a different value of the same length; the snapped-range warning, the malformed_value error and the could-not-verify warning no longer repeat a value or a raw error. - An option's label is option.label, the text the browser shows. select matches it by default and with --by label, and no longer matches the hidden text of an option that has a label override, which removes false ambiguity. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): type --clear is refused on readonly fields Any step that destroys a field's value is refused on a readonly field, not only fill: type --clear empties the value before the browser drops the text. A plain type does not clear, so it keeps its behavior. The type help, docs, MCP description and skill text say so. Co-Authored-By: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-Authored-By: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-Authored-By: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com> * fix(interaction): fill and type act on one resolved control, refuse non-text targets and report altered text Labels and date parts resolve to their control once, and focus, clear, insert and read-back all use it. Options and hidden, image, button, submit and reset inputs are refused with the other targets that never take text, from one table. type compares the read-back with the prior value plus the typed text and warns on a maxlength cut or a mask rewrite. Errors and warnings name the target from the caller's selector and a fixed tag and input-type vocabulary; ids, tag names and option labels from the page are never included. * docs: describe refused targets and ambiguous select results * fix(interaction): scrub page strings from select errors, refuse buttons and controlless labels, warn only when typed text is missing * fix(interaction): page text never reaches form errors, refuse targets that take no focus, report maxlength cuts and replace editable content The precheck, select and value-input failures return a kind or a number and the message is built in Rust, so nothing a page returns is repeated in an error. fill and type refuse a target that neither takes focus nor forwards it to another field, walking open and closed shadow roots. type warns when the old value plus the typed text exceeds maxlength and the field is full, even when the old value already contains the typed text. fill replaces the content of an editable region instead of appending. * fix(interaction): refuse by focusability, not by focus movement; keys-only text skips the focus guard A focusable target whose focus handler forwards to the already-focused field is a valid typing path. The guard now refuses only a target that cannot take focus and where focus did not land. Key-only text goes to the focused control as before. * fix(daemon): box fill/type futures and isolate the har_stop test env The fill and type futures grew the execute_command frame past a debug test thread's stack. The har_stop test built its state without the env lock, so an action policy path set by another test leaked into it. * fix(interaction): guard on an observed focus signal instead of tabIndex A hidden, display:none or inert input has tabIndex 0 but cannot take focus. The guard now allows a target that received focus or a focus event during focus() and refuses otherwise. * fix(interaction): count only trusted focus events in the focus guard A page could override focus() to dispatch a synthetic focus event and pass the guard, sending text to the field that already had focus. * fix(interaction): clear editable regions in their own document, return select options as error data, measure maxlength after focus selection - fill and type --clear select and delete an editable region through its ownerDocument, so a region inside a same-origin iframe is replaced instead of prepended to. - select no-match errors keep fixed text with the option count; the options go to data.options as [{value, label}], printed inside content boundaries by the CLI. - the maxlength check subtracts the text selected after focus, so a field that selects on focus does not report a cut that did not happen. * fix(form): treat input and textarea as text controls inside a contenteditable ancestor isContentEditable is inherited by form controls, so fill deleted a textarea and the read-back used innerText. One helper classifies by tag first; only a non-control element with isContentEditable is an editor. * fix(mcp): pass select's by mode after the selector The select parser reads its first argument as the selector, so --by placed before it became the selector. MCP now builds select -- <selector> [--by <mode>] -- <values>. * fix(select): refuse an empty value list and keep option data out of the MCP advice rewrite An empty list matched nothing but cleared the selection. The by-field rewrite now touches only the error message, so option labels in the response data stay as the page wrote them. * fix(interaction): refuse clearing a field that turns readonly on focus The readonly check ran before focus, so a field whose focus handler sets readOnly passed it, and the clear step then emptied the value. fill and type --clear now check again at the clear step and refuse with read_only, keeping the value. * fix: accept every css color chrome accepts when filling a color input * fix: update the mcp tool catalog for color fill * fix(interaction): check stored color, controls in editors, and normalized range values A color input that stores a color other than the one requested, such as black for red on a browser that accepts only #rrggbb, now fails with malformed_value and keeps its previous value. A select, option, or button inside an editable region is refused like it is anywhere else instead of being replaced by the text, unless it is itself an editing host. Range and other value inputs are compared with the value the browser stored, so 50.0 stored as 50 no longer warns. --------- Co-authored-by: FredAmartey <43480311+FredAmartey@users.noreply.github.com> Co-authored-by: dwin-gharibi <20875684+dwin-gharibi@users.noreply.github.com> Co-authored-by: HoneyTyagii <78690656+HoneyTyagii@users.noreply.github.com>