//#region packages/kernel/src/errors.d.ts
/**
 * The known error codes as a value, so gates can enumerate them: every code
 * here must resolve a hint through `defaultHintForCode`, and every code
 * `retriableForErrorCode` classifies must have a recovery quiz in the help
 * benchmark (scripts/__tests__/help-conformance-error-recovery-coverage.test.ts).
 * `KnownAppErrorCode` is derived from this array, so a new code cannot be added
 * to the type without entering the enumeration.
 */
declare const KNOWN_APP_ERROR_CODES: readonly ['INVALID_ARGS', 'DEVICE_NOT_FOUND', 'DEVICE_IN_USE', 'TOOL_MISSING', 'APP_NOT_INSTALLED', 'UNSUPPORTED_PLATFORM', 'UNSUPPORTED_OPERATION', 'NOT_IMPLEMENTED', 'COMMAND_FAILED', 'SESSION_NOT_FOUND', 'UNAUTHORIZED', 'AMBIGUOUS_MATCH', 'REPLAY_DIVERGENCE', 'REPAIR_SESSION_EXPIRED', 'REPAIR_COMMIT_FAILED', 'UNKNOWN'];
type KnownAppErrorCode = (typeof KNOWN_APP_ERROR_CODES)[number];
type AppErrorCode = KnownAppErrorCode | (string & {});
declare class AppError extends Error {
  static [Symbol.hasInstance](value: unknown): boolean;
  code: AppErrorCode;
  details?: AppErrorDetails;
  cause?: unknown;
  constructor(code: AppErrorCode, message: string, details?: AppErrorDetails, cause?: unknown);
}
/**
 * Locator for one request's diagnostics record on the daemon host, in the
 * daemon's own vocabulary rather than as a filesystem path: `logPath` names
 * that same record as a path, which only a caller on the daemon host can read.
 * A remote caller fetches the record by this locator instead
 * (`GET /sessions/<session>/requests/<requestId>/diagnostics`).
 */
type DiagnosticsRecordRef = {
  session: string;
  requestId: string;
};
/**
 * Whether the operation a failed request asked for reached the device. `no`: it provably never
 * did, so resending it is safe. `unknown`: it may have landed, so observe the device before
 * resending. A failure without the field was classified by no producer. The producer rows live in
 * `contracts/fixtures/dispatch-disclosure.json`.
 */
type DispatchDisclosure = 'no' | 'unknown';
/** The error details bag as it crosses the wire: free-form, with the typed keys a reader may rely on. */
type ErrorWireDetails = Record<string, unknown> & {
  dispatched?: DispatchDisclosure;
};
type ErrorCause = {
  message: string;
  code?: string;
};
/**
 * Details bag for AppError. Free-form context is allowed, but these keys carry
 * meaning at normalize/render time and must keep their types:
 * - `hint` — overrides `defaultHintForCode`; re-wraps preserve an existing hint.
 * - `diagnosticId` / `logPath` / `logPathUnavailable` / `diagnosticsRecord` —
 *   lifted onto the normalized error, stripped from details.
 * - `processExitError` + `stdout`/`stderr`/`exitCode` — marks a wrap of a real
 *   process exit so normalizeError can surface the first meaningful stderr line;
 *   build these via `execFailureDetails`/`requireExecSuccess` in @agent-device/host-kit/command
 *   rather than by hand.
 * - `retriable` — typed retry signal hoisted to the wire error shape.
 * - `reason` — machine-dispatchable sub-classification within a code.
 * - `dispatched` — {@link DispatchDisclosure} set by the producer that proved it; kept in details on
 *   the wire and never defaulted.
 */
type AppErrorDetails = Record<string, unknown> & {
  hint?: string;
  diagnosticId?: string;
  logPath?: string;
  logPathUnavailable?: string;
  diagnosticsRecord?: DiagnosticsRecordRef;
  retriable?: boolean;
  supportedOn?: string;
  processExitError?: boolean;
  stdout?: string;
  stderr?: string;
  exitCode?: number | null;
  reason?: string;
  dispatched?: DispatchDisclosure;
};
type NormalizedError = {
  code: string;
  message: string;
  cause?: ErrorCause;
  hint?: string;
  diagnosticId?: string;
  /**
   * Diagnostics record path **the reader of this error can open**. A daemon
   * renders its own host path here; a client talking to a REMOTE daemon
   * replaces it with the caller-local copy it fetched, or drops it and sets
   * `logPathUnavailable` (see `localizeRemoteDaemonError`). A path the reader
   * cannot open never belongs in this field (#1801).
   */
  logPath?: string;
  /**
   * Why no readable `logPath` could be produced, e.g.
   * `remote daemon https://host, request 8f2c: 404`. Set only in place of
   * `logPath`, and never carries a daemon-host path.
   */
  logPathUnavailable?: string;
  /** Locator the record can be fetched by when it lives on a remote daemon. */
  diagnosticsRecord?: DiagnosticsRecordRef;
  /**
   * Lifted from `details.retriable` when a throw site classified the failure as
   * clearly transient (or clearly not). Included only when set, so the default
   * error wire shape is unchanged.
   */
  retriable?: boolean;
  supportedOn?: string;
  details?: ErrorWireDetails;
};
/**
 * Error payload returned by the daemon transport. It is kept beside the local
 * error representation because clients immediately rehydrate this wire shape
 * into `AppError` before rendering or handling it.
 */
