Documentation
¶
Index ¶
- Constants
- func Click(ctx context.Context, req ClickRequest) error
- func DecideTypeTextRoute(text string, imeActive bool) (route, reason string)
- func Drag(ctx context.Context, req DragRequest) error
- func Move(ctx context.Context, point contract.Point) error
- func PressKey(ctx context.Context, chord string) error
- func ResolveContextFor(ctx context.Context, points ...contract.Point) (contract.ResolveContext, error)
- func Scroll(ctx context.Context, req ScrollRequest) error
- func TypeText(ctx context.Context, text string) error
- type ClickRequest
- type DragRequest
- type ScrollRequest
- type TypeTextRequest
- type TypeTextResult
Constants ¶
const ( TypeTextViaAuto = "auto" TypeTextViaXTest = "xtest" TypeTextViaPaste = "paste" )
TypeTextVia enumerates the routing modes for TypeText.
- "auto" (default): if len(text) > 64 OR text contains non-ASCII OR text contains control chars → "paste"; else "xtest". If an IME is active "paste" is forced regardless of length.
- "xtest": layout-aware XTest keystroke injection. Refuses chars not reachable from the active XKB layout with INPUT_LAYOUT_UNREACHABLE. Rejected with INPUT_IME_ACTIVE when an IME is detected.
- "paste": save current CLIPBOARD → write text → ctrl+v → restore. Surfaces clipboard_restored:bool in the result.
const ( TypeTextReasonIMEActive = "ime-active" TypeTextReasonLengthGt64 = "len>64" TypeTextReasonNonASCII = "non-ascii" TypeTextReasonControl = "control-char" TypeTextReasonShortASCII = "short-ascii" )
Route-reason tags surfaced by DecideTypeTextRoute. Stable strings — agents may compare these literally when previewing a type_text via dry-run. Keep in sync with the documented values in conventions.yaml.
Variables ¶
This section is empty.
Functions ¶
func DecideTypeTextRoute ¶
DecideTypeTextRoute is the pure, read-only via-decision used by the auto policy. It returns the concrete route ("xtest" | "paste") and a stable reason tag explaining why. Used by:
- TypeTextWith's auto branch (real execution path).
- The pipeline dry-run preview, which calls this to surface details.via + details.route_reason without performing XTest / paste side effects.
Auto policy (FIXED — pinned by tests):
IME active → paste, "ime-active" len(text) > 64 → paste, "len>64" contains non-ASCII (r > 0x7e) → paste, "non-ascii" contains control char other than \n,\t → paste, "control-char" otherwise → xtest, "short-ascii"
func ResolveContextFor ¶
func ResolveContextFor(ctx context.Context, points ...contract.Point) (contract.ResolveContext, error)
ResolveContextFor builds a ResolveContext populated for the spaces the given Points actually use. We only spend the round-trip cost on window/monitor lists when at least one point requires it. Every coordinate-space conversion still routes through contract.Resolve — this helper just supplies the ambient inputs Resolve needs.
Exported so the pipeline dry-run path can hydrate a ResolveContext without going through a mutating Move/Click call. The unexported alias resolveContextFor is retained for in-package callers.
Types ¶
type ClickRequest ¶
type DragRequest ¶
type ScrollRequest ¶
type TypeTextRequest ¶
type TypeTextRequest struct {
Text string `json:"text"`
Via string `json:"via,omitempty" jsonschema:"xtest, paste, or auto (default auto)"`
}
TypeTextRequest is the structured input for the upgraded TypeText. Empty Via is treated as "auto". A zero-value request types empty string, which is a no-op.
type TypeTextResult ¶
type TypeTextResult struct {
Via string `json:"via"`
ClipboardRestored bool `json:"clipboard_restored,omitempty"`
IMEActive bool `json:"ime_active,omitempty"`
IMEEngine string `json:"ime_engine,omitempty"`
}
TypeTextResult surfaces the chosen route plus paste-route bookkeeping.
func TypeTextWith ¶
func TypeTextWith(ctx context.Context, req TypeTextRequest) (TypeTextResult, error)
TypeTextWith is the v0.2 entry point with explicit via routing.
auto policy is FIXED and documented here verbatim:
len(text) > 64 OR contains non-ASCII OR contains control chars → paste else → xtest
When an IME is active, "auto" always routes through paste regardless of length. "xtest" with an active IME is rejected with INPUT_IME_ACTIVE; "paste" is always allowed.