Files
goclaw/pkg/browser/roles.go
T
Viet Tran f3f4c67b36 Initial commit: GoClaw AI agent gateway
Multi-agent AI gateway with WebSocket RPC, HTTP API, and messaging channel integrations.
Go port of OpenClaw with multi-tenant PostgreSQL, per-user isolation, security hardening,
and production observability.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 14:58:07 +07:00

80 lines
2.1 KiB
Go

package browser
// Role sets ported from OpenClaw TS pw-role-snapshot.ts:26-78.
// Used to determine which AX tree nodes get ref assignments.
// interactiveRoles are elements users can interact with.
// These always get a ref in snapshots.
var interactiveRoles = map[string]bool{
"button": true,
"link": true,
"textbox": true,
"checkbox": true,
"radio": true,
"combobox": true,
"listbox": true,
"menuitem": true,
"menuitemcheckbox": true,
"menuitemradio": true,
"option": true,
"searchbox": true,
"slider": true,
"spinbutton": true,
"switch": true,
"tab": true,
"treeitem": true,
}
// contentRoles are meaningful content elements.
// These get a ref only when they have a name.
var contentRoles = map[string]bool{
"heading": true,
"cell": true,
"gridcell": true,
"columnheader": true,
"rowheader": true,
"listitem": true,
"article": true,
"region": true,
"main": true,
"navigation": true,
}
// structuralRoles are layout/grouping elements.
// These never get refs. In compact mode, unnamed ones are removed.
var structuralRoles = map[string]bool{
"generic": true,
"group": true,
"list": true,
"table": true,
"row": true,
"rowgroup": true,
"grid": true,
"treegrid": true,
"menu": true,
"menubar": true,
"toolbar": true,
"tablist": true,
"tree": true,
"directory": true,
"document": true,
"application": true,
"presentation": true,
"none": true,
}
// IsInteractive returns true if the role represents an interactive element.
func IsInteractive(role string) bool {
return interactiveRoles[role]
}
// IsContent returns true if the role represents a content element.
func IsContent(role string) bool {
return contentRoles[role]
}
// IsStructural returns true if the role represents a structural element.
func IsStructural(role string) bool {
return structuralRoles[role]
}