type DaemonError = NormalizedError;
declare function isAgentDeviceError(err: unknown): err is AppError;
type NormalizeErrorContext = {
  diagnosticId?: string;
  logPath?: string;
  diagnosticsRecord?: DiagnosticsRecordRef;
};
declare function normalizeAgentDeviceError(err: unknown, context?: NormalizeErrorContext): NormalizedError;
declare function normalizeError(err: unknown, context?: NormalizeErrorContext): NormalizedError;
/**
 * The recovery step for a failure whose producer gave no hint. The CLI prints it as the `Next:`
 * step, so it never asks for a `--debug` rerun (a failure already flushed its diagnostics log) or
 * for a blind retry. It depends on the code only: the CLI adds the observe-first step from the
 * final `details.dispatched` when it prints the line, so a layer that raises the disclosure after
 * this hint was resolved cannot leave a stale retry instruction behind.
 */
declare function defaultHintForCode(code: string): string;
//#endregion
//#region packages/kernel/src/snapshot.d.ts
/**
 * Structured quality verdict computed once by a platform snapshot capture/presentation plan.
 * The daemon renders it; it never re-derives degradation from node shapes.
 *
 * Defined here (the foundational snapshot type module) rather than in
 * capture-kit's snapshot-quality-verdict.ts so SnapshotNode can reference it without a cyclic
 * import. Ownership splits three ways: this module owns the vocabularies below, capture-kit parses
 * an untrusted runner payload into them, and contracts re-hydrates a verdict this repo published.
 */
/**
 * Which capture STRATEGY produced a snapshot, within one platform's plan —
 * distinct from `SnapshotBackend`, which names the platform channel
 * (`xctest`/`android`/…). A platform plan may change strategy mid-sequence, and two strategies do
 * not return comparable views of one screen (#1569). Android's helper presentation is included
 * here so its quality verdict uses the same typed contract as the iOS strategy chain.
 */
type SnapshotCaptureBackend = 'tree' | 'queries' | 'private-ax' | 'android-helper';
/** Internal backends that evidence probes may select explicitly. */
type SnapshotPreferredBackend = 'tree' | 'private-ax';
type SnapshotQualityTiming = {
  acquisitionMs: number;
  presentationMs: number;
};
/**
 * The verdict states a capture plan may stamp. This tuple is the ONE declaration of that
 * vocabulary, and `SnapshotQualityVerdict['state']` is its projection; readers hold exhaustive maps
 * over the union instead of importing this module, because the eager-closure gate freezes their
 * loading shape (#2872). This tuple and the Apple runner's `SnapshotQualityState.allCases` are each
 * pinned as a set to `contracts/fixtures/ios-snapshot-quality-states.json`, so a state one side
 * renames, adds, or deletes without the other goes red there instead of arriving as a verdict the
 * host cannot name — which reads as verdict-absent and drops the disclosure with it.
 */
