input

package
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 27, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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.
View Source
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 Click

func Click(ctx context.Context, req ClickRequest) error

func DecideTypeTextRoute

func DecideTypeTextRoute(text string, imeActive bool) (route, reason string)

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 Drag

func Drag(ctx context.Context, req DragRequest) error

func Move

func Move(ctx context.Context, point contract.Point) error

func PressKey

func PressKey(ctx context.Context, chord string) error

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.

func Scroll

func Scroll(ctx context.Context, req ScrollRequest) error

func TypeText

func TypeText(ctx context.Context, text string) error

TypeText is the legacy entry point. It defaults to auto routing and discards the rich result. New callers should prefer TypeTextWith.

Types

type ClickRequest

type ClickRequest struct {
	Point  contract.Point `json:"point"`
	Button string         `json:"button,omitempty" jsonschema:"left, middle, right"`
	Count  int            `json:"count,omitempty"`
}

type DragRequest

type DragRequest struct {
	From       contract.Point `json:"from"`
	To         contract.Point `json:"to"`
	Button     string         `json:"button,omitempty"`
	DurationMS int            `json:"duration_ms,omitempty"`
}

type ScrollRequest

type ScrollRequest struct {
	Point     contract.Point `json:"point"`
	Direction string         `json:"direction" jsonschema:"up, down, left, right"`
	Amount    int            `json:"amount,omitempty"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL