Expand description
smix-sdk — user-facing public surface for the smix Rust library.
Wraps SimctlDriver + SimctlClient + HttpRunnerClient with
an ergonomic Rust API.
use smix_sdk::{App, text};
use std::time::Duration;
let app = App::connect_to_runner(22087).await?;
app.launch("com.example.app").await?;
app.wait_for(&text("Login"), Duration::from_secs(5)).await?;
app.tap(&text("Login")).await?;
app.fill(&text("Email"), "user@example.com").await?;
app.press_key(smix_sdk::KeyName::Return).await?;Re-exports§
pub use issued_ledger::IssuedAction;pub use issued_ledger::IssuedKind;pub use issued_ledger::IssuedLedger;pub use device_control::DeviceControl;pub use device_control::Permission;pub use ios_device::IosDeviceControl;pub use android_device::AndroidDeviceControl;pub use capsule::CapsuleReconciliation;pub use capsule::DEFAULT_RECONCILE_WINDOW_MS;pub use capsule::FOCUS_CHANGE_RAW_CODE;pub use capsule::reconcile;
Modules§
- android_
device - Android
DeviceControlimpl backed bysmix_adb::AdbClient. - capsule
- Capsule reconciliation (pure function).
- device_
control - v6.0 c1b —
DeviceControltrait: cross-platform sim/host control. - ios_
device - v6.0 c1b — iOS
DeviceControlimpl backed bySimctlClient. - issued_
ledger - v5.1 c3 — SDK 内部 issued-action 账本(Capsule 软胶囊 G angle 主线)。
Structs§
- A11y
Node - Single-node accessibility snapshot returned by
/tree. Fields mirror the Swift-sideTreeRoute.nodeToDictshape. - Anchor
Box - Anchor base form’s spatial keys. Identical shape to the spatial half
of
Modifiersbut without nth/first/last (Anchor stacks IndexModifiers separately). - App
- Element
Summary - Element summary — projected view of an
A11yNodeused in AI-readable failure prompts anddriver.describe()output. - Expectation
Failure - Structured failure thrown by SDK matchers and driver calls. Shape is AI-feed-back-ready.
- Failure
Init - Builder/Init form for ergonomic construction.
- Http
Runner Client - HTTP client to the swift-side SmixRunnerCore. Async (tokio-based).
Constructed once per Cell;
ensure_reachablememoizes a successful/healthprobe so subsequent calls don’t re-probe. - Index
Modifiers - IndexModifiers — the subset BaseAnchor can stack. Kept separate from
Modifiersso anchor callers can’t accidentally write the top-level spatial form (which would be two surfaces for the same intent). - Launch
AppOptions - Typed shape of maestro yaml
launchApp:mapping. Adapter assembles this from yaml fields; SDK consumes it inApp::launch_app_with_options. Covers maestrolaunchApp.permissions / arguments / stopApp. - Launch
Result - Launched-app result.
- Modifiers
- Modifier set stackable on Text / Id / Label / Role base forms. Spatial keys (near/below/above/leftOf/rightOf/inside) carry recursive selectors that resolve to an anchor node; index keys (nth/first/last) pick from the surviving candidate list.
- OcrFrame
- Normalized OCR bounding box returned by
HttpRunnerClient::find_text_by_ocr. Coordinates are normalized to[0, 1]in UIKit coord space (top-left origin, y-down). Apple Vision’s native bbox is bottom-left origin + y-up — the swift handler converts before returning so all consumers see UIKit coords. - Rect
- Logical-points rectangle (origin top-left, +x right, +y down — matches
UIKit / XCUITest coordinate space). All fields
f64because the runner/treeroute emits floating-point points (sub-pixel scale factors). - Screen
Description - Aggregate screen description.
elementsis a DFS-collected ordered list of visible+enabledElementSummaryentries;screenshotis an optional base64 PNG;frontApp/summary/captured_atare caller-populated metadata. - Session
App::open_session; drop the value or callSession::closeto release. While a session is open the wrappedAppsends theSession-Idheader on every request, and the runner uses the session’s cachedXCUIApplicationbinding — no per-request activation storm.- Simctl
Client - Stateless wrapper around xcrun simctl. Methods are free functions
in spirit (no instance state beyond optionally-cached
xcrunpath); kept as a struct for API ergonomics + future caching. - System
Popup - One system-popup discovered on the screen (alert / sheet / banner).
- True
- Newtype around
true— used as theSelector::Focuseddiscriminator. Serializes/deserializes as the JSON literaltrue.
Enums§
- Appearance
- UI appearance mode for
xcrun simctl ui <udid> appearance. - Assert
Screenshot Outcome - Outcome of
App::assert_screenshot. Distinguishes the first-run “auto-record baseline” path (which writes the captured PNG to disk and treats as Ok) from the steady-state diff path (which compares dhash hamming distance against the recorded baseline). - Failure
Code - All failure codes smix surfaces back to the SDK / MCP / CLI (SCREAMING_SNAKE_CASE wire).
- Include
Scope includescope literal — currently onlyall-windows(system popups pierce the app frame).- KeyName
- Keyboard key name for
press_key/record(camelCase serde 1:1 跟 TS). - Launch
Fresh Op - Atomic op in the
App::launch_freshorchestration plan. Exposed so the plan is testable as a pure function (noSimctlClientstub — and a stub wouldn’t help much sinceSimctlClientis a ZST). - Maestro
Orientation - Maestro
setOrientation: <variant>literal enum.landscapeyaml alias normalizes toLandscapeLeftat the parser layer (same as maestro default). 1:1 mirrorssmix_driver::Orientation. - Pattern
- String-or-regex pattern. Wire-compatible: plain JSON string ↔
Pattern::Text; tagged object{regex, flags}↔Pattern::Regex. - Permission
Action - Maestro yaml
permissions:action — controls iOS privacy state per bundle. Maestro yaml parity: - Reset
AppData Wait For - v1.0.14 Cluster A — completion-signal wait strategy for the
resetAppDataverb (URL-scheme JS-wipe). See.claude/rfcs/1.0.14-*.md§Cluster A. The runtime executor (smix-adapter-maestro) is responsible for interpreting these variants; smix-sdk owns the type so the adapter’sStepand the runtime’s dispatch stay in agreement. - Role
- Accessibility role enum (29 variants).
- Runner
Scroll Selector - Reduced selector shape used by
/scroll(text-or-id only; complex selectors are host-side-resolved before reaching the runner). - Runner
Transport Error - Transport-level failure (network, non-2xx, malformed body). Mirrors
TS
RunnerTransportError1:1. - Selector
- Selector — 6 mutually exclusive base forms.
- Session
State - Top-level surface for test authors. Mirrors Playwright’s
pagedeliberately — AI authoring quality is highest when names overlap with corpus the AI was trained on. - Simctl
Error - Failure variants for any
xcrun simctlinvocation. - Simctl
Permission - Permission names accepted by
xcrun simctl privacy <udid> grant <name>. - Swipe
Direction - Maestro yaml
direction:semantic (per [[smix-must-be-superset-of-maestro]]): the direction names what content the caller wants to see (navigation through content), NOT the finger gesture direction.Down= “navigate down through content” = reveal what’s BELOW the current viewport (visually content moves up, finger gestures up). Mirrors maestro CLIdirection: DOWNsemantics. - TapMode
POST /tapmode discriminator.
Functions§
- assert_
screenshot_ inner - Nucleus of
App::assert_screenshot. Wraps fs IO + the dhash algorithm without anyAppdependency, so it can be exercised in host-side unit tests. Helper fn — not a user-facing capability. - build_
suggestions - Generate “Did you mean …?” suggestions from the current visible element list. Contract: threshold > 0.5, top 3, score desc → field (name > text) → DFS index asc.
- collect_
visible_ summaries - Collect up to
limitvisible+enabled nodes (DFS pre-order), projecting each viasummarize_node. Default limit = 1000. - describe_
selector - Human / AI-readable rendering of a
Selectorfor error prompts and logs. Stable enough that AI can pattern-match against past failures. Mirrors TSdescribeSelectorinsrc/core/selector.ts:118-1601:1. - edit_
distance - Levenshtein edit distance (Wagner-Fischer).
- focused
focused()shortcut.- id
id("btn-x")shortcut.- is_
visible_ enough - Visibility check.
- label
label("Settings")shortcut.- match_
text - Match a
Patternagainst the six text-bearing fields of a node (label,title,value,placeholderValue,identifier,text) — OR semantics, case-insensitive. SDK convenience wrapper that compiles the pattern on every call; for hot loops preferPattern::compileonce +match_text_compiledper node. - match_
text_ compiled - Text matching against an
A11yNode. 1:1 with TSsrc/core/resolve-selector.ts:153-184(matchText). - plan_
launch_ fresh_ calls - Pure planner for
App::launch_fresh— computes the simctl op sequence + warnings from(clear_state, clear_keychain, app_path). - plan_
launch_ fresh_ calls_ v2 - v1.0.4 §D12 — extended planner with an explicit
force_reinstallswitch. Whenfalse(the new default),clear_state=trueruns the in-place sandbox clear + privacy reset instead ofsimctl uninstall + install. This avoids the iOS 26.5 XCUITest binding loss (feedback §F) and the ReportCrash “Insight quit unexpectedly” system dialog (feedback §H) — both of which stem from the uninstall+install sequence. - role
role(Role::Button)shortcut.- role_
named role_named(Role::Button, "Submit")shortcut.- similarity
- Normalized
[0, 1]string similarity. 1 = identical, 0 = completely different. - summarize_
node - Project an
A11yNodeto anElementSummary. - text
text("Login")shortcut. Mirrors TS{ text: 'Login' }shorthand.- text_
regex text_regex("^Lo")shortcut.- visible_
area - Intersection area in logical points².
Type Aliases§
- Bounds
- Bounds alias —
BoundsandRectare used interchangeably. Downstream code may prefer one name or the other. - Simctl
Driver - Back-compat alias.
SimctlDriverwas renamed toIosDriverfor cross-platform naming; this alias keeps existing importsuse smix_driver::SimctlDrivercompiling.