declare const SNAPSHOT_QUALITY_STATES: readonly ['healthy', 'recovered', 'sparse'];
type SnapshotQualityState = (typeof SNAPSHOT_QUALITY_STATES)[number];
type SnapshotQualityNote = {
  code: 'regular-geometry-clipped';
  clippedNodeCount: number;
  droppedNodeCount: number;
};
type SnapshotQualityVerdict = {
  state: SnapshotQualityState;
  backend: SnapshotCaptureBackend;
  reason?: string;
  reasonCode?: 'ax-rejected' | 'sparse-tree' | 'budget' | 'no-nodes' | 'capture-failed' | 'presentation-failed' | 'deferred' | 'requested-backend';
  effectiveDepth?: number;
  collapsedLeafIndexes?: number[];
  /**
   * Coverage of an opt-in custom-action pass (`snapshot --actions`): how many
   * merged elements were eligible and how many the bounded pass reached. An
   * unread element is indistinguishable from one with no actions, so a partial
   * pass has to be disclosed rather than left to look complete.
   */
  customActions?: {
    read: number;
    candidates: number;
    truncated: number;
    blocked: boolean;
  };
  /** Response-level phase timing for the backend named by `backend`. */
  timing?: SnapshotQualityTiming;
};
type Rect = {
  x: number;
  y: number;
  width: number;
  height: number;
};
type Point = {
  x: number;
  y: number;
};
type IosSnapshotObservation = {
  mode: 'observe-only';
  activationPerformed: false;
  /** XCTest's report, not proof of foreground ownership (#2696). */
  appState: 'runningForeground';
  appStateSource: 'xcuiapplication-state';
};
type SnapshotOptions = {
  observeOnly?: boolean;
  interactiveOnly?: boolean;
  depth?: number;
  scope?: string;
  raw?: boolean;
  /**
   * Internal (never CLI-exposed): capture with this backend first regardless of
   * channel health. Evidence comparisons are only valid same-backend (backends
   * are not comparable views of a screen), so a corroboration probe must be
   * captured the way its baseline was.
   */
  preferredBackend?: SnapshotPreferredBackend;
  /**
   * Read accessibility custom actions for elements that merge their children
   * away. Opt-in because each such element costs its own accessibility round
   * trip; see `RawSnapshotNode.actions`.
   */
  customActions?: boolean;
};
/** The CLI/daemon flag key for each snapshot capture option, by option name. */
declare const SNAPSHOT_OPTION_FLAGS: {
  readonly interactiveOnly: 'snapshotInteractiveOnly';
  readonly depth: 'snapshotDepth';
  readonly scope: 'snapshotScope';
  readonly raw: 'snapshotRaw';
  readonly observeOnly: 'snapshotObserveOnly';
  readonly customActions: 'snapshotCustomActions';
  readonly forceFull: 'snapshotForceFull';
  readonly includeHiddenContentHints: 'snapshotIncludeHiddenContentHints';
  readonly preferredBackend: 'snapshotPreferredBackend';
};
type SnapshotOptionKey = keyof typeof SNAPSHOT_OPTION_FLAGS;
type SnapshotOptionValues = {
  observeOnly: boolean;
  interactiveOnly: boolean;
  depth: number;
  scope: string;
  raw: boolean;
  customActions: boolean;
  forceFull: boolean;
  includeHiddenContentHints: boolean;
  preferredBackend: SnapshotPreferredBackend;
};
/** The option-vocabulary view of the declared pairs, narrowed to `TKeys`. */
type SnapshotOptionFields<TKeys extends SnapshotOptionKey = SnapshotOptionKey> = { [TKey in TKeys]?: SnapshotOptionValues[TKey]; };
/**
 * Option keys a `snapshot`/`diff` command request carries end to end. `scope` is
 * resolved against the session before capture, so seams that resolve it spread
 * this projection and then override that one key.
 */
declare const SNAPSHOT_COMMAND_OPTION_KEYS: readonly ['observeOnly', 'interactiveOnly', 'depth', 'scope', 'raw', 'customActions', 'forceFull'];
/**
 * The snapshot capture options a `snapshot`/`diff` request is stated in, in
 * every vocabulary that names them: the public SDK type, the internal request
 * bag and the command runtime options each reference THIS type instead of
 * re-listing the same six keys.
 */
type SnapshotCommandOptionFields = SnapshotOptionFields<(typeof SNAPSHOT_COMMAND_OPTION_KEYS)[number]>;
/** Option keys that identify a presentation; see {@link buildSnapshotPresentationKey}. */
declare const SNAPSHOT_PRESENTATION_OPTION_KEYS: readonly ['depth', 'interactiveOnly', 'raw', 'scope', 'customActions'];
/** The options that decide a capture's node set, and so the refs minted on it. */
type SnapshotPresentation = SnapshotOptionFields<(typeof SNAPSHOT_PRESENTATION_OPTION_KEYS)[number]>;
/**
 * The bounded, non-actionable description of the element that occludes a covered node. It carries
 * only what the occlusion scan observed — presented role, an optional clipped accessible name, and
 * the cover's rect — and deliberately no ref: the cover may be a container the snapshot never
 * issues refs for, and naming it is diagnosis, not an invitation to target it.
 */
