agent-device
Version:
Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.
2,136 lines • 88.5 kB
TypeScript
import { $ as DaemonError, A as IosSnapshotObservation, B as SnapshotNode, C as DeviceKind, D as PublicPlatform, E as PlatformSelector, F as Rect, G as SnapshotQualityVerdict, J as SnapshotVisibility, K as SnapshotUnchanged, M as Point, N as PresentedSurface, R as SnapshotCommandOptionFields, W as SnapshotQualityNote, _ as ScriptDeliveryFailure, a as DaemonRequest, b as AppleOS, c as DaemonServerMode, f as LeaseBackend, g as ResponseLevel, i as DaemonLockPolicy, j as IosTargetActivation, k as AppleApplicationState, l as DaemonTransportPreference, m as NetworkIncludeMode, nt as NormalizedError, o as DaemonResponse, q as SnapshotViewportSize, r as DaemonInstallSource, s as DaemonResponseData, t as DaemonArtifact, v as SessionIsolationMode, w as DeviceTarget, x as BootPickPolicy, y as SessionRuntimeHints, z as SnapshotKeyboardBandFact } from "./sdk-contracts.js";
import { t as BatchRunResult } from "./sdk-batch-runner.js";
import { _ as PressCommandResponseData, b as PostGestureOutcome, f as ClickCommandResponseData, g as LongPressCommandResponseData, h as HoverCommandResponseData, m as FindCommandResponseData, p as FillCommandResponseData, v as SettleObservation, y as ClickButton } from "./sdk-selectors.js";
import { A as ScrollDirection, C as HardwareButtonName, D as ScreenshotCaptureBackend, E as SnapshotDiagnosticsSummary, F as BackMode, I as SessionSurface, M as SwipePattern, N as SwipePreset, P as TransformGestureParams, S as FoldScreenCoordinateSpace, T as SetFoldPoseInput, _ as TvRemoteButton, a as AndroidSnapshotBackendMetadata, b as DeviceRotation, c as ScreenshotResultData, d as PermissionAction, f as PermissionMode, h as SettingName, i as CloudProviderSessionResult, j as ScrollInputDirection, k as ScreenshotScreenMask, l as MACOS_PERMISSION_TARGETS, m as SETTINGS, o as FindLocator, t as AgentArtifactsResult, u as MOBILE_PERMISSION_TARGETS, v as ScrollCommandResult, w as OrientationRequest, x as FoldPose } from "./cloud-artifacts.js";
import { a as RecordingExportQuality, i as RecordingScope, r as ReplaySuiteResult, t as ReplayCommandResult } from "./replay.js";
import { c as MetroPrepareOptions, d as MetroReloadResult, l as MetroPrepareResult, o as RemoteConnectionProfileFields, r as CloudProviderProfileFields, u as MetroReloadOptions } from "./sdk-remote-config.js";
import { i as GesturePointerCount, t as KeyboardCommandResult } from "./keyboard.js";
import { t as AppsFilter } from "./app-inventory.js";
//#region packages/contracts/src/client-connection.d.ts
/**
* Who owns the daemon on a client's state directory.
*
* - `managed`: the client starts a missing daemon and replaces an incompatible one itself, and may
* retire a hung one after a timeout. This is the default until 0.22.
* - `attach`: the client only connects to the daemon registered in the state directory. It never
* starts, replaces or kills one. A missing daemon fails with `details.reason: 'daemon-not-running'`
* and an incompatible one with `'daemon-incompatible'`; `ensureDaemon()` is the explicit way to
* start or replace one.
*
* Independent of `daemonTransport`, `daemonServerMode` and `daemonBaseUrl`: a remote connection
* never starts or retires a local daemon in either mode.
*/
type DaemonLifecycle = 'attach' | 'managed';
/** What a client can learn about a daemon without talking to it: how it identifies itself on disk. */
type DaemonIdentity = {
pid: number;
version?: string;
/** `installed` for a published package, `checkout` for a source tree. */
codeOrigin?: 'installed' | 'checkout';
codeSignature?: string;
processStartTime?: string;
};
/**
* The one daemon instance a client is pinned to: its credentials and its process lifetime together.
*
* A pin is checked against the registered daemon before a request is dispatched, and the pinned
* token is what authenticates the request — never a token discovered on the way. So a state
* directory whose daemon was replaced fails with `details.reason: 'daemon-binding-mismatch'` instead
* of sending a caller's work to a different instance, and a replacement that lands between that
* check and the write is refused by the new instance's own token check. A pinned client never
* starts, replaces, retires, or redirects a daemon.
*
* The token is a bearer capability for that instance: treat the object that carries it as a
* credential, and keep it inside the host that owns the daemon.
*/
type DaemonBinding = {
/** The instance's daemon token, as its `daemon.json` published it. */
token: string;
pid: number;
/** The instance's process start time; a pid alone cannot tell a lifetime from its successor. */
processStartTime: string;
};
type EnsureDaemonOptions = {
/** The state directory the daemon owns; defaults to `AGENT_DEVICE_STATE_DIR`, then the user default. */
stateDir?: string;
daemonTransport?: DaemonTransportPreference;
daemonServerMode?: DaemonServerMode;
/**
* Called when this call started a daemon, before `ensureDaemon` returns. `missing` means no
* usable daemon was registered; `incompatible` means a daemon this client cannot use was
* replaced after it agreed to leave. `previous` is the daemon that was replaced, when there was
* one: a `missing` start with a `previous` replaced a registered daemon that answered nothing,
* either unreachable or hung and force-retired, or one that agreed to leave but outlasted its drain
* and was force-retired.
*/
onStart?: (reason: 'missing' | 'incompatible', previous?: DaemonIdentity) => void;
};
/** A reachable local daemon. It carries no credentials. */
type DaemonConnection = {
stateDir: string;
daemon: DaemonIdentity;
/** True when this call started the daemon. */
started: boolean;
};
type AgentDeviceDaemonTransportContext = {
authToken?: string;
/** How this request treats the local daemon; `managed` when omitted. */
daemonLifecycle?: DaemonLifecycle;
/** See {@link DaemonBinding}. A client built with one sends this same pin on every request. */
daemonBinding?: DaemonBinding;
/**
* Cancels this one in-flight request. A built-in transport that sees an abort destroys the
* request's connection, which makes the daemon mark the request canceled; the promise rejects
* with the typed canceled-request error. A custom transport that ignores the signal keeps its
* own cancellation contract, and the client still rejects the caller's promise on abort.
*/
signal?: AbortSignal;
};
type AgentDeviceDaemonTransport = (req: Omit<DaemonRequest, 'token'>, context?: AgentDeviceDaemonTransportContext) => Promise<DaemonResponse>;
type AgentDeviceClientConfig = RemoteConnectionProfileFields & CloudProviderProfileFields & {
/** See `DaemonLifecycle`. */
daemonLifecycle?: DaemonLifecycle;
/**
* Pins this client to one daemon instance: every request addresses that instance, authenticates
* with its token, and refuses a state directory whose daemon is any other instance. See
* {@link DaemonBinding}.
*/
daemonBinding?: DaemonBinding;
session?: string;
lockPolicy?: DaemonLockPolicy;
lockPlatform?: PlatformSelector;
requestId?: string;
sessionIsolation?: SessionIsolationMode;
leaseBackend?: LeaseBackend;
leaseTtlMs?: number;
runtime?: SessionRuntimeHints;
cwd?: string;
debug?: boolean;
cost?: boolean;
responseLevel?: ResponseLevel;
iosXctestrunFile?: string;
iosXctestDerivedDataPath?: string;
iosXctestEnvDir?: string;
};
type AgentDeviceRequestOverrides = Pick<AgentDeviceClientConfig, 'session' | 'lockPolicy' | 'lockPlatform' | 'requestId' | 'daemonBaseUrl' | 'daemonAuthToken' | 'daemonTransport' | 'daemonServerMode' | 'tenant' | 'sessionIsolation' | 'runId' | 'leaseId' | 'leaseBackend' | 'leaseProvider' | 'deviceKey' | 'clientId' | 'providerApp' | 'providerOsVersion' | 'providerDeviceType' | 'providerProject' | 'providerBuild' | 'providerSessionName' | 'providerDeviceOrientation' | 'providerGeoLocation' | 'providerTimezone' | 'providerAppiumVersion' | 'providerLanguage' | 'providerLocale' | 'providerNetworkProfile' | 'providerCustomNetwork' | 'providerNoResignApp' | 'providerNetworkLogs' | 'providerNetworkHosts' | 'awsProjectArn' | 'awsDeviceArn' | 'awsAppArn' | 'awsRegion' | 'awsInteractionMode' | 'leaseTtlMs' | 'cwd' | 'debug' | 'cost' | 'responseLevel' | 'iosXctestrunFile' | 'iosXctestDerivedDataPath' | 'iosXctestEnvDir'> & {
/**
* Cancels this one call. Already aborted: the call rejects without sending anything
* (`details.dispatched: 'no'`). Aborted in flight: the request's connection closes, the daemon
* marks the request canceled, and the promise rejects with the typed canceled-request error
* (`details.reason: 'request_canceled'`). An abort is never a timeout: no runner sweep, no
* daemon reset.
*
* The guarantee covers the daemon request, and the built-in transports enforce it; a custom
* transport receives the signal on its context and may implement cancellation differently. Two
* phases run outside it: a response-artifact download started after the response begins is not
* canceled, and a canceled one-shot replay still runs the existing cleanup that may tear down a
* daemon this client started.
*/
signal?: AbortSignal;
};
type AgentDeviceIdentifiers = {
session?: string;
deviceId?: string;
deviceName?: string;
udid?: string;
serial?: string;
appId?: string;
appBundleId?: string;
package?: string;
};
type AgentDeviceSelectionOptions = {
platform?: PlatformSelector;
target?: DeviceTarget;
device?: string;
udid?: string;
serial?: string;
iosSimulatorDeviceSet?: string;
androidDeviceAllowlist?: string;
};
type DeviceCommandBaseOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions;
//#endregion
//#region packages/contracts/src/json.d.ts
type JsonPrimitive = string | number | boolean | null;
type JsonValue = JsonPrimitive | JsonObject | JsonValue[];
type JsonObject = {
[key: string]: JsonValue;
};
declare function isRecord(value: unknown): value is Record<string, unknown>;
//#endregion
//#region packages/contracts/src/prepare.d.ts
type PrepareIosRunnerCacheKind = 'exact' | 'miss' | 'external';
type PrepareIosRunnerArtifactState = 'valid' | 'rebuilt';
type PrepareIosRunnerTiming = {
totalMs: number;
additiveParts: {
buildMs?: number;
connectAfterBuildMs: number;
healthCheckMs: number;
};
containment: {
connectMs?: ['buildMs'];
healthCheckMs: [];
};
note: string;
};
/**
* Public daemon result for `prepare ios-runner`. The runner-local prepare result
* is projected by `prepareIosRunnerResponseData` with device identity and timing
* guidance before it reaches the client.
*/
type PrepareCommandResult = {
action: 'ios-runner';
platform: PublicPlatform;
deviceId: string;
deviceName: string;
kind: DeviceKind;
durationMs: number;
runner: JsonObject;
cache?: PrepareIosRunnerCacheKind;
artifact?: PrepareIosRunnerArtifactState;
buildMs?: number;
connectMs: number;
healthCheckMs: number;
xctestrunPath?: string;
recoveryReason?: string;
failureReason?: string;
timing: PrepareIosRunnerTiming;
message: string;
};
//#endregion
//#region packages/contracts/src/push.d.ts
type PushCommandResult = {
platform: 'ios';
bundleId: string;
message: string;
} | {
platform: 'android';
package: string;
action: string;
extrasCount: number;
message: string;
};
//#endregion
//#region packages/contracts/src/target-shutdown-contract.d.ts
type TargetShutdownResult = {
success: boolean;
exitCode: number;
stdout: string;
stderr: string;
error?: NormalizedError;
};
//#endregion
//#region packages/contracts/src/application-lifecycle-runtime.d.ts
/** Which leg left a seen launch confirmation unanswered. Keyed, never inferred from text. */
type LaunchConfirmationUnansweredReason = 'alert-unrecognized' | 'url-owner-unresolved';
/**
* A launch-confirmation probe step that failed or whose result could not be verified, so whether a
* prompt is up is unknown. Not an outcome of the confirmation itself: the open reports no
* confirmation for it and carries this step on the response beside a warning, keeping probe
* failure separate from what a completed probe saw.
*/
type LaunchConfirmationProbeFailure = 'alert-read' | 'alert-accept' | 'runner';
/** What the open reports about a launch confirmation it saw, with its typed outcome paired. */
type LaunchConfirmationOutcome = Readonly<{
launchConfirmation: 'accepted';
launchConfirmationProbeFailure?: undefined;
}> | Readonly<{
launchConfirmation: 'unanswered';
launchConfirmationReason: LaunchConfirmationUnansweredReason;
launchConfirmationProbeFailure?: undefined;
}>;
/**
* What a client reports about a launch confirmation. The platform always pairs an `unanswered`
* outcome with its reason; a version-skewed daemon may not, so this adds the arm where only the
* outcome survives and the unknown reason is omitted.
*/
type LaunchConfirmationClientOutcome = LaunchConfirmationOutcome | Readonly<{
launchConfirmation: 'unanswered';
launchConfirmationReason?: undefined;
launchConfirmationProbeFailure?: undefined;
}>;
/** No confirmation reported: either none was seen or the probe could not read one. */
type LaunchConfirmationAbsent = Readonly<{
launchConfirmation?: undefined;
launchConfirmationProbeFailure?: LaunchConfirmationProbeFailure;
}>;
//#endregion
//#region packages/contracts/src/client-device-view.d.ts
type AgentDeviceDevice = {
platform: PublicPlatform;
target: DeviceTarget;
kind: DeviceKind;
id: string;
name: string;
booted?: boolean;
/**
* Additive Apple-OS discriminant (iPhone/iPad/tvOS/visionOS/macOS). Present only for
* Apple devices; `platform` still carries the leaf (`ios`/`macos`).
*/
appleOs?: AppleOS;
/** Hardware model, for example `iPhone 17 Pro` or `Pixel 9`, when discovery reports it. */
model?: string;
/** OS version, for example `26.1` or `16`, when discovery reports it. */
osVersion?: string;
identifiers: AgentDeviceIdentifiers;
/**
* Present when a host-local device claim currently blocks foreign use of
* this device (#1320). Provably dead owners are not projected — the next
* open reconciles and replaces them automatically.
*/
claimedBy?: {
session: string;
workspace: string;
};
ios?: {
udid: string;
};
android?: {
serial: string;
};
harmonyos?: {
serial: string;
};
vega?: {
serial: string;
};
};
type AgentDeviceCapabilitiesResult = {
device: AgentDeviceDevice;
availableCommands: string[];
targetReadiness?: {
press: 'bounded-geometry';
};
};
type AgentDeviceSessionDevice = {
platform: PublicPlatform;
target: DeviceTarget;
id: string;
name: string;
/**
* Additive Apple-OS discriminant (iPhone/iPad/tvOS/visionOS/macOS). Present only for
* Apple devices; `platform` still carries the leaf (`ios`/`macos`).
*/
appleOs?: AppleOS;
/** Simulator/emulator/physical split. Absent only from a daemon older than the field. */
kind?: DeviceKind;
/** Hardware model, for example `iPhone 17 Pro` or `Pixel 9`, when the host or provider reports it. */
model?: string;
/** OS version, for example `26.1` or `16`, when the host or provider reports it. Never inferred. */
osVersion?: string;
identifiers: AgentDeviceIdentifiers;
ios?: {
udid: string;
simulatorSetPath?: string | null;
};
android?: {
serial: string;
};
harmonyos?: {
serial: string;
};
vega?: {
serial: string;
};
};
type AgentDeviceSession = {
name: string;
/**
* The exact value `--session` must carry to address this session, which is not always `name`:
* a session opened without `--session` is named `default` but stored — and addressed — as
* `cwd:<hash>:default` (#2031/#1394). Optional only because a daemon older than the field does
* not send it.
*/
address?: string;
createdAt: number;
sessionStateDir?: string;
runnerLogPath?: string;
device: AgentDeviceSessionDevice;
identifiers: AgentDeviceIdentifiers;
};
type StartupPerfSample = {
durationMs: number;
measuredAt: string;
method: string;
appTarget?: string;
appBundleId?: string;
};
type DeviceBootOptions = DeviceCommandBaseOptions & {
headless?: boolean;
/**
* When the request names no device and several equally preferred devices match, all shut down,
* boot one instead of failing with `AMBIGUOUS_MATCH`. `newest`: mobile over TV, newest OS
* version, then the first name in name order, with numbers compared by value; that is not device
* age (stopped Android AVDs report no OS version, so the name decides). Several booted matches
* still fail. `selection.reason` reports the pick.
*/
pick?: BootPickPolicy;
/** Startup budget in milliseconds: bounds the boot wait on a cold Simulator or emulator. */
timeoutMs?: number;
};
type DeviceShutdownOptions = DeviceCommandBaseOptions;
//#endregion
//#region packages/contracts/src/client-lease.d.ts
type Lease = {
leaseId: string;
tenantId: string;
runId: string;
backend: LeaseBackend;
leaseProvider?: string;
deviceKey?: string;
clientId?: string;
/**
* What an allocate answered: `true` when this request created the lease, `false` on reuse.
* Only allocate answers this; heartbeats and older daemons omit creation evidence.
* A discarded allocate response can be released unless `created` is false.
* Rollback after binding requires `created` to be true.
*/
created?: boolean;
/**
* The device granted for a request that named a device spec, written by the backend that
* honoured the spec. A daemon refuses a spec instead, so only such a backend sets it.
*/
device?: LeaseDevice;
/** Present when the daemon keeps this lease through session `close`; an older daemon omits it. */
retainOnClose?: true;
createdAt?: number;
heartbeatAt?: number;
expiresAt?: number;
};
/**
* A device spec a lease request can name beside platform, target and device. Only a backend in
* front of the daemon honours it; a daemon refuses every request that names one, with
* `UNSUPPORTED_OPERATION` and `details.reason: 'device-spec-unsupported'`.
*/
type LeaseDeviceSpec = {
/** OS version or range, opaque to agent-device; the backend validates it. */
osVersion?: string;
/** Android system image tag, for example `google_apis_playstore`. */
imageTag?: string;
/** iOS simulator mode, `slim` or `full`; the backend validates it. */
deviceMode?: string;
/** Name of a saved, prepared device state the backend restores; the backend validates it. */
deviceBaseline?: string;
/** `true` asks for a physical device instead of a simulator or emulator. */
physical?: boolean;
};
/** The device facts the backend granted for a {@link LeaseDeviceSpec}. */
type LeaseDevice = {
model: string;
/** The exact OS version granted. */
osVersion: string;
imageTag?: string;
/** The iOS simulator mode granted, when the backend reports it. */
deviceMode?: string;
/** The baseline the backend restored, when the lease was allocated with one. */
baseline?: {
name: string;
version: number;
};
physical: boolean;
};
/**
* A session lease a daemon request ended. A reply to a request that ended leases lists them once in
* `endedLeases` at response level: in `data` on success, in `error.details` on failure. A `close`,
* a `batch` close step, a `replay` or `test` script's close, and `test` session cleanup each end the
* lease they close with, unless it was allocated with `retainOnClose`. A daemon older than this
* field omits it.
*/
type EndedLease = {
leaseId: string;
outcome: 'released';
};
type LeaseOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions & {
ttlMs?: number;
};
type LeaseAllocateOptions = LeaseOptions & LeaseDeviceSpec & {
tenant: string;
runId: string;
/**
* The id for the new lease (16-128 hex characters), refused when the daemon already issued it;
* the client's configured `leaseId` is never sent here. Use the returned lease's `leaseId`: a daemon that predates this field mints its own,
* and a run that already holds a lease gets that lease back.
*/
leaseId?: string;
leaseBackend?: LeaseBackend;
leaseProvider?: string;
provider?: string;
deviceKey?: string;
clientId?: string;
/**
* Keeps the lease through session `close`; it then ends only through `leases.release`, expiry, or
* daemon shutdown. Asking for it on a lease the same client already holds for the run turns it on
* for that lease; the returned lease's `retainOnClose` says whether the daemon honored it.
*/
retainOnClose?: boolean;
};
type LeaseScopedOptions = LeaseOptions & {
tenant?: string;
runId?: string;
leaseId: string;
leaseBackend?: LeaseBackend;
leaseProvider?: string;
provider?: string;
deviceKey?: string;
clientId?: string;
};
type CloudArtifactsOptions = AgentDeviceRequestOverrides & {
provider?: string;
providerSessionId?: string;
};
type HumanControlHoldScope = {
backend: LeaseBackend;
leaseProvider?: string;
deviceKey: string;
};
type HumanControlHold = {
id: string;
scope: HumanControlHoldScope;
reason?: string;
state: 'activating' | 'active';
createdAt: number;
updatedAt: number;
expiresAt?: number;
};
type HumanControlHoldOptions = {
reason?: string;
ttlMs?: number;
};
//#endregion
//#region packages/contracts/src/gesture-input.d.ts
type DragGesturePayload = {
kind: 'drag';
source: string;
destination: string;
sourceHoldMs?: number;
moveMs?: number;
destinationHoldMs?: number;
};
type PanGesturePayload = {
kind: 'pan';
origin: Point;
delta: Point;
pointerCount?: GesturePointerCount;
durationMs?: number;
};
type FlingGesturePayload = {
kind: 'fling';
direction: ScrollDirection;
origin: Point;
distance?: number;
};
type SwipeGesturePayload = {
kind: 'swipe';
preset: SwipePreset;
};
type PinchGesturePayload = {
kind: 'pinch';
scale: number;
origin?: Point;
};
type RotateGesturePayload = {
kind: 'rotate';
degrees: number;
origin?: Point;
};
type TransformGesturePayload = {
kind: 'transform';
origin: Point;
delta: Point;
scale: number;
degrees: number;
durationMs?: number;
};
type TapGesturePayload = {
kind: 'tap';
points: Point[];
holdMs?: number;
count?: number;
pauseMs?: number;
};
type GesturePayload = PanGesturePayload | FlingGesturePayload | SwipeGesturePayload | PinchGesturePayload | RotateGesturePayload | TransformGesturePayload | TapGesturePayload | DragGesturePayload;
//#endregion
//#region packages/contracts/src/snapshot-capture-annotations.d.ts
type SnapshotCaptureAnalysis = {
rawNodeCount: number;
maxDepth: number;
};
type SnapshotCaptureFreshness = {
action: string;
retryCount: number;
staleAfterRetries: boolean;
reason?: 'empty-interactive' | 'sharp-drop' | 'stuck-route';
};
type SnapshotCaptureAnnotations = {
analysis?: SnapshotCaptureAnalysis;
androidSnapshot?: AndroidSnapshotBackendMetadata;
freshness?: SnapshotCaptureFreshness;
quality?: SnapshotQualityVerdict;
qualityNotes?: SnapshotQualityNote[];
warnings?: string[];
/** The Apple runner re-activated the session app while serving this capture (#2682). */
targetActivation?: IosTargetActivation;
observation?: IosSnapshotObservation;
};
type PublicSnapshotCaptureAnnotations = Pick<SnapshotCaptureAnnotations, 'androidSnapshot' | 'warnings' | 'targetActivation' | 'observation'> & {
snapshotQuality?: SnapshotQualityVerdict;
snapshotQualityNotes?: SnapshotQualityNote[];
};
//#endregion
//#region packages/contracts/src/client-capture.d.ts
type CaptureSnapshotOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions & Omit<SnapshotCommandOptionFields, 'customActions'> & {
/**
* List the custom actions an element merged away, such as a card's reply control.
* Not invocable: reach the control via its detail screen, a labeled element elsewhere,
* or its rect. iOS simulator only; costs one accessibility round trip per merged element.
*/
customActions?: SnapshotCommandOptionFields['customActions'];
timeoutMs?: number;
/**
* #1271 stage 2 (ADR 0012 amendment): `snapshot` is observation-only and
* excluded from a repair-armed heal by default; `record` forces it
* through. Mutually exclusive with `noRecord`.
*/
noRecord?: boolean;
record?: boolean;
};
type CaptureSnapshotResult = {
nodes: SnapshotNode[];
/** Present only when the capture owner establishes whether the tree was truncated. */
truncated?: boolean;
appName?: string;
appBundleId?: string;
visibility?: SnapshotVisibility;
unchanged?: SnapshotUnchanged;
snapshotDiagnostics?: SnapshotDiagnosticsSummary;
/**
* The keyboard band this capture's producer measured (#2660), in the same orientation space as the
* node rects. The acting commands read it off the session state they act with; it is published so a
* caller can see the band a `tap_keyboard_occludes_target` refusal measured against. Absent means
* the producer measured no band and the tap guard derived one from the tree.
*/
keyboard?: SnapshotKeyboardBandFact;
/**
* The box the node rects are measured in, as the producer measured it (#3182). Same coordinate
* space and orientation as the rects beside it, so a consumer scales and clips against the screen
* it is being shown instead of inferring it from the largest rect on screen.
*
* Which surface it names is the producer's answer, not always the physical panel: the app window
* for iOS (so iPad Split View and a foldable panel do not inflate it), the screen the bounds were
* measured on for Android and Apple TV. Absent means the producer measured no box — a desktop
* capture whose rects are absolute in window space, a backend that reads a tree without reading a
* screen, or a raw projection nothing validated a box against — and never a zero. This is the full
* screen size only; content-safe gesture bounds stay with #1821.
*/
viewport?: SnapshotViewportSize;
/**
* iOS: whether the capture read a modal presentation over the app (#3565), decided on the acquired
* tree before interactive filtering, compaction, depth, or scope. `'absent'` is a positive reading;
* a capture whose producer could not decide — or did not speak — reports `'unknown'`, and absence
* of the field means a non-iOS producer or an older runner published nothing.
*/
presentedSurface?: PresentedSurface;
/**
* Present when the tree may not show the surface at rest: `unsettled` (still changing after a
* gesture), `no-effect` (a gesture changed nothing), or `loading` (the app launched by `open`
* still showed no first screen when its wait ran out).
*/
postGestureOutcome?: PostGestureOutcome;
/**
* Screenshot captured automatically when the semantic snapshot was sparse.
* Remote clients receive a materialized local path through the daemon artifact channel.
*/
fallbackScreenshotPath?: string;
identifiers: AgentDeviceIdentifiers;
/**
* ADR 0014: the response-level ref-frame epoch the plain node refs were minted
* from. A ref-issuing snapshot carries it ONCE (nodes stay plain `@e12` for the
* token budget); pair a ref with it (`@e12~s<refsGeneration>`) before a mutation.
*/
refsGeneration?: number;
/**
* Digest response view only: a capped list of `{ ref, label? }` pairs taken
* from the full `nodes` tree so the MCP layer can still pin refs when the
* default-level `nodes` payload is intentionally omitted.
*/
refs?: Array<{
ref: string;
label?: string;
}>;
/**
* ADR 0016 (#4564): a remote recording's script version this capture recorded was not delivered.
* The capture kept its success, so the caller file may hold an older version.
*/
scriptDeliveryFailure?: ScriptDeliveryFailure;
} & PublicSnapshotCaptureAnnotations;
type CaptureScreenshotOptions = AgentDeviceRequestOverrides & {
path?: string;
overlayRefs?: boolean;
/** Crop the capture to the frame of the selector resolved on the same screen. */
cropOn?: string;
pixelDensity?: number;
screenMask?: ScreenshotScreenMask;
fullscreen?: boolean;
scale?: number;
stabilize?: boolean;
normalizeStatusBar?: boolean;
/** `runner`: capture an Apple target through the XCTest runner instead of `simctl`. */
captureBackend?: ScreenshotCaptureBackend;
surface?: SessionSurface;
};
type CaptureScreenshotResult = ScreenshotResultData & {
path: string;
/**
* ADR 0016 (#4564): a remote recording's script version this capture recorded was not delivered.
* The capture kept its success, so the caller file may hold an older version.
*/
scriptDeliveryFailure?: ScriptDeliveryFailure;
identifiers: AgentDeviceIdentifiers;
};
type CaptureDiffOptions = DeviceCommandBaseOptions & Pick<CaptureSnapshotOptions, 'interactiveOnly' | 'depth' | 'scope' | 'raw'> & {
kind: 'snapshot';
out?: string;
};
type CaptureAuditOptions = DeviceCommandBaseOptions;
type SelectorSnapshotCommandOptions = Pick<CaptureSnapshotOptions, 'depth' | 'scope' | 'raw'>;
type FindSnapshotCommandOptions = Pick<CaptureSnapshotOptions, 'depth' | 'raw'>;
//#endregion
//#region packages/contracts/src/client-target.d.ts
type PointTarget = {
x: number;
y: number;
ref?: never;
selector?: never;
label?: never;
};
type RefTarget = {
ref: string;
label?: string;
x?: never;
y?: never;
selector?: never;
};
type SelectorTarget = {
selector: string;
x?: never;
y?: never;
ref?: never;
label?: never;
};
type InteractionTarget = PointTarget | RefTarget | SelectorTarget;
type ElementTarget = RefTarget | SelectorTarget;
//#endregion
//#region packages/contracts/src/client-gesture.d.ts
type RepeatedPressOptions = {
count?: number;
intervalMs?: number;
holdMs?: number;
jitterPx?: number;
doubleTap?: boolean;
};
/**
* Opt-in (#1101): after the action, wait for the UI to go quiet and return the
* settled diff vs the pre-action tree (`settle` on the result) in the same
* response. Best-effort — never fails the action. `settleQuietMs` tunes the
* quiet window (default 500ms, or 300ms when the settled tree comes from the iOS
* simulator snapshot bridge); `timeoutMs` bounds the settle wait (default
* 10s) when `settle` is true. A bare `timeoutMs` without `settle` is ignored
* for compatibility; `settleQuietMs` still requires `settle`.
*/
type SettleCommandOptions = {
settle?: boolean;
settleQuietMs?: number;
timeoutMs?: number;
};
/** For a caller that verifies the screen by polling it: opts out of the checks after a gesture or an app launch. */
type PostGestureStabilizationOptions = {
/**
* Set false to skip the movement check on a directional scroll and the stabilization wait
* before the next read, or, on a local iOS simulator, the first-screen wait after an app launch.
* Set it only when your own polling verifies the screen: the next read can return a tree that the
* gesture is still moving or the launch screen.
*/
postGestureStabilization?: boolean;
};
type ClickOptions = DeviceCommandBaseOptions & SelectorSnapshotCommandOptions & InteractionTarget & RepeatedPressOptions & SettleCommandOptions & {
button?: ClickButton;
/**
* Opt-in (#1047): return cheap post-action evidence (AX digest, node counts,
* changedFromBefore) in the response instead of requiring a follow-up
* snapshot to confirm the action had an effect.
*/
verify?: boolean;
};
type PressOptions = DeviceCommandBaseOptions & SelectorSnapshotCommandOptions & InteractionTarget & RepeatedPressOptions & SettleCommandOptions & {
verify?: boolean;
};
type LongPressOptions = DeviceCommandBaseOptions & SelectorSnapshotCommandOptions & InteractionTarget & SettleCommandOptions & {
durationMs?: number;
};
type HoverOptions = DeviceCommandBaseOptions & SelectorSnapshotCommandOptions & InteractionTarget & SettleCommandOptions;
type SwipeOptions = DeviceCommandBaseOptions & PostGestureStabilizationOptions & {
from: {
x: number;
y: number;
};
to: {
x: number;
y: number;
};
count?: number;
pauseMs?: number;
pattern?: SwipePattern;
};
type GestureOptions = DeviceCommandBaseOptions & (GesturePayload | (SwipeGesturePayload & PostGestureStabilizationOptions));
type PanOptions = DeviceCommandBaseOptions & {
x: number;
y: number;
dx: number;
dy: number;
pointerCount?: GesturePointerCount;
durationMs?: number;
};
type DragOptions = DeviceCommandBaseOptions & Omit<DragGesturePayload, 'kind'>;
type FlingOptions = DeviceCommandBaseOptions & {
direction: ScrollDirection;
x: number;
y: number;
distance?: number;
};
type SwipeGestureOptions = DeviceCommandBaseOptions & Omit<SwipeGesturePayload, 'kind'> & PostGestureStabilizationOptions;
type FocusOptions = DeviceCommandBaseOptions & {
x: number;
y: number;
};
type TypeTextOptions = DeviceCommandBaseOptions & {
text: string;
delayMs?: number;
};
type FillOptions = DeviceCommandBaseOptions & SelectorSnapshotCommandOptions & InteractionTarget & SettleCommandOptions & {
text: string;
delayMs?: number;
/** Publish this fill value as `${VAR}` when script recording is armed. */
recordAs?: string;
/** The text came from the CLI's stdin; keep it out of diagnostics and recorded actions. */
textStdin?: boolean;
verify?: boolean;
};
type PinchOptions = DeviceCommandBaseOptions & {
scale: number;
x?: number;
y?: number;
};
type RotateGestureOptions = DeviceCommandBaseOptions & {
degrees: number;
x?: number;
y?: number;
};
type TransformGestureOptions = DeviceCommandBaseOptions & TransformGestureParams;
/** Touches 2 to 5 points and holds them for `holdMs`; `count` repeats the same contacts. */
type TapGestureOptions = DeviceCommandBaseOptions & Omit<TapGesturePayload, 'kind'>;
type ScrollOptions = DeviceCommandBaseOptions & SettleCommandOptions & PostGestureStabilizationOptions & {
direction: ScrollInputDirection;
amount?: number;
pixels?: number;
durationMs?: number;
/** Repeat scroll passes until this selector is visible on screen, then stop. */
until?: string;
/** Maximum scroll gestures for an until search (1–200, default 12). */
maxPasses?: number;
};
//#endregion
//#region packages/contracts/src/client-app.d.ts
type DeviceSelectionReason = 'explicit-selector' | 'existing-session' | 'single-booted-local' | 'single-bootable-local' | 'single-app-installed-local' |
/** `boot --pick newest` chose among several equally preferred, shut-down local devices. */
'newest-bootable-local' | 'preferred-local' | 'single-provider-device';
type DeviceSelectionSource = 'session' | 'local' | 'provider';
/** Deterministic device-selection evidence shared by daemon responses and the published client. */
type DeviceSelectionMetadata = {
reason: DeviceSelectionReason;
source: DeviceSelectionSource;
candidateCount: number;
/** Whether this request booted a previously stopped local virtual target during open. */
bootOccurred: boolean;
};
type AppInstallOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions & LeaseDeviceSpec & {
app?: string;
appPath: string;
};
type AppDeployOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions & LeaseDeviceSpec & {
app: string;
appPath: string;
};
type AppDeployResult = {
app: string;
appPath: string;
platform: PublicPlatform;
appId?: string;
bundleId?: string;
package?: string;
identifiers: AgentDeviceIdentifiers;
};
type AppOpenOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions & LeaseDeviceSpec & PostGestureStabilizationOptions & {
app?: string;
url?: string;
surface?: SessionSurface;
activity?: string;
launchConsole?: string;
launchArgs?: string[];
relaunch?: boolean;
/** Startup budget in milliseconds: bounds the Simulator boot wait on a cold device. */
timeoutMs?: number;
/**
* Wait up to n milliseconds (100-120000) while another session holds the device, then fail
* with DEVICE_IN_USE. A claim held by another workspace fails at once. The wait extends this
* command's timeout.
*/
waitMs?: number;
/**
* Include an initial interactive snapshot in a fresh open response. With no
* app argument, discover the sole running app on the sole booted iOS
* simulator; ambiguous environments fail closed.
*/
foreground?: boolean;
saveScript?: boolean | string;
/** #1258: overwrite an existing --save-script target instead of refusing. Alias: --overwrite. */
force?: boolean;
testIme?: boolean;
noRecord?: boolean;
runtime?: SessionRuntimeHints;
};
type AppOpenResult = AppOpenResultBase & (LaunchConfirmationClientOutcome | LaunchConfirmationAbsent);
type AppOpenResultBase = {
session: string;
warnings?: string[];
/**
* ADR 0016 (#4564): a remote recording's first script version was not delivered. The open kept
* its success, so the caller file may hold no script at all, or an older one.
*/
scriptDeliveryFailure?: ScriptDeliveryFailure;
sessionStateDir?: string;
runnerLogPath?: string;
requestLogPath?: string;
eventLogPath?: string;
appName?: string;
appBundleId?: string;
appId?: string;
startup?: StartupPerfSample;
runtime?: SessionRuntimeHints;
selection?: DeviceSelectionMetadata;
device?: AgentDeviceSessionDevice;
/**
* Initial interactive snapshot captured immediately after an open that
* requested `foreground`, composed from the same snapshot-runtime dispatch
* `agent-device snapshot -i` uses. It stays loosely typed rather than reusing
* `CaptureSnapshotResult` because the daemon-side composition does not attach
* client-only fields like `identifiers`.
*/
snapshot?: Record<string, unknown>;
/**
* open --foreground: present when the session opened successfully but the
* composed initial snapshot capture failed. Carries the FULL daemon error
* shape (code, message, hint, details, diagnosticId, logPath) so recovery
* guidance survives to the caller; the session itself is open and usable —
* a `warnings` entry says so and points at `snapshot -i`.
*/
initialSnapshotError?: DaemonError;
identifiers: AgentDeviceIdentifiers;
};
type AppCloseOptions = AgentDeviceRequestOverrides & {
app?: string;
shutdown?: boolean;
saveScript?: boolean | string;
/** #1258: overwrite an existing --save-script target instead of refusing. Alias: --overwrite. */
force?: boolean;
};
type AppCloseResult = {
session: string;
closedApp?: string;
shutdown?: TargetShutdownResult;
/**
* #1258: absolute path of the committed session/healed script when this close
* published one (`close --save-script`, or a repair-armed session's finalize)
* — so a client that requested publication learns where the file landed.
*/
savedScript?: string;
/** ADR 0016 (#4564): the close's response warnings, kept so a lost final script is read, not skipped. */
warnings?: string[];
/**
* ADR 0016 (#4564): the final script of a remote recording was not delivered. The close kept its
* success, so this is the only channel that says the caller file still holds an older version.
*/
scriptDeliveryFailure?: ScriptDeliveryFailure;
identifiers: AgentDeviceIdentifiers;
};
type AppInstallFromSourceOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions & {
source: DaemonInstallSource;
retainPaths?: boolean;
retentionMs?: number;
};
type AppInstallFromSourceResult = {
appName?: string;
appId?: string;
bundleId?: string;
packageName?: string;
launchTarget: string;
installablePath?: string;
archivePath?: string;
materializationId?: string;
materializationExpiresAt?: string;
identifiers: AgentDeviceIdentifiers;
};
type AppListOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions & {
appsFilter?: AppsFilter;
};
type AppPushOptions = DeviceCommandBaseOptions & {
app: string;
payload: string | JsonObject;
};
type AppUninstallOptions = DeviceCommandBaseOptions & LeaseDeviceSpec & {
app: string;
};
type AppTriggerEventOptions = DeviceCommandBaseOptions & {
event: string;
payload?: JsonObject;
};
type MaterializationReleaseOptions = AgentDeviceRequestOverrides & {
materializationId: string;
};
type MaterializationReleaseResult = {
released: boolean;
materializationId: string;
identifiers: AgentDeviceIdentifiers;
};
//#endregion
//#region packages/contracts/src/logs.d.ts
declare const LOG_ACTION_VALUES: readonly ['path', 'start', 'stop', 'doctor', 'mark', 'clear'];
type LogAction = (typeof LOG_ACTION_VALUES)[number];
//#endregion
//#region packages/contracts/src/perf.d.ts
declare const PERF_AREA_VALUES: readonly ['frames', 'memory', 'cpu', 'trace'];
declare const PERF_ACTION_VALUES: readonly ['sample', 'snapshot', 'start', 'stop', 'report'];
declare const PERF_SUBJECT_VALUES: readonly ['profile'];
declare const PERF_KIND_VALUES: readonly ['xctrace', 'simpleperf', 'perfetto', 'android-hprof', 'memgraph'];
type PerfArea = (typeof PERF_AREA_VALUES)[number];
type PerfAction = (typeof PERF_ACTION_VALUES)[number];
type PerfSubject = (typeof PERF_SUBJECT_VALUES)[number];
type PerfKind = (typeof PERF_KIND_VALUES)[number];
//#endregion
//#region packages/contracts/src/client-observability.d.ts
type PerfOptions = DeviceCommandBaseOptions & {
/** Select focused performance evidence. */
area: PerfArea;
subject?: PerfSubject;
action?: PerfAction;
kind?: PerfKind;
template?: string;
out?: string;
tracePath?: string;
};
type LogsOptions = AgentDeviceRequestOverrides & {
action?: LogAction;
message?: string;
restart?: boolean;
};
type EventsOptions = AgentDeviceRequestOverrides & {
cursor?: string;
limit?: number;
};
type NetworkOptions = DeviceCommandBaseOptions & {
action?: 'dump' | 'log';
limit?: number;
include?: NetworkIncludeMode;
};
type AudioOptions = DeviceCommandBaseOptions & {
action?: 'probe';
probeAction?: 'start' | 'status' | 'stop';
durationMs?: number;
bucketMs?: number;
};
type RecordOptions = AgentDeviceRequestOverrides & {
action: 'start' | 'stop';
path?: string;
fps?: number;
quality?: RecordingExportQuality;
hideTouches?: boolean;
recordingScope?: RecordingScope;
};
type TraceOptions = AgentDeviceRequestOverrides & {
action: 'start' | 'stop';
path?: string;
};
//#endregion
//#region packages/contracts/src/client-replay.d.ts
type ReplayRunOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions & {
path: string;
runtime?: SessionRuntimeHints;
/**
* @deprecated ADR 0012 migration step 6: `--update` no longer rewrites
* the script. Accepted for backward compatibility; every divergence
* already carries ranked selector suggestions regardless of this flag.
*/
update?: boolean;
/** @deprecated Use backend: 'maestro'. */
maestro?: boolean;
backend?: string;
env?: string[];
timeoutMs?: number;
/**
* ADR 0012 decision 4 / migration step 5: resume at this 1-based plan
* step, skipping `1..resumeFrom-1` without executing them. Requires
* `resumePlanDigest` from the divergence report that reported this
* step as the failure. `replay` only — `test` has no resume fields.
*/
resumeFrom?: number;
/** The `resume.planDigest` from the divergence report `resumeFrom` came from. */
resumePlanDigest?: string;
/** Leave the session active by suppressing an authored terminal `close` in native `.ad`. */
keepSession?: boolean;
/**
* ADR 0012 decision 6, R1/R6: arms agent-supervised re-record repair
* from this replay attempt onward. Optional string value is the healed
* `.ad`'s output path; absent one, it defaults to the `<path>` sibling
* `<stem>.healed.ad` when the repair ends with `close --save-script`.
*/
saveScript?: boolean | string;
/** #1258: overwrite an existing --save-script target instead of refusing. Alias: --overwrite. */
force?: boolean;
/**
* Activate the headless Android test IME for the sessions this replay opens
* (default on for emulators; opt-in on real devices). `false` keeps the real
* keyboard even on emulators.
*/
testIme?: boolean;
};
type ReplayTestOptions = AgentDeviceRequestOverrides & AgentDeviceSelectionOptions & {
paths: string[];
runtime?: SessionRuntimeHints;
update?: boolean;
/** @deprecated Use backend: 'maestro'. */
maestro?: boolean;
backend?: string;
env?: string[];
failFast?: boolean;
timeoutMs?: number;
retries?: number;
recordVideo?: boolean;
artifactsDir?: string;
/** @deprecated Use the CLI --reporter junit:<path> or --report-junit <path>. */
reportJunit?: string;
shardAll?: number;
shardSplit?: number;
/**
* Activate the headless Android test IME for the sessions each suite attempt
* opens (default on for emulators; opt-in on real devices). `false` keeps the
* real keyboard even on emulators.
*/
testIme?: boolean;
};
type BatchStep = {
command: string;
input: Record<string, unknown>;
runtime?: SessionRuntimeHints;
};
type BatchRunOptions = AgentDeviceRequestOverrides & {
steps: BatchStep[];
onError?: 'stop';
maxSteps?: number;
out?: string;
};
//#endregion
//#region packages/contracts/src/client-request.d.ts
type CommandRequestResult = DaemonResponseData;
//#endregion
//#region packages/contracts/src/is-predicate.d.ts
/** The complete predicate vocabulary accepted by the `is` command. */
declare const IS_PREDICATES: readonly ['visible', 'hidden', 'exists', 'absent', 'editable', 'selected', 'checked', 'focused', 'text'];
type IsPredicate = (typeof IS_PREDICATES)[number];
//#endregion
//#region packages/contracts/src/client-selector-read.d.ts
/**
* #1271 stage 2 (ADR 0012 amendment): `get`/`is`/`find` are observation-only
* and excluded from a repair-armed heal by default. `record` forces this
* action through (the corrective-read case); `noRecord` continues to opt the
* action out entirely. Mutually exclusive.
*/
type RecordControlOptions = {
noRecord?: boolean;
record?: boolean;
};
type GetOptions = DeviceCommandBaseOptions & SelectorSnapshotCommandOptions & ElementTarget & RecordControlOptions & {
format: 'text' | 'attrs';
};
type IsTextPredicateOptions = DeviceCommandBaseOptions & SelectorSnapshotCommandOptions & RecordControlOptions & {
predicate: Extract<IsPredicate, 'text'>;
selector: string;
value: string;
};
type IsStatePredicateOptions = DeviceCommandBaseOptions & SelectorSnapshotCommandOptions & RecordControlOptions & {
predicate: Exclude<IsPredicate, 'text'>;
selector: string;
value?: never;
};
type IsOptions = IsTextPredicateOptions | IsStatePredicateOptions;
type FindBaseOptions = DeviceCommandBaseOptions & FindSnapshotCommandOptions & RecordControlOptions & {
locator?: FindLocator;
query: string;
first?: boolean;
last?: boolean;
};
type FindOptions = (FindBaseOptions & {
action?: 'click' | 'focus' | 'exists' | 'getText' | 'getAttrs' | 'list';
}) | (FindBaseOptions & {
action: 'wait';
timeoutMs?: number;
}) | (FindBaseOptions & {
action: 'fill' | 'type';
value: string;
});
//#endregion
//#region packages/contracts/src/client-session.d.ts
type SessionCloseResult = {
session: string;
shutdown?: TargetShutdownResult;
provider?: CloudProviderSessionResult;
/**
* #1258: absolute path of the committed session/healed script when this close
* published one (`close --save-script`, or a repair-armed session's finalize)
* — so a client that requested publication learns where the file landed.
*/
savedScript?: string;
/** ADR 0016 (#4564): the close's response warnings, kept so a lost final script is read, not skipped. */
warnings?: string[];
/**
* ADR 0016 (#4564): the final script of a remote recording was not delivered. The close kept its
* success, so this is the only channel that says the caller file still holds an older version.
*/
scriptDeliveryFailure?: ScriptDeliveryFailure;
identifiers: AgentDeviceIdentifiers;
};
type SessionSaveScriptOptions = AgentDeviceRequestOverrides & {
path?: string;
/** Atomically replace an existing target instead of refusing publication. */
force?: boolean;
};
type SessionSaveScriptResult = {
session: string;
savedScript: string;
actionCount: number;
identifiers: AgentDeviceIdentifiers;
};
//#endregion
//#region packages/contracts/src/client-settings.d.ts
/** Every permission the public client can name: the app-scoped targets plus the macOS ones. */
type PermissionTarget = (typeof MOBILE_PERMISSION_TARGETS)[number] | (typeof MACOS_PERMISSION_TARGETS)[number];
type FormState<Form> = Form extends {
kind: 'on-off';
} ? 'on' | 'off' : Form extends {
kind: 'choice';
states: readonly (infer State)[];
} ? State : never;
type SettingState<Name extends SettingName> = FormState<(typeof SETTINGS)[Name]['forms'][number]>;
/** Settings whose whole input is a state: no app, coordinates, or permission target. */
type StateOnlySetting = { [Name in SettingName]: (typeof SETTINGS)[Name] extends {
app: string;
} ? never : Name; }[SettingName];
/** A readable setting omits `state` to read the value the target holds. */
type StateOnlySettingOptions = { [Name in StateOnlySetting]: DeviceCommandBaseOptions & ((typeof SETTINGS)[Name] extends {
readable: true;
} ? {
setting: Name;
state?: SettingState<Name>;
} : {
setting: Name;
state: SettingState<Name>;
}); }[StateOnlySetting];
/** Switches that change the whole Android device; naming an app is refused with `setting_app_not_consumed`. */
type DeviceLevelToggleSetting = { [Name in SettingName]: (typeof SETTINGS)[Name] extends {
app: 'input';
appScope: {
mobile: 'device-level';
};
} ? Name : never; }[SettingName];
type DeviceLevelToggleOptions = { [Name in DeviceLevelToggleSetting]: DeviceCommandBaseOptions & {
setting: Name;
state: SettingState<Name>;
app?: string;
}; }[DeviceLevelToggleSetting];
type SettingsUpdateOptions = StateOnlySettingOptions | DeviceLevelToggleOptions | (DeviceCommandBaseOptions & {
setting: 'clear-app-state';
state: 'clear';
app?: string;
}) |
/** On Apple simulators `on`/`off` is a location-permission change for `app` (or the session app). */
(DeviceCommandBaseOptions & {
setting: 'location';
state: 'on' | 'off';
app?: string;
}) | (DeviceCommandBaseOptions & {
setting: 'location';
state: 'set';
latitude: number;
longitude: number;
app?: string;
}) | (DeviceCommandBaseOptions & {
setting: 'permission';
state: PermissionAction;
permission: PermissionTarget;
mode?: PermissionMode;
/**
* The app the permission changes, by bundle id, package name, or app name, resolved as `open`
* resolves it: an iOS simulator, local or Limrun, matches display names and accepts only an
* installed bundle id, and Android accepts only an installed package and refuses a name that
* resolves to an intent with `setting_app_not_package`. Without it the session app is used;
* no app has to be running or open. macOS permissions are host-level TCC grants, so naming an
* app there is refused.
*/
app?: string;
});
//#endregion
//#region packages/contracts/src/alert-contract.d.ts
declare const ALERT_ACTIONS: readonly ['get', 'accept', 'dismiss', 'wait'];
type AlertAction = (typeof ALERT_ACTIONS)[number];
//#endregion
//#region packages/contracts/src/telephony-input.d.ts
/**
* The telephony events an emulator can be asked to simulate: an incoming voice call (`call`),
* answering it (`accept`), ending it (`cancel`), and an inbound text message (`sms`).
*/
declare const TELEPHONY_CALL_ACTIONS: readonly ['call', 'accept', 'cancel'];
type TelephonyCallAction = (typeof TELEPHONY_CALL_ACTIONS)[number];
/** Neutral intent for one telephony event, already validated by {@link parseTelephonyEventInput}. */
type TelephonyEventInput = Readonly<{
action: TelephonyCallAction;
number: string;
}> | Readonly<{
action: 'sms';
number: string;
text: string;
}>;
//#endregion
//#region packages/contracts/src/client-system.d.ts
type WaitCommandTarget = {
durationMs: number;
text?: never;
ref?: never;
selector?: never;
absent?: never;
stable?: never;
quietMs?: never;
timeoutMs?: never;
} | (SelectorSnapshotCommandOptions & {
text: string;
durationMs?: never;
ref?: never;
selector?: never;
absent?: never;
stable?: never;
quietMs?: never;
timeoutMs?: number;
}) | (SelectorSnapshotCommandOptions & {
ref: string;
durationMs?: never;
text?: never;
selector?: never;
absent?: never;
stable?: never;
quietMs?: never;
timeoutMs?: number;
}) | (SelectorSnapshotCommandOptions & {
selector: string;
durationMs?: never;
text?: never;
ref?: never;
absent?: never;
stable?: never;
quietMs?: never;
timeoutMs?: number;
}) | (SelectorSnapshotCommandOptions & {
absent: string;
durationMs?: never;
text?: never;
ref?: never;
selector?: never;
stable?: never;
quietMs?: never;
timeoutMs?: number;
}) | (SelectorSnapshotCommandOptions & {
stable: true;
durationMs?: never;
text?: never;
ref?: never;
selector?: never;
absent?: never;
quietMs?: number;
timeoutMs?: number;
});
type WaitCommandOptions = DeviceCommandBaseOptions & WaitCommandTarget;
type AlertCommandOptions = DeviceCommandBaseOptions & {
action?: AlertAction;
timeoutMs?: number;
};
type AppStateCommandOptions = DeviceCommandBaseOptions;
/** #1638: `back` carries the shared `--settle` triple, and its result may carry the settled diff. */
type BackCommandOptions = DeviceCommandBaseOptions & {
mode?: BackMode;
} & SettleCommandOptions;
type HomeCommandOptions = DeviceCommandBaseOptions;
type OrientationCommandOptions = DeviceCommandBaseOptions & {
/** A fixed rotation, or `auto` to hand rotation back to the sensor (ADB-backed Android only). */
orientation: OrientationRequest;
};
type FoldCommandOptions = DeviceCommandBaseOptions & SetFoldPoseInput;
type AppSwitcherCommandOptions = DeviceCommandBaseOptions;
type ActionButtonCommandOptions = DeviceCommandBaseOptions;
type TvRemoteCommandOptions = DeviceCommandBaseOptions & {
button: TvRemoteButton;
durationMs?: number;
};
type HardwareButtonCommandOptions = DeviceCommandBaseOptions & {
button: HardwareButtonName;
};
type TelephonyCommandOptions = DeviceCommandBaseOptions & TelephonyEventInput;
type KeyboardCommandOptions = DeviceCommandBaseOptions & {
action?: 'status' | 'dismiss' | 'enter' | 'return';
};
type ClipboardCommandOptions = (DeviceCommandBaseOptions & {
action: 'read';
}) | (DeviceCommandBaseOptions & {
action: 'write';
text: string;
});
type ReactNativeCommandOptions = DeviceCommandBaseOptions & {
action: 'dismiss-overlay';
};
type PrepareCommandOptions = DeviceCommandBaseOptions & {
action: 'ios-runner';
timeoutMs?: number;
};
type DoctorCommandOptions = DeviceCommandBaseOptions & {
targetApp?: string;
remote?: boolean;
};
type ViewportCommandOptions = DeviceCommandBaseOptions & {
width: number;
height: number;
};
//#endregion
//#region packages/contracts/src/debug-symbols.d.ts
type DebugSymbolsOptions = {
action?: 'symbols';
artifact: string;
dsym?: string;
searchPath?: string;
out?: string;
cwd?: string;
};
type DebugSymbolsImage = {
name: string;
uuid: string;
arch?: string;
dsymPath: string;
binaryPath: string;
};
type DebugSymbolsCrashFrame = {
index: number;
image: string;
address: string;
symbol?: string;
};
type DebugSymbolsCrashSummary = {
format: 'ips' | 'text';
appName?: string;
bundleId?: string;
version?: string;
incident?: string;
timestamp?: string;
exceptionType?: string;
exceptionCodes?: string;
terminationReason?: string;
crashedThread?: number;
topFrames: DebugSymbolsCrashFrame[];
findings: string[];
};
type DebugSymbolsResult = {
kind: 'debugSymbols';
platform: 'apple';
artifactPath: string;
outPath: string;
crash: DebugSymbolsCrashSummary;
matchedImages: DebugSymbolsImage[];
symbolicatedFrames: number;
skippedImages: number;
warnings?: string[];
message: string;
};
//#endregion
//#region packages/contracts/src/doctor.d.ts
type DoctorStatus = 'pass' | 'warn' | 'fail' | 'info';
type DoctorKind = 'auto' | 'react-native' | 'expo' | 'repack';
type DoctorCheck = {
id: string;
status: DoctorStatus;
summary: string;
hint?: string;
command?: string;
evidence?: Record<string, unknown>;
};
type DoctorCommandResult = {
status: DoctorStatus;
summary: string;
kind: DoctorKind;
platform?: PlatformSelector;
target?: DeviceTarget;
targetApp?: string;
metro?: {
host: string;
port: number;
};
checks: DoctorCheck[];
};
//#endregion
//#region packages/contracts/src/audit.d.ts
type AuditFindingKind = 'small-target' | 'missing-name' | 'covered-control';
type AuditSizeUnit = 'pt' | 'dp';
/** A `small-target` finding's measured size and the recommendation, all in `unit`. */
type AuditSizeDetail = {
unit: AuditSizeUnit;
width: number;
height: number;
recommendedSize: number;
};
type AuditFindingBase = {
/** Plain ref (`@e7`) of the node. It is valid only with the response's `refsGeneration`. */
ref: string;
/** The node's rect in snapshot coordinates (points on iOS, physical pixels on Android). */
rect?: Rect;
/** Control role as the snapshot presents it, such as `button`. */
role: string;
/** Accessible label from the captured node. */
label?: string;
/** Accessibility identifier or resource id from the captured node. */
identifier?: string;
};
type AuditFinding = (AuditFindingBase & {
kind: 'small-target';
severity: 'warning';
detail: AuditSizeDetail;
}) | (AuditFindingBase & {
kind: 'missing-name';
severity: 'warning';
}) | (AuditFindingBase & {
kind: 'covered-control';
severity: 'observation';
});
type AuditChecks = {
/** `unknown`: the producer cannot report truncation, so the tree may be partial. */
snapshot: 'complete' | 'partial' | 'unknown';
};
type AuditResult = {
findings: AuditFinding[];
guidance: Partial<Record<AuditFindingKind, string>>;
checks: AuditChecks;
/** Checks the audit could not run or could only partly run, with the reason. */
limitations: string[];
};
type AuditSnapshotCommandResult = AuditResult & {
/**
* Ref-frame epoch the finding refs were minted from (ADR 0014). Present only when the audit
* returned a finding; pair each ref with it (`@e7~s<refsGeneration>`) before a mutation.
*/
refsGeneration?: number;
warnings?: string[];
};
//#endregion
//#region packages/contracts/src/diff.d.ts
type SnapshotDiffLine = {
kind: 'added' | 'removed' | 'unchanged';
text: string;
/**
* Plain ref body (`e12`) of the current-tree node behind an added line.
* Only populated with `withRefs`; removed and unchanged lines never carry it.
*/
ref?: string;
};
type SnapshotDiffSummary = {
additions: number;
removals: number;
unchanged: number;
};
type DiffSnapshotCommandResult = {
mode: 'snapshot';
baselineInitialized: boolean;
summary: SnapshotDiffSummary;
lines: SnapshotDiffLine[];
warnings?: string[];
};
//#endregion
//#region packages/contracts/src/viewport.d.ts
type ViewportCommandResult = {
width: number;
height: number;
message: string;
};
//#endregion
//#region packages/contracts/src/app-events.d.ts
type TriggerAppEventCommandResult = {
event: string;
eventUrl: string;
transport: 'deep-link';
message: string;
};
//#endregion
//#region packages/contracts/src/app-state.d.ts
/**
* Closed result of the `appstate` command, grounded in the daemon handler's
* success returns (packages/daemon/src/sessions/handlers/session-appstate.ts `handleAppStateCommand`).
* A discriminated union on `platform`:
* - Apple (`ios` / `macos`) session state, with iOS-only device locators that
* the previous hand-written mirror omitted; and
* - Android and HarmonyOS foreground `package` / `activity`.
*
* The handler returns one of these fixed objects (errors take the `ok: false`
* path), so each branch is closed.
*/
type AppStateCommandResult = {
platform: 'ios' | 'macos';
appName: string;
appBundleId?: string;
/** `runner` when the runner read the session app's state; `session` when only the record answered. */
source: 'session' | 'runner';
/**
* How the session app is running, as the runner reads it; absent with `source: 'session'`.
* `runningBackground` after `home` says the app left the foreground, not what took it.
*/
state?: AppleApplicationState;
surface: SessionSurface;
/** iOS only — the session device's UDID. */
device_udid?: string;
/** iOS only — the simulator set path, or `null` when unknown. */
ios_simulator_device_set?: string | null;
} | {
platform: 'android' | 'harmonyos';
package: string;
activity: string;
};
//#endregion
//#region packages/contracts/src/telephony-runtime.d.ts
/**
* Closed result of the `telephony` command: a discriminated union on `action`. The call actions
* echo the number; `sms` also reports the length of the text it delivered.
*/
type TelephonyCommandResult = {
action: Exclude<TelephonyEventInput['action'], 'sms'>;
number: string;
message: string;
} | {
action: 'sms';
number: string;
textLength: number;
message: string;
};
//#endregion
//#region packages/contracts/src/device.d.ts
/**
* Closed result of the `boot` command. Mirrors the daemon handler's only
* success return EXACTLY (packages/daemon/src/sessions/handlers/session-boot.ts via
* session-device-status-response.ts) — the fixed
* object literal `{ platform, target, device, id, kind, booted }` plus the
* additive `appleOs` discriminant, emitted only for Apple devices, and the
* additive `selection` evidence.
*/
type BootCommandResult = {
platform: PublicPlatform;
target: DeviceTarget;
/** Human-readable device name (`device.name`). */
device: string;
/** Stable device id (`device.id`). */
id: string;
kind: DeviceKind;
/** Always `true` on the success path. */
booted: true;
/**
* Additive Apple-OS discriminant (`device.appleOs`): iPhone/iPad/tvOS/visionOS/macOS.
* Present only for Apple devices; absent for non-Apple platforms. `platform` stays the
* leaf (`ios`/`macos`) — this is an extra field, not a replacement.
*/
appleOs?: AppleOS;
/** How the daemon chose this device, as on `open`. */
selection?: DeviceSelectionMetadata;
};
/**
* Closed result of the `shutdown` command. Mirrors the daemon handler's success
* return EXACTLY (packages/daemon/src/sessions/handlers/session-shutdown.ts via
* session-device-status-response.ts) — the fixed object
* literal `{ platform, target, device, id, kind, shutdown }` plus the additive
* `appleOs` discriminant (Apple devices only). The `shutdown` field is the raw
* {@link TargetShutdownResult} returned by the bound `shutdownTarget` operation.
*/
type ShutdownCommandResult = {
platform: PublicPlatform;
target: DeviceTarget;
/** Human-readable device name (`device.name`). */
device: string;
/** Stable device id (`device.id`). */
id: string;
kind: DeviceKind;
shutdown: TargetShutdownResult;
/**
* Additive Apple-OS discriminant (`device.appleOs`): iPhone/iPad/tvOS/visionOS/macOS.
* Present only for Apple devices; absent for non-Apple platforms. `platform` stays the
* leaf (`ios`/`macos`) — this is an extra field, not a replacement.
*/
appleOs?: AppleOS;
};
//#endregion
//#region packages/contracts/src/fold-runtime.d.ts
/**
* The panel the device lights after the pose settled, in that panel's own native points: its pixel
* size divided by its point scale, never rotated. `coordinateSpace` is always
* {@link FoldScreenCoordinateSpace}, and these numbers are NOT snapshot coordinates — the active
* app window can differ from the panel (iPhone Duo: a 669x951 inner panel hosts a 951x669 app
* window), so they cannot place a tap. A caller that needs the app viewport must take a fresh
* snapshot.
*/
type FoldScreenReport = Readonly<{
/** The CoreDevice display name of the panel the device now lights. */
display: string;
/** Marks these dimensions as the panel's native points, never a snapshot's app viewport. */
coordinateSpace: FoldScreenCoordinateSpace;
widthPt: number;
heightPt: number;
}>;
//#endregion
//#region packages/contracts/src/navigation.d.ts
/**
* Closed results of the navigation/global action commands. Each mirrors its
* request-scoped runtime's literal return: a fixed `action` discriminant plus the always-present
* `successText` message (the handlers always pass a non-empty message, so it is
* required here). The handlers spread nothing else, so the shapes are closed —
* consistent with the `viewport` contract, the generic-dispatch Android
* dialog-recovery `warning` annotation is intentionally not part of the contract.
*/
/** `home` — `{ action: 'home', message: 'Home' }`. */
type HomeCommandResult = {
action: 'home';
message: string;
};
/**
* `back` — `{ action: 'back', mode, message: 'Back' }`; `mode` defaults to
* `'in-app'`. The one field the generic route may add on top of the dispatch
* runtime's literal return: `settle`, the opt-in `--settle` observation
* (#1638), attached after the command by the generic dispatcher.
*/
type BackCommandResult = {
action: 'back';
mode: BackMode;
message: string;
settle?: SettleObservation;
};
/**
* `orientation` — `{ action: 'orientation', orientation, message: 'Rotated to <orientation>' }`.
*
* An owner that reports no resulting rotation is not evidence that the device
* rotated. That case keeps the requested `orientation` for compatibility, but
* discloses `confirmed: false` plus a `warning`, and names the request in
* `message` (`Rotation requested: <orientation> (unconfirmed)`).
*/
type OrientationCommandResult = {
action: 'orientation';
orientation: DeviceRotation;
message: string;
confirmed?: boolean;
warning?: string;
};
/**
* `fold` — `{ action: 'fold', pose, hingeAngleDegrees, screen?, message }`.
*
* Unlike `orientation`, there is no unconfirmed variant: the Apple owner reads the hinge angle
* back from CoreDevice after the simulator HID helper sends the pose, and reports a pose only when
* that reading agrees with the request. `screen` names the panel the device lights afterwards and
* that panel's native point size (ADR 0025); it is the panel's geometry, not the app viewport, so a
* caller must take a fresh snapshot before placing a tap.
*/
type FoldCommandResult = {
action: 'fold';
pose: FoldPose;
hingeAngleDegrees: number;
screen?: FoldScreenReport;
message: string;
};
/** `app-switcher` — `{ action: 'app-switcher', message: 'Opened app switcher' }`. */
type AppSwitcherCommandResult = {
action: 'app-switcher';
message: string;
};
/**
* `action-button` — `{ action: 'action-button', message: 'Pressed Action Button' }`.
*
* Deliberately narrower than `tv-remote`: `XCUIDevice.press(.action)` takes no hold duration, so
* there is no `durationMs` to report and no button to name.
*/
type ActionButtonCommandResult = {
action: 'action-button';
message: string;
};
/** `tv-remote` — `{ action: 'tv-remote', button, durationMs?, message }`. */
type TvRemoteCommandResult = {
action: 'tv-remote';
button: TvRemoteButton;
durationMs?: number;
message: string;
};
/**
* `hardware-button` — `{ action: 'hardware-button', button, message: 'Pressed hardware button <button>' }`.
*
* The button is the public name (`volume-up`, `volume-down`, `power`, `mute`, `sleep`, `wake`, or
* one of the five media names). The result reports that the press was dispatched; it carries no
* volume level, mute state, or screen state, because the command observes none of them (#3848).
*/
type HardwareButtonCommandResult = {
action: 'hardware-button';
button: HardwareButtonName;
message: string;
};
//#endregion
//#region packages/contracts/src/clipboard.d.ts
/**
* Closed result of the `clipboard` command. Mirrors the session runtime's
* literal return exactly (`packages/daemon/src/execution/handlers/session-clipboard.ts`): a
* discriminated union on `action`. `read` returns the clipboard `text`; `write`
* reports the written `textLength` plus the `successText` message. The handler
* spreads nothing else, so each branch is closed.
*/
type ClipboardCommandResult = {
action: 'read';
text: string;
} | {
action: 'write';
textLength: number;
message: string;
};
//#endregion
//#region packages/contracts/src/wait.d.ts
/**
* Public daemon result for `wait`. The runtime-local result carries a `kind`
* discriminant, but `toDaemonWaitData` intentionally projects the normal daemon
* payload to this compact shape. The direct iOS selector fast path may still
* include `kind: 'selector'` additively.
*/
type WaitCommandResult = {
waitedMs: number;
kind?: 'selector';
text?: string;
selector?: string;
captures?: number;
nodeCount?: number;
hint?: string;
warning?: string;
};
//#endregion
//#region packages/contracts/src/recording-stop-observation.d.ts
/**
* What a recording backend observed about its recorder when it was asked to stop
* (ADR 0024 2.2). This is the first of the two facts a stop answers; whether a playable export
* exists is answered separately by the export itself.
*
* The observation describes what was observed, never what identity proved. An identity probe that
* could not be read is `unconfirmed`, not `lost`, and a proven mismatch is `lost` even though the
* same probe found nothing.
*
* The variants below define the vocabulary; they are not a claim that anything emits each one.
* Today's producers answer `confirmed` — an exited `simctl` process, an acknowledged runner stop,
* Android recorders proven gone, a stopped HarmonyOS toggle, a stopped browser provider — and `lost`
* with `owner-session-lost` for an Apple recording whose session was invalidated. The unconfirmed
* reasons and the two identity reasons for `lost` arrive with the steps that gain the probe or the
* retry they describe; until a step owns one, a stop that cannot prove its recorder gone reports
* that as its own error rather than serving an export labelled `unconfirmed`.
*/
declare const RECORDER_OBSERVATION_VALUES: readonly ['confirmed', 'unconfirmed', 'lost'];
/** The one word every backend reports, and the word the `record stop` response serves. */
type RecorderObservation = (typeof RECORDER_OBSERVATION_VALUES)[number];
//#endregion
//#region packages/contracts/src/recording-native-path.d.ts
/**
* What may happen to the recorder's native artifact path — the file the recorder itself writes
* (the `simctl` output, the device-side chunks, the media-library item, the browser's WebM) once a
* recording's export is committed (ADR 0024 2.3). This is the second of the two facts a stop
* answers, and it stays independent of the recorder observation: a recorder that never confirmed
* leaves its path `pending` even when the export is playable, and a `lost` identity says nothing
* about who writes there now, so it never permits a deletion either.
*
* - `pending`: the backend has not proven the writer gone, so nothing may remove the path.
* - `retirable`: the writer is proven gone; a fenced retirement is still owed.
* - `retired`: retirement succeeded or the backend verified the artifact is absent.
*
* The bullets define the vocabulary; they are not a claim that anything emits each state. Today's
* producers answer `retirable` for an Apple runner artifact left on the device and `retired` for an
* Android recording whose chunks the device no longer shows or a HarmonyOS recording whose removals
* were verified. A backend whose recorder writes the served export itself omits the field. `pending`
* is declared ahead of the step that reports a recorder nobody proved gone, and no stop emits it yet.
*/
declare const NATIVE_PATH_DISPOSITION_VALUES: readonly ['pending', 'retirable', 'retired'];
type NativePathDisposition = (typeof NATIVE_PATH_DISPOSITION_VALUES)[number];
//#endregion
//#region packages/contracts/src/recording.d.ts
type RecordingAppIdentity = {
bundleId: string;
name?: string;
};
type RecordingStartCommandResult = {
recording: 'started';
outPath: string;
sessionStateDir: string;
recordingBackend?: string;
recordingScope?: RecordingScope;
recordOnlySession?: boolean;
activeSessionApp?: RecordingAppIdentity;
showTouches: boolean;
};
type RecordingStopCommandResult = {
recording: 'stopped';
outPath: string;
telemetryPath?: string;
artifacts: DaemonArtifact[];
recordingBackend?: string;
recordingScope?: RecordingScope;
recordOnlySession?: boolean;
activeSessionApp?: RecordingAppIdentity;
durationMs: number;
capturedDurationMs?: number;
/**
* What the recorder itself was observed doing when the stop was carried out (ADR 0024 2.2).
* `confirmed` is the ordinary answer; `unconfirmed` and `lost` say the export was served without
* proof that the recorder terminated, which is a disclosure and not a failure. Absent on a
* response replayed from a manifest written before this field existed.
*/
recorder?: RecorderObservation;
/**
* What the recorder's native artifact path was left as (ADR 0024 2.3): `retired` once the backend
* removed it and verified that, `retirable` when the writer is proven gone and a fenced removal is
* still owed, `pending` when nothing proves the writer gone yet. Absent when the backend has no
* native path of its own to keep.
*/
nativePathDisposition?: NativePathDisposition;
showTouches: boolean;
warning?: string;
overlayWarning?: string;
chunks?: Array<{
index: number;
path: string;
}>;
};
type RecordingCommandResult = RecordingStartCommandResult | RecordingStopCommandResult;
type TraceCommandResult = {
trace: 'started';
outPath: string;
} | {
trace: 'stopped';
outPath: string;
artifacts: DaemonArtifact[];
};
//#endregion
//#region packages/command-registry/src/command-result.d.ts
/**
* The additive typed-result spine (ADR 0008, "Consequences" result-narrowing
* gap).
*
* Maps a command name to the per-command result type from `@agent-device/contracts`. It
* is SEEDED, not exhaustive: a command is listed here only once its accurate,
* closed result shape lives in the contracts layer. Commands whose daemon
* handler spreads dynamic/Record data (screenshot overlays, gesture
* visualization, perf, logs, …) are deliberately omitted rather than given an
* invented shape.
*
* Batches 1-2 wired `boot` / `shutdown` / `viewport` and the navigation/action
* commands `home` / `back` / `orientation` / `app-switcher` alongside the seed
* interaction quartet. Batch 3 adds `clipboard` (a closed `read`/`write` union) and
* `appstate` (a closed `platform` union — Apple session state with the iOS-only
* device locators, or Android package/activity). Batch 4 adds `keyboard` (a
* closed flat shape). Batch 5 adds the compact daemon projections for `wait`,
* `prepare`, `push`, and `trigger-app-event`. #1652 adds `scroll`
* (ScrollCommandResult): the shared dispatch vocabulary plus the opt-in
* settle observation, so the settle-capable generic-route pair (`back`,
* `scroll`) is fully typed and its MCP output schema derives from the trait.
* Each entry is grounded in a
* re-read of the handler's literal return; see the per-type docstrings.
*/
interface CommandResultMap {
'action-button': ActionButtonCommandResult;
'app-switcher': AppSwitcherCommandResult;
appstate: AppStateCommandResult;
audit: AuditSnapshotCommandResult;
back: BackCommandResult;
boot: BootCommandResult;
click: ClickCommandResponseData;
clipboard: ClipboardCommandResult;
diff: DiffSnapshotCommandResult;
doctor: DoctorCommandResult;
fill: FillCommandResponseData;
find: FindCommandResponseData;
fold: FoldCommandResult;
'hardware-button': HardwareButtonCommandResult;
home: HomeCommandResult;
hover: HoverCommandResponseData;
keyboard: KeyboardCommandResult;
longpress: LongPressCommandResponseData;
orientation: OrientationCommandResult;
prepare: PrepareCommandResult;
press: PressCommandResponseData;
push: PushCommandResult;
record: RecordingCommandResult;
replay: ReplayCommandResult;
scroll: ScrollCommandResult;
shutdown: ShutdownCommandResult;
telephony: TelephonyCommandResult;
test: ReplaySuiteResult;
trace: TraceCommandResult;
'trigger-app-event': TriggerAppEventCommandResult;
'tv-remote': TvRemoteCommandResult;
viewport: ViewportCommandResult;
wait: WaitCommandResult;
}
/**
* The typed result for a command named `N`. Seeded commands resolve to their
* contract result type from {@link CommandResultMap}; every other (unmigrated)
* command falls back to the untyped `Record<string, unknown>` bag. That default
* branch is what keeps the mapping total over every command name, so consumers
* can switch to `CommandResult<Name>` without first migrating every command.
* Add a command to the map only when its producer exposes an accurate closed
* contract. Do not narrow an unmigrated result with casts, compatibility
* aliases, or invented partial shapes.
*/
type CommandResult<N extends string> = N extends keyof CommandResultMap ? CommandResultMap[N] : Record<string, unknown>;
//#endregion
//#region packages/command-surface/src/client-port.d.ts
type AgentDeviceCommandClient = {
back: (options?: BackCommandOptions) => Promise<CommandResult<'back'>>;
home: (options?: HomeCommandOptions) => Promise<CommandResult<'home'>>;
orientation: (options: OrientationCommandOptions) => Promise<CommandResult<'orientation'>>;
fold: (options: FoldCommandOptions) => Promise<CommandResult<'fold'>>;
appSwitcher: (options?: AppSwitcherCommandOptions) => Promise<CommandResult<'app-switcher'>>;
actionButton: (options?: ActionButtonCommandOptions) => Promise<CommandResult<'action-button'>>;
tvRemote: (options: TvRemoteCommandOptions) => Promise<CommandResult<'tv-remote'>>;
hardwareButton: (options: HardwareButtonCommandOptions) => Promise<CommandResult<'hardware-button'>>;
telephony: (options: TelephonyCommandOptions) => Promise<CommandResult<'telephony'>>;
wait: (options: WaitCommandOptions) => Promise<CommandResult<'wait'>>;
alert: (options?: AlertCommandOptions) => Promise<CommandRequestResult>;
appState: (options?: AppStateCommandOptions) => Promise<CommandResult<'appstate'>>;
keyboard: (options?: KeyboardCommandOptions) => Promise<CommandResult<'keyboard'>>;
clipboard: (options: ClipboardCommandOptions) => Promise<CommandResult<'clipboard'>>;
reactNative: (options: ReactNativeCommandOptions) => Promise<CommandRequestResult>;
doctor: (options?: DoctorCommandOptions) => Promise<CommandResult<'doctor'>>;
/**
* JSON prepare results include timing.additiveParts for additive wall-clock phases.
* Top-level buildMs/connectMs/healthCheckMs are diagnostics and may overlap.
*/
prepare: (options: PrepareCommandOptions) => Promise<CommandResult<'prepare'>>;
viewport: (options: ViewportCommandOptions) => Promise<CommandResult<'viewport'>>;
};
type AgentDeviceClient = {
command: AgentDeviceCommandClient;
devices: {
list: (options?: AgentDeviceRequestOverrides & AgentDeviceSelectionOptions) => Promise<AgentDeviceDevice[]>;
capabilities: (options?: AgentDeviceRequestOverrides & AgentDeviceSelectionOptions) => Promise<AgentDeviceCapabilitiesResult>;
boot: (options?: DeviceBootOptions) => Promise<CommandResult<'boot'>>;
shutdown: (options?: DeviceShutdownOptions) => Promise<CommandResult<'shutdown'>>;
};
sessions: {
list: (options?: AgentDeviceRequestOverrides) => Promise<AgentDeviceSession[]>;
stateDir: (options?: AgentDeviceRequestOverrides & Pick<AgentDeviceClientConfig, 'stateDir'>) => Promise<string>;
close: (options?: AgentDeviceRequestOverrides & {
shutdown?: boolean;
saveScript?: boolean | string;
/** #1258: overwrite an existing --save-script target instead of refusing. Alias: --overwrite. */
force?: boolean;
}) => Promise<SessionCloseResult>;
saveScript: (options?: SessionSaveScriptOptions) => Promise<SessionSaveScriptResult>;
artifacts: (options?: CloudArtifactsOptions) => Promise<AgentArtifactsResult>;
};
apps: {
install: (options: AppInstallOptions) => Promise<AppDeployResult>;
reinstall: (options: AppDeployOptions) => Promise<AppDeployResult>;
uninstall: (options: AppUninstallOptions) => Promise<CommandResult<'uninstall'>>;
installFromSource: (options: AppInstallFromSourceOptions) => Promise<AppInstallFromSourceResult>;
list: (options?: AppListOptions) => Promise<string[]>;
open: (options: AppOpenOptions) => Promise<AppOpenResult>;
close: (options?: AppCloseOptions) => Promise<AppCloseResult>;
push: (options: AppPushOptions) => Promise<CommandResult<'push'>>;
triggerEvent: (options: AppTriggerEventOptions) => Promise<CommandResult<'trigger-app-event'>>;
};
materializations: {
release: (options: MaterializationReleaseOptions) => Promise<MaterializationReleaseResult>;
};
leases: {
allocate: (options: LeaseAllocateOptions) => Promise<Lease>;
heartbeat: (options: LeaseScopedOptions) => Promise<Lease>;
release: (options: LeaseScopedOptions) => Promise<{
released: boolean;
provider?: CloudProviderSessionResult;
}>;
humanControl: {
list: (options?: AgentDeviceRequestOverrides) => Promise<HumanControlHold[]>;
put: (id: string, input?: HumanControlHoldOptions, options?: AgentDeviceRequestOverrides) => Promise<HumanControlHold>;
remove: (id: string, options?: AgentDeviceRequestOverrides) => Promise<boolean>;
};
};
metro: {
prepare: (options: MetroPrepareOptions) => Promise<MetroPrepareResult>;
reload: (options?: MetroReloadOptions) => Promise<MetroReloadResult>;
};
capture: {
snapshot: (options?: CaptureSnapshotOptions) => Promise<CaptureSnapshotResult>;
screenshot: (options?: CaptureScreenshotOptions) => Promise<CaptureScreenshotResult>;
diff: (options: CaptureDiffOptions) => Promise<CommandResult<'diff'>>;
audit: (options?: CaptureAuditOptions) => Promise<CommandResult<'audit'>>;
};
interactions: {
gesture: (options: GestureOptions) => Promise<CommandRequestResult>;
click: (options: ClickOptions) => Promise<CommandResult<'click'>>;
press: (options: PressOptions) => Promise<CommandResult<'press'>>;
longPress: (options: LongPressOptions) => Promise<CommandResult<'longpress'>>;
hover: (options: HoverOptions) => Promise<CommandResult<'hover'>>;
swipe: (options: SwipeOptions) => Promise<CommandRequestResult>;
pan: (options: PanOptions) => Promise<CommandRequestResult>;
drag: (options: DragOptions) => Promise<CommandRequestResult>;
fling: (options: FlingOptions) => Promise<CommandRequestResult>;
swipeGesture: (options: SwipeGestureOptions) => Promise<CommandRequestResult>;
focus: (options: FocusOptions) => Promise<CommandRequestResult>;
type: (options: TypeTextOptions) => Promise<CommandRequestResult>;
fill: (options: FillOptions) => Promise<CommandResult<'fill'>>;
scroll: (options: ScrollOptions) => Promise<CommandRequestResult>;
pinch: (options: PinchOptions) => Promise<CommandRequestResult>;
rotateGesture: (options: RotateGestureOptions) => Promise<CommandRequestResult>;
transformGesture: (options: TransformGestureOptions) => Promise<CommandRequestResult>;
tapGesture: (options: TapGestureOptions) => Promise<CommandRequestResult>;
get: (options: GetOptions) => Promise<CommandRequestResult>;
is: (options: IsOptions) => Promise<CommandRequestResult>;
find: (options: FindOptions) => Promise<CommandResult<'find'>>;
};
replay: {
run: (options: ReplayRunOptions) => Promise<CommandResult<'replay'>>;
test: (options: ReplayTestOptions) => Promise<CommandResult<'test'>>;
};
batch: {
run: (options: BatchRunOptions) => Promise<BatchRunResult>;
};
observability: {
perf: (options: PerfOptions) => Promise<CommandRequestResult>;
logs: (options?: LogsOptions) => Promise<CommandRequestResult>;
events: (options?: EventsOptions) => Promise<CommandRequestResult>;
network: (options?: NetworkOptions) => Promise<CommandRequestResult>;
audio: (options?: AudioOptions) => Promise<CommandRequestResult>;
};
debug: {
symbols: (options: DebugSymbolsOptions) => Promise<DebugSymbolsResult>;
};
recording: {
record: (options: RecordOptions) => Promise<CommandResult<'record'>>;
trace: (options: TraceOptions) => Promise<CommandResult<'trace'>>;
};
settings: {
update: (options: SettingsUpdateOptions) => Promise<CommandRequestResult>;
};
};
//#endregion
export { RecordOptions as $, CloudArtifactsOptions as $t, AlertAction as A, DaemonBinding as An, PressOptions as At, IsStatePredicateOptions as B, ElementTarget as Bt, PrepareCommandOptions as C, isRecord as Cn, FocusOptions as Ct, ViewportCommandOptions as D, AgentDeviceIdentifiers as Dn, PanOptions as Dt, TvRemoteCommandOptions as E, AgentDeviceDaemonTransportContext as En, LongPressOptions as Et, SessionSaveScriptResult as F, EnsureDaemonOptions as Fn, SwipeGestureOptions as Ft, BatchStep as G, CaptureAuditOptions as Gt, RecordControlOptions as H, PointTarget as Ht, FindBaseOptions as I, SwipeOptions as It, AudioOptions as J, CaptureScreenshotResult as Jt, ReplayRunOptions as K, CaptureDiffOptions as Kt, FindOptions as L, TapGestureOptions as Lt, SettingsUpdateOptions as M, DaemonIdentity as Mn, RotateGestureOptions as Mt, SessionCloseResult as N, DaemonLifecycle as Nn, ScrollOptions as Nt, WaitCommandOptions as O, AgentDeviceRequestOverrides as On, PinchOptions as Ot, SessionSaveScriptOptions as P, DeviceCommandBaseOptions as Pn, SettleCommandOptions as Pt, PerfOptions as Q, SelectorSnapshotCommandOptions as Qt, GetOptions as R, TransformGestureOptions as Rt, OrientationCommandOptions as S, JsonValue as Sn, FlingOptions as St, TelephonyCommandOptions as T, AgentDeviceDaemonTransport as Tn, HoverOptions as Tt, CommandRequestResult as U, RefTarget as Ut, IsTextPredicateOptions as V, InteractionTarget as Vt, BatchRunOptions as W, SelectorTarget as Wt, LogsOptions as X, CaptureSnapshotResult as Xt, EventsOptions as Y, CaptureSnapshotOptions as Yt, NetworkOptions as Z, FindSnapshotCommandOptions as Zt, DoctorCommandOptions as _, TargetShutdownResult as _n, MaterializationReleaseOptions as _t, WaitCommandResult as a, LeaseAllocateOptions as an, AppInstallFromSourceOptions as at, HomeCommandOptions as b, JsonObject as bn, DragOptions as bt, DoctorCommandResult as c, LeaseOptions as cn, AppListOptions as ct, ActionButtonCommandOptions as d, AgentDeviceDevice as dn, AppPushOptions as dt, EndedLease as en, TraceOptions as et, AlertCommandOptions as f, AgentDeviceSession as fn, AppTriggerEventOptions as ft, ClipboardCommandOptions as g, StartupPerfSample as gn, DeviceSelectionSource as gt, BackCommandOptions as h, DeviceShutdownOptions as hn, DeviceSelectionReason as ht, TraceCommandResult as i, Lease as in, AppDeployResult as it, PermissionTarget as j, DaemonConnection as jn, RepeatedPressOptions as jt, WaitCommandTarget as k, AgentDeviceSelectionOptions as kn, PostGestureStabilizationOptions as kt, DebugSymbolsOptions as l, LeaseScopedOptions as ln, AppOpenOptions as lt, AppSwitcherCommandOptions as m, DeviceBootOptions as mn, DeviceSelectionMetadata as mt, AgentDeviceCommandClient as n, HumanControlHoldOptions as nn, AppCloseResult as nt, TriggerAppEventCommandResult as o, LeaseDevice as on, AppInstallFromSourceResult as ot, AppStateCommandOptions as p, AgentDeviceSessionDevice as pn, AppUninstallOptions as pt, ReplayTestOptions as q, CaptureScreenshotOptions as qt, RecordingCommandResult as r, HumanControlHoldScope as rn, AppDeployOptions as rt, DiffSnapshotCommandResult as s, LeaseDeviceSpec as sn, AppInstallOptions as st, AgentDeviceClient as t, HumanControlHold as tn, AppCloseOptions as tt, DebugSymbolsResult as u, AgentDeviceCapabilitiesResult as un, AppOpenResult as ut, FoldCommandOptions as v, PushCommandResult as vn, MaterializationReleaseResult as vt, ReactNativeCommandOptions as w, AgentDeviceClientConfig as wn, GestureOptions as wt, KeyboardCommandOptions as x, JsonPrimitive as xn, FillOptions as xt, HardwareButtonCommandOptions as y, PrepareCommandResult as yn, ClickOptions as yt, IsOptions as z, TypeTextOptions as zt };