Repository navigation
Conversation
…IElement Adds an AXProvider interface to internal/display (mirroring the existing provider registry pattern) with a macOS AXUIElement backend, and two new computer-use tools: - GetUIElements walks the accessibility tree of the frontmost app, the Dock, or the menu bar and returns pressable elements (role, title, bbox) mapped into the GetLatestFrame frame space, so centers feed straight into MouseClick. Read-only: no cursor movement, no screen lock, usable by background sessions. - PressUIElement invokes an element's default press action by title without moving the cursor; it takes the screen lock and requires approval under computer_use.approval: destructive. No provider registered (non-macOS), missing TCC permission, or an empty tree degrade to a message steering the model to the GetLatestFrame vision pipeline - never a hard failure. Linux AT-SPI2 and Windows UIA backends can register behind the same interface later. Closes #998
…use.yaml files computer_use.yaml was decoded into a zero struct, so tool sections added after a user's file was seeded loaded as enabled: false - GetUIElements and PressUIElement were silently absent from the toolset. LoadComputerUse now decodes the file over the in-code defaults (LoadYAMLMerged), so missing sections keep their defaults. Also steer the model to the accessibility tree first: MouseMove, MouseClick, and GetLatestFrame descriptions now name GetUIElements as the preferred way to locate elements, with GetLatestFrame as fallback.
Contributor
Author
|
Superseded by #1086 — same GetUIElements/PressUIElement tools, rewritten fully cgo-free (purego + robotgo cgo-free backend). Closing to avoid duplicates. |
edenreich
added a commit
that referenced
this pull request
Aug 20, 2026
Supersedes #1085 — delivers the same accessibility-tree tools, rewritten to be **fully cgo-free**. ## What The macOS computer-use layer no longer needs cgo. The whole CLI now cross-compiles with `CGO_ENABLED=0` on darwin, linux and windows from a single host. ### Tools (unchanged public surface) - `GetUIElements` — lists pressable accessibility elements (`frontmost`, `dock`, `menubar`). - `PressUIElement` — presses an element by title without moving the cursor. ### cgo → cgo-free | Area | Before | After | |------|--------|-------| | AX tree | cgo / Objective-C | purego (`dlopen` + `purego/objc`) walking AXUIElement | | App focus (list / frontmost / activate) | NSWorkspace via cgo | robotgo cgo-free backend (`-tags mac`) | | Screen capture + input | robotgo (cgo) | robotgo cgo-free backend | | Accessibility permission | `AXIsProcessTrusted` (cgo) | purego `AXIsProcessTrusted` | | Clipboard | `golang.design/x/clipboard` (cgo, text + image) | robotgo clipboard subpackage (exec, text only) | ### Dependencies - robotgo pinned to a cgo-free `main` pseudo-version. - Removed `golang.design/x/clipboard` and `golang.design/x/x11`. ## Build / CI reconciliation One mechanism across Taskfile, CI and the flake: - `CGO_ENABLED=0` everywhere. - `-tags mac` **only** where a darwin binary is produced — robotgo is imported on darwin only, so the tag is unnecessary for linux/windows. Taskfile `GOTAGS`, CI `build-macos`, the release darwin step, and the flake all follow this. - No global `GOFLAGS`, no cross-build tag clearing. ## Behavior changes - Application IDs are now `pid:<N>` on every platform (was the bundle ID on macOS). `ActivateApp` accepts `pid:<N>` or a name substring. - Image clipboard is dropped — text copy/paste only. ## Verification - `CGO_ENABLED=0` build + cross-compile for linux/amd64, windows/amd64, darwin/arm64 — all green. - `task build`, `task test` (`-tags mac`), `task precommit:run` (lint: 0 issues) — green on darwin. - Linux X11/Wayland runtime paths are compile-verified only (no Linux host available). ## Docs Public-surface change (new tools + cgo-free build); a `[DOCS]` follow-up for `inference-gateway/docs` is warranted.
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.
Closes #998 (macOS phase).
What
Two new computer-use tools backed by the platform accessibility tree, behind a new
display.AXProviderinterface that mirrors the existinginternal/displayprovider-registry pattern:frontmost(default),dock, ormenubarand returns pressable elements (role, title, bbox) rendered through the samedomain.AnnotationTextshape as annotated frames. Coordinates are mapped into theGetLatestFrameframe space viaFitDims, so an element center feeds straight intoMouseClick. Read-only: no cursor movement and no screen lock, so background sessions can use it for non-invasive inspection.computer_use.approval: destructive.macOS backend
internal/display/macos/ax_darwin.go(cgo/ObjC, following theclient_darwin.goconventions):AXUIElementCreateApplication+ recursiveAXChildrenwalk, keeping elements that supportkAXPressActionand have a title (AXTitle, fallbackAXDescription). Dock resolves via thecom.apple.dockapp (AXList → AXDockItems); menubar walks the frontmost app'sAXMenuBarone level deep (menu titles only — pressing one opens the menu, thenGetUIElements(frontmost)sees the items; documented in the tool description). Caps: depth 8, 200 elements.Degradation
Never a hard failure: no registered provider (Linux/Windows today), missing Accessibility (TCC) permission, or an app exposing an empty tree all return a clear message steering the model to the
GetLatestFrame+ region-zoom vision pipeline. Linux AT-SPI2 and Windows UIA backends can register behind the same interface in follow-ups.Verified
task precommit:rungreen; fullgo test ./...green.GetUIElements(dock)returned 31 dock items in frame space (1024x665),GetUIElements(menubar)the frontmost app's menu titles,GetUIElements(frontmost)Chrome's buttons;PressUIElement("Finder", dock)opened Finder with zero cursor movement.TestAXProviderListDock) skips cleanly when the permission is absent (CI-safe); parse/scale/validate logic is covered cross-platform.