Skip to content

feat(core): agent bridge at @once-ui-system/core/agent, with data-agent-* marks - #608

Closed
lorant-one wants to merge 3 commits into
feat/control-change-detailsfrom
feat/agent-bridge
Closed

lorant-one wants to merge 3 commits into
feat/control-change-detailsfrom
feat/agent-bridge

Conversation

@lorant-one

@lorant-one lorant-one commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

Requested by Lorant · project thread

This PR covers steps 2 and 3 of the agent-operable controls plan. It is stacked on #607 (change details) and targets that PR's branch. Once #607 merges, retarget it to preview.

What

A new @once-ui-system/core/agent entry exports createAgent(), which gives you:

  • snapshot(): every mounted control and page section, with its accessible name, its state and the actions it takes right now. Refs look like c3 and s1. The list is capped at 100 entries, and password values come back redacted.
  • act({ steps }): several changes in one call. Each step runs through the control's own change path inside withChangeSource("agent"), so onXChange sees details.source === "agent" and can call cancel(). A refused set is reported as an error. A step can name its control by ref or label, and a choice by its label or its value.
  • query(): a list's choices, 50 at a time, or the controls that match a text.
  • allow: an option that decides each step. agentTools describes the three tools as JSON Schema. registerTools() offers them through WebMCP (document.modelContext) where the browser supports it, and it requires an allow.

These controls register themselves: Input, Textarea, Select, Checkbox, Switch, RadioGroup, Slider (single thumb), SegmentedControl, Tabs, Button and ThemeProvider (as the theme). A composite control such as Select speaks for its inner field through AgentOwnedContext.

Marks (step 3)

Each mark applies to the element that carries it and to everything inside it.

  • data-agent-hidden: the control or region is left out of the bridge entirely.
  • data-agent-secret: an agent can write the field but can't read it. Values, choices and changes come back as [redacted].
  • data-agent-confirm="Deletes the project": the entry and the allow request both carry confirm, so the app can ask a person first. If the app set no allow, the step is refused.

Checks

  • agent-bridge.test.tsx has 9 tests. One of them changes every setting on a settings page in a single act call.
  • The full core suite passes (4,919 tests). tsc is clean, and the lint gate is at its baseline of 112.

Follow-ups

  • Adapters for Combobox, DatePicker, TagInput and RangeSlider.
  • Change subscriptions.

🤖 Generated with Claude Code

https://claude.ai/code/session_016gNJtyAjxtXFsms7HWCd1w

createAgent() gives snapshot, act and query over every mounted control and
page section. Steps run through each control's own change path inside
withChangeSource("agent"), so onXChange callbacks hear the source and can
cancel; a canceled or ignored set is reported as declined. An allow callback
decides each step. agentTools describes the tools as JSON Schema and
registerTools() offers them over WebMCP with a required allow.

Input, Textarea, Select, Checkbox, Switch, RadioGroup, Slider,
SegmentedControl, Tabs, Button and ThemeProvider register themselves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyAjxtXFsms7HWCd1w
hidden keeps a control or region out of the bridge; secret redacts its
values, choices and changes while still letting an agent write it; confirm
puts the mark's text on the entry and on the allow request, and refuses the
step when the app gave no allow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyAjxtXFsms7HWCd1w
@lorant-one lorant-one changed the title feat(core): agent bridge at @once-ui-system/core/agent feat(core): agent bridge at @once-ui-system/core/agent, with data-agent-* marks Nov 25, 2026

Copy link
Copy Markdown
Member Author

The Compare check flagged a single shot: blocks_streaming@1280__tile02, the hero image in the Streaming1 Carousel, with 19.7% of its pixels changed.

I couldn't reproduce it. I built the docs locally from this branch and from its base (feat/control-change-details) and captured /blocks/streaming with scripts/visual/capture.mjs. All four 1280 px tiles came out pixel-identical (0 px changed), tile02 included. Nothing in this PR touches Carousel or Media.

I've re-run the visual workflow once. If it still fails, I'll pull the artifact and dig into the image itself.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants