agent-device 0.21.32 → 0.21.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.32.apk → agent-device-android-ime-helper-0.21.33.apk} +0 -0
  2. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.33.apk.sha256 +1 -0
  3. package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.32.manifest.json → agent-device-android-ime-helper-0.21.33.manifest.json} +4 -4
  4. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.32.apk → agent-device-android-snapshot-helper-0.21.33.apk} +0 -0
  5. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.33.apk.sha256 +1 -0
  6. package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.32.manifest.json → agent-device-android-snapshot-helper-0.21.33.manifest.json} +7 -7
  7. package/apple/fold-helper/Fold.m +32 -11
  8. package/apple/snapshot-bridge/ForegroundApplicationGeometry.h +4 -16
  9. package/apple/snapshot-bridge/SnapshotBridgeRuntime.m +1 -2
  10. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +36 -58
  11. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +66 -111
  12. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerScrollViewportPolicy.swift +1 -2
  13. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +2 -2
  14. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +5 -29
  15. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +4 -17
  16. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Navigation.swift +66 -117
  17. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollDragExecution.swift +4 -4
  18. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedGesturePolicy.swift +21 -75
  19. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SynthesizedInteraction.swift +7 -61
  20. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TypeExecution.swift +1 -4
  21. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.h +24 -53
  22. package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerXCTestEventBridge.m +13 -39
  23. package/dist/src/app-backend.js +1 -1
  24. package/dist/src/app-launch.js +1 -1
  25. package/dist/src/command-metadata.js +1 -1
  26. package/dist/src/config.js +1 -1
  27. package/dist/src/device-readiness-runtime.js +1 -1
  28. package/dist/src/display-inventory.js +1 -1
  29. package/dist/src/fold-helper.js +2 -2
  30. package/dist/src/fold-runtime.js +1 -0
  31. package/dist/src/interactor.js +5 -5
  32. package/dist/src/internal/bin.js +1 -1
  33. package/dist/src/mechanics.js +12 -12
  34. package/dist/src/physical-device-control.js +1 -1
  35. package/dist/src/runtime.js +3 -3
  36. package/dist/src/runtime3.js +5 -5
  37. package/dist/src/simulator.js +1 -1
  38. package/package.json +7 -2
  39. package/server.json +2 -2
  40. package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.32.apk.sha256 +0 -1
  41. package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.32.apk.sha256 +0 -1
@@ -3,20 +3,10 @@
3
3
 
4
4
  NS_ASSUME_NONNULL_BEGIN
5
5
 
6
- // Shared reflection surface for XCTest's private event-synthesis API
7
- // (XCSynthesizedEventRecord / XCPointerEventPath). Both gesture synthesis
8
- // (RunnerSynthesizedGesture) and text-entry synthesis (RunnerSynthesizedTextEntry)
9
- // reflect into this same private API; resolving the part they have in common here
10
- // means a selector rename only has to be found in one place.
11
- //
12
- // Each caller additionally resolves whichever XCSynthesizedEventRecord init
13
- // overload and XCPointerEventPath factory/mutator selectors its own event kind
14
- // needs: gesture uses `initWithName:displayID:interfaceOrientation:` plus
15
- // touch-path selectors (`initForTouchAtPoint:offset:`, `moveToPoint:atOffset:`,
16
- // `liftUpAtOffset:`); text entry uses the 1-arg `initWithName:` plus text-input
17
- // selectors (`initForTextInput`, `typeText:atOffset:typingSpeed:shouldRedact:`,
18
- // `typeKey:modifiers:atOffset:`). Those genuinely differ and are resolved by
19
- // each caller on top of this shared core, not forced into one shape here.
6
+ // Shared reflection core for XCTest's private event-synthesis API (XCSynthesizedEventRecord /
7
+ // XCPointerEventPath). Gesture and text-entry synthesis each resolve on top of this core the
8
+ // record-init overload and mutator selectors their own event kind needs, so a rename in the part
9
+ // they share is found in one place.
20
10
  typedef struct {
21
11
  Class recordClass; // XCSynthesizedEventRecord
22
12
  Class pathClass; // XCPointerEventPath
@@ -32,7 +22,7 @@ typedef void (*RunnerMsgSendAddPath)(id, SEL, id);
32
22
  typedef BOOL (*RunnerMsgSendSynthesize)(id, SEL, NSError **);
33
23
 
34
24
  // Why the display hosting the target app could not be named. Callers branch on this rather than
35
- // on the message, so a refusal keeps its reason across the language boundary (#2728).
25
+ // on the message, so a refusal keeps its reason across the language boundary.
36
26
  typedef NS_ENUM(NSUInteger, RunnerApplicationScreenFailure) {
37
27
  RunnerApplicationScreenFailureNone,
38
28
  // No window with a usable frame, so nothing resolves and its screen would only report main.
@@ -41,28 +31,20 @@ typedef NS_ENUM(NSUInteger, RunnerApplicationScreenFailure) {
41
31
  RunnerApplicationScreenFailureUnresolvedScreen,
42
32
  };
43
33
 
44
- // Resolves the shared core described above against the live XCTest runtime.
45
- // Returns nil and populates `bridge` on success. Returns a non-nil
46
- // "private XCTest <surface> synthesis unavailable: ..." message and leaves
47
- // `bridge` unspecified when a class or selector the private API is expected to
48
- // expose is missing (the API changed, or is unavailable on this OS/Xcode).
49
- // `surface` names the calling feature ("event" or "text") so the message text
50
- // matches what that caller has always reported.
34
+ // Resolves the shared core against the live XCTest runtime. Returns nil on success, or a
35
+ // "private XCTest <surface> synthesis unavailable: ..." message when a class or selector the
36
+ // private API is expected to expose is missing. `surface` names the calling feature.
51
37
  FOUNDATION_EXPORT NSString * _Nullable RunnerResolveXCTestEventBridge(
52
38
  id application,
53
39
  NSString *surface,
54
40
  RunnerXCTestEventBridge *bridge
55
41
  );
56
42
 
57
- // Resolves the `XCUIScreen` hosting the application's window and that screen's `displayID`, which
58
- // is the only display identity that follows a foldable app to whichever panel it currently lights.
59
- // Reading the window frame must precede reading its screen: an unresolved element still reports the
60
- // main screen. Never selects a screen by number or by position in `XCUIScreen.screens`.
61
- // Returns YES and writes the screen to capture into `screen` and its identity into `displayID`.
62
- // Otherwise returns NO, leaves both empty, and names the reason in `failure` so callers branch on
63
- // the reason rather than on message text (#2728). Private KVC raises rather than returns nil when
64
- // XCTest has no such value, so both reads are guarded here and surface as a typed failure instead
65
- // of an exception reaching the caller.
43
+ // Resolves the `XCUIScreen` hosting the application's window and its `displayID`, the only display
44
+ // identity that follows an app to the panel it lights. Reading the window frame must precede
45
+ // reading its screen: an unresolved element still reports the main screen, and neither read is
46
+ // ever selected by number or position. Private KVC raises rather than returns nil, so both reads
47
+ // are guarded here and any failure surfaces as the typed `failure`, never an exception.
66
48
  FOUNDATION_EXPORT BOOL RunnerResolveApplicationScreen(
67
49
  id application,
68
50
  id _Nullable *screen,
@@ -70,27 +52,19 @@ FOUNDATION_EXPORT BOOL RunnerResolveApplicationScreen(
70
52
  RunnerApplicationScreenFailure *failure
71
53
  );
72
54
 
73
- // Reads the display ID off an already-resolved window. When a caller has resolved the app window
74
- // for geometry, routing the synthesized gesture by this window keeps the record's display and the
75
- // booked reference frame on the same window instead of re-walking `windows.firstMatch`.
55
+ // Reads the display ID off an already-resolved window, keeping a synthesized record's display and
56
+ // the caller's booked reference frame on the same window. The frame is still read before the
57
+ // screen; a window that answers empty or raises fails closed with a refusal message naming the
58
+ // same reason the application walk gives.
76
59
  FOUNDATION_EXPORT NSString * _Nullable RunnerResolveWindowDisplayID(
77
60
  id window,
78
61
  NSUInteger *displayID
79
62
  );
80
63
 
81
- // Reads the display ID of the device's only screen, for a gesture whose app window XCTest cannot
82
- // resolve because the app's accessibility tree is too deep to serialize. On an iPhone with exactly
83
- // one screen that screen hosts the full-screen app, so no window is needed to name it. On an iPad
84
- // the same route opens only while the app provably fills that screen, decided in-process by the
85
- // evidence seam below without the app's tree. Anywhere else this returns a message and leaves
86
- // `displayID` untouched: a windowed iPad app sits in part of its screen, and only a window can say
87
- // which panel lights a foldable's app.
88
- FOUNDATION_EXPORT NSString * _Nullable RunnerResolveSoleScreenDisplayID(
89
- id application,
90
- NSUInteger *displayID
91
- );
92
-
93
- // Resolves the screen and display identity under the same sole-screen rule used by synthesis.
64
+ // Resolves the device's only screen and its `displayID` under the sole-screen rule that synthesis
65
+ // and capture share: an iPhone with one screen always, an iPad only while the AXRuntime probe
66
+ // proves the app fills that screen. Returns nil on success; on refusal it returns a message,
67
+ // empties `screen`, and leaves `displayID` untouched.
94
68
  FOUNDATION_EXPORT NSString * _Nullable RunnerResolveSoleScreen(
95
69
  id application,
96
70
  id _Nullable *screen,
@@ -111,12 +85,9 @@ typedef NS_ENUM(NSUInteger, RunnerFullScreenEvidence) {
111
85
  RunnerFullScreenEvidenceUnknown,
112
86
  };
113
87
 
114
- // Decides the evidence from the values the AXRuntime probe reads. AXRuntime reports the primary
115
- // app's window and the system app, which spans the screen, in one native space; this is the same
116
- // comparison the Simulator snapshot bridge refuses a capture on (`app-window-not-full-screen`,
117
- // ADR 0004). Neither read walks the app's tree, so the decision survives a tree XCTest cannot
118
- // serialize. A pid that cannot name a process (<= 0) or an unreadable frame answers Unknown, never
119
- // a guess.
88
+ // Decides the evidence from the values the AXRuntime probe reads, which AXRuntime reports in one
89
+ // native space (ADR 0004). Neither read walks the app's tree, so the decision survives a tree
90
+ // XCTest cannot serialize. An unreadable pid or frame answers Unknown, never a guess.
120
91
  FOUNDATION_EXPORT RunnerFullScreenEvidence RunnerFullScreenEvidenceFromForeground(
121
92
  pid_t targetProcessID,
122
93
  pid_t primaryProcessID,
@@ -114,17 +114,10 @@ static NSString *RunnerApplicationScreenFailureDescription(
114
114
  }
115
115
  }
116
116
 
117
- // One window read. XCTest answers with a value or raises. The window object is handed back because
118
- // resolving this instance is what its `screen` will answer from — re-querying `firstMatch` would
119
- // return an unresolved element that still names the main screen.
120
- //
121
- // Both answers are required. An app with no window answers `frame` with `(0,0 0x0)` without raising,
122
- // which geometry alone would read as a window the runtime has not measured, and only the query
123
- // itself says whether it has one. Measured on a live Duo: the runner host process, which has no
124
- // window, answers `exists` NO and `frame` `(0,0 0x0)` (#2728).
125
- //
126
- // The frame the read produced is reported even when it is refused: a capture that fails closed has
127
- // to say what it looked at, or the reason code cannot be told apart from a stale device.
117
+ // One window read. Both answers are required: an app with no window answers `frame` with
118
+ // `(0,0 0x0)` without raising, so only `exists` says whether the window is there. The window
119
+ // object is handed back because resolving this instance is what its `screen` will answer from.
120
+ // The frame is reported even when refused, so a refusal names what it looked at.
128
121
  static RunnerApplicationScreenFailure RunnerResolveUsableWindow(
129
122
  id application,
130
123
  id _Nullable *window,
@@ -158,9 +151,8 @@ static RunnerApplicationScreenFailure RunnerResolveUsableWindow(
158
151
  return RunnerApplicationScreenFailureNone;
159
152
  }
160
153
 
161
- // The screen read that must follow window resolution on that same window instance. Before the
162
- // frame above is asked for, the window's `screen` can still name main, so this is never merged
163
- // into the read ahead of it.
154
+ // The screen read that must follow window resolution on that same window instance: before the frame
155
+ // is asked for, `screen` can still name main, so this never merges into the read ahead of it.
164
156
  static RunnerApplicationScreenFailure RunnerReadResolvedWindowScreen(
165
157
  id window,
166
158
  CGRect windowFrame,
@@ -212,31 +204,18 @@ BOOL RunnerResolveApplicationScreen(
212
204
  return *failure == RunnerApplicationScreenFailureNone;
213
205
  }
214
206
 
215
- // Reads the display ID off a window the caller already resolved, so a synthesized record can be
216
- // routed by the same window its reference frame was measured on. The window still resolves here:
217
- // its frame is read before its screen, and a window that answers empty or raises fails closed with
218
- // the same reasons the application walk gives.
219
- NSString * _Nullable RunnerResolveSoleScreenDisplayID(id application, NSUInteger *displayID) {
220
- id screen = nil;
221
- return RunnerResolveSoleScreen(application, &screen, displayID);
222
- }
223
-
224
207
  RunnerFullScreenEvidence RunnerFullScreenEvidenceFromForeground(
225
208
  pid_t targetProcessID,
226
209
  pid_t primaryProcessID,
227
210
  CGRect appFrame,
228
211
  CGRect screenFrame
229
212
  ) {
230
- // A pid that could not be read (or cannot own a process) proves nothing about ownership, so the
231
- // answer is Unknown, never a guess that the app is not the primary app.
232
213
  if (targetProcessID <= 0 || primaryProcessID <= 0) {
233
214
  return RunnerFullScreenEvidenceUnknown;
234
215
  }
235
- if (!AgentDeviceForegroundOwnershipMatches(primaryProcessID, targetProcessID)) {
216
+ if (primaryProcessID != targetProcessID) {
236
217
  return RunnerFullScreenEvidenceNotPrimaryApp;
237
218
  }
238
- // A frame that is not a usable measurement is a runtime that said nothing, not a window that
239
- // differs, so the answer is Unknown, never the Windowed a comparison of the numbers would read as.
240
219
  if (!AgentDeviceForegroundFramesAreMeasurable(appFrame, screenFrame)) {
241
220
  return RunnerFullScreenEvidenceUnknown;
242
221
  }
@@ -255,9 +234,8 @@ static NSString *const RunnerXCTAutomationSupportPath =
255
234
  @"/Developer/Library/PrivateFrameworks/XCTAutomationSupport.framework/XCTAutomationSupport";
256
235
 
257
236
  static Class<AgentDeviceForegroundElement> _Nullable RunnerForegroundElementClass(void) {
258
- // Cache the answer including its absence: a runtime without the class would otherwise pay two
259
- // RTLD_NOW lookups per window-less gesture forever. Code availability is the only thing cached
260
- // here — the probe re-measures every attempt, because a resize changes the answer.
237
+ // Cache the answer including its absence; code availability is all that is cached — the probe
238
+ // re-measures every attempt because a resize changes the answer.
261
239
  static BOOL resolved = NO;
262
240
  static Class<AgentDeviceForegroundElement> _Nullable cached = Nil;
263
241
  if (!resolved) {
@@ -273,11 +251,9 @@ static Class<AgentDeviceForegroundElement> _Nullable RunnerForegroundElementClas
273
251
  return cached;
274
252
  }
275
253
 
276
- // One contained probe: it checks each selector before sending it and reads the target pid, the
277
- // primary app's frame, and the system app's frame inside one exception scope, so any failed read
278
- // answers Unknown — the same typed nothing-a-guess the decision seam already reports. The target
279
- // pid comes from the existing runner owner for that read (RunnerAXSnapshotBridge), which picks the
280
- // correctly sized send for the pid_t return through the method signature.
254
+ // One contained probe: it checks each selector before sending it and reads the target pid and both
255
+ // frames inside one exception scope, so any failed read answers Unknown. The target pid comes from
256
+ // the existing runner owner for that read (RunnerAXSnapshotBridge).
281
257
  static RunnerFullScreenEvidence RunnerProbeApplicationFillsScreen(id application) {
282
258
  if (application == nil) {
283
259
  return RunnerFullScreenEvidenceUnknown;
@@ -346,9 +322,7 @@ NSString * _Nullable RunnerResolveSoleScreen(
346
322
  return @"private XCTest event synthesis unavailable: no resolved application window and no sole screen to route to";
347
323
  }
348
324
  // An iPhone keeps every app full-screen, so its idiom answers the rule and the route never pays
349
- // for the probe. Off the phone idiom the route opens only on the fills-screen proof — an iPad can
350
- // show an app in part of its only screen — and windowed or unknown evidence keeps requiring a
351
- // window. The probe answers only what it proved or failed to prove, never "not probed".
325
+ // for the probe. Off the phone idiom the route opens only on the fills-screen proof.
352
326
  if (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPhone &&
353
327
  RunnerProbeApplicationFillsScreen(application) != RunnerFullScreenEvidenceFillsScreen) {
354
328
  return @"private XCTest event synthesis unavailable: no resolved application window, and the sole screen is not provably the app's full-screen frame";
@@ -1 +1 @@
1
- import{R as e}from"./sdk-contracts.js";import{b as t,z as n}from"./sdk-device.js";import{o as r}from"./session.js";import{n as i}from"./gesture-admission.js";const a={visionos:`visionOS uses spatial input and does not support two-finger touch synthesis.`,tvos:`tvOS has no touch input — this gesture is supported on Android, iOS, and iPadOS.`,macos:`macOS automation has no multi-touch input — this gesture is supported on Android, iOS, and iPadOS.`};function o(e,r){if(!t(e.platform))throw s(r,e.platform);let o=n(e);if(o!==`ios`&&o!==`ipados`)throw s(r,i[o],a[o])}function s(t,n,r){return new e(`UNSUPPORTED_OPERATION`,`gesture ${t} is not supported on ${n}`,r===void 0?void 0:{hint:r})}function c(e){return r(t=>e[t])}export{a as n,o as r,c as t};
1
+ import{R as e}from"./sdk-contracts.js";import{C as t,M as n}from"./tv-remote.js";import{_t as r}from"./sdk-io.js";import"./diagnostics.js";import{b as i,z as a}from"./sdk-device.js";import{Sn as o}from"./sdk-batch.js";import{o as s}from"./session.js";import{n as c}from"./gesture-admission.js";import{t as l}from"./fold-runtime.js";import{c as u,s as d}from"./config.js";import{r as f}from"./simulator.js";import{r as p}from"./display-inventory.js";import{n as m}from"./fold-helper.js";const h={visionos:`visionOS uses spatial input and does not support two-finger touch synthesis.`,tvos:`tvOS has no touch input — this gesture is supported on Android, iOS, and iPadOS.`,macos:`macOS automation has no multi-touch input — this gesture is supported on Android, iOS, and iPadOS.`};function g(e,t){if(!i(e.platform))throw _(t,e.platform);let n=a(e);if(n!==`ios`&&n!==`ipados`)throw _(t,c[n],h[n])}function _(t,n,r){return new e(`UNSUPPORTED_OPERATION`,`gesture ${t} is not supported on ${n}`,r===void 0?void 0:{hint:r})}async function v(e,t,i={}){i.signal?.throwIfAborted(),f(e,`fold`);let a=t,o=a.keyframes?.at(-1)?.angle,s=a.pose??n(o),c=m(e);x(e,await p(e,{signal:i.signal,foldHelper:c})),await c.setPose(a.keyframes??s,i.signal),r({level:`info`,phase:`apple_fold_pose_dispatched`,data:{deviceId:e.id,pose:s}});let l=await S(e,c,s,i.signal,o),u=await j(e,c,i.signal);return{pose:n(l),hingeAngleDegrees:l,...u?{screen:M(u)}:{}}}function y(t){return t instanceof e&&t.details?.reason===`fold-hinge-angle-no-sample`}async function b(t,n,r,i,a,o){let s=await j(t,n,i);return new e(`COMMAND_FAILED`,`${t.name} received the ${r} pose request, but the first hinge-angle read returned no sample to verify it`,{deviceId:t.id,requestedPose:r,...a===void 0?{}:{targetAngleDegrees:a},reason:`fold-pose-dispatched-unverified`,...s?{screen:M(s)}:{},...o instanceof e?{hingeReadFailure:o.details}:{},hint:`The pose request was sent and the device may have followed it, but the first hinge-angle read returned no sample, so fold cannot confirm it. Take a screenshot or snapshot to see which panel is lit; hingeReadFailure names why the read failed.`},o)}function x(t,n){if(n.unresolved)throw new e(`COMMAND_FAILED`,`The simulator reported no panel table`,{deviceId:t.id,hint:`fold needs the simulator's panel table to tell a foldable from a single-panel simulator: 'devicectl device info displays' in the default device set, or the fold helper's guest panel read in a scoped set. The apple_display_inventory_unresolved diagnostic names why the read failed.`});if(!n.multiScreen)throw new e(`UNSUPPORTED_OPERATION`,`${t.name} is not a foldable simulator: fold requires more than one integrated panel`,{deviceId:t.id,reason:`single-panel-device`,hint:`fold sets the hinge angle of a foldable simulator such as iPhone Duo; this simulator reports one integrated panel, so it has no hinge to pose.`})}async function S(e,t,n,r,i){let a,o;for(let s=1;s<=8;s+=1){r?.throwIfAborted(),o=a;try{a=await t.readHingeAngle({signal:r,windowMs:s>1?d:0})}catch(o){throw a!==void 0||!y(o)?o:await b(e,t,n,r,i,o)}if(C(a,o,n,i))return a}throw E(e,n,a,o,i)}function C(e,t,r,i){return i===void 0?n(e)===r?r!==`half-open`||t!==void 0&&D(e,t):!1:w(e,t,i)}function w(e,t,n){return T(e,n)?n===0||n===180||t!==void 0&&T(t,n)&&Math.abs(e-t)<=.5:!1}function T(e,t){return t===void 0||e!==void 0&&Math.abs(e-t)<=.5}function E(t,r,i,a,o){return T(i,o)?o!==void 0&&i!==void 0?A(t,n(i),i,a):i!==void 0&&r===`half-open`&&n(i)===r?A(t,r,i,a):k(t,r,i):new e(`COMMAND_FAILED`,`The hinge did not reach the final keyframe angle`,{reason:`fold-angle-unverified`,targetAngleDegrees:o,hingeAngleDegrees:i,deviceId:t.id})}function D(e,t){return n(e)===`half-open`&&n(t)===`half-open`&&Math.abs(e-t)<=.5}function O(e,t,r){return{deviceId:e.id,requestedPose:t,observedPose:r===void 0?void 0:n(r),hingeAngleDegrees:r}}function k(t,n,r){return new e(`COMMAND_FAILED`,`${t.name} did not reach the ${n} pose: the simulator still reports a hinge angle of ${r}°`,{...O(t,n,r),reason:`fold-pose-unverified`,hint:`The simulator HID command completed, but the hinge did not follow. Verify that the selected Xcode and simulator runtime support foldable HID control, then retry.`})}function A(t,n,r,i){return new e(`COMMAND_FAILED`,`${t.name} was observed ${n} at ${r}° but did not settle: 8 hinge reads never held two consecutive angles within ${u}° of each other`,{...O(t,n,r),reason:`fold-pose-unsettled`,...i===void 0?{}:{previousHingeAngleDegrees:i},hint:`The hinge reached the requested pose and was still moving when the read budget ended. Retry the fold to see whether the simulator holds the pose.`})}async function j(e,t,n){let r=await p(e,{signal:n,foldHelper:t});if(!(r.unresolved||r.ambiguous))return r.activeDisplay}function M(e){return{display:e.name,coordinateSpace:t,widthPt:Math.round(e.widthPx/e.pointScale),heightPt:Math.round(e.heightPx/e.pointScale)}}const N=Object.freeze({available:!0}),P=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`fold is supported on foldable iPhone simulators controlled through simulator HID; a physical device is folded by hand.`}),F=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`fold poses the hinge of a foldable iPhone; tvOS, macOS, watchOS and visionOS simulators have no hinge.`});function I(e){if(e.kind!==`simulator`)return P;let t=a(e);return t!==`ios`&&t!==`ipados`?F:N}function L(e){return l({fold:I(e)})}function R(e){let{device:t,signal:n}=e;return o(L(t).setFoldPose,()=>({setFoldPose:async e=>(n.throwIfAborted(),await v(t,e,{signal:n}))}))}function z(e){return s(t=>e[t])}export{g as a,h as i,L as n,R as r,z as t};
@@ -1,2 +1,2 @@
1
- import{R as e}from"./sdk-contracts.js";import{a as t,i as n,o as r}from"./sdk-batch-runner.js";import{K as i,L as a,V as o,_t as s,q as c}from"./sdk-io.js";import"./diagnostics.js";import{T as l,w as u}from"./sdk-device.js";import{n as d,t as f}from"./launch-console.js";import"./observability.js";import"./command.js";import"./retry.js";import{O as p,o as m}from"./host-file.js";import{f as h,n as g,v as _}from"./config.js";import{a as v,o as y}from"./tool-provider.js";import{t as b}from"./physical-device-control.js";import{n as x}from"./simctl.js";import{c as S}from"./runner-client.js";import{t as C}from"./simulator.js";import{a as w,d as T,u as E}from"./app-resolution.js";import D from"node:path";function O(t){if(!(t instanceof e)||t.code!==`COMMAND_FAILED`)return!1;let n=t.details??{};if(n.exitCode!==4)return!1;let r=String(n.stderr??``).toLowerCase();return r.includes(`fbsopenapplicationserviceerrordomain`)&&r.includes(`the request to open`)}async function k(e,t){let n=await y(x(e,[`get_app_container`,e.id,t]),{allowFailure:!0});if(n.exitCode!==0)return{installed:!1};let r=n.stdout.trim();if(!r)return{installed:!1};let i=await v(`plutil`,[`-extract`,`CFBundleExecutable`,`raw`,`-o`,`-`,`${r}/Info.plist`],{allowFailure:!0});if(i.exitCode!==0||!i.stdout.trim())return{installed:!0};let a=`${r}/${i.stdout.trim()}`,o=await v(`otool`,[`-l`,a],{allowFailure:!0});if(o.exitCode!==0)return{installed:!0};let s=o.stdout.toLowerCase();return{installed:!0,simulatorCompatible:s.includes(`iossimulator`)||s.includes(`platform 7`)}}function A(e){return e.installed?e.simulatorCompatible===!1?`ARCH_MISMATCH`:`PERSISTENT_LAUNCH_FAIL`:`APP_NOT_INSTALLED`}function j(e){switch(e){case`ARCH_MISMATCH`:return`The app binary was not built for the simulator platform. Rebuild with a simulator destination or use a physical device.`;case`APP_NOT_INSTALLED`:return`The app bundle is not installed on this simulator. Run install before open.`;case`PERSISTENT_LAUNCH_FAIL`:return`The simulator repeatedly refused to launch the app. Inspect crash logs in Console.app or ~/Library/Logs/DiagnosticReports/ and consider reinstalling the app.`;default:return`The simulator failed to launch the app. Retry with --debug and inspect diagnostics log for details.`}}const M=25e3;async function N(i,a,o){let s=o?.launchConsole?.trim(),c=o?.launchArgs;if(s&&(!u(i)||i.kind!==`simulator`))throw new e(`UNSUPPORTED_OPERATION`,d);if(l(i)){if(c&&c.length>0)throw new e(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on macOS; launch arguments are currently iOS-only.`);await T(i,a,o);return}let p=o?.url?.trim();if(p){if(s)throw new e(`INVALID_ARGS`,f);if(!n(p))throw new e(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(i.kind===`simulator`){let e=!!c||t(p);if(o?.terminateRunningApp||e){let t=o?.appBundleId??await w(i,a);e?await z(i,t,{...c?{launchArgs:c}:{},...o?.terminateRunningApp?{terminateRunningApp:!0}:{}}):await R(i,t)}await P(i,p,void 0,o?.runnerOptions);return}let l=o?.appBundleId??await w(i,a),u=r(l,p);if(!u)throw new e(`INVALID_ARGS`,`Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.`);await W(i,u,{payloadUrl:p,launchArgs:c,runnerOptions:o?.runnerOptions});return}let m=a.trim();if(n(m)){if(s)throw new e(`INVALID_ARGS`,f);if(i.kind===`simulator`){await P(i,m,c,o?.runnerOptions);return}let t=r(o?.appBundleId,m);if(!t)throw new e(`INVALID_ARGS`,`Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.`);await W(i,t,{payloadUrl:m,launchArgs:c,runnerOptions:o?.runnerOptions});return}let h=o?.appBundleId??await w(i,a);if(i.kind===`simulator`){await z(i,h,{...s?{launchConsole:s}:{},...c?{launchArgs:c}:{},...o?.terminateRunningApp?{terminateRunningApp:!0}:{}});return}await W(i,h,{launchArgs:c,runnerOptions:o?.runnerOptions})}async function P(t,n,r,i){if(r&&r.length>0)throw new e(`INVALID_ARGS`,`--launch-args is not supported with iOS simulator URL opens (simctl openurl ignores launch args). Launch the app first with --launch-args, then issue the URL open in a separate call.`);await C(t);let a=x(t,[`openurl`,t.id,n]);try{await y(a,{timeoutMs:h,...i?.signal?{signal:i.signal}:{}})}catch(n){throw c(n)?new e(`COMMAND_FAILED`,`xcrun simctl openurl did not answer within ${h}ms.`,{...n.details,reason:`ios-simulator-openurl-timeout`,timeoutMs:h,deviceId:t.id,hint:`The Simulator may still have received the URL; CoreSimulator is slow to answer. Retry the open, or answer any "Open in" prompt with alert accept.`}):n}}async function F(e){l(e)||e.kind===`simulator`&&await C(e)}async function I(e,t,n,r){if(l(e)){await E(e,t,r);return}let i=await w(e,t);if(e.kind===`simulator`){await R(e,i);return}await L(i),await b(e).terminateApp(e,i,{runnerOptions:n,runRunnerCommand:S})}async function L(t){let{iosSystemSurfaceHost:n,iosSystemSurfaceOpenRefusal:r}=await import(`./ios-system-surface.js`).then(e=>e.a);if(n(t))throw new e(`UNSUPPORTED_OPERATION`,r(t),{reason:`system-surface-host-not-openable`,appBundleId:t})}async function R(t,n){await L(n),await C(t);let r=x(t,[`terminate`,t.id,n]),a=await y(r,{allowFailure:!0,timeoutMs:_});if(a.exitCode!==0&&!a.stderr.toLowerCase().includes(`found nothing to terminate`))throw new e(`COMMAND_FAILED`,`xcrun exited with code ${a.exitCode}`,i(a,{cmd:`xcrun`,args:r}))}async function z(t,n,r){await L(n),await C(t);let s=0,c=a.fromTimeoutMs(g);try{await o(async({deadline:a})=>{if(a?.isExpired())throw new e(`COMMAND_FAILED`,`App launch deadline exceeded`,{timeoutMs:g});let o=x(t,B(t.id,n,r)),s=r?.launchConsole?await V(o,r.launchConsole):await y(o,{allowFailure:!0});if(s.exitCode!==0)throw new e(`COMMAND_FAILED`,`xcrun exited with code ${s.exitCode}`,i(s,{cmd:`xcrun`,args:o}))},{maxAttempts:10,baseDelayMs:1e3,maxDelayMs:5e3,jitter:.2,shouldRetry(e){return O(e)?(s+=1,s<3):!1}},{deadline:c})}catch(e){if(O(e)){let r=e,i=A(await k(t,n));r.details={...r.details,hint:j(i)}}throw e}}function B(e,t,n){let r=[`launch`];return n?.launchConsole&&r.push(`--console-pty`),n?.terminateRunningApp&&r.push(`--terminate-running-process`),r.push(e,t),n?.launchArgs&&n.launchArgs.length>0&&r.push(...n.launchArgs),r}async function V(t,n){await m(D.dirname(n));try{let e=await y(t,{allowFailure:!0,timeoutMs:M});return await H(n,e.stdout,e.stderr),e}catch(t){let r=(t instanceof e?t:void 0)?.details;if(r?.timeoutMs===M){let e=typeof r.stdout==`string`?r.stdout:``,t=typeof r.stderr==`string`?r.stderr:``;return await H(n,e,t),s({level:`warn`,phase:`ios_simulator_launch_console_capture_timeout`,data:{timeoutMs:M,logPath:n,stdoutBytes:Buffer.byteLength(e),stderrBytes:Buffer.byteLength(t)}}),{stdout:e,stderr:t,exitCode:0}}throw t}}async function H(e,t,n){await p(e,U(t,n))}function U(e,t){return!e||!t||e.endsWith(`
1
+ import{R as e}from"./sdk-contracts.js";import{a as t,i as n,o as r}from"./sdk-batch-runner.js";import{K as i,L as a,V as o,_t as s,q as c}from"./sdk-io.js";import"./diagnostics.js";import{T as l,w as u}from"./sdk-device.js";import{n as d,t as f}from"./launch-console.js";import"./observability.js";import"./command.js";import"./retry.js";import{O as p,o as m}from"./host-file.js";import{n as h,p as g,y as _}from"./config.js";import{a as v,o as y}from"./tool-provider.js";import{t as b}from"./physical-device-control.js";import{n as x}from"./simctl.js";import{c as S}from"./runner-client.js";import{t as C}from"./simulator.js";import{a as w,d as T,u as E}from"./app-resolution.js";import D from"node:path";function O(t){if(!(t instanceof e)||t.code!==`COMMAND_FAILED`)return!1;let n=t.details??{};if(n.exitCode!==4)return!1;let r=String(n.stderr??``).toLowerCase();return r.includes(`fbsopenapplicationserviceerrordomain`)&&r.includes(`the request to open`)}async function k(e,t){let n=await y(x(e,[`get_app_container`,e.id,t]),{allowFailure:!0});if(n.exitCode!==0)return{installed:!1};let r=n.stdout.trim();if(!r)return{installed:!1};let i=await v(`plutil`,[`-extract`,`CFBundleExecutable`,`raw`,`-o`,`-`,`${r}/Info.plist`],{allowFailure:!0});if(i.exitCode!==0||!i.stdout.trim())return{installed:!0};let a=`${r}/${i.stdout.trim()}`,o=await v(`otool`,[`-l`,a],{allowFailure:!0});if(o.exitCode!==0)return{installed:!0};let s=o.stdout.toLowerCase();return{installed:!0,simulatorCompatible:s.includes(`iossimulator`)||s.includes(`platform 7`)}}function A(e){return e.installed?e.simulatorCompatible===!1?`ARCH_MISMATCH`:`PERSISTENT_LAUNCH_FAIL`:`APP_NOT_INSTALLED`}function j(e){switch(e){case`ARCH_MISMATCH`:return`The app binary was not built for the simulator platform. Rebuild with a simulator destination or use a physical device.`;case`APP_NOT_INSTALLED`:return`The app bundle is not installed on this simulator. Run install before open.`;case`PERSISTENT_LAUNCH_FAIL`:return`The simulator repeatedly refused to launch the app. Inspect crash logs in Console.app or ~/Library/Logs/DiagnosticReports/ and consider reinstalling the app.`;default:return`The simulator failed to launch the app. Retry with --debug and inspect diagnostics log for details.`}}const M=25e3;async function N(i,a,o){let s=o?.launchConsole?.trim(),c=o?.launchArgs;if(s&&(!u(i)||i.kind!==`simulator`))throw new e(`UNSUPPORTED_OPERATION`,d);if(l(i)){if(c&&c.length>0)throw new e(`UNSUPPORTED_OPERATION`,`--launch-args is not supported on macOS; launch arguments are currently iOS-only.`);await T(i,a,o);return}let p=o?.url?.trim();if(p){if(s)throw new e(`INVALID_ARGS`,f);if(!n(p))throw new e(`INVALID_ARGS`,`open <app> <url> requires a valid URL target`);if(i.kind===`simulator`){let e=!!c||t(p);if(o?.terminateRunningApp||e){let t=o?.appBundleId??await w(i,a);e?await z(i,t,{...c?{launchArgs:c}:{},...o?.terminateRunningApp?{terminateRunningApp:!0}:{}}):await R(i,t)}await P(i,p,void 0,o?.runnerOptions);return}let l=o?.appBundleId??await w(i,a),u=r(l,p);if(!u)throw new e(`INVALID_ARGS`,`Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.`);await W(i,u,{payloadUrl:p,launchArgs:c,runnerOptions:o?.runnerOptions});return}let m=a.trim();if(n(m)){if(s)throw new e(`INVALID_ARGS`,f);if(i.kind===`simulator`){await P(i,m,c,o?.runnerOptions);return}let t=r(o?.appBundleId,m);if(!t)throw new e(`INVALID_ARGS`,`Deep link open on iOS devices requires an active app bundle ID. Open the app first, then open the URL.`);await W(i,t,{payloadUrl:m,launchArgs:c,runnerOptions:o?.runnerOptions});return}let h=o?.appBundleId??await w(i,a);if(i.kind===`simulator`){await z(i,h,{...s?{launchConsole:s}:{},...c?{launchArgs:c}:{},...o?.terminateRunningApp?{terminateRunningApp:!0}:{}});return}await W(i,h,{launchArgs:c,runnerOptions:o?.runnerOptions})}async function P(t,n,r,i){if(r&&r.length>0)throw new e(`INVALID_ARGS`,`--launch-args is not supported with iOS simulator URL opens (simctl openurl ignores launch args). Launch the app first with --launch-args, then issue the URL open in a separate call.`);await C(t);let a=x(t,[`openurl`,t.id,n]);try{await y(a,{timeoutMs:g,...i?.signal?{signal:i.signal}:{}})}catch(n){throw c(n)?new e(`COMMAND_FAILED`,`xcrun simctl openurl did not answer within ${g}ms.`,{...n.details,reason:`ios-simulator-openurl-timeout`,timeoutMs:g,deviceId:t.id,hint:`The Simulator may still have received the URL; CoreSimulator is slow to answer. Retry the open, or answer any "Open in" prompt with alert accept.`}):n}}async function F(e){l(e)||e.kind===`simulator`&&await C(e)}async function I(e,t,n,r){if(l(e)){await E(e,t,r);return}let i=await w(e,t);if(e.kind===`simulator`){await R(e,i);return}await L(i),await b(e).terminateApp(e,i,{runnerOptions:n,runRunnerCommand:S})}async function L(t){let{iosSystemSurfaceHost:n,iosSystemSurfaceOpenRefusal:r}=await import(`./ios-system-surface.js`).then(e=>e.a);if(n(t))throw new e(`UNSUPPORTED_OPERATION`,r(t),{reason:`system-surface-host-not-openable`,appBundleId:t})}async function R(t,n){await L(n),await C(t);let r=x(t,[`terminate`,t.id,n]),a=await y(r,{allowFailure:!0,timeoutMs:_});if(a.exitCode!==0&&!a.stderr.toLowerCase().includes(`found nothing to terminate`))throw new e(`COMMAND_FAILED`,`xcrun exited with code ${a.exitCode}`,i(a,{cmd:`xcrun`,args:r}))}async function z(t,n,r){await L(n),await C(t);let s=0,c=a.fromTimeoutMs(h);try{await o(async({deadline:a})=>{if(a?.isExpired())throw new e(`COMMAND_FAILED`,`App launch deadline exceeded`,{timeoutMs:h});let o=x(t,B(t.id,n,r)),s=r?.launchConsole?await V(o,r.launchConsole):await y(o,{allowFailure:!0});if(s.exitCode!==0)throw new e(`COMMAND_FAILED`,`xcrun exited with code ${s.exitCode}`,i(s,{cmd:`xcrun`,args:o}))},{maxAttempts:10,baseDelayMs:1e3,maxDelayMs:5e3,jitter:.2,shouldRetry(e){return O(e)?(s+=1,s<3):!1}},{deadline:c})}catch(e){if(O(e)){let r=e,i=A(await k(t,n));r.details={...r.details,hint:j(i)}}throw e}}function B(e,t,n){let r=[`launch`];return n?.launchConsole&&r.push(`--console-pty`),n?.terminateRunningApp&&r.push(`--terminate-running-process`),r.push(e,t),n?.launchArgs&&n.launchArgs.length>0&&r.push(...n.launchArgs),r}async function V(t,n){await m(D.dirname(n));try{let e=await y(t,{allowFailure:!0,timeoutMs:M});return await H(n,e.stdout,e.stderr),e}catch(t){let r=(t instanceof e?t:void 0)?.details;if(r?.timeoutMs===M){let e=typeof r.stdout==`string`?r.stdout:``,t=typeof r.stderr==`string`?r.stderr:``;return await H(n,e,t),s({level:`warn`,phase:`ios_simulator_launch_console_capture_timeout`,data:{timeoutMs:M,logPath:n,stdoutBytes:Buffer.byteLength(e),stderrBytes:Buffer.byteLength(t)}}),{stdout:e,stderr:t,exitCode:0}}throw t}}async function H(e,t,n){await p(e,U(t,n))}function U(e,t){return!e||!t||e.endsWith(`
2
2
  `)||e.endsWith(`\r`)?`${e}${t}`:`${e}\n${t}`}async function W(e,t,n){await L(t),await b(e).launchApp(e,t,{...n,runRunnerCommand:S})}export{N as n,F as r,I as t};
@@ -71,4 +71,4 @@ Changing the pose:
71
71
 
72
72
  Requirements: an iOS simulator session on a foldable device and an Xcode toolchain with the iOS simulator SDK and foldable HID support (verified on Xcode 27.1). ${nm.permissions} The command runs a small helper through simctl spawn for the session UDID; the helper is built once per Fold.m source hash and Xcode toolchain, cached under ~/.agent-device/fold-helper, and rebuilt only when the source or the toolchain changes. The same helper reads the hinge and, in a scoped set, the panels. Build or dispatch failures are reported without a UI fallback. The app under test reads the resulting pose as UIHinge.status.
73
73
  Android emulators: fold sets the posture through the emulator console (adb emu posture 1|2|3), then reads adb shell cmd device_state print-state until the guest commits CLOSED, HALF_OPENED, or OPENED, and reports the hinge sensor's angle, which the AVD profile defines per posture: 0, 90 and 180 degrees on the Pixel folds, 15, 90 and 165 on the generic 7.6in Foldable. Folding to the cover display can raise Android's "Swipe up to continue" lock screen; fold dismisses it so the app stays reachable. An emulator profile without those device states (a phone) fails with UNSUPPORTED_OPERATION and reason single-panel-device, and a physical device is refused. Keyframes are not supported on Android, and the response carries no panel geometry: re-snapshot after every fold.
74
- If a task asserts behavior for more than one pose, fold to each pose and re-snapshot, and report which poses the run covered.`},am=R(Wp,`Navigate back in the app or through system navigation. Use in-app for the app navigation stack and system when the platform back behavior is required. On iOS, a single-screen iPhone or an iPad whose app provably fills its screen can use a top-leading tap when the app tree is unreadable, with before/after visual verification. A capture failure reports an unknown outcome.`,{mode:F(lt),...ms(Wp)}),om=R(Gp,`Set device orientation on iOS and Android. auto hands rotation back to the sensor on ADB-backed Android (local and Limrun); other backends refuse it.`,{orientation:A(F(le))}),sm={pose:F(Fe,`Instant preset; mutually exclusive with keyframes.`),keyframes:I({type:`array`,minItems:2,maxItems:64,description:`Piecewise-linear hinge motion. Start at 0ms; strictly increasing timestamps, up to 60000ms. Repeated angles create holds. Mutually exclusive with pose.`,items:{type:`object`,required:[`atMs`,`angle`],additionalProperties:!1,properties:{atMs:{type:`integer`,minimum:0,maximum:re},angle:{type:`number`,minimum:0,maximum:180}}}})},cm=R(Kp,rm,sm,{readInput:e=>{let{pose:t,keyframes:n,...r}=Zr(e,sm);return{...r,...de({pose:t,keyframes:n})}}}),lm={...cm,inputSchema:{...cm.inputSchema,oneOf:[{required:[`pose`],not:{required:[`keyframes`]}},{required:[`keyframes`],not:{required:[`pose`]}}]}},um=R(Jp,`Inspect Android keyboard visibility/type or press/dismiss the device keyboard. To hide the keyboard, use keyboard dismiss. It taps the keyboard dismiss/hide key when one is exposed, verifies the keyboard closed, and reports UNSUPPORTED_OPERATION when no dismiss key exists — background taps are never attempted.`,{action:F($p)}),dm=R(Yp,`Read the current device clipboard text, or replace its contents with the given text. Android runs both through the clipboard service shell command, and a build that implements none (Android 16 does not) refuses with UNSUPPORTED_OPERATION rather than reporting an empty clipboard.`,{action:A(F(Qp)),text:j()},{parseableOutput:!0}),fm=R(Xp,`Press or long-press a TV remote button on Android TV, tvOS, or Vega OS. Android TV also supports volume, power, media, channel, guide, captions, input, color keys, and android-keycode:N. tvOS and Vega OS support up, down, left, right, select, menu, home, and back. Phones and WebDriver sessions are unsupported. The aliases ok, center, and enter map to select.`,{button:A(Hr(em,(e,t)=>ge(typeof e[t]==`string`?e[t]:void 0))),durationMs:N(`Press duration in milliseconds. tvOS and Vega OS use the exact hold duration; Android TV maps any positive value to an ADB longpress (${Me(`android`)}).`,{min:0})}),pm=R(qp,`Press a phone hardware button once: volume-up, volume-down, power, mute, sleep, wake, media-play-pause, media-next, media-previous, media-rewind, or media-fast-forward. The press is dispatched without activating the session app and nothing is re-observed afterwards, so the OS decides what the key does — which audio stream a volume press moves, which media session a media key reaches, and whether the HUD shows, is device behavior this command does not claim. Power toggles the Android screen; sleep and wake are the explicit Android events that turn it off or on without toggling, and after a press that turns it off, later commands may hit a locked screen. Android (ADB-backed and Appium) presses all eleven on phones and tablets; a physical iPhone or iPad presses volume only through the local runner or Appium, never power, mute, sleep, wake, or media. iOS Simulators, Android TV and tvOS targets refuse: on TV targets use tv-remote.`,{button:A(F(Pe,`One press each. volume-up and volume-down move the system volume stream the OS selects; power toggles the screen on Android; sleep and wake are the explicit Android events that turn the screen off or on without toggling; mute, media-play-pause, media-next, media-previous, media-rewind, and media-fast-forward are Android keys the OS routes to its own streams and media sessions. All of these except volume are refused on every Apple leaf.`))}),mm={action:A(F(De,`call starts an incoming call, accept answers it, cancel ends it, sms delivers a text message.`)),number:A(j(`Caller or sender phone number: digits with an optional leading +.`)),text:j(`Message text for sms; required for sms and refused for the call actions. The emulator drops characters outside the Basic Multilingual Plane, such as emoji.`)},hm=R(Zp,`Simulate an incoming phone call or SMS on an Android emulator through its console over adb: call rings from the number, accept answers, cancel ends the call, and sms delivers a text message. The call screen or notification can cover the app, so re-snapshot afterwards.`,mm,{readInput:e=>{let{action:t,number:n,text:r,...i}=Zr(e,mm);return{...i,...ye({action:t,number:n,text:r})}}}),gm={...hm,inputSchema:{...hm.inputSchema,oneOf:[{properties:{action:T(`sms`)},required:[`text`]},{properties:{action:w(Ce)},not:{required:[`text`]}}]}},_m={usageOverride:`back [--in-app|--system] [--settle]`,usageFlags:[],allowedFlags:[`backMode`,...hs(Wp)]},vm={usageOverride:`orientation <${le.join(`|`)}>`,positionalArgs:[`orientation`]},ym={usageOverride:`fold [${pe}]`,positionalArgs:[`pose?`],allowedFlags:qi},bm={usageOverride:`keyboard [status|get|dismiss|enter|return]`,positionalArgs:[`action?`]},xm={usageOverride:`clipboard read | clipboard write <text>`,listUsageOverride:`clipboard read | clipboard write <text>`,positionalArgs:[`read|write`,`text?`],allowsExtraPositionals:!0},Sm={usageOverride:`tv-remote [press|longpress] ${Oe}`,listUsageOverride:`tv-remote press|longpress <button> [--duration-ms <ms>]`,positionalArgs:[`press|longpress?`,`button`],allowedFlags:[`durationMs`]},Cm={usageOverride:`hardware-button ${ie}`,positionalArgs:[`button`]},wm={usageOverride:be,listUsageOverride:`telephony call|accept|cancel|sms <number> [text]`,positionalArgs:[`call|accept|cancel|sms`,`number`,`text?`],allowsExtraPositionals:!0},Tm=(e,t)=>({...v(t),mode:t.backMode}),Em=(e,t)=>({...v(t),orientation:fe(e[0])}),Dm=(e,t)=>({...v(t),...de({pose:e[0],keyframes:t.keyframes===void 0?void 0:ae(t.keyframes)})}),Om=(e,t)=>({...v(t),...Qm(e)}),km=(e,t)=>({...v(t),...$m(e)}),Am=(e,t)=>({...v(t),...eh(e,t.durationMs)}),jm=(e,t)=>({...v(t),...th(e)}),Mm=(e,t)=>({...v(t),...he(e)}),Nm=e=>_(Wp,[],{...e,backMode:Xm(e.mode)}),Pm=g(Gp,e=>[S(e.orientation,`orientation requires orientation`)]),Fm=e=>{let t=de(e);return _(Kp,t.pose?[t.pose]:[],{...e,keyframes:t.keyframes?JSON.stringify(t.keyframes):void 0})},Im=g(Jp,e=>y(e.action)),Lm=g(Yp,e=>Zm(e)),Rm=g(Xp,e=>[S(e.button,`tv-remote requires button`)]),zm=g(qp,e=>[S(e.button,`hardware-button requires button`)]),Bm=g(Zp,e=>Ne(ye(e))),Vm=fi({name:`appstate`,description:`Show foreground app/activity (Android and HarmonyOS; iOS and macOS answer per session)`,text:{summary:`Show the foreground app and activity`},run:(e,t)=>e.command.appState(t),cliOutputFormatter:$.appstate}),Hm=z({name:Wp,text:{summary:`Navigate back in the app or system`},metadata:am,run:(e,t)=>e.command.back(t),cliSchema:_m,cliReader:Tm,daemonWriter:Nm,cliOutputFormatter:$.back}),Um=fi({name:`home`,description:`Send the selected device to its home screen. This leaves the app session open but moves the foreground away from the app.`,text:{summary:`Go to the device home screen`},run:(e,t)=>e.command.home(t),cliOutputFormatter:$.home}),Wm=z({name:Gp,text:{summary:`Set device orientation`},metadata:om,run:(e,t)=>e.command.orientation(t),cliSchema:vm,cliReader:Em,daemonWriter:Pm,cliOutputFormatter:$.orientation}),Gm=z({name:Kp,text:{summary:`Fold or unfold a foldable iPhone simulator or Android emulator`,cliDetail:`iPhone Duo simulators and foldable Android emulators. iOS sends a ${nm.hingeEvent} and confirms the hinge angle inside the simulator; Android sets the emulator console posture and confirms the device state. Refs and coordinates do not survive a pose change.`},metadata:lm,run:(e,t)=>e.command.fold(t),cliSchema:ym,cliReader:Dm,daemonWriter:Fm,cliOutputFormatter:$.fold}),Km=fi({name:`app-switcher`,description:`Open the device app switcher to inspect or change foreground apps. This changes the visible system UI and may move focus away from the current app.`,text:{summary:`Open the device app switcher`},run:(e,t)=>e.command.appSwitcher(t),cliOutputFormatter:$[`app-switcher`]}),qm=z({name:Jp,text:{summary:`Inspect, press, or dismiss the device keyboard`},metadata:um,run:(e,t)=>e.command.keyboard(t),cliSchema:bm,cliReader:Om,daemonWriter:Im,cliOutputFormatter:$.keyboard}),Jm=z({name:Yp,text:{summary:`Read or write device clipboard text`},metadata:dm,run:(e,t)=>e.command.clipboard(t),cliSchema:xm,cliReader:km,daemonWriter:Lm,cliOutputFormatter:$.clipboard}),Ym=B({name:`system`,commands:[Vm,Hm,Um,Wm,Gm,Km,fi({name:`action-button`,description:`Press the iPhone or iPad Action Button once. The press is dispatched without activating the session app and nothing is re-observed afterwards, so the app keeps the state the press found. What the system does with the press is not observed by this command: Simulators run no Shortcuts or App Intents, so delivery to an assigned Shortcut is verifiable only on a physical iPhone.`,text:{summary:`Press the iPhone or iPad Action Button`,cliDetail:`iPhone and iPad only. The runner asks the device for the button and reports unsupported when that model has none.`},run:(e,t)=>e.command.actionButton(t),cliOutputFormatter:$[`action-button`]}),qm,Jm,z({name:Xp,text:{summary:`Press a TV remote navigation, media, or hardware button`,cliDetail:`longpress selects the 500ms preset; --duration-ms overrides it. Android TV uses the system long-press duration.`},metadata:fm,run:(e,t)=>e.command.tvRemote(t),cliSchema:Sm,cliReader:Am,daemonWriter:Rm,cliOutputFormatter:$[`tv-remote`]}),z({name:qp,text:{summary:`Press a phone hardware button once`,cliDetail:`Single press; no hold. Android presses all eleven named keys on phones and tablets: volume-up, volume-down, power, mute, sleep, wake, and the five media keys. A physical iPhone or iPad presses volume only; the other keys are never supported on Apple targets. iOS Simulators, Android TV, and tvOS refuse — use tv-remote on TV targets.`},metadata:pm,run:(e,t)=>e.command.hardwareButton(t),cliSchema:Cm,cliReader:jm,daemonWriter:zm,cliOutputFormatter:$[`hardware-button`]}),z({name:Zp,text:{summary:`Simulate an incoming call or SMS on an Android emulator over adb`,cliDetail:`Android emulators through the local adb executor; WebDriver (Appium) and Limrun sessions refuse it. Quote the SMS text, or pass it as the remaining words. Re-snapshot after the event: the call screen or notification can cover the app.`},metadata:gm,run:(e,t)=>e.command.telephony(t),cliSchema:wm,cliReader:Mm,daemonWriter:Bm,cliOutputFormatter:$.telephony})]});function Xm(e){return e===`in-app`||e===`system`?e:void 0}function Zm(e){return e.action===`read`?[`read`]:[`write`,e.text]}function Qm(e){if(e.length>1)throw new i(`INVALID_ARGS`,`keyboard accepts at most one action argument.`);return m({action:nh(e[0])})}function $m(e){let t=e[0]?.toLowerCase();if(t!==`read`&&t!==`write`)throw new i(`INVALID_ARGS`,`clipboard requires a subcommand: read or write.`);if(t===`read`){if(e.length!==1)throw new i(`INVALID_ARGS`,`clipboard read does not accept additional arguments.`);return{action:t}}if(e.length<2)throw new i(`INVALID_ARGS`,`clipboard write requires text.`);return{action:t,text:e.slice(1).join(` `)}}function eh(e,t){let n=e[0]?.toLowerCase(),r=n===`press`||n===`longpress`?e.slice(1):e;if(r.length!==1)throw new i(`INVALID_ARGS`,`tv-remote requires exactly one button: ${we.join(`, `)}, or android-keycode:<n>.`);let a=t??(n===`longpress`?500:void 0);return m({button:ge(r[0]),durationMs:a})}function th(e){return{button:me[se(e)]}}function nh(e){let t=e?.toLowerCase();if(t===`get`)return`status`;if(t===void 0||t===`status`||t===`dismiss`||t===`enter`||t===`return`)return t;throw new i(`INVALID_ARGS`,`keyboard action must be status, get, dismiss, enter, or return.`)}const rh=[kc,Hu,as,Ym,Vf,Mp,zd,Af,us,op,Ju,Bi];function ih(){return rh.flatMap(e=>[...e.metadata])}function ah(){return rh.flatMap(e=>[...e.definitions])}function oh(){return uh(`cliSchemas`)}function sh(){return uh(`cliReaders`)}function ch(){return uh(`daemonWriters`)}function lh(){return uh(`cliOutputFormatters`)}function uh(e){let t={};for(let n of rh){let r=n[e];if(r)for(let[n,i]of Object.entries(r)){if(Object.hasOwn(t,n))throw Error(`Duplicate ${String(e)} command family entry: ${n}`);t[n]=i}}return t}const dh=ih(),fh=new Map(dh.map(e=>[e.name,e]));function ph(){return[...dh]}function mh(){return Ot().map(e=>{let t=gh(e);if(!t)throw Error(`Missing command metadata for MCP-exposed command: ${e}`);return t})}function hh(e){return fh.has(e)}function gh(e){return fh.get(e)}export{Xi as A,E as B,gs as C,ta as D,aa as E,T as F,Wn as G,wr as H,w as I,Dn as J,jn as K,k as L,_i as M,gi as N,na as O,O as P,D as R,_c as S,Ao as T,Yn as U,Cr as V,Xn as W,On as Y,Su as _,lh as a,El as b,ch as c,tm as d,im as f,wu as g,Bu as h,mh as i,Ai as j,ra as k,ah as l,Ku as m,hh as n,sh as o,kp as p,Mn as q,ph as r,oh as s,gh as t,ih as u,Gl as v,Yo as w,Ec as x,Hl as y,C as z};
74
+ If a task asserts behavior for more than one pose, fold to each pose and re-snapshot, and report which poses the run covered.`},am=R(Wp,`Navigate back in the app or through system navigation. Use in-app for the app navigation stack and system when the platform back behavior is required. On iOS, a single-screen iPhone or an iPad whose app provably fills its screen can use a top-leading tap when the app tree is unreadable, with before/after visual verification. A capture failure reports an unknown outcome.`,{mode:F(lt),...ms(Wp)}),om=R(Gp,`Set device orientation on iOS and Android. auto hands rotation back to the sensor on ADB-backed Android (local and Limrun); other backends refuse it. A foldable iPhone simulator (iPhone Duo) refuses portrait-upside-down, and refuses every rotation in a scoped simulator set.`,{orientation:A(F(le))}),sm={pose:F(Fe,`Instant preset; mutually exclusive with keyframes.`),keyframes:I({type:`array`,minItems:2,maxItems:64,description:`Piecewise-linear hinge motion. Start at 0ms; strictly increasing timestamps, up to 60000ms. Repeated angles create holds. Mutually exclusive with pose.`,items:{type:`object`,required:[`atMs`,`angle`],additionalProperties:!1,properties:{atMs:{type:`integer`,minimum:0,maximum:re},angle:{type:`number`,minimum:0,maximum:180}}}})},cm=R(Kp,rm,sm,{readInput:e=>{let{pose:t,keyframes:n,...r}=Zr(e,sm);return{...r,...de({pose:t,keyframes:n})}}}),lm={...cm,inputSchema:{...cm.inputSchema,oneOf:[{required:[`pose`],not:{required:[`keyframes`]}},{required:[`keyframes`],not:{required:[`pose`]}}]}},um=R(Jp,`Inspect Android keyboard visibility/type or press/dismiss the device keyboard. To hide the keyboard, use keyboard dismiss. It taps the keyboard dismiss/hide key when one is exposed, verifies the keyboard closed, and reports UNSUPPORTED_OPERATION when no dismiss key exists — background taps are never attempted.`,{action:F($p)}),dm=R(Yp,`Read the current device clipboard text, or replace its contents with the given text. Android runs both through the clipboard service shell command, and a build that implements none (Android 16 does not) refuses with UNSUPPORTED_OPERATION rather than reporting an empty clipboard.`,{action:A(F(Qp)),text:j()},{parseableOutput:!0}),fm=R(Xp,`Press or long-press a TV remote button on Android TV, tvOS, or Vega OS. Android TV also supports volume, power, media, channel, guide, captions, input, color keys, and android-keycode:N. tvOS and Vega OS support up, down, left, right, select, menu, home, and back. Phones and WebDriver sessions are unsupported. The aliases ok, center, and enter map to select.`,{button:A(Hr(em,(e,t)=>ge(typeof e[t]==`string`?e[t]:void 0))),durationMs:N(`Press duration in milliseconds. tvOS and Vega OS use the exact hold duration; Android TV maps any positive value to an ADB longpress (${Me(`android`)}).`,{min:0})}),pm=R(qp,`Press a phone hardware button once: volume-up, volume-down, power, mute, sleep, wake, media-play-pause, media-next, media-previous, media-rewind, or media-fast-forward. The press is dispatched without activating the session app and nothing is re-observed afterwards, so the OS decides what the key does — which audio stream a volume press moves, which media session a media key reaches, and whether the HUD shows, is device behavior this command does not claim. Power toggles the Android screen; sleep and wake are the explicit Android events that turn it off or on without toggling, and after a press that turns it off, later commands may hit a locked screen. Android (ADB-backed and Appium) presses all eleven on phones and tablets; a physical iPhone or iPad presses volume only through the local runner or Appium, never power, mute, sleep, wake, or media. iOS Simulators, Android TV and tvOS targets refuse: on TV targets use tv-remote.`,{button:A(F(Pe,`One press each. volume-up and volume-down move the system volume stream the OS selects; power toggles the screen on Android; sleep and wake are the explicit Android events that turn the screen off or on without toggling; mute, media-play-pause, media-next, media-previous, media-rewind, and media-fast-forward are Android keys the OS routes to its own streams and media sessions. All of these except volume are refused on every Apple leaf.`))}),mm={action:A(F(De,`call starts an incoming call, accept answers it, cancel ends it, sms delivers a text message.`)),number:A(j(`Caller or sender phone number: digits with an optional leading +.`)),text:j(`Message text for sms; required for sms and refused for the call actions. The emulator drops characters outside the Basic Multilingual Plane, such as emoji.`)},hm=R(Zp,`Simulate an incoming phone call or SMS on an Android emulator through its console over adb: call rings from the number, accept answers, cancel ends the call, and sms delivers a text message. The call screen or notification can cover the app, so re-snapshot afterwards.`,mm,{readInput:e=>{let{action:t,number:n,text:r,...i}=Zr(e,mm);return{...i,...ye({action:t,number:n,text:r})}}}),gm={...hm,inputSchema:{...hm.inputSchema,oneOf:[{properties:{action:T(`sms`)},required:[`text`]},{properties:{action:w(Ce)},not:{required:[`text`]}}]}},_m={usageOverride:`back [--in-app|--system] [--settle]`,usageFlags:[],allowedFlags:[`backMode`,...hs(Wp)]},vm={usageOverride:`orientation <${le.join(`|`)}>`,positionalArgs:[`orientation`]},ym={usageOverride:`fold [${pe}]`,positionalArgs:[`pose?`],allowedFlags:qi},bm={usageOverride:`keyboard [status|get|dismiss|enter|return]`,positionalArgs:[`action?`]},xm={usageOverride:`clipboard read | clipboard write <text>`,listUsageOverride:`clipboard read | clipboard write <text>`,positionalArgs:[`read|write`,`text?`],allowsExtraPositionals:!0},Sm={usageOverride:`tv-remote [press|longpress] ${Oe}`,listUsageOverride:`tv-remote press|longpress <button> [--duration-ms <ms>]`,positionalArgs:[`press|longpress?`,`button`],allowedFlags:[`durationMs`]},Cm={usageOverride:`hardware-button ${ie}`,positionalArgs:[`button`]},wm={usageOverride:be,listUsageOverride:`telephony call|accept|cancel|sms <number> [text]`,positionalArgs:[`call|accept|cancel|sms`,`number`,`text?`],allowsExtraPositionals:!0},Tm=(e,t)=>({...v(t),mode:t.backMode}),Em=(e,t)=>({...v(t),orientation:fe(e[0])}),Dm=(e,t)=>({...v(t),...de({pose:e[0],keyframes:t.keyframes===void 0?void 0:ae(t.keyframes)})}),Om=(e,t)=>({...v(t),...Qm(e)}),km=(e,t)=>({...v(t),...$m(e)}),Am=(e,t)=>({...v(t),...eh(e,t.durationMs)}),jm=(e,t)=>({...v(t),...th(e)}),Mm=(e,t)=>({...v(t),...he(e)}),Nm=e=>_(Wp,[],{...e,backMode:Xm(e.mode)}),Pm=g(Gp,e=>[S(e.orientation,`orientation requires orientation`)]),Fm=e=>{let t=de(e);return _(Kp,t.pose?[t.pose]:[],{...e,keyframes:t.keyframes?JSON.stringify(t.keyframes):void 0})},Im=g(Jp,e=>y(e.action)),Lm=g(Yp,e=>Zm(e)),Rm=g(Xp,e=>[S(e.button,`tv-remote requires button`)]),zm=g(qp,e=>[S(e.button,`hardware-button requires button`)]),Bm=g(Zp,e=>Ne(ye(e))),Vm=fi({name:`appstate`,description:`Show foreground app/activity (Android and HarmonyOS; iOS and macOS answer per session)`,text:{summary:`Show the foreground app and activity`},run:(e,t)=>e.command.appState(t),cliOutputFormatter:$.appstate}),Hm=z({name:Wp,text:{summary:`Navigate back in the app or system`},metadata:am,run:(e,t)=>e.command.back(t),cliSchema:_m,cliReader:Tm,daemonWriter:Nm,cliOutputFormatter:$.back}),Um=fi({name:`home`,description:`Send the selected device to its home screen. This leaves the app session open but moves the foreground away from the app.`,text:{summary:`Go to the device home screen`},run:(e,t)=>e.command.home(t),cliOutputFormatter:$.home}),Wm=z({name:Gp,text:{summary:`Set device orientation`},metadata:om,run:(e,t)=>e.command.orientation(t),cliSchema:vm,cliReader:Em,daemonWriter:Pm,cliOutputFormatter:$.orientation}),Gm=z({name:Kp,text:{summary:`Fold or unfold a foldable iPhone simulator or Android emulator`,cliDetail:`iPhone Duo simulators and foldable Android emulators. iOS sends a ${nm.hingeEvent} and confirms the hinge angle inside the simulator; Android sets the emulator console posture and confirms the device state. Refs and coordinates do not survive a pose change.`},metadata:lm,run:(e,t)=>e.command.fold(t),cliSchema:ym,cliReader:Dm,daemonWriter:Fm,cliOutputFormatter:$.fold}),Km=fi({name:`app-switcher`,description:`Open the device app switcher to inspect or change foreground apps. This changes the visible system UI and may move focus away from the current app.`,text:{summary:`Open the device app switcher`},run:(e,t)=>e.command.appSwitcher(t),cliOutputFormatter:$[`app-switcher`]}),qm=z({name:Jp,text:{summary:`Inspect, press, or dismiss the device keyboard`},metadata:um,run:(e,t)=>e.command.keyboard(t),cliSchema:bm,cliReader:Om,daemonWriter:Im,cliOutputFormatter:$.keyboard}),Jm=z({name:Yp,text:{summary:`Read or write device clipboard text`},metadata:dm,run:(e,t)=>e.command.clipboard(t),cliSchema:xm,cliReader:km,daemonWriter:Lm,cliOutputFormatter:$.clipboard}),Ym=B({name:`system`,commands:[Vm,Hm,Um,Wm,Gm,Km,fi({name:`action-button`,description:`Press the iPhone or iPad Action Button once. The press is dispatched without activating the session app and nothing is re-observed afterwards, so the app keeps the state the press found. What the system does with the press is not observed by this command: Simulators run no Shortcuts or App Intents, so delivery to an assigned Shortcut is verifiable only on a physical iPhone.`,text:{summary:`Press the iPhone or iPad Action Button`,cliDetail:`iPhone and iPad only. The runner asks the device for the button and reports unsupported when that model has none.`},run:(e,t)=>e.command.actionButton(t),cliOutputFormatter:$[`action-button`]}),qm,Jm,z({name:Xp,text:{summary:`Press a TV remote navigation, media, or hardware button`,cliDetail:`longpress selects the 500ms preset; --duration-ms overrides it. Android TV uses the system long-press duration.`},metadata:fm,run:(e,t)=>e.command.tvRemote(t),cliSchema:Sm,cliReader:Am,daemonWriter:Rm,cliOutputFormatter:$[`tv-remote`]}),z({name:qp,text:{summary:`Press a phone hardware button once`,cliDetail:`Single press; no hold. Android presses all eleven named keys on phones and tablets: volume-up, volume-down, power, mute, sleep, wake, and the five media keys. A physical iPhone or iPad presses volume only; the other keys are never supported on Apple targets. iOS Simulators, Android TV, and tvOS refuse — use tv-remote on TV targets.`},metadata:pm,run:(e,t)=>e.command.hardwareButton(t),cliSchema:Cm,cliReader:jm,daemonWriter:zm,cliOutputFormatter:$[`hardware-button`]}),z({name:Zp,text:{summary:`Simulate an incoming call or SMS on an Android emulator over adb`,cliDetail:`Android emulators through the local adb executor; WebDriver (Appium) and Limrun sessions refuse it. Quote the SMS text, or pass it as the remaining words. Re-snapshot after the event: the call screen or notification can cover the app.`},metadata:gm,run:(e,t)=>e.command.telephony(t),cliSchema:wm,cliReader:Mm,daemonWriter:Bm,cliOutputFormatter:$.telephony})]});function Xm(e){return e===`in-app`||e===`system`?e:void 0}function Zm(e){return e.action===`read`?[`read`]:[`write`,e.text]}function Qm(e){if(e.length>1)throw new i(`INVALID_ARGS`,`keyboard accepts at most one action argument.`);return m({action:nh(e[0])})}function $m(e){let t=e[0]?.toLowerCase();if(t!==`read`&&t!==`write`)throw new i(`INVALID_ARGS`,`clipboard requires a subcommand: read or write.`);if(t===`read`){if(e.length!==1)throw new i(`INVALID_ARGS`,`clipboard read does not accept additional arguments.`);return{action:t}}if(e.length<2)throw new i(`INVALID_ARGS`,`clipboard write requires text.`);return{action:t,text:e.slice(1).join(` `)}}function eh(e,t){let n=e[0]?.toLowerCase(),r=n===`press`||n===`longpress`?e.slice(1):e;if(r.length!==1)throw new i(`INVALID_ARGS`,`tv-remote requires exactly one button: ${we.join(`, `)}, or android-keycode:<n>.`);let a=t??(n===`longpress`?500:void 0);return m({button:ge(r[0]),durationMs:a})}function th(e){return{button:me[se(e)]}}function nh(e){let t=e?.toLowerCase();if(t===`get`)return`status`;if(t===void 0||t===`status`||t===`dismiss`||t===`enter`||t===`return`)return t;throw new i(`INVALID_ARGS`,`keyboard action must be status, get, dismiss, enter, or return.`)}const rh=[kc,Hu,as,Ym,Vf,Mp,zd,Af,us,op,Ju,Bi];function ih(){return rh.flatMap(e=>[...e.metadata])}function ah(){return rh.flatMap(e=>[...e.definitions])}function oh(){return uh(`cliSchemas`)}function sh(){return uh(`cliReaders`)}function ch(){return uh(`daemonWriters`)}function lh(){return uh(`cliOutputFormatters`)}function uh(e){let t={};for(let n of rh){let r=n[e];if(r)for(let[n,i]of Object.entries(r)){if(Object.hasOwn(t,n))throw Error(`Duplicate ${String(e)} command family entry: ${n}`);t[n]=i}}return t}const dh=ih(),fh=new Map(dh.map(e=>[e.name,e]));function ph(){return[...dh]}function mh(){return Ot().map(e=>{let t=gh(e);if(!t)throw Error(`Missing command metadata for MCP-exposed command: ${e}`);return t})}function hh(e){return fh.has(e)}function gh(e){return fh.get(e)}export{Xi as A,E as B,gs as C,ta as D,aa as E,T as F,Wn as G,wr as H,w as I,Dn as J,jn as K,k as L,_i as M,gi as N,na as O,O as P,D as R,_c as S,Ao as T,Yn as U,Cr as V,Xn as W,On as Y,Su as _,lh as a,El as b,ch as c,tm as d,im as f,wu as g,Bu as h,mh as i,Ai as j,ra as k,ah as l,Ku as m,hh as n,sh as o,kp as p,Mn as q,ph as r,oh as s,gh as t,ih as u,Gl as v,Yo as w,Ec as x,Hl as y,C as z};
@@ -1 +1 @@
1
- const e=18e4,t=6e4,n=6e4,r=2e4,i=12e4,a=1e4,o=15e3,s=2e4,c=2e4,l=5e3,u=15e3,d=4e3,f=1e3,p=.5,m=15e3,h=2e4,g=1e3,_=5e3;export{a as _,i as a,d as c,t as d,s as f,c as g,m as h,r as i,h as l,_ as m,n,f as o,g as p,e as r,p as s,l as t,u,o as v};
1
+ const e=18e4,t=6e4,n=6e4,r=2e4,i=12e4,a=1e4,o=15e3,s=2e4,c=2e4,l=5e3,u=15e3,d=4e3,f=1e3,p=.5,m=2e3,h=15e3,g=2e4,_=1e3,v=5e3;export{c as _,i as a,p as c,u as d,t as f,h as g,v as h,r as i,d as l,_ as m,n,m as o,s as p,e as r,f as s,l as t,g as u,a as v,o as y};
@@ -1 +1 @@
1
- import{v as e}from"./sdk-batch-runner.js";import{T as t,w as n}from"./sdk-device.js";import{r}from"./recording-export-quality.js";import{r as i}from"./recording-scope.js";import{i as a,n as o}from"./recording-stop-observation.js";import{t as s}from"./screen-recording-completion.js";import{t as c}from"./artifact-paths.js";async function l(e,t){try{return await e()}catch{if(t?.aborted)throw t.reason;return!1}}function u(e){return e.exitCode===0}function d(e){return Object.freeze({setFoldPose:e.fold})}function f(e){return process.platform===`darwin`&&(t(e)||n(e)&&e.kind===`simulator`||e.platform===`android`&&e.kind===`emulator`)}const p=[`scope`,`showTouches`,`recordOnlySession`,`activeSessionApp`,`exportQuality`,`fps`];function m(e){return i(e.scope)&&typeof e.showTouches==`boolean`&&typeof e.recordOnlySession==`boolean`&&(e.exportQuality===void 0||r(e.exportQuality))&&h(e.fps)&&g(e.activeSessionApp)}function h(e){return e===void 0||typeof e==`number`&&Number.isInteger(e)&&e>0}function g(t){return t===void 0?!0:!e(t)||!_(t.bundleId)?!1:t.name===void 0||_(t.name)}function _(e){return typeof e==`string`&&e.length>0}function v(e){return e.exportPath===void 0?e.observation===void 0||e.observation.recorder===`unconfirmed`:!1}const y=`stopObservation`,b=`stoppedAtMs`,x=`stopRecorderWarning`,S=`collectedPath`,C=`exportPath`,w=`stopFinalization`,T=Symbol(`unreadable`),E={telemetryPath:N(),warning:N(),overlayWarning:N(),nativePathDisposition:{encode:e=>e,read:e=>e===void 0?void 0:a(e)?e:T},chunks:{encode:e=>e.map(P),read:e=>e===void 0?void 0:F(e)??T},capturedDurationMs:{encode:e=>e,read:e=>e===void 0?void 0:L(e)?e:T}};function D(e){return{...e.observation===void 0?{}:{[y]:k(e.observation)},...e.stoppedAtMs===void 0?{}:{[b]:e.stoppedAtMs},...e.recorderWarning===void 0?{}:{[x]:e.recorderWarning},...e.collectedPath===void 0?{}:{[S]:e.collectedPath},...e.exportPath===void 0?{}:{[C]:e.exportPath},...e.finalization===void 0?{}:{[w]:A(e.finalization)}}}function O(e){let t=e?.[y],n=e?.[b],r=R(e?.[x]),i=R(e?.[S]),a=R(e?.[C]),s=j(e?.[w]);return{...o(t)?{observation:t}:{},...L(n)?{stoppedAtMs:n}:{},...r===void 0?{}:{recorderWarning:r},...i===void 0?{}:{collectedPath:i},...a===void 0?{}:{exportPath:a},...s===void 0?{}:{finalization:s}}}function k(e){return e.recorder===`confirmed`?{recorder:e.recorder}:{recorder:e.recorder,why:e.why}}function A(e){let t={};for(let n of M()){let r=e[n];r!==void 0&&(t[n]=E[n].encode(r))}return t}function j(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n={};for(let e of M()){let r=E[e].read(t[e]);if(r===T)return;r!==void 0&&(n[e]=r)}return Object.keys(n).length===0?void 0:n}function M(){return Object.keys(E)}function N(){return{encode:e=>e,read:R}}function P(e){return{index:e.index,path:e.path,...e.clientOutPath===void 0?{}:{clientOutPath:e.clientOutPath}}}function F(e){if(!Array.isArray(e))return;let t=e.map(I);return t.every(e=>e!==void 0)?t:void 0}function I(e){if(typeof e!=`object`||!e)return;let{index:t,path:n,clientOutPath:r}=e,i=R(n),a=R(r);if(!(!Number.isInteger(t)||t<1||i===void 0)&&(r===void 0||a!==void 0))return{index:t,path:i,...a===void 0?{}:{clientOutPath:a}}}function L(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function R(e){return typeof e==`string`&&e.length>0?e:void 0}async function z(e){let{steps:t,snapshot:n,progress:r,now:i=Date.now}=e,a=O(r?.learned),o=a.observation,l=a.recorderWarning,u=a.stoppedAtMs;if(v(a)){u=i();let e=await t.stop();o=e.observation,l=e.warning,r?.record(D({observation:o,stoppedAtMs:u,recorderWarning:e.warning}))}if(o===void 0)throw Error(`record stop reached collection without an observation of its recorder and a committed export`);let d=a.collectedPath??c(n.outPath);a.collectedPath===void 0&&(await t.collect(d),r?.record(D({collectedPath:d})));let f=a.finalization??await t.finalize({collectedPath:d,exportPath:n.outPath,stoppedAtMs:u??i()});r?.record(D({exportPath:n.outPath,finalization:f})),await t.discard(d);let{nativePathDisposition:p,warning:m,...h}=f,g=[m,l].filter(e=>e!==void 0&&e.length>0);return s(n,{...h,...g.length===0?{}:{warning:g.join(` `)}},{stopObservation:o,...p===void 0?{}:{nativePathDisposition:p}})}const B=`boot_timeout`;export{m as a,u as c,p as i,l,z as n,f as o,O as r,d as s,B as t};
1
+ import{v as e}from"./sdk-batch-runner.js";import{T as t,w as n}from"./sdk-device.js";import{r}from"./recording-export-quality.js";import{r as i}from"./recording-scope.js";import{i as a,n as o}from"./recording-stop-observation.js";import{t as s}from"./screen-recording-completion.js";import{t as c}from"./artifact-paths.js";async function l(e,t){try{return await e()}catch{if(t?.aborted)throw t.reason;return!1}}function u(e){return e.exitCode===0}function d(e){return process.platform===`darwin`&&(t(e)||n(e)&&e.kind===`simulator`||e.platform===`android`&&e.kind===`emulator`)}const f=[`scope`,`showTouches`,`recordOnlySession`,`activeSessionApp`,`exportQuality`,`fps`];function p(e){return i(e.scope)&&typeof e.showTouches==`boolean`&&typeof e.recordOnlySession==`boolean`&&(e.exportQuality===void 0||r(e.exportQuality))&&m(e.fps)&&h(e.activeSessionApp)}function m(e){return e===void 0||typeof e==`number`&&Number.isInteger(e)&&e>0}function h(t){return t===void 0?!0:!e(t)||!g(t.bundleId)?!1:t.name===void 0||g(t.name)}function g(e){return typeof e==`string`&&e.length>0}function _(e){return e.exportPath===void 0?e.observation===void 0||e.observation.recorder===`unconfirmed`:!1}const v=`stopObservation`,y=`stoppedAtMs`,b=`stopRecorderWarning`,x=`collectedPath`,S=`exportPath`,C=`stopFinalization`,w=Symbol(`unreadable`),T={telemetryPath:M(),warning:M(),overlayWarning:M(),nativePathDisposition:{encode:e=>e,read:e=>e===void 0?void 0:a(e)?e:w},chunks:{encode:e=>e.map(N),read:e=>e===void 0?void 0:P(e)??w},capturedDurationMs:{encode:e=>e,read:e=>e===void 0?void 0:I(e)?e:w}};function E(e){return{...e.observation===void 0?{}:{[v]:O(e.observation)},...e.stoppedAtMs===void 0?{}:{[y]:e.stoppedAtMs},...e.recorderWarning===void 0?{}:{[b]:e.recorderWarning},...e.collectedPath===void 0?{}:{[x]:e.collectedPath},...e.exportPath===void 0?{}:{[S]:e.exportPath},...e.finalization===void 0?{}:{[C]:k(e.finalization)}}}function D(e){let t=e?.[v],n=e?.[y],r=L(e?.[b]),i=L(e?.[x]),a=L(e?.[S]),s=A(e?.[C]);return{...o(t)?{observation:t}:{},...I(n)?{stoppedAtMs:n}:{},...r===void 0?{}:{recorderWarning:r},...i===void 0?{}:{collectedPath:i},...a===void 0?{}:{exportPath:a},...s===void 0?{}:{finalization:s}}}function O(e){return e.recorder===`confirmed`?{recorder:e.recorder}:{recorder:e.recorder,why:e.why}}function k(e){let t={};for(let n of j()){let r=e[n];r!==void 0&&(t[n]=T[n].encode(r))}return t}function A(e){if(typeof e!=`object`||!e||Array.isArray(e))return;let t=e,n={};for(let e of j()){let r=T[e].read(t[e]);if(r===w)return;r!==void 0&&(n[e]=r)}return Object.keys(n).length===0?void 0:n}function j(){return Object.keys(T)}function M(){return{encode:e=>e,read:L}}function N(e){return{index:e.index,path:e.path,...e.clientOutPath===void 0?{}:{clientOutPath:e.clientOutPath}}}function P(e){if(!Array.isArray(e))return;let t=e.map(F);return t.every(e=>e!==void 0)?t:void 0}function F(e){if(typeof e!=`object`||!e)return;let{index:t,path:n,clientOutPath:r}=e,i=L(n),a=L(r);if(!(!Number.isInteger(t)||t<1||i===void 0)&&(r===void 0||a!==void 0))return{index:t,path:i,...a===void 0?{}:{clientOutPath:a}}}function I(e){return typeof e==`number`&&Number.isFinite(e)&&e>=0}function L(e){return typeof e==`string`&&e.length>0?e:void 0}async function R(e){let{steps:t,snapshot:n,progress:r,now:i=Date.now}=e,a=D(r?.learned),o=a.observation,l=a.recorderWarning,u=a.stoppedAtMs;if(_(a)){u=i();let e=await t.stop();o=e.observation,l=e.warning,r?.record(E({observation:o,stoppedAtMs:u,recorderWarning:e.warning}))}if(o===void 0)throw Error(`record stop reached collection without an observation of its recorder and a committed export`);let d=a.collectedPath??c(n.outPath);a.collectedPath===void 0&&(await t.collect(d),r?.record(E({collectedPath:d})));let f=a.finalization??await t.finalize({collectedPath:d,exportPath:n.outPath,stoppedAtMs:u??i()});r?.record(E({exportPath:n.outPath,finalization:f})),await t.discard(d);let{nativePathDisposition:p,warning:m,...h}=f,g=[m,l].filter(e=>e!==void 0&&e.length>0);return s(n,{...h,...g.length===0?{}:{warning:g.join(` `)}},{stopObservation:o,...p===void 0?{}:{nativePathDisposition:p}})}const z=`boot_timeout`;export{p as a,l as c,f as i,R as n,d as o,D as r,u as s,z as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime.js";import{R as t}from"./sdk-contracts.js";import{_t as n,q as r}from"./sdk-io.js";import"./diagnostics.js";import"./command.js";import{u as i}from"./config.js";import{c as a}from"./devicectl.js";import{u as o}from"./simctl.js";var s=e({appleSimulatorDisplayArgvFragment:()=>P,buildInventory:()=>D,parseCoreDeviceDisplays:()=>v,queryAppleDisplayInventory:()=>u,readPanelPower:()=>T,resolveAppleCaptureDisplay:()=>A,resolveAppleCaptureTarget:()=>j});const c=new Set([`activeOn`,`inactiveOn`,`activeDimmed`]),l=new Set([`off`]);async function u(e,t){let n=o(e).simulatorSetPath?await f(e,t):await d(e,t);return n.ok?m(e,n.payload):(g(e,n.reason,n.detail),_())}async function d(e,t){try{let n=await a({jsonPrefix:`agent-device-apple-displays`,args:[`devicectl`,`device`,`info`,`displays`,`--device`,e.id],timeoutMs:t.timeoutMs??5e3,signal:t.signal});return n.ok?{ok:!0,payload:n.payload}:{ok:!1,reason:n.reason,detail:n.result.stderr.trim()}}catch(e){return p(e,r(e)?`probe-timed-out`:`probe-failed`)}}async function f(e,t){let n=AbortSignal.timeout(i),a=t.signal?AbortSignal.any([t.signal,n]):n;try{let{createFoldHelper:n}=await import(`./fold-helper.js`).then(e=>e.r);return{ok:!0,payload:await(t.foldHelper??n(e)).readPanelPayload({signal:a,timeoutMs:t.timeoutMs??5e3})}}catch(e){return t.signal?.throwIfAborted(),p(e,r(e)||n.aborted?`probe-timed-out`:`guest-panels-failed`)}}function p(e,t){return{ok:!1,reason:t,detail:e instanceof Error?e.message:String(e)}}function m(e,t){let n=v(t),r=h(t);return n.filter(e=>e.integrated).length===r&&n.length>0?D(n):r>=2?{displays:n.filter(e=>e.integrated),multiScreen:!0,ambiguous:!0,unresolved:!1}:(g(e,n.length===0?`empty-display-list`:`incomplete-panel-table`,``),_())}function h(e){let t=e?.result?.displays;return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&E(e.type)).length:0}function g(e,t,r){n({level:`warn`,phase:`apple_display_inventory_unresolved`,data:{platform:e.platform,deviceId:e.id,reason:t,...r?{detail:r}:{},...t===`command-failed`||t===`unreadable-json`?{hint:`This Xcode/CoreDevice toolchain does not report 'devicectl device info displays'. Update Xcode to a version that ships the display-information feature before targeting multi-display Apple devices.`}:{}}})}function _(){return{displays:[],multiScreen:!1,ambiguous:!1,unresolved:!0}}function v(e){let t=e?.result?.displays;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=y(e);t&&n.push(t)}return n}function y(e){let t=b(e);if(t)return{...t,power:T(e.backlightState,e.active),primary:e.primary===!0,currentOrientation:typeof e.currentOrientation==`string`?e.currentOrientation:`unknown`,integrated:E(e.type)}}function b(e){let t=x(e.name),n=C(e.displayId),r=w(e.pointScale),i=S(e.nativeSize);if(!(!t||n===void 0||r===void 0||!i))return{name:t,displayId:n,pointScale:r,widthPx:i.widthPx,heightPx:i.heightPx}}function x(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function S(e){if(!Array.isArray(e))return;let t=w(e[0]),n=w(e[1]);if(t!==void 0&&n!==void 0)return{widthPx:t,heightPx:n}}function C(e){return typeof e==`number`&&Number.isInteger(e)?e:void 0}function w(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function T(e,t){return typeof e==`string`?c.has(e)?`lit`:l.has(e)?`dark`:`unknown`:t===!0?`lit`:t===!1?`dark`:`unknown`}function E(e){return typeof e==`object`&&!!e&&Object.hasOwn(e,`integrated`)}function D(e){let t=e.filter(e=>e.integrated);if(t.length<2)return{displays:e,multiScreen:!1,ambiguous:!1,unresolved:!1};k(t);let r=t.filter(e=>e.power===`lit`),i=t.find(e=>e.primary),a=r.length===1,o=a?r[0]:i,s=!a||i===void 0;return s&&n({level:`warn`,phase:`apple_display_capture_ambiguous`,data:{reason:i===void 0?`no-primary-panel`:`lit-panel-count`,litPanelCount:r.length,...o?{capturedDisplay:o.name,hint:`Panel power did not identify exactly one lit panel, so the capture names the primary panel without claiming to know which panel the device is showing. Read the device pose from the app under test with UIHinge.status.`}:{hint:O}}}),{displays:t,multiScreen:!0,...o?{activeDisplay:o}:{},ambiguous:s,unresolved:!1}}const O=`The panel table named no primary panel and panel power did not identify exactly one lit panel. Retry after one panel reports a lit backlightState; agent-device help foldable names the panel table source for each device set.`;function k(e){let t=e.find(e=>e.primary);if(!t)return;let r=e=>e.widthPx*e.heightPx,i=e.filter(e=>e!==t).reduce((e,t)=>r(t)>r(e)?t:e);r(t)<r(i)||n({level:`warn`,phase:`apple_display_primary_geometry_conflict`,data:{primaryDisplay:t.name,largestDisplay:i.name,hint:"The panel table reported the primary panel as at least as large as the other panel. Its `primary` flag still selects the capture fallback; verify the device type capabilities."}})}async function A(e,t={}){return(await j(e,t)).display}async function j(e,n={}){let r=await u(e,n);if(r.unresolved)return{};if(r.multiScreen){if(r.activeDisplay)return{display:r.activeDisplay};throw new t(`COMMAND_FAILED`,`The panel table did not identify which panel of ${e.name} to capture`,{deviceId:e.id,reason:`capture-panel-unidentified`,litPanelCount:r.displays.filter(e=>e.power===`lit`).length,hint:O})}let i=r.displays.find(e=>e.integrated),a=i?N(i):void 0;return a?{displayRotation:a}:{}}const M=new Map([[`rot0`,`portrait`],[`rot90`,`landscape-right`],[`rot180`,`portrait-upside-down`],[`rot270`,`landscape-left`]]);function N(e){return M.get(e.currentOrientation)}function P(e){return e?[`--display=${e.name}`]:[]}export{j as i,s as n,u as r,P as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{R as t}from"./sdk-contracts.js";import{_t as n,q as r}from"./sdk-io.js";import"./diagnostics.js";import"./command.js";import{d as i}from"./config.js";import{c as a}from"./devicectl.js";import{u as o}from"./simctl.js";var s=e({appleSimulatorDisplayArgvFragment:()=>P,buildInventory:()=>D,parseCoreDeviceDisplays:()=>v,queryAppleDisplayInventory:()=>u,readPanelPower:()=>T,resolveAppleCaptureDisplay:()=>A,resolveAppleCaptureTarget:()=>j});const c=new Set([`activeOn`,`inactiveOn`,`activeDimmed`]),l=new Set([`off`]);async function u(e,t){let n=o(e).simulatorSetPath?await f(e,t):await d(e,t);return n.ok?m(e,n.payload):(g(e,n.reason,n.detail),_())}async function d(e,t){try{let n=await a({jsonPrefix:`agent-device-apple-displays`,args:[`devicectl`,`device`,`info`,`displays`,`--device`,e.id],timeoutMs:t.timeoutMs??5e3,signal:t.signal});return n.ok?{ok:!0,payload:n.payload}:{ok:!1,reason:n.reason,detail:n.result.stderr.trim()}}catch(e){return p(e,r(e)?`probe-timed-out`:`probe-failed`)}}async function f(e,t){let n=AbortSignal.timeout(i),a=t.signal?AbortSignal.any([t.signal,n]):n;try{let{createFoldHelper:n}=await import(`./fold-helper.js`).then(e=>e.r);return{ok:!0,payload:await(t.foldHelper??n(e)).readPanelPayload({signal:a,timeoutMs:t.timeoutMs??5e3})}}catch(e){return t.signal?.throwIfAborted(),p(e,r(e)||n.aborted?`probe-timed-out`:`guest-panels-failed`)}}function p(e,t){return{ok:!1,reason:t,detail:e instanceof Error?e.message:String(e)}}function m(e,t){let n=v(t),r=h(t);return n.filter(e=>e.integrated).length===r&&n.length>0?D(n):r>=2?{displays:n.filter(e=>e.integrated),multiScreen:!0,ambiguous:!0,unresolved:!1}:(g(e,n.length===0?`empty-display-list`:`incomplete-panel-table`,``),_())}function h(e){let t=e?.result?.displays;return Array.isArray(t)?t.filter(e=>typeof e==`object`&&!!e&&E(e.type)).length:0}function g(e,t,r){n({level:`warn`,phase:`apple_display_inventory_unresolved`,data:{platform:e.platform,deviceId:e.id,reason:t,...r?{detail:r}:{},...t===`command-failed`||t===`unreadable-json`?{hint:`This Xcode/CoreDevice toolchain does not report 'devicectl device info displays'. Update Xcode to a version that ships the display-information feature before targeting multi-display Apple devices.`}:{}}})}function _(){return{displays:[],multiScreen:!1,ambiguous:!1,unresolved:!0}}function v(e){let t=e?.result?.displays;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(!e||typeof e!=`object`)continue;let t=y(e);t&&n.push(t)}return n}function y(e){let t=b(e);if(t)return{...t,power:T(e.backlightState,e.active),primary:e.primary===!0,currentOrientation:typeof e.currentOrientation==`string`?e.currentOrientation:`unknown`,integrated:E(e.type)}}function b(e){let t=x(e.name),n=C(e.displayId),r=w(e.pointScale),i=S(e.nativeSize);if(!(!t||n===void 0||r===void 0||!i))return{name:t,displayId:n,pointScale:r,widthPx:i.widthPx,heightPx:i.heightPx}}function x(e){if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0}function S(e){if(!Array.isArray(e))return;let t=w(e[0]),n=w(e[1]);if(t!==void 0&&n!==void 0)return{widthPx:t,heightPx:n}}function C(e){return typeof e==`number`&&Number.isInteger(e)?e:void 0}function w(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:void 0}function T(e,t){return typeof e==`string`?c.has(e)?`lit`:l.has(e)?`dark`:`unknown`:t===!0?`lit`:t===!1?`dark`:`unknown`}function E(e){return typeof e==`object`&&!!e&&Object.hasOwn(e,`integrated`)}function D(e){let t=e.filter(e=>e.integrated);if(t.length<2)return{displays:e,multiScreen:!1,ambiguous:!1,unresolved:!1};k(t);let r=t.filter(e=>e.power===`lit`),i=t.find(e=>e.primary),a=r.length===1,o=a?r[0]:i,s=!a||i===void 0;return s&&n({level:`warn`,phase:`apple_display_capture_ambiguous`,data:{reason:i===void 0?`no-primary-panel`:`lit-panel-count`,litPanelCount:r.length,...o?{capturedDisplay:o.name,hint:`Panel power did not identify exactly one lit panel, so the capture names the primary panel without claiming to know which panel the device is showing. Read the device pose from the app under test with UIHinge.status.`}:{hint:O}}}),{displays:t,multiScreen:!0,...o?{activeDisplay:o}:{},ambiguous:s,unresolved:!1}}const O=`The panel table named no primary panel and panel power did not identify exactly one lit panel. Retry after one panel reports a lit backlightState; agent-device help foldable names the panel table source for each device set.`;function k(e){let t=e.find(e=>e.primary);if(!t)return;let r=e=>e.widthPx*e.heightPx,i=e.filter(e=>e!==t).reduce((e,t)=>r(t)>r(e)?t:e);r(t)<r(i)||n({level:`warn`,phase:`apple_display_primary_geometry_conflict`,data:{primaryDisplay:t.name,largestDisplay:i.name,hint:"The panel table reported the primary panel as at least as large as the other panel. Its `primary` flag still selects the capture fallback; verify the device type capabilities."}})}async function A(e,t={}){return(await j(e,t)).display}async function j(e,n={}){let r=await u(e,n);if(r.unresolved)return{};if(r.multiScreen){if(r.activeDisplay)return{display:r.activeDisplay};throw new t(`COMMAND_FAILED`,`The panel table did not identify which panel of ${e.name} to capture`,{deviceId:e.id,reason:`capture-panel-unidentified`,litPanelCount:r.displays.filter(e=>e.power===`lit`).length,hint:O})}let i=r.displays.find(e=>e.integrated),a=i?N(i):void 0;return a?{displayRotation:a}:{}}const M=new Map([[`rot0`,`portrait`],[`rot90`,`landscape-right`],[`rot180`,`portrait-upside-down`],[`rot270`,`landscape-left`]]);function N(e){return M.get(e.currentOrientation)}function P(e){return e?[`--display=${e.name}`]:[]}export{j as i,s as n,u as r,P as t};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime.js";import{Q as t,R as n}from"./sdk-contracts.js";import{K as r,q as i}from"./sdk-io.js";import{o as a}from"./file.js";import"./command.js";import{r as o}from"./version.js";import{f as s}from"./host-file.js";import{c}from"./config.js";import{a as l}from"./tool-provider.js";import{t as u}from"./apple-runner-platform.js";import{o as d}from"./simctl.js";import{a as f,i as p,n as m,r as h,t as g}from"./host2.js";import{createHash as _}from"node:crypto";import v from"node:path";async function y(e,t){let n=await x(e,`xcodebuild`,[`-version`],t),r=await x(e,`sw_vers`,[`-productVersion`],t),i=await x(e,`sw_vers`,[`-buildVersion`],t),a=await b(e,t);if(a!==`arm64`&&a!==`x86_64`)throw f(`unsupported`,`simulator-architecture-unsupported`,{architecture:a});return{xcode:n,macosProductVersion:r,macosBuild:i,architecture:a}}async function b(e,t){let n=h(t,`host-arch-deadline`),r=t.signal,i,a,o=new Promise((e,t)=>{i=setTimeout(()=>t(f(`timeout`,`host-arch-deadline`)),n),i.unref?.(),a=()=>t(f(`cancelled`,`abort-signal`)),r?.addEventListener(`abort`,a,{once:!0})});try{return await Promise.race([e.cpuArch(),o])}finally{clearTimeout(i),a&&r?.removeEventListener(`abort`,a)}}async function x(e,t,n,r){let i=await S(e,t,n,r);if(i.exitCode!==0)throw f(`unsupported`,`toolchain-probe-failed`,{command:t,exitCode:i.exitCode,stderr:i.stderr.slice(0,1024)});let a=(i.stdout||i.stderr).trim();if(!a)throw f(`unsupported`,`toolchain-probe-empty`,{command:t});return a}async function S(e,t,n,r){let i=[],a;for(let o=1;;o+=1){let s;try{s=Math.min(u,h(r,`toolchain-probe-deadline`))}catch(e){throw a??e}i.push(s);try{return await T(e,t,n,r,s)}catch(e){if(a=C(e,t,r,i),o>=2)throw a}}}function C(e,n,r,a){if(t(e))throw f(`cancelled`,`abort-signal`,{},e);if(!i(e))throw e;if(r.signal?.aborted)throw f(`cancelled`,`abort-signal`);return w(n,a,e)}function w(e,t,n){let r=t.length;return f(`timeout`,`toolchain-probe-stalled`,{command:e,attemptTimeoutsMs:[...t],hint:`${e} did not answer within ${t[r-1]}ms on ${r} attempt(s). A toolchain probe that cannot answer is a host condition rather than a toolchain defect: run \`${e}\` by hand until it answers, then retry.`},n)}function T(e,t,n,r,i){return e.run(t,n,{allowFailure:!0,signal:r.signal,timeoutMs:i})}const E=`manifest.json`;async function D(e){let{host:t,deadline:n,cacheRoot:r,binaryFilename:i}=e,o=_(`sha256`).update(JSON.stringify(e.keyInputs)).digest(`hex`).slice(0,32),s=v.join(r,o);return await a({acquire:()=>t.acquireLock(v.join(r,`${o}.lock`),{deadline:n,description:e.lockDescription}),task:async()=>{let a=await O(t,s,i,o,n);if(a)return{path:a,cacheKey:o};h(n,`native-build-deadline`),t.exists(s)&&await t.remove(s),h(n,`native-build-deadline`),await t.ensureDirectory(r);let c=v.join(r,`.${o}.${t.processId()}.tmp`);h(n,`native-build-deadline`),await t.remove(c);try{h(n,`native-build-deadline`),await t.ensureDirectory(c);let r=v.join(c,i);await e.build(r),h(n,`native-build-deadline`),await t.chmod(r,493);let a=await A(t,r),l={...e.keyInputs,cacheKey:o,binarySha256:a};return await t.writeText(v.join(c,E),`${JSON.stringify(l,null,2)}\n`),h(n,`native-build-deadline`),await t.rename(c,s),{path:v.join(s,i),cacheKey:o}}catch(e){throw await t.remove(c),e}}})}async function O(e,t,n,r,i){let a=v.join(t,n),o=v.join(t,E);if(!(!e.exists(a)||!e.exists(o)))try{let t=JSON.parse(await e.readText(o));return t.cacheKey!==r||typeof t.binarySha256!=`string`?void 0:(h(i,`native-cache-hash-deadline`),await A(e,a)===t.binarySha256?a:void 0)}catch(e){if(k(e))throw e;return}}function k(e){return e instanceof p&&(e.buildFailureKind===`cancelled`||e.buildFailureKind===`timeout`)}async function A(e,t){return _(`sha256`).update(await e.readBinary(t)).digest(`hex`)}async function j(e,t,n,r){let i=_(`sha256`);for(let a of n){let n=v.join(t,a);if(h(r,`native-source-fingerprint-deadline`),!e.exists(n))throw f(`unsupported`,`native-source-missing`,{filePath:n});i.update(a),i.update(`\0`),i.update(await e.readBinary(n)),i.update(`\0`)}return i.digest(`hex`)}async function M(e){let t=Math.min(e.budgetMs,h(e.deadline,`native-build-deadline`));try{return await e.host.run(`xcrun`,[...e.argv],{signal:e.deadline.signal,timeoutMs:t,allowFailure:!0})}catch(n){throw i(n)?f(`timeout`,`native-build-stalled`,{timeoutMs:t,hint:`The Simulator SDK toolchain did not answer within ${t}ms, which stopped the ${e.label} build before clang reported anything. Run \`xcrun --sdk iphonesimulator clang --version\` by hand until it answers, then retry.`},n):n}}const N=`Fold.m`,P=3e4,F=u+P;async function I(e={}){let t=e.host??L(),n=m(F,e.signal);try{let r=e.sourceRoot??v.join(o(),`apple`,`fold-helper`),i=await j(t,r,[N],n),a=await y(t,n);return await D({host:t,deadline:n,lockDescription:`iOS Simulator fold helper cache`,cacheRoot:e.cacheRoot??v.join(s(),`.agent-device`,`fold-helper`),binaryFilename:`fold-helper`,keyInputs:{schemaVersion:1,sourceHash:i,toolchain:a,compileArgv:R({sourceRoot:``,outputPath:``})},build:e=>z(t,n,r,e)})}catch(e){throw B(e)}}function L(){return g(l)}function R(e){return[`--sdk`,`iphonesimulator`,`clang`,`-mios-simulator-version-min=15.0`,`-fobjc-arc`,`-Wall`,`-Wextra`,`-framework`,`Foundation`,`-framework`,`IOKit`,v.join(e.sourceRoot,N),`-o`,e.outputPath]}async function z(e,t,n,i){let a=await M({host:e,deadline:t,argv:R({sourceRoot:n,outputPath:i}),budgetMs:P,label:`fold helper`});if(a.exitCode!==0||!e.exists(i))throw V(r(a))}function B(e){return!(e instanceof p)||e.buildFailureKind===`cancelled`?e:V({...e.buildDetails,cause:e.buildFailureCode},e)}function V(e,t){return new n(`COMMAND_FAILED`,`Unable to build the simulator fold helper`,{hint:`Select an Xcode with the iOS simulator SDK and foldable HID support using DEVELOPER_DIR.`,...e,reason:`fold-helper-build-failed`},t)}var H=e({HINGE_ANGLE_NO_SAMPLE_REASON:()=>U,createFoldHelper:()=>W,parseHingeReading:()=>Y});const U=`fold-hinge-angle-no-sample`;function W(e){let t,a=async(a,o,s)=>{let{signal:c,timeoutMs:l,failure:u}=o;c?.throwIfAborted();let{path:f}=await(t??=I({signal:c}));c?.throwIfAborted();let p;try{p=await d(e,[`spawn`,e.id,f,...a],{signal:c,timeoutMs:l,kill:{signal:`SIGTERM`,graceMs:1e3},allowFailure:!0})}catch(t){throw c?.aborted||!i(t)?t:new n(`COMMAND_FAILED`,u.message,{...t.details,deviceId:e.id,...u.details},t)}let m=p.exitCode===0?s(p.stdout):void 0;if(m!==void 0)return m;throw new n(`COMMAND_FAILED`,u.message,r(p,{deviceId:e.id,...u.details}))};return Object.freeze({async setPose(e,t){let n=typeof e==`string`?0:e.at(-1).atMs,r=typeof e==`string`?e:JSON.stringify(e);await a([`set`,r],{signal:t,timeoutMs:n+1e4,failure:G},()=>!0)},async readHingeAngle({signal:e,windowMs:t=0}={}){return await a([`hinge`,String(t)],{signal:e,timeoutMs:c+t,failure:K},Y)},async readPanelPayload({signal:e,timeoutMs:t}){return await a([`panels`],{signal:e,timeoutMs:t,failure:q},e=>{let t=J(e)?.displays;return Array.isArray(t)?{result:{displays:t}}:void 0})}})}const G={message:`Unable to send the simulator hinge pose`,details:{reason:`fold-hid-dispatch-failed`}},K={message:`The simulator reported no hinge angle sample`,details:{reason:U,hint:`The fold helper's hinge read returned no valid CoreMotion sample. The details name the cause: stderr such as a simulator runtime without CMAngleManager, or timeoutMs when the read did not finish.`}},q={message:`The simulator reported no panel table`,details:{reason:`fold-helper-panels-unreadable`}};function J(e){let t=e.trim().split(`
2
- `).at(-1);if(!t)return;let n;try{n=JSON.parse(t)}catch{return}if(typeof n!=`object`||!n)return;let r=n;return r.version===1?r:void 0}function Y(e){let t=J(e);if(!t||t.angleValid!==!0)return;let n=t.angleDegrees;if(!(typeof n!=`number`||!Number.isFinite(n)||n<0||n>180))return n}export{M as a,D as i,W as n,j as o,H as r,y as s,U as t};
1
+ import{r as e}from"./rolldown-runtime.js";import{Q as t,R as n}from"./sdk-contracts.js";import{K as r,q as i}from"./sdk-io.js";import{o as a}from"./file.js";import"./command.js";import{r as o}from"./version.js";import{f as s}from"./host-file.js";import{l as c}from"./config.js";import{a as l}from"./tool-provider.js";import{t as u}from"./apple-runner-platform.js";import{o as d}from"./simctl.js";import{a as f,i as p,n as m,r as h,t as g}from"./host2.js";import{createHash as _}from"node:crypto";import v from"node:path";async function y(e,t){let n=await x(e,`xcodebuild`,[`-version`],t),r=await x(e,`sw_vers`,[`-productVersion`],t),i=await x(e,`sw_vers`,[`-buildVersion`],t),a=await b(e,t);if(a!==`arm64`&&a!==`x86_64`)throw f(`unsupported`,`simulator-architecture-unsupported`,{architecture:a});return{xcode:n,macosProductVersion:r,macosBuild:i,architecture:a}}async function b(e,t){let n=h(t,`host-arch-deadline`),r=t.signal,i,a,o=new Promise((e,t)=>{i=setTimeout(()=>t(f(`timeout`,`host-arch-deadline`)),n),i.unref?.(),a=()=>t(f(`cancelled`,`abort-signal`)),r?.addEventListener(`abort`,a,{once:!0})});try{return await Promise.race([e.cpuArch(),o])}finally{clearTimeout(i),a&&r?.removeEventListener(`abort`,a)}}async function x(e,t,n,r){let i=await S(e,t,n,r);if(i.exitCode!==0)throw f(`unsupported`,`toolchain-probe-failed`,{command:t,exitCode:i.exitCode,stderr:i.stderr.slice(0,1024)});let a=(i.stdout||i.stderr).trim();if(!a)throw f(`unsupported`,`toolchain-probe-empty`,{command:t});return a}async function S(e,t,n,r){let i=[],a;for(let o=1;;o+=1){let s;try{s=Math.min(u,h(r,`toolchain-probe-deadline`))}catch(e){throw a??e}i.push(s);try{return await T(e,t,n,r,s)}catch(e){if(a=C(e,t,r,i),o>=2)throw a}}}function C(e,n,r,a){if(t(e))throw f(`cancelled`,`abort-signal`,{},e);if(!i(e))throw e;if(r.signal?.aborted)throw f(`cancelled`,`abort-signal`);return w(n,a,e)}function w(e,t,n){let r=t.length;return f(`timeout`,`toolchain-probe-stalled`,{command:e,attemptTimeoutsMs:[...t],hint:`${e} did not answer within ${t[r-1]}ms on ${r} attempt(s). A toolchain probe that cannot answer is a host condition rather than a toolchain defect: run \`${e}\` by hand until it answers, then retry.`},n)}function T(e,t,n,r,i){return e.run(t,n,{allowFailure:!0,signal:r.signal,timeoutMs:i})}const E=`manifest.json`;async function D(e){let{host:t,deadline:n,cacheRoot:r,binaryFilename:i}=e,o=_(`sha256`).update(JSON.stringify(e.keyInputs)).digest(`hex`).slice(0,32),s=v.join(r,o);return await a({acquire:()=>t.acquireLock(v.join(r,`${o}.lock`),{deadline:n,description:e.lockDescription}),task:async()=>{let a=await O(t,s,i,o,n);if(a)return{path:a,cacheKey:o};h(n,`native-build-deadline`),t.exists(s)&&await t.remove(s),h(n,`native-build-deadline`),await t.ensureDirectory(r);let c=v.join(r,`.${o}.${t.processId()}.tmp`);h(n,`native-build-deadline`),await t.remove(c);try{h(n,`native-build-deadline`),await t.ensureDirectory(c);let r=v.join(c,i);await e.build(r),h(n,`native-build-deadline`),await t.chmod(r,493);let a=await A(t,r),l={...e.keyInputs,cacheKey:o,binarySha256:a};return await t.writeText(v.join(c,E),`${JSON.stringify(l,null,2)}\n`),h(n,`native-build-deadline`),await t.rename(c,s),{path:v.join(s,i),cacheKey:o}}catch(e){throw await t.remove(c),e}}})}async function O(e,t,n,r,i){let a=v.join(t,n),o=v.join(t,E);if(!(!e.exists(a)||!e.exists(o)))try{let t=JSON.parse(await e.readText(o));return t.cacheKey!==r||typeof t.binarySha256!=`string`?void 0:(h(i,`native-cache-hash-deadline`),await A(e,a)===t.binarySha256?a:void 0)}catch(e){if(k(e))throw e;return}}function k(e){return e instanceof p&&(e.buildFailureKind===`cancelled`||e.buildFailureKind===`timeout`)}async function A(e,t){return _(`sha256`).update(await e.readBinary(t)).digest(`hex`)}async function j(e,t,n,r){let i=_(`sha256`);for(let a of n){let n=v.join(t,a);if(h(r,`native-source-fingerprint-deadline`),!e.exists(n))throw f(`unsupported`,`native-source-missing`,{filePath:n});i.update(a),i.update(`\0`),i.update(await e.readBinary(n)),i.update(`\0`)}return i.digest(`hex`)}async function M(e){let t=Math.min(e.budgetMs,h(e.deadline,`native-build-deadline`));try{return await e.host.run(`xcrun`,[...e.argv],{signal:e.deadline.signal,timeoutMs:t,allowFailure:!0})}catch(n){throw i(n)?f(`timeout`,`native-build-stalled`,{timeoutMs:t,hint:`The Simulator SDK toolchain did not answer within ${t}ms, which stopped the ${e.label} build before clang reported anything. Run \`xcrun --sdk iphonesimulator clang --version\` by hand until it answers, then retry.`},n):n}}const N=`Fold.m`,P=3e4,F=u+P;async function I(e={}){let t=e.host??L(),n=m(F,e.signal);try{let r=e.sourceRoot??v.join(o(),`apple`,`fold-helper`),i=await j(t,r,[N],n),a=await y(t,n);return await D({host:t,deadline:n,lockDescription:`iOS Simulator fold helper cache`,cacheRoot:e.cacheRoot??v.join(s(),`.agent-device`,`fold-helper`),binaryFilename:`fold-helper`,keyInputs:{schemaVersion:1,sourceHash:i,toolchain:a,compileArgv:R({sourceRoot:``,outputPath:``})},build:e=>z(t,n,r,e)})}catch(e){throw B(e)}}function L(){return g(l)}function R(e){return[`--sdk`,`iphonesimulator`,`clang`,`-mios-simulator-version-min=15.0`,`-fobjc-arc`,`-Wall`,`-Wextra`,`-framework`,`Foundation`,`-framework`,`IOKit`,v.join(e.sourceRoot,N),`-o`,e.outputPath]}async function z(e,t,n,i){let a=await M({host:e,deadline:t,argv:R({sourceRoot:n,outputPath:i}),budgetMs:P,label:`fold helper`});if(a.exitCode!==0||!e.exists(i))throw V(r(a))}function B(e){return!(e instanceof p)||e.buildFailureKind===`cancelled`?e:V({...e.buildDetails,cause:e.buildFailureCode},e)}function V(e,t){return new n(`COMMAND_FAILED`,`Unable to build the simulator fold helper`,{hint:`Select an Xcode with the iOS simulator SDK and foldable HID support using DEVELOPER_DIR.`,...e,reason:`fold-helper-build-failed`},t)}var H=e({HINGE_ANGLE_NO_SAMPLE_REASON:()=>U,createFoldHelper:()=>W,parseHingeReading:()=>X});const U=`fold-hinge-angle-no-sample`;function W(e){let t,a=async(a,o,s)=>{let{signal:c,timeoutMs:l,failure:u}=o;c?.throwIfAborted();let{path:f}=await(t??=I({signal:c}));c?.throwIfAborted();let p;try{p=await d(e,[`spawn`,e.id,f,...a],{signal:c,timeoutMs:l,kill:{signal:`SIGTERM`,graceMs:1e3},allowFailure:!0})}catch(t){throw c?.aborted||!i(t)?t:new n(`COMMAND_FAILED`,u.message,{...t.details,deviceId:e.id,...u.details},t)}let m=p.exitCode===0?s(p.stdout):void 0;if(m!==void 0)return m;throw new n(`COMMAND_FAILED`,u.message,r(p,{deviceId:e.id,...u.details}))};return Object.freeze({async setPose(e,t){let n=typeof e==`string`?0:e.at(-1).atMs,r=typeof e==`string`?e:JSON.stringify(e);await a([`set`,r],{signal:t,timeoutMs:n+1e4,failure:G},()=>!0)},async rotate(e,t){await a([`rotate`,e],{signal:t,timeoutMs:5e3,failure:K},()=>!0)},async readHingeAngle({signal:e,windowMs:t=0}={}){return await a([`hinge`,String(t)],{signal:e,timeoutMs:c+t,failure:q},X)},async readPanelPayload({signal:e,timeoutMs:t}){return await a([`panels`],{signal:e,timeoutMs:t,failure:J},e=>{let t=Y(e)?.displays;return Array.isArray(t)?{result:{displays:t}}:void 0})}})}const G={message:`Unable to send the simulator hinge pose`,details:{reason:`fold-hid-dispatch-failed`}},K={message:`Unable to send the simulator orientation`,details:{reason:`orientation-hid-dispatch-failed`}},q={message:`The simulator reported no hinge angle sample`,details:{reason:U,hint:`The fold helper's hinge read returned no valid CoreMotion sample. The details name the cause: stderr such as a simulator runtime without CMAngleManager, or timeoutMs when the read did not finish.`}},J={message:`The simulator reported no panel table`,details:{reason:`fold-helper-panels-unreadable`}};function Y(e){let t=e.trim().split(`
2
+ `).at(-1);if(!t)return;let n;try{n=JSON.parse(t)}catch{return}if(typeof n!=`object`||!n)return;let r=n;return r.version===1?r:void 0}function X(e){let t=Y(e);if(!t||t.angleValid!==!0)return;let n=t.angleDegrees;if(!(typeof n!=`number`||!Number.isFinite(n)||n<0||n>180))return n}export{M as a,D as i,W as n,j as o,H as r,y as s,U as t};
@@ -0,0 +1 @@
1
+ function e(e){return Object.freeze({setFoldPose:e.fold})}export{e as t};