Skip to main content

teksilo_automation/
lib.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! # teksilo-automation
5//!
6//! GUI-free runtime-introspection & automation toolkit for Teksilo apps.
7//!
8//! A Teksilo app exposes a rich semantic surface — the AccessKit
9//! accessibility tree — plus an AT-action dispatch path, both of which are
10//! queryable and drivable **in-process, without the OS accessibility
11//! layer**. This crate turns that latent capability into a small set of
12//! serde DTOs plus one core function, [`execute`], that an MCP server (or
13//! any other harness) marshals operations to.
14//!
15//! ```text
16//! execute(tree: &mut WidgetTree, ops: &mut dyn WindowOps,
17//!         op: &AutomationOp, settle: &SettleSpec) -> AutomationReply
18//! ```
19//!
20//! The wire protocol is **serde DTOs, never closures or `!Send` handles**
21//! ([`dto`]). [`WidgetTree`](teksilo_core::WidgetTree) is `!Send`, so it
22//! lives on exactly one thread; async / socket layers marshal `Send` DTOs
23//! to it. Two operations need context [`execute`] doesn't hold —
24//! `list_windows` (the window manager) and `screenshot` (a GPU / platform
25//! window) — and return [`dto::codes::HOST_REQUIRED`]; the headless server
26//! and the live bridge serve those themselves. `live_image_stats` is half
27//! the host's: [`execute`] reports the source and the attachment, and the
28//! host adds its window's textures and wakes with [`with_window_stats`]; a
29//! screenshot's live pictures come from [`live_image_shots`].
30//!
31//! This crate has no GUI, render, platform, or async dependency. It mirrors
32//! `teksilo-data`'s "core-only peer" design so a CI harness, a headless
33//! test, or the live in-app bridge can all share it.
34//!
35//! ## Modules
36//! - [`client`] — finding the MCP client binary, and the install command
37//!   to name when it is absent.
38//! - [`dto`] — the serde wire protocol.
39//! - [`executor`] — [`execute`] and the settle model.
40//! - [`recording_ops`] — a non-panicking [`WindowOps`](teksilo_core::WindowOps)
41//!   for the headless server.
42//! - [`mcp_schema`] — the canonical tool catalog.
43//! - [`wire`] — the live-bridge framing, token handshake and endpoint
44//!   discovery, shared verbatim by the in-app bridge and the MCP client.
45
46pub mod client;
47pub mod dto;
48pub mod executor;
49pub mod mcp_schema;
50pub mod recording_ops;
51pub mod wire;
52
53pub use client::{CLIENT_BIN, CLIENT_VERSION, find_client, install_command};
54pub use dto::{
55    AnnouncementDto, Assertion, AssertionResult, AutomationOp, AutomationReply, AutomationRequest,
56    DensityDto, LayoutNode, LiveImageAttachmentStatsDto, LiveImageMapReply, LiveImageShot,
57    LiveImageSourceStatsDto, LiveImageStatsReply, LiveTextureStatsDto, LiveWakeStatsDto,
58    NodeBounds, NodeRef, PointerAction, PointerButtonDto, PointerKindDto, PointerReport,
59    ScreenshotMeta, SemanticNode, SequenceMemberDto, SettleSpec, ShortcutInfo, TouchPhaseDto,
60    TouchSequenceReport, TouchStep, TouchStepReport, WaitCondition, WindowInfo, codes,
61};
62pub use executor::{execute, live_image_shots, run_settle, with_window_stats};
63pub use mcp_schema::{TOOL_CATALOG, TOOL_COUNT, ToolDescriptor};
64pub use recording_ops::{RecordedWindow, RecordingWindowOps};
65pub use wire::{Endpoint, EndpointFile, Transport};
66
67#[cfg(test)]
68mod tests;