feat(agent): read computed styles in project tools
LE
3d ago+694+694+012345678901234567890123456789-17-17-01234567890123456789
What and why
- A read-only project tool can measure computed CSS on a listed node, such as whether an error is red, through
getToolContext(options).read({ id }, { style }). - Only allow-listed properties of a node in the newest observation are read. Reads share the operation queue and step deadline, return secret-redacted values, and are denied to
mutates: truetools. ctx.readthrows the same agent codes asctx.observeandctx.actions: a detached or unlisted node isLOCATOR_NOT_FOUND, an engine withoutreadStyleisPOLICY_DENIED.- Engines get an optional
readStyle(ref, properties, context)member,engine/readStyleover JSON-RPC, and thecomputed-stylecapability. Web implements it; mobile does not. SPI and protocol versions stay 1. e2e/engineexportsCOMPUTED_STYLE_PROPERTIESandvalidateComputedStyleProperties(properties).@e2e-dev/webcalls the validator, so itse2epeer floor is0.23.2.
const context = getToolContext(executionOptions);
await context.observe();
const { style } = await context.read({ id: nodeId }, {
style: ['color', 'font-weight', 'visibility', 'opacity'],
});
flowchart LR
Tool[Read-only project tool] --> ID[Node in newest observation]
ID --> RPC[engine/readStyle]
RPC --> CSS[getComputedStyle]
CSS --> Redact[Redact values]
Redact --> Tool
Issue
Fixes #1228
Verified
Ran it locally: yes
- Testbed, built CLI, scratch config with a scripted model and two project tools:
e2e run --config e2e.style-scratch.config.ts --video --reporter list,markdown. The test signs in with bad credentials on/login, styles the alert, and the read-only tool measures it.
| main | this branch |
|---|---|
context.read is not a function | rgb(255, 0, 0), 700, and <secret:tone> for the opacity that matches a configured secret |
✓ reads computed style through a project tool > agent.act "measure the error style and prove mutating reads are denied" 223ms · 3 model calls
✓ |web| tests-style-scratch/style.e2e.ts (1 test) 678ms ai 6 tokens
Test Files 1 passed (1)
What the tools saw in that run:
{
"measured": { "style": { "color": "rgb(255, 0, 0)", "font-weight": "700", "opacity": "<secret:tone>" } },
"unknownNode": "LOCATOR_NOT_FOUND",
"badProperty": "INVALID_ARGUMENT",
"mutatingRead": "POLICY_DENIED"
}
grep -rfor the secret value under.e2e/finds nothing.- Testbed suite on the built CLI: 588 passed, 1 skipped.
- Not run at this head: the web benchmark and the live agent suites. The video stays local, the installed
ghhas no--attach.