Repository navigation
feat(computer-use): accessibility-tree tools, fully cgo-free - #1086
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.
|
Docs follow-up filed: inference-gateway/docs#581 ([DOCS] cgo-free computer-use build + accessibility-tree tools). |
Replace the macOS cgo/Objective-C surface with cgo-free equivalents so the whole CLI cross-compiles with CGO_ENABLED=0 on darwin, linux and windows from a single host. - Accessibility tree (GetUIElements/PressUIElement) walks AXUIElement via purego (dlopen + purego/objc) instead of the cgo backend. - App focus (list/frontmost/activate), screen capture and input run on robotgo's cgo-free backend (build tag mac), pinned to a main pseudo-version. Application IDs are now pid:<N> on every platform. - Accessibility-permission check uses purego AXIsProcessTrusted. - Clipboard text uses robotgo's exec-based clipboard subpackage; image paste shells out to the platform clipboard tool (osascript, wl-paste/ xclip, PowerShell). Image clipboard writes are dropped. - Drop golang.design/x/clipboard and x11 dependencies. Reconcile the build around one mechanism: CGO_ENABLED=0 wherever a binary is produced (Taskfile build/install, CI build jobs, release, flake) with -tags mac only where a darwin binary is built. Test jobs keep the default cgo toolchain, which the race detector requires; the flox dev shell no longer pins CGO_ENABLED at all.
8699bc5 to
88f2787
Compare
|
@infer Can you review this PR? is it ready for merge? use /ponytail:ponytail /ponytail:ponytail-review /go /go-concurrency |
|
Model: Todos
Pull Request✅ Infer Result: SuccessReview: PR #1086 — feat(cgo-free-computer-use)Git log: 3 commits (c959b92, db19577, 88f2787). Files changed: 37, +1447/−359. Correctness & Architecturecgo-free approach is sound. AX tree walking ( Config backfill ( Graceful degradation: Both Go idioms (per the Go skill): error sentinel values with Concurrency (per the go-concurrency skill): Build system reconciliation: Ponytail Over-Engineering ReviewPer
Net result: Edge Cases & Potential Issues (not blocking merge)
VerdictReady for merge. The cgo-free approach is correctly implemented — purego dlopen, CF release discipline, autorelease pools, graceful degradation, consistent build system. The AX tools are well-structured, the tests cover the important paths, and the config backfill fix prevents silent regressions for existing users. The three edge cases above (full process table, WeakActivePID, image clipboard no-op) are design trade-offs explicitly acknowledged in the PR description and comments, not bugs.
Model: Tokens: 1,077,680 in · 7,550 out · 1,085,230 total (15 requests) Tool calls: 37 total · 100% success rate TracesStatsTriggered by edenreich · Infer Action · OSS |
|
🎉 This PR is included in version 0.178.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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=0on 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
dlopen+purego/objc) walking AXUIElement-tags mac)AXIsProcessTrusted(cgo)AXIsProcessTrustedgolang.design/x/clipboard(cgo, text + image)Dependencies
mainpseudo-version.golang.design/x/clipboardandgolang.design/x/x11.Build / CI reconciliation
One mechanism across Taskfile, CI and the flake:
CGO_ENABLED=0everywhere.-tags maconly where a darwin binary is produced — robotgo is imported on darwin only, so the tag is unnecessary for linux/windows. TaskfileGOTAGS, CIbuild-macos, the release darwin step, and the flake all follow this.GOFLAGS, no cross-build tag clearing.Behavior changes
pid:<N>on every platform (was the bundle ID on macOS).ActivateAppacceptspid:<N>or a name substring.Verification
CGO_ENABLED=0build + 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.Docs
Public-surface change (new tools + cgo-free build); a
[DOCS]follow-up forinference-gateway/docsis warranted.