type SnapshotCoveringNode = {
  /** The canonical persistent-bar kind or the cover's presented role. */
  kind: string;
  /** The cover's accessible name, trimmed and clipped to {@link SNAPSHOT_COVERING_LABEL_MAX_LENGTH}. */
  label?: string;
  /** The cover's positive rect as the scan measured it. */
  rect?: Rect;
  /**
   * Set when the cover is persistent bar chrome (tab bar, toolbar, navigation bar, bottom
   * navigation), read from the cover's type, role, and subrole. Absent for any other cover.
   */
  persistentBar?: true;
};
/** Evidence from an exact English React Native iOS value signature, not proof of its renderer. */
type IosValueSemantics = {
  source: 'react-native-ios-value-heuristic';
  encoding: 'en';
  role?: string;
  checked?: boolean | 'mixed';
  expanded?: boolean;
  busy?: true;
};
type RawSnapshotNode = {
  index: number;
  type?: string;
  role?: string;
  subrole?: string;
  label?: string;
  value?: string;
  /** Derived RN evidence; value and native type/role remain verbatim. Explicit facts take precedence. */
  iosValueSemantics?: IosValueSemantics;
  /**
   * Android content description when it is not already the `label`. An Android node is
   * labelled by its text and falls back to the content description only when it has none,
   * so an accessibility label the app set beside visible text (a labelled text view, a
   * filled or hinted field) is carried here for consumers that want the accessible name.
   */
  contentDescription?: string;
  /**
   * Android view text when it is not already the `label`: the empty string on a view that has
   * a content description and no text, where the description is the label. Absent otherwise,
   * so `text ?? label` is the text the view shows.
   */
  text?: string;
  identifier?: string;
  rect?: Rect;
  enabled?: boolean;
  selected?: boolean;
  /** Checked state of a checkable control (switch, checkbox, radio); absent means not checkable or unavailable. */
  checked?: boolean;
  focused?: boolean;
  /** Accessibility heading flag an app set on the node; absent means not a heading or unavailable. */
  heading?: boolean;
  /** Localized role description an app set beside the native class, verbatim (`Tab`, `Tab List`, `Link`). */
  roleDescription?: string;
  /** Native accessibility facts; absent means unavailable, not false. */
  editable?: boolean;
  password?: boolean;
  hintShowing?: boolean;
  /**
   * Placeholder text of a text field (the Android hint), whether or not the field is showing it.
   * Absent when the field has none or the producer did not read it.
   */
  placeholder?: string;
  /** Accessibility selection offsets, never a character count or proof of value equality. */
  selectionStart?: number;
  selectionEnd?: number;
  visibleToUser?: boolean;
  /** UIKit `isUserInteractionEnabled`; absent means the producer did not read it, not false. */
  userInteractionEnabled?: boolean;
  hittable?: boolean;
  clickable?: boolean;
  focusable?: boolean;
  longClickable?: boolean;
  scrollable?: boolean;
  depth?: number;
  parentIndex?: number;
  pid?: number;
  bundleId?: string;
  /**
   * Android status/navigation bar subtree membership, retained when ancestors are omitted.
   * Shade headers, dialogs, and other SystemUI overlays are not bars. Absent means the
   * producer did not establish bar membership.
   */
  systemBar?: 'status' | 'navigation';
  appName?: string;
  windowTitle?: string;
  surface?: string;
  /** Keyboard tap-surface membership, including hosted app controls; independent of settle ownership.
   * Omission means unevaluated. Survives ancestor removal. */
  keyboardOwned?: boolean;
  hiddenContentAbove?: boolean;
  hiddenContentBelow?: boolean;
  interactionBlocked?: 'covered';
  /**
   * Bounded description of the element the geometric occlusion scan found drawing on top of this
   * node, published together with `interactionBlocked: 'covered'` so a refusal can name the culprit
   * instead of only the fact of coverage. Absent when the covered decision came from a
   * backend-policy annotation that reports a boolean, and when the cover the scan found is an
   * anonymous container no reader could recognize; both refusals keep the generic recovery rather
   * than guessing a culprit. This is a description, not an authorization: it carries no ref and is
   * never an actionable target.
   */
  coveredBy?: SnapshotCoveringNode;
  presentationHints?: string[];
  /**
   * Backend-minted ref for this node, when the capture backend already assigns a
   * stable, actionable ref (e.g. the web/agent-browser backend resolves actions
   * against its own `@eN` refs). `attachRefs` preserves this instead of re-minting
   * a dense positional ref, so the ref an agent sees in the snapshot is the same
   * ref the backend can resolve on the next action. Absent for backends that do
   * not mint refs — those fall back to dense `e${index}` numbering.
   */
  ref?: string;
  /**
   * Accessibility custom actions the element exposes (iOS
   * `UIAccessibilityCustomAction`, React Native `accessibilityActions`). Merged
   * cards publish their real affordances here instead of as child elements, so
   * this is often the only evidence that a collapsed node has any. Populated by
   * opt-in captures only — see `snapshot --actions`.
   */
  actions?: string[];
};
/**
 * Keyboard evidence in the node coordinate space: `visible` measured; `derived` from the shared
 * docked-tree policy before projection; `visibility-only` boolean; `tree-rejected` rejected geometry
 * against a usable viewport with optional visibility; `unmeasurable` unknown; `absent` explicit absence.
 * `treeBound`: read from the capture's own tree (iOS XCTest, Android, docked-tree), not a probe. A full
 * pre-projection iOS root scan proves absence; projected or partial nodes and omitted facts never do.
 */
