Files
cthulhu/docs/tentacle-automation.md
T

4.3 KiB
Raw Permalink Blame History

Opt-in application automation

This extension builds on application-bindings. Protocol 1.1 negotiates an additional automation API and install permission. It requires presentation, interaction and application bindings, but none of those permissions imply this new grant. Existing installations do not acquire automation authority. Older readers reject the unsupported API/permission during package validation.

An application command additionally declares automation: true. The host checks the declaration against the explicit install grant before activation. Returning an automation result from an ordinary interactive command grants no authority. The Go SDK exports Automation, AutomationAction and Command.Automation; Python uses the matching command flag and result dictionary.

Local development specs opt in with SessionEvents, ApplicationBindings, Presentation, Interaction, and Automation all true. Package manifests include commands, session-events, presentation, interaction, application-bindings and automation APIs, with presentation, interaction, and automation capabilities. Registry entries retain the automation grant across restart. Install confirmation names mouse/OCR control separately from forms/clipboard access.

A terminal interaction may return:

{"automation":{"actions":[{"kind":"move","x":5000,"y":5000},{"kind":"click","button":3,"modifier":"shift","milliseconds":20},{"kind":"delay","milliseconds":100},{"kind":"move","x":10000,"y":0}]},"done":true}

It cannot combine with forms, continuations, clipboard/source requests, reader settings, remote requests, protected speech, or background leases. Up to 16 actions are admitted, with at most 2,000 ms of aggregate requested waits and a five-second worker deadline. The Tentacle owns shortcut choices and explicit action timing.

Kind Fields Meaning
move x, y, each 0–10000 Move relative to the captured client rectangle, rounded and clamped inside it
click button: 1 or 3; optional modifier: shift or control; milliseconds: 0–1000 Click at the pointer, holding the button for the requested duration
drag x, y, each 0–10000; milliseconds: 0–1000 Left-button drag, waiting for the requested duration before and after motion
scroll nonzero steps: −100 to 100; milliseconds: 0–1000 Wheel up/down, waiting for the requested duration between steps
delay milliseconds: 1–1000 Cancellable wait
ocr-route none First action only: route to the current recognized word
ocr-dismiss none Retire OCR internally; send no Escape to the application
ocr-scan none Last action only: start a window OCR scan with an X server timestamp cutoff
tone none Optional reader feedback; playback failure does not block input

Unrelated fields are rejected. The reader captures the application window, foreground epoch and client bounds before invoking the child, checks them between effects, and uses the secure-input gate at every injected step. It waits for captured chord release before injecting. Physical keys (including modifiers still held after the captured keys release) or mouse buttons cause refusal. It retires the old OCR result before mouse effects.

OCR routing retains a private capture snapshot and checks fresh pixels after shortcut release, immediately before routing. Native focus and frozen bounds protect the following route-to-click interval; normal hover highlights do not invalidate the click. Missing, clipboard, changed or unmapped results are refused. No OCR text or native handles reach the child.

Waits belong to cancellable Go code. Native steps atomically check class, focus and geometry before input; no wait holds the X server or secure-input mutex. Cleanup releases every synthetic button/modifier after cancellation, focus changes, locks or errors. Process revocation cancels the joined interaction worker. Commands are declined while an interaction is occupied rather than queued indefinitely.

X11 is supported; native Wayland automation is unavailable. The API provides reader-owned lifecycle checks, not an account sandbox or application authentication. Live application behavior, audible feedback and physical input need acceptance separate from protocol and private-display tests.