Repository navigation
feat(widget): add opt-in built-in DOM page actions - #23
Merged
Merged
Conversation
Pages can let the agent operate their DOM without writing handlers. With domActions (or data-dom-actions="true" on the CDN script) the widget offers page.snapshot, page.scroll, page.click and page.fill. Snapshot refs are tied to a generation and stale refs are refused; password, card and one-time-code fields, hidden elements, [data-dewee-ignore] and the widget are never listed or touched. click and fill always need the visitor's approval, and the dialog names the target element. fill uses the native value setter so React and Vue controlled inputs see the change. Host actions with the same name win, and domActionsRoot limits where the agent may act. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The agent could
navigatea host page but could not scroll, click or type. The widget ships no DOM actions: it only runs the actions a host registers in JS, and the examples register justnavigate. Calls toscroll/click/fillcame back asUnknown action "click". Available: navigate, and CDN-only hosts (data-*attributes) could not register any action at all.What
Opt-in built-in page actions, off by default:
domActions(JS, React, Vue) ordata-dom-actions="true"on the CDN script;domActionsRoot/data-dom-actions-rootlimits where the agent may act.page.snapshot(read): visible links, buttons and fields ase3 textbox "Email" value="…"lines, with ageneration; supportsquery,offset,limit.page.scroll(read): one screen up/down, top/bottom, or a ref into view.page.click,page.fill(mutate): always need the visitor's approval; the dialog (and a hostconfirmhook, asargs.target) names the element, e.g.button "Increment".autocomplete, name hints), hidden elements,[data-dewee-ignore]subtrees and the widget itself.page.fillsets the value through the prototype setter and firesinput+change, so React/Vue controlled inputs update; handles textarea, select (value or label) and contenteditable.Docs: README "Built-in DOM actions" section and options table,
docs/http-contract.mdtable of names, args and results.Verification
pnpm -r test: 18 files passed, 253 tests (PHP parity suites skipped as before, no PHP locally). Newtest/dom-actions.test.ts(11 tests) and 3 widget cases intest/widget-page-actions.test.ts.pnpm typecheck,pnpm -r build(all examples),pnpm test:bundlers: pass.data-dom-actions="true", a React 18 controlled input and a stubbed backend. Snapshot skipped the password field; scroll reached the bottom; Allow on the real dialog ran the click (counter 0 → 1) and the fill (React state became "Dewee",onChangefired); results came backstatus: ok.Not verified: a real agent on the gateway choosing these actions from the manifest, and the react-vite example against a live backend.
🤖 Generated with Claude Code