type SnapshotKeyboardBandFact = {
  kind: 'visible';
  frame: Rect;
  treeBound?: true;
} | {
  kind: 'derived';
  derivation: 'docked-tree';
  frame: Rect;
  treeBound?: true;
} | {
  kind: 'visibility-only';
  visible: boolean;
} | {
  kind: 'tree-rejected';
  derivation: 'docked-tree';
  visible?: boolean;
} | {
  kind: 'absent';
  treeBound?: true;
} | {
  kind: 'unmeasurable';
  reason: string;
};
/**
 * Whether this capture read a modal presentation over the app's own content (#3565).
 *
 * The capture producer owns this: an interactive capture, a full capture, a depth cut, and a scoped
 * capture of ONE screen all answer the same value, because the fact is decided on the acquired tree
 * before any of those projections runs. Settle's dismissal confirmation (#1831) arms on this value
 * instead of reconstructing a presentation from the shape of a tree it happens to hold.
 *
 * `'absent'` is a positive reading, not a default: the producer walked every window it captured and
 * every window showed only its own presentation container. Anything the producer could not read —
 * a tree from a producer that reports no UIKit class facts, an unexplained extra container, a
 * truncated capture — answers `'unknown'`, never `'absent'`.
 */
type PresentedSurface = 'presented' | 'absent' | 'unknown';
/**
 * The box a capture's node rects are measured in, published beside them so a reader never has to
 * infer it from the tree (#3182). Two dimensions and no origin: the field answers "how big is the
 * surface these numbers describe", which is the only question a consumer that places points on the
 * tree cannot answer from the tree itself when the tree is empty or sparse.
 *
 * It is the box of the surface the producer read, which is not always the physical panel. iOS
 * reports the app window in the app's orientation space (ADR 0004), which is smaller than the panel
 * under iPad Split View and is never the foldable panel `fold` reports (ADR 0025); Android and the
 * Apple TV runner report the screen the bounds were measured on. The Tizen and webOS TV plugins
 * report the page's layout viewport in CSS px, which is not the screenshot size: a webOS app at
 * 1280x720 fills only the top-left 1280x720 of a 1920x1080 capture. A producer that has no box of its
 * own to answer with leaves the field off: the macOS desktop, whose rects are absolute in window
 * space and answer to no single frame, and the web and Linux backends, which read a tree without
 * reading a screen. A consumer that needs a *gesture* band inside those bounds still reads `keyboard`
 * and the app window, which is #1821's remaining scope.
 *
 * Absent means the producer measured no box. Absence is never `0`: `snapshotViewportSizeFrom` from
 * `@agent-device/kernel/rect` is the sole construction path and refuses a box
 * `isPositiveFiniteRect` refuses. The brand makes that invariant part of the type: a plain
 * `{ width, height }` literal — including one with a zero in it — is not assignable here, so only
 * modules that import the brand token from `kernel/rect` can build one, and they build it through
 * the guard.
 */
type SnapshotViewportSize = {
  width: number;
  height: number;
} & SnapshotViewportSizeBrand;
/** @internal Exported only so `kernel/rect` can mint values of {@link SnapshotViewportSize}. */
declare const SNAPSHOT_VIEWPORT_SIZE_BRAND: unique symbol;
type SnapshotViewportSizeBrand = {
  readonly [SNAPSHOT_VIEWPORT_SIZE_BRAND]: 'validated';
};
/**
 * Screenshot pixels per rect unit, published by a producer whose own screenshots magnify its rects:
 * a TV app page's `visualViewport.scale`, which a meta viewport sets and which the page's
 * `devicePixelRatio` does not predict. Positive and finite by construction:
 * `snapshotCaptureScaleFrom` from `@agent-device/kernel/rect` is the sole construction path, and the
 * brand keeps a plain number from standing in for one.
 */
type SnapshotCaptureScale = number & SnapshotCaptureScaleBrand;
/** @internal Exported only so `kernel/rect` can mint values of {@link SnapshotCaptureScale}. */
declare const SNAPSHOT_CAPTURE_SCALE_BRAND: unique symbol;
type SnapshotCaptureScaleBrand = {
  readonly [SNAPSHOT_CAPTURE_SCALE_BRAND]: 'validated';
};
type SnapshotNode = RawSnapshotNode & {
  /**
   * The ref an agent addresses this node by, or absent when nothing can address it.
   *
   * A backend that mints its own refs (web/agent-browser) owns that namespace and can only act on
   * the refs it minted, so {@link attachRefs} mints nothing into it — a node the backend left
   * unaddressed stays ref-less in the tree, which is how on-screen-but-not-actionable content
   * (static text, a status region) reaches a reader without ever being offered as a tap target.
   * Backends that mint no refs (Apple, Android, Linux) keep dense `e${index}` numbering, so every
   * node of their trees carries a ref, as before.
   *
   * Every consumer that offers a node as an address must read this as an absence rather than print
   * one: a ref-less node is selectable by text and by `find`/`wait`/`get`, and refused as a target.
   *
   * A ref-less node also carries no `rect`. Producers that mint refs measure geometry for the refs
   * they issued (see `RawSnapshotNode.ref`), and producers that mint none get dense numbering, so
   * every node a geometry-requiring path can reach — promotion, the touch point, the covered and
   * keyboard refusals — has a ref. That is why those paths print `node.ref` without a guard.
   */
  ref?: string;
  /**
   * Normalized role, from the same table the text presenter reads (`formatRole` below). `type`
   * stays the raw platform class; `kind` is the presenter's own answer, published so a `--json`
   * consumer gets the presented role without re-deriving it from `type` (#2656). `attachRefs` is
   * the one production construction path and always sets it; optional here only so the many
   * hand-built `SnapshotNode` fixtures across the daemon/selector test suites that predate #2656 and
   * never route through `attachRefs` do not all need updating for a field their assertions never
   * read. An absent `ref` is a real answer about the node; an absent `kind` is a fixture shortcut.
   */
  kind?: string;
  /**
   * Output-only marker set by client-serialization dedup (see
   * ../snapshot/snapshot-label-dedup.ts) when `label`/`identifier` was omitted
   * because it string-equals the nearest ancestor's value in the parent chain.
   * Never set on the in-daemon session tree used by selectors/wait/replay.
   */
  inheritsLabel?: true;
  inheritsIdentifier?: true;
};
/**
 * Reasons the Apple runner can stamp when serving a command required re-activating the session app
 * (#2682). Mirrors its `activateTarget(bundleId:reason:)` call sites.
 */
declare const IOS_TARGET_ACTIVATION_REASONS: readonly ['bundle_changed', 'stale_target', 'missing_after_wait', 'interaction_foreground_guard'];
type IosTargetActivationReason = (typeof IOS_TARGET_ACTIVATION_REASONS)[number];
/**
 * How XCTest reports an app running (`XCUIApplication.State`), in the SDK's raw order: unknown 0,
 * notRunning 1, suspended 2, plain background 3, foreground 4 — the SDK declares suspended on
 * non-macOS platforms only. This is the one declaration of those names; the `appState` runner
 * command answers the session app's state with them, and `RunnerTests+ApplicationStateRawValueTests`
 * ties them to the SDK enum. The `appState` path names states, so nothing here assigns a raw value;
 * only the activation decoder's raw table does.
 */
declare const APPLE_APPLICATION_STATES: readonly ['unknown', 'notRunning', 'runningBackgroundSuspended', 'runningBackground', 'runningForeground'];
type AppleApplicationState = (typeof APPLE_APPLICATION_STATES)[number];
/**
 * States an activation could have been needed for: every Apple state except the foreground one,
 * which the runner skips `activate()` in and therefore stamps no fact about. Derived from the full
 * list so the two cannot drift, and in the SDK's raw order — a state added to the full list lands
 * here and must then be pinned natively before the decoder tie accepts it.
 */
declare const IOS_TARGET_ACTIVATION_PRIOR_STATES: readonly ("notRunning" | "runningBackground" | "runningBackgroundSuspended" | "unknown")[];
type IosTargetActivationPriorState = (typeof IOS_TARGET_ACTIVATION_PRIOR_STATES)[number];
/**
 * Foreground repair the Apple runner performed while serving one command (#2682). `priorState` is
 * the session app's state BEFORE the runner activated it, so the fact describes what was repaired
 * rather than what the repair produced. `otherActiveApplicationPid` is present only when exactly one
 * application other than the session app held an active accessibility session at that moment: a
 * liveness claim and nothing more, since the private AX client reports no ordering of
 * `activeApplications`, resolves pids only, and answers no bundle id for an arbitrary app.
 */
type IosTargetActivation = Readonly<{
  reason: IosTargetActivationReason;
  priorState: IosTargetActivationPriorState;
  otherActiveApplicationPid?: number;
}>;
type SnapshotUnchanged = {
  ageMs: number;
  nodeCount: number;
  interactiveOnly?: boolean;
  scope?: string;
};
type SnapshotVisibilityReason = 'offscreen-nodes' | 'scroll-hidden-above' | 'scroll-hidden-below';
type SnapshotVisibility = {
  partial: boolean;
  visibleNodeCount: number;
  totalNodeCount: number;
  reasons: SnapshotVisibilityReason[];
};
type ScreenshotOverlayRef = {
  ref: string;
  label?: string;
  rect: Rect;
  overlayRect: Rect;
  center: Point;
};
declare function centerOfRect(rect: Rect): Point;
//#endregion
//#region packages/kernel/src/source-value.d.ts
type EnvMap = Record<string, string | undefined>;
/**
 * The process-level inputs a host hands to the code it runs: the environment and working
 * directory. An entry point captures it once; everything below receives it.
 */
type HostEnvironment = Readonly<{
  env: Readonly<EnvMap>;
  cwd: string;
}>;
//#endregion
//#region packages/kernel/src/device.d.ts
declare const APPLE_OS_VALUES: readonly ['ios', 'ipados', 'tvos', 'watchos', 'visionos', 'macos'];
type AppleOS = (typeof APPLE_OS_VALUES)[number];
declare const PLATFORMS: readonly ['apple', 'android', 'harmonyos', 'vega', 'linux', 'web'];
type Platform = (typeof PLATFORMS)[number];
declare const PUBLIC_PLATFORMS: readonly ['ios', 'macos', 'android', 'harmonyos', 'vega', 'linux', 'web'];
type PublicPlatform = (typeof PUBLIC_PLATFORMS)[number];
declare const PLATFORM_SELECTORS: readonly ["apple", "android", "harmonyos", "vega", "linux", "web", "ios", "macos"];
type PlatformSelector = (typeof PLATFORM_SELECTORS)[number];
declare const DEVICE_KINDS: readonly ['simulator', 'emulator', 'device'];
type DeviceKind = (typeof DEVICE_KINDS)[number];
declare const DEVICE_TARGETS: readonly ['mobile', 'tv', 'desktop'];
type DeviceTarget = (typeof DEVICE_TARGETS)[number];
type DeviceInfo = {
  platform: Platform;
  id: string;
  name: string;
  kind: DeviceKind;
  target?: DeviceTarget;
  appleOs?: AppleOS;
  model?: string;
  osVersion?: string;
  booted?: boolean;
  simulatorSetPath?: string;
  iosPhysicalDeviceBackend?: 'coredevice' | 'xctest';
  /**
   * Set when this device is one app of a host device rather than the host itself (ADR 0035). Its
   * id is {@link hostAppDeviceId} of the two, so every per-device lock, claim, and session check
   * treats the app as a device of its own; only {@link devicesOverlap} relates it to its host.
   */
  hostApp?: {
    hostDeviceId: string;
    bundleId: string;
  };
};
/** Tie-break policies `boot --pick` accepts. */
declare const BOOT_PICK_POLICIES: readonly ['newest'];
type BootPickPolicy = (typeof BOOT_PICK_POLICIES)[number];
//#endregion
//#region packages/kernel/src/contracts.d.ts
declare const SESSION_RUNTIME_PLATFORMS: readonly ['ios', 'android', 'harmonyos'];
type SessionRuntimePlatform = (typeof SESSION_RUNTIME_PLATFORMS)[number];
type SessionRuntimeHints = {
  platform?: SessionRuntimePlatform;
  metroHost?: string;
  metroPort?: number;
  bundleUrl?: string;
  launchUrl?: string;
};
type DaemonInstallSource = {
  kind: 'url';
  url: string;
  headers?: Record<string, string>;
} | {
  kind: 'path';
  path: string;
} | ({
  kind: 'github-actions-artifact';
  owner: string;
  repo: string;
} & ({
  artifactId: number;
} | {
  runId: number;
  artifactName: string;
} | {
  artifactName: string;
}));
/** Install sources that can be materialized by a local daemon. */
type LocalInstallSource = Extract<DaemonInstallSource, {
  kind: 'url' | 'path';
}>;
declare const DAEMON_LOCK_POLICIES: readonly ['reject', 'strip'];
type DaemonLockPolicy = (typeof DAEMON_LOCK_POLICIES)[number];
declare const LEASE_BACKENDS: readonly ['ios-simulator', 'ios-instance', 'android-instance', 'harmonyos-instance', 'macos-app'];
type LeaseBackend = (typeof LEASE_BACKENDS)[number];
declare const DAEMON_SERVER_MODES: readonly ['socket', 'http', 'dual'];
type DaemonServerMode = (typeof DAEMON_SERVER_MODES)[number];
declare const DAEMON_TRANSPORT_PREFERENCES: readonly ['auto', 'socket', 'http'];
type DaemonTransportPreference = (typeof DAEMON_TRANSPORT_PREFERENCES)[number];
declare const SESSION_ISOLATION_MODES: readonly ['none', 'tenant'];
type SessionIsolationMode = (typeof SESSION_ISOLATION_MODES)[number];
declare const NETWORK_INCLUDE_MODES: readonly ['summary', 'headers', 'body', 'all'];
type NetworkIncludeMode = (typeof NETWORK_INCLUDE_MODES)[number];
declare const RESPONSE_LEVELS: readonly ['digest', 'default', 'full'];
type ResponseLevel = (typeof RESPONSE_LEVELS)[number];
type DaemonRequestMeta = {
  requestId?: string;
  debug?: boolean;
  includeCost?: boolean;
  responseLevel?: ResponseLevel;
  cwd?: string;
  /** The client's `DEVELOPER_DIR`, applied to the commands a local daemon spawns for this request. */
  developerDir?: string;
  sessionExplicit?: boolean;
  tenantId?: string;
  runId?: string;
  leaseId?: string;
  leaseTtlMs?: number;
  leaseRetainOnClose?: boolean;
  leaseBackend?: LeaseBackend;
  leaseProvider?: string;
  deviceKey?: string;
  clientId?: string;
  /** A local caller's digest of its lease-provider credential variables, compared on allocation. */
  providerCredentialFingerprint?: string;
  sessionIsolation?: SessionIsolationMode;
  uploadedArtifactId?: string;
  clientArtifactPaths?: Record<string, string>;
  /** The ID a remote client minted for its `open --save-script`; each script version carries it. */
  scriptPublicationId?: string;
  installSource?: DaemonInstallSource;
  retainMaterializedPaths?: boolean;
  materializedPathRetentionMs?: number;
  materializationId?: string;
  lockPolicy?: DaemonLockPolicy;
  lockPlatform?: PlatformSelector;
  requestProgress?: 'replay-test' | 'command';
};
type DaemonRequest = {
  token?: string;
  session?: string;
  command: string;
  positionals: string[];
  input?: Record<string, unknown>;
  flags?: Record<string, unknown>;
  runtime?: SessionRuntimeHints;
  meta?: DaemonRequestMeta;
};
type DaemonArtifactKnownType = 'screenshot' | 'screenshot-diff' | 'screen-recording' | 'screen-recording-chunk' | 'screen-recording-contact-sheet' | 'screen-recording-telemetry' | 'trace-log' | 'test-artifacts' | 'session-script';
type DaemonArtifactType = DaemonArtifactKnownType | (string & {});
type DaemonArtifact = {
  field: string;
  artifactType?: DaemonArtifactType;
  artifactId?: string;
  fileName?: string;
  localPath?: string;
  path?: string;
  /** The remote `open --save-script` publication a `session-script` artifact belongs to. */
  scriptPublicationId?: string;
  /** A `session-script` version number. Versions of one recording grow, so the newest one wins. */
  scriptRevision?: number;
};
/**
 * A remote recording's script version that was not delivered (ADR 0016). The action that recorded
 * it keeps its success; the response carries this beside a warning with the same text.
 */
type ScriptDeliveryFailure = {
  reason: 'script_delivery_failed';
  publicationId: string;
  message: string;
  hint: string;
  /** Why the client could not download or save the version, when the client found the failure. */
  cause?: string;
};
type ResponseCost = {
  wallClockMs: number;
  runnerRoundTrips: number;
  nodeCount?: number;
};
type DaemonResponseData = Record<string, unknown> & {
  artifacts?: DaemonArtifact[];
  cost?: ResponseCost;
};
type DaemonResponse = {
  ok: true;
  data?: DaemonResponseData;
} | {
  ok: false;
  error: DaemonError;
};
type JsonRpcId = string | number | null;
type JsonRpcRequestEnvelope<TParams = unknown> = {
  jsonrpc?: string;
  id?: JsonRpcId;
  method?: string;
  params?: TParams;
};
//#endregion
export { DaemonError as $, IosSnapshotObservation as A, SnapshotNode as B, DeviceKind as C, PublicPlatform as D, PlatformSelector as E, Rect as F, SnapshotQualityVerdict as G, SnapshotPreferredBackend as H, ScreenshotOverlayRef as I, SnapshotVisibility as J, SnapshotUnchanged as K, SnapshotCaptureScale as L, Point as M, PresentedSurface as N, HostEnvironment as O, RawSnapshotNode as P, AppErrorDetails as Q, SnapshotCommandOptionFields as R, DeviceInfo as S, Platform as T, SnapshotPresentation as U, SnapshotOptions as V, SnapshotQualityNote as W, AppError as X, centerOfRect as Y, AppErrorCode as Z, ScriptDeliveryFailure as _, DaemonRequest as a, normalizeAgentDeviceError as at, AppleOS as b, DaemonServerMode as c, JsonRpcRequestEnvelope as d, ErrorCause as et, LeaseBackend as f, ResponseLevel as g, ResponseCost as h, DaemonLockPolicy as i, isAgentDeviceError as it, IosTargetActivation as j, AppleApplicationState as k, DaemonTransportPreference as l, NetworkIncludeMode as m, DaemonArtifactType as n, NormalizedError as nt, DaemonResponse as o, normalizeError as ot, LocalInstallSource as p, SnapshotViewportSize as q, DaemonInstallSource as r, defaultHintForCode as rt, DaemonResponseData as s, DaemonArtifact as t, KnownAppErrorCode as tt, JsonRpcId as u, SessionIsolationMode as v, DeviceTarget as w, BootPickPolicy as x, SessionRuntimeHints as y, SnapshotKeyboardBandFact as z };