-
Notifications
You must be signed in to change notification settings - Fork 109
Expand file tree
/
Copy pathcommand-schema.ts
More file actions
1508 lines (1461 loc) · 44.3 KB
/
command-schema.ts
File metadata and controls
1508 lines (1461 loc) · 44.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { SETTINGS_USAGE_OVERRIDE } from '../core/settings-contract.ts';
import { SESSION_SURFACES } from '../core/session-surface.ts';
export type CliFlags = {
json: boolean;
config?: string;
remoteConfig?: string;
stateDir?: string;
daemonBaseUrl?: string;
daemonAuthToken?: string;
daemonTransport?: 'auto' | 'socket' | 'http';
daemonServerMode?: 'socket' | 'http' | 'dual';
tenant?: string;
sessionIsolation?: 'none' | 'tenant';
runId?: string;
leaseId?: string;
sessionLock?: 'reject' | 'strip';
sessionLocked?: boolean;
sessionLockConflicts?: 'reject' | 'strip';
platform?: 'ios' | 'macos' | 'android' | 'linux' | 'apple';
target?: 'mobile' | 'tv' | 'desktop';
device?: string;
udid?: string;
serial?: string;
iosSimulatorDeviceSet?: string;
androidDeviceAllowlist?: string;
out?: string;
session?: string;
runtime?: string;
metroHost?: string;
metroPort?: number;
metroProjectRoot?: string;
metroKind?: 'auto' | 'react-native' | 'expo';
metroPublicBaseUrl?: string;
metroProxyBaseUrl?: string;
metroBearerToken?: string;
metroPreparePort?: number;
metroListenHost?: string;
metroStatusHost?: string;
metroStartupTimeoutMs?: number;
metroProbeTimeoutMs?: number;
metroRuntimeFile?: string;
metroNoReuseExisting?: boolean;
metroNoInstallDeps?: boolean;
bundleUrl?: string;
launchUrl?: string;
boot?: boolean;
reuseExisting?: boolean;
verbose?: boolean;
snapshotInteractiveOnly?: boolean;
snapshotDiff?: boolean;
snapshotCompact?: boolean;
snapshotDepth?: number;
snapshotScope?: string;
snapshotRaw?: boolean;
networkInclude?: 'summary' | 'headers' | 'body' | 'all';
overlayRefs?: boolean;
screenshotFullscreen?: boolean;
baseline?: string;
threshold?: string;
appsFilter?: 'user-installed' | 'all';
count?: number;
fps?: number;
hideTouches?: boolean;
intervalMs?: number;
delayMs?: number;
holdMs?: number;
jitterPx?: number;
pixels?: number;
doubleTap?: boolean;
clickButton?: 'primary' | 'secondary' | 'middle';
backMode?: 'in-app' | 'system';
pauseMs?: number;
pattern?: 'one-way' | 'ping-pong';
activity?: string;
header?: string[];
saveScript?: boolean | string;
shutdown?: boolean;
relaunch?: boolean;
surface?: 'app' | 'frontmost-app' | 'desktop' | 'menubar';
headless?: boolean;
restart?: boolean;
noRecord?: boolean;
retainPaths?: boolean;
retentionMs?: number;
replayUpdate?: boolean;
failFast?: boolean;
timeoutMs?: number;
retries?: number;
artifactsDir?: string;
reportJunit?: string;
steps?: string;
stepsFile?: string;
findFirst?: boolean;
findLast?: boolean;
batchOnError?: 'stop';
batchMaxSteps?: number;
batchSteps?: Array<{
command: string;
positionals?: string[];
flags?: Record<string, unknown>;
}>;
help: boolean;
version: boolean;
};
export type FlagKey = keyof CliFlags;
type FlagType = 'boolean' | 'int' | 'enum' | 'string' | 'booleanOrString';
export type FlagDefinition = {
key: FlagKey;
names: readonly string[];
type: FlagType;
multiple?: boolean;
enumValues?: readonly string[];
min?: number;
max?: number;
setValue?: CliFlags[FlagKey];
usageLabel?: string;
usageDescription?: string;
};
type CommandSchema = {
helpDescription: string;
summary?: string;
positionalArgs: readonly string[];
allowsExtraPositionals?: boolean;
allowedFlags: readonly FlagKey[];
defaults?: Partial<CliFlags>;
skipCapabilityCheck?: boolean;
usageOverride?: string;
listUsageOverride?: string;
};
const SNAPSHOT_FLAGS = [
'snapshotInteractiveOnly',
'snapshotCompact',
'snapshotDepth',
'snapshotScope',
'snapshotRaw',
] as const satisfies readonly FlagKey[];
const SELECTOR_SNAPSHOT_FLAGS = [
'snapshotDepth',
'snapshotScope',
'snapshotRaw',
] as const satisfies readonly FlagKey[];
const FIND_SNAPSHOT_FLAGS = ['snapshotDepth', 'snapshotRaw'] as const satisfies readonly FlagKey[];
const AGENT_SKILLS = [
{ label: 'agent-device', description: 'Canonical mobile automation flows' },
{ label: 'dogfood', description: 'Exploratory QA and bug hunts' },
] as const;
const CONFIGURATION_LINES = [
'Default config files: ~/.agent-device/config.json, ./agent-device.json',
'Use --config <path> or AGENT_DEVICE_CONFIG to load one explicit config file.',
] as const;
const ENVIRONMENT_LINES = [
{ label: 'AGENT_DEVICE_SESSION', description: 'Default session name' },
{ label: 'AGENT_DEVICE_PLATFORM', description: 'Default platform binding' },
{ label: 'AGENT_DEVICE_SESSION_LOCK', description: 'Bound-session conflict mode' },
{ label: 'AGENT_DEVICE_DAEMON_BASE_URL', description: 'Connect to remote daemon' },
] as const;
const EXAMPLE_LINES = [
'agent-device open Settings --platform ios',
'agent-device open TextEdit --platform macos',
'agent-device snapshot -i',
'agent-device fill @e3 "test@example.com"',
'agent-device replay ./session.ad',
'agent-device test ./suite --platform android',
] as const;
const FLAG_DEFINITIONS: readonly FlagDefinition[] = [
{
key: 'config',
names: ['--config'],
type: 'string',
usageLabel: '--config <path>',
usageDescription: 'Load CLI defaults from a specific config file',
},
{
key: 'remoteConfig',
names: ['--remote-config'],
type: 'string',
usageLabel: '--remote-config <path>',
usageDescription: 'Load remote host + Metro workflow settings from a specific profile file',
},
{
key: 'stateDir',
names: ['--state-dir'],
type: 'string',
usageLabel: '--state-dir <path>',
usageDescription: 'Daemon state directory (defaults to ~/.agent-device)',
},
{
key: 'daemonBaseUrl',
names: ['--daemon-base-url'],
type: 'string',
usageLabel: '--daemon-base-url <url>',
usageDescription: 'Explicit remote HTTP daemon base URL (skip local daemon discovery/startup)',
},
{
key: 'daemonAuthToken',
names: ['--daemon-auth-token'],
type: 'string',
usageLabel: '--daemon-auth-token <token>',
usageDescription: 'Remote HTTP daemon auth token (sent as request token and bearer header)',
},
{
key: 'daemonTransport',
names: ['--daemon-transport'],
type: 'enum',
enumValues: ['auto', 'socket', 'http'],
usageLabel: '--daemon-transport auto|socket|http',
usageDescription: 'Daemon client transport preference',
},
{
key: 'daemonServerMode',
names: ['--daemon-server-mode'],
type: 'enum',
enumValues: ['socket', 'http', 'dual'],
usageLabel: '--daemon-server-mode socket|http|dual',
usageDescription: 'Daemon server mode used when spawning daemon',
},
{
key: 'tenant',
names: ['--tenant'],
type: 'string',
usageLabel: '--tenant <id>',
usageDescription: 'Tenant scope identifier for isolated daemon sessions',
},
{
key: 'sessionIsolation',
names: ['--session-isolation'],
type: 'enum',
enumValues: ['none', 'tenant'],
usageLabel: '--session-isolation none|tenant',
usageDescription: 'Session isolation strategy (tenant prefixes session namespace)',
},
{
key: 'runId',
names: ['--run-id'],
type: 'string',
usageLabel: '--run-id <id>',
usageDescription: 'Run identifier used for tenant lease admission checks',
},
{
key: 'leaseId',
names: ['--lease-id'],
type: 'string',
usageLabel: '--lease-id <id>',
usageDescription: 'Lease identifier bound to tenant/run admission scope',
},
{
key: 'sessionLock',
names: ['--session-lock'],
type: 'enum',
enumValues: ['reject', 'strip'],
usageLabel: '--session-lock reject|strip',
usageDescription:
'Lock bound-session device routing for this CLI invocation and nested batch steps',
},
{
key: 'sessionLocked',
names: ['--session-locked'],
type: 'boolean',
usageLabel: '--session-locked',
usageDescription: 'Deprecated alias for --session-lock reject',
},
{
key: 'sessionLockConflicts',
names: ['--session-lock-conflicts'],
type: 'enum',
enumValues: ['reject', 'strip'],
usageLabel: '--session-lock-conflicts reject|strip',
usageDescription: 'Deprecated alias for --session-lock',
},
{
key: 'platform',
names: ['--platform'],
type: 'enum',
enumValues: ['ios', 'macos', 'android', 'linux', 'apple'],
usageLabel: '--platform ios|macos|android|linux|apple',
usageDescription: 'Platform to target (`apple` aliases the Apple automation backend)',
},
{
key: 'target',
names: ['--target'],
type: 'enum',
enumValues: ['mobile', 'tv', 'desktop'],
usageLabel: '--target mobile|tv|desktop',
usageDescription: 'Device target class to match',
},
{
key: 'device',
names: ['--device'],
type: 'string',
usageLabel: '--device <name>',
usageDescription: 'Device name to target',
},
{
key: 'udid',
names: ['--udid'],
type: 'string',
usageLabel: '--udid <udid>',
usageDescription: 'iOS device UDID',
},
{
key: 'serial',
names: ['--serial'],
type: 'string',
usageLabel: '--serial <serial>',
usageDescription: 'Android device serial',
},
{
key: 'surface',
names: ['--surface'],
type: 'enum',
enumValues: SESSION_SURFACES,
usageLabel: '--surface app|frontmost-app|desktop|menubar',
usageDescription: 'macOS session surface for open (defaults to app)',
},
{
key: 'headless',
names: ['--headless'],
type: 'boolean',
usageLabel: '--headless',
usageDescription: 'Boot: launch Android emulator without a GUI window',
},
{
key: 'runtime',
names: ['--runtime'],
type: 'string',
usageLabel: '--runtime <id>',
usageDescription:
'ensure-simulator: CoreSimulator runtime identifier (e.g. com.apple.CoreSimulator.SimRuntime.iOS-18-0)',
},
{
key: 'metroHost',
names: ['--metro-host'],
type: 'string',
usageLabel: '--metro-host <host>',
usageDescription: 'Session-scoped Metro/debug host hint',
},
{
key: 'metroPort',
names: ['--metro-port'],
type: 'int',
min: 1,
max: 65535,
usageLabel: '--metro-port <port>',
usageDescription: 'Session-scoped Metro/debug port hint',
},
{
key: 'metroProjectRoot',
names: ['--project-root'],
type: 'string',
usageLabel: '--project-root <path>',
usageDescription: 'metro prepare: React Native project root (default: cwd)',
},
{
key: 'metroKind',
names: ['--kind'],
type: 'enum',
enumValues: ['auto', 'react-native', 'expo'],
usageLabel: '--kind auto|react-native|expo',
usageDescription: 'metro prepare: detect or force the Metro launcher kind',
},
{
key: 'metroPublicBaseUrl',
names: ['--public-base-url'],
type: 'string',
usageLabel: '--public-base-url <url>',
usageDescription: 'metro prepare: public base URL used to build bundle hints',
},
{
key: 'metroProxyBaseUrl',
names: ['--proxy-base-url'],
type: 'string',
usageLabel: '--proxy-base-url <url>',
usageDescription: 'metro prepare: optional remote host bridge base URL for Metro access',
},
{
key: 'metroBearerToken',
names: ['--bearer-token'],
type: 'string',
usageLabel: '--bearer-token <token>',
usageDescription:
'metro prepare: host bridge bearer token (prefer AGENT_DEVICE_PROXY_TOKEN or AGENT_DEVICE_METRO_BEARER_TOKEN)',
},
{
key: 'metroPreparePort',
names: ['--port'],
type: 'int',
min: 1,
max: 65535,
usageLabel: '--port <port>',
usageDescription: 'metro prepare: local Metro port (default: 8081)',
},
{
key: 'metroListenHost',
names: ['--listen-host'],
type: 'string',
usageLabel: '--listen-host <host>',
usageDescription: 'metro prepare: host Metro listens on (default: 0.0.0.0)',
},
{
key: 'metroStatusHost',
names: ['--status-host'],
type: 'string',
usageLabel: '--status-host <host>',
usageDescription: 'metro prepare: host used for local /status polling (default: 127.0.0.1)',
},
{
key: 'metroStartupTimeoutMs',
names: ['--startup-timeout-ms'],
type: 'int',
min: 1,
usageLabel: '--startup-timeout-ms <ms>',
usageDescription: 'metro prepare: timeout while waiting for Metro to become ready',
},
{
key: 'metroProbeTimeoutMs',
names: ['--probe-timeout-ms'],
type: 'int',
min: 1,
usageLabel: '--probe-timeout-ms <ms>',
usageDescription: 'metro prepare: timeout for /status and proxy bridge calls',
},
{
key: 'metroRuntimeFile',
names: ['--runtime-file'],
type: 'string',
usageLabel: '--runtime-file <path>',
usageDescription: 'metro prepare: optional file path to persist the JSON result',
},
{
key: 'metroNoReuseExisting',
names: ['--no-reuse-existing'],
type: 'boolean',
usageLabel: '--no-reuse-existing',
usageDescription: 'metro prepare: always start a fresh Metro process',
},
{
key: 'metroNoInstallDeps',
names: ['--no-install-deps'],
type: 'boolean',
usageLabel: '--no-install-deps',
usageDescription: 'metro prepare: skip package-manager install when node_modules is missing',
},
{
key: 'bundleUrl',
names: ['--bundle-url'],
type: 'string',
usageLabel: '--bundle-url <url>',
usageDescription: 'Session-scoped bundle URL hint',
},
{
key: 'launchUrl',
names: ['--launch-url'],
type: 'string',
usageLabel: '--launch-url <url>',
usageDescription: 'Session-scoped deep link / launch URL hint',
},
{
key: 'boot',
names: ['--boot'],
type: 'boolean',
usageLabel: '--boot',
usageDescription: 'ensure-simulator: boot the simulator after ensuring it exists',
},
{
key: 'reuseExisting',
names: ['--reuse-existing'],
type: 'boolean',
usageLabel: '--reuse-existing',
usageDescription: 'ensure-simulator: reuse an existing simulator (default: true)',
},
{
key: 'iosSimulatorDeviceSet',
names: ['--ios-simulator-device-set'],
type: 'string',
usageLabel: '--ios-simulator-device-set <path>',
usageDescription: 'Scope iOS simulator discovery/commands to this simulator device set',
},
{
key: 'androidDeviceAllowlist',
names: ['--android-device-allowlist'],
type: 'string',
usageLabel: '--android-device-allowlist <serials>',
usageDescription: 'Comma/space separated Android serial allowlist for discovery/selection',
},
{
key: 'activity',
names: ['--activity'],
type: 'string',
usageLabel: '--activity <component>',
usageDescription: 'Android app launch activity (package/Activity); not for URL opens',
},
{
key: 'header',
names: ['--header'],
type: 'string',
multiple: true,
usageLabel: '--header <name:value>',
usageDescription: 'install-from-source: repeatable HTTP header for URL downloads',
},
{
key: 'session',
names: ['--session'],
type: 'string',
usageLabel: '--session <name>',
usageDescription: 'Named session',
},
{
key: 'count',
names: ['--count'],
type: 'int',
min: 1,
max: 200,
usageLabel: '--count <n>',
usageDescription: 'Repeat count for press/swipe series',
},
{
key: 'fps',
names: ['--fps'],
type: 'int',
min: 1,
max: 120,
usageLabel: '--fps <n>',
usageDescription: 'Record: target frames per second (iOS physical device runner)',
},
{
key: 'hideTouches',
names: ['--hide-touches'],
type: 'boolean',
usageLabel: '--hide-touches',
usageDescription: 'Record: disable touch overlays in the final video',
},
{
key: 'intervalMs',
names: ['--interval-ms'],
type: 'int',
min: 0,
max: 10_000,
usageLabel: '--interval-ms <ms>',
usageDescription: 'Delay between press iterations',
},
{
key: 'delayMs',
names: ['--delay-ms'],
type: 'int',
min: 0,
max: 10_000,
usageLabel: '--delay-ms <ms>',
usageDescription: 'Delay between typed characters',
},
{
key: 'holdMs',
names: ['--hold-ms'],
type: 'int',
min: 0,
max: 10_000,
usageLabel: '--hold-ms <ms>',
usageDescription: 'Press hold duration for each iteration',
},
{
key: 'jitterPx',
names: ['--jitter-px'],
type: 'int',
min: 0,
max: 100,
usageLabel: '--jitter-px <n>',
usageDescription: 'Deterministic coordinate jitter radius for press',
},
{
key: 'pixels',
names: ['--pixels'],
type: 'int',
min: 1,
max: 100_000,
usageLabel: '--pixels <n>',
usageDescription: 'Scroll: explicit gesture distance in pixels',
},
{
key: 'doubleTap',
names: ['--double-tap'],
type: 'boolean',
usageLabel: '--double-tap',
usageDescription: 'Use double-tap gesture per press iteration',
},
{
key: 'clickButton',
names: ['--button'],
type: 'enum',
enumValues: ['primary', 'secondary', 'middle'],
usageLabel: '--button primary|secondary|middle',
usageDescription: 'Click: choose mouse button (middle reserved for future macOS support)',
},
// These aliases encode the value directly in the flag name so `back` reads naturally as
// `back --in-app` or `back --system` without introducing a separate `--back-mode` flag.
{
key: 'backMode',
names: ['--in-app'],
type: 'enum',
enumValues: ['in-app', 'system'],
setValue: 'in-app',
usageLabel: '--in-app',
usageDescription: 'Back: use app-provided back UI when available',
},
{
key: 'backMode',
names: ['--system'],
type: 'enum',
enumValues: ['in-app', 'system'],
setValue: 'system',
usageLabel: '--system',
usageDescription: 'Back: use system back input or gesture when available',
},
{
key: 'pauseMs',
names: ['--pause-ms'],
type: 'int',
min: 0,
max: 10_000,
usageLabel: '--pause-ms <ms>',
usageDescription: 'Delay between swipe iterations',
},
{
key: 'pattern',
names: ['--pattern'],
type: 'enum',
enumValues: ['one-way', 'ping-pong'],
usageLabel: '--pattern one-way|ping-pong',
usageDescription: 'Swipe repeat pattern',
},
{
key: 'verbose',
names: ['--debug', '--verbose', '-v'],
type: 'boolean',
usageLabel: '--debug, --verbose, -v',
usageDescription: 'Enable debug diagnostics and stream daemon/runner logs',
},
{
key: 'json',
names: ['--json'],
type: 'boolean',
usageLabel: '--json',
usageDescription: 'JSON output',
},
{
key: 'help',
names: ['--help', '-h'],
type: 'boolean',
usageLabel: '--help, -h',
usageDescription: 'Print help and exit',
},
{
key: 'version',
names: ['--version', '-V'],
type: 'boolean',
usageLabel: '--version, -V',
usageDescription: 'Print version and exit',
},
{
key: 'snapshotDiff',
names: ['--diff'],
type: 'boolean',
usageLabel: '--diff',
usageDescription: 'Snapshot: show structural diff against the previous session baseline',
},
{
key: 'saveScript',
names: ['--save-script'],
type: 'booleanOrString',
usageLabel: '--save-script [path]',
usageDescription: 'Save session script (.ad) on close; optional custom output path',
},
{
key: 'networkInclude',
names: ['--include'],
type: 'enum',
enumValues: ['summary', 'headers', 'body', 'all'],
usageLabel: '--include summary|headers|body|all',
usageDescription: 'Network: include headers, bodies, or both in output',
},
{
key: 'shutdown',
names: ['--shutdown'],
type: 'boolean',
usageLabel: '--shutdown',
usageDescription: 'close: shutdown associated iOS simulator after ending session',
},
{
key: 'relaunch',
names: ['--relaunch'],
type: 'boolean',
usageLabel: '--relaunch',
usageDescription: 'open: terminate app process before launching it',
},
{
key: 'restart',
names: ['--restart'],
type: 'boolean',
usageLabel: '--restart',
usageDescription: 'logs clear: stop active stream, clear logs, then start streaming again',
},
{
key: 'retainPaths',
names: ['--retain-paths'],
type: 'boolean',
usageLabel: '--retain-paths',
usageDescription: 'install-from-source: keep materialized artifact paths after install',
},
{
key: 'retentionMs',
names: ['--retention-ms'],
type: 'int',
min: 1,
usageLabel: '--retention-ms <ms>',
usageDescription: 'install-from-source: retention TTL for materialized artifact paths',
},
{
key: 'noRecord',
names: ['--no-record'],
type: 'boolean',
usageLabel: '--no-record',
usageDescription: 'Do not record this action',
},
{
key: 'replayUpdate',
names: ['--update', '-u'],
type: 'boolean',
usageLabel: '--update, -u',
usageDescription: 'Replay: update selectors and rewrite replay file in place',
},
{
key: 'failFast',
names: ['--fail-fast'],
type: 'boolean',
usageLabel: '--fail-fast',
usageDescription: 'Test: stop the suite after the first failing script',
},
{
key: 'timeoutMs',
names: ['--timeout'],
type: 'int',
min: 1,
usageLabel: '--timeout <ms>',
usageDescription: 'Test: maximum wall-clock time per script attempt',
},
{
key: 'retries',
names: ['--retries'],
type: 'int',
min: 0,
max: 3,
usageLabel: '--retries <n>',
usageDescription: 'Test: retry each failed script up to n additional times',
},
{
key: 'artifactsDir',
names: ['--artifacts-dir'],
type: 'string',
usageLabel: '--artifacts-dir <path>',
usageDescription: 'Test: root directory for suite artifacts',
},
{
key: 'reportJunit',
names: ['--report-junit'],
type: 'string',
usageLabel: '--report-junit <path>',
usageDescription: 'Test: write a JUnit XML report for the replay suite',
},
{
key: 'steps',
names: ['--steps'],
type: 'string',
usageLabel: '--steps <json>',
usageDescription: 'Batch: JSON array of steps',
},
{
key: 'stepsFile',
names: ['--steps-file'],
type: 'string',
usageLabel: '--steps-file <path>',
usageDescription: 'Batch: read steps JSON from file',
},
{
key: 'batchOnError',
names: ['--on-error'],
type: 'enum',
enumValues: ['stop'],
usageLabel: '--on-error stop',
usageDescription: 'Batch: stop when a step fails',
},
{
key: 'batchMaxSteps',
names: ['--max-steps'],
type: 'int',
min: 1,
max: 1000,
usageLabel: '--max-steps <n>',
usageDescription: 'Batch: maximum number of allowed steps',
},
{
key: 'appsFilter',
names: ['--user-installed'],
type: 'enum',
setValue: 'user-installed',
usageLabel: '--user-installed',
usageDescription: 'Apps: list user-installed apps',
},
{
key: 'appsFilter',
names: ['--all'],
type: 'enum',
setValue: 'all',
usageLabel: '--all',
usageDescription: 'Apps: list all apps (include system/default apps)',
},
{
key: 'snapshotInteractiveOnly',
names: ['-i'],
type: 'boolean',
usageLabel: '-i',
usageDescription: 'Snapshot: interactive elements only',
},
{
key: 'snapshotCompact',
names: ['-c'],
type: 'boolean',
usageLabel: '-c',
usageDescription: 'Snapshot: compact output (drop empty structure)',
},
{
key: 'snapshotDepth',
names: ['--depth', '-d'],
type: 'int',
min: 0,
usageLabel: '--depth, -d <depth>',
usageDescription: 'Snapshot: limit snapshot depth',
},
{
key: 'snapshotScope',
names: ['--scope', '-s'],
type: 'string',
usageLabel: '--scope, -s <scope>',
usageDescription: 'Snapshot: scope snapshot to label/identifier',
},
{
key: 'snapshotRaw',
names: ['--raw'],
type: 'boolean',
usageLabel: '--raw',
usageDescription: 'Snapshot: raw node output',
},
{
key: 'findFirst',
names: ['--first'],
type: 'boolean',
usageLabel: '--first',
usageDescription: 'Find: pick the first match when ambiguous',
},
{
key: 'findLast',
names: ['--last'],
type: 'boolean',
usageLabel: '--last',
usageDescription: 'Find: pick the last match when ambiguous',
},
{
key: 'out',
names: ['--out'],
type: 'string',
usageLabel: '--out <path>',
usageDescription: 'Output path',
},
{
key: 'overlayRefs',
names: ['--overlay-refs'],
type: 'boolean',
usageLabel: '--overlay-refs',
usageDescription:
'Screenshot: draw current snapshot refs and target rectangles onto the saved PNG; diff screenshot: also write a separate current-screen overlay guide',
},
{
key: 'screenshotFullscreen',
names: ['--fullscreen'],
type: 'boolean',
usageLabel: '--fullscreen',
usageDescription: 'Screenshot: capture the full screen instead of the app window',
},
{
key: 'baseline',
names: ['--baseline', '-b'],
type: 'string',
usageLabel: '--baseline, -b <path>',
usageDescription: 'Diff screenshot: path to baseline image file',
},
{
key: 'threshold',
names: ['--threshold'],
type: 'string',
usageLabel: '--threshold <0-1>',
usageDescription: 'Diff screenshot: color distance threshold (default 0.1)',
},
];
export const GLOBAL_FLAG_KEYS = new Set<FlagKey>([
'json',
'config',
'remoteConfig',
'stateDir',
'daemonBaseUrl',
'daemonAuthToken',
'daemonTransport',
'daemonServerMode',
'tenant',
'sessionIsolation',
'runId',
'leaseId',
'sessionLock',
'sessionLocked',
'sessionLockConflicts',
'help',
'version',
'verbose',
'platform',
'target',
'device',
'udid',
'serial',
'iosSimulatorDeviceSet',
'androidDeviceAllowlist',
'session',
'noRecord',
]);
const COMMAND_SCHEMAS: Record<string, CommandSchema> = {
boot: {
helpDescription: 'Ensure target device/simulator is booted and ready',
summary: 'Boot target device/simulator',
positionalArgs: [],
allowedFlags: ['headless'],
},
open: {
helpDescription:
'Boot device/simulator; optionally launch app or deep link URL (macOS also supports --surface app|frontmost-app|desktop|menubar)',
summary: 'Open an app, deep link or URL, save replays',
positionalArgs: ['appOrUrl?', 'url?'],
allowedFlags: ['activity', 'saveScript', 'relaunch', 'surface'],
},
close: {
helpDescription: 'Close app or just end session',
summary: 'Close app or end session',
positionalArgs: ['app?'],
allowedFlags: ['saveScript', 'shutdown'],
},
reinstall: {
helpDescription: 'Uninstall + install app from binary path',
summary: 'Reinstall app from binary path',
positionalArgs: ['app', 'path'],
allowedFlags: [],
},
install: {
helpDescription: 'Install app from binary path without uninstalling first',
summary: 'Install app from binary path',
positionalArgs: ['app', 'path'],
allowedFlags: [],
},
'install-from-source': {
helpDescription: 'Install app from a URL source through the normal daemon artifact flow',
summary: 'Install app from a URL source',
positionalArgs: ['url'],
allowedFlags: ['header', 'retainPaths', 'retentionMs'],
},
push: {
helpDescription: 'Simulate push notification payload delivery',
summary: 'Deliver push payload',
positionalArgs: ['bundleOrPackage', 'payloadOrJson'],
allowedFlags: [],
},
snapshot: {
usageOverride: 'snapshot [--diff] [-i] [-c] [-d <depth>] [-s <scope>] [--raw]',
helpDescription: 'Capture accessibility tree or diff against the previous session baseline',
positionalArgs: [],
allowedFlags: ['snapshotDiff', ...SNAPSHOT_FLAGS],
},
diff: {
usageOverride:
'diff snapshot | diff screenshot --baseline <path> [current.png] [--out <diff.png>] [--threshold <0-1>] [--overlay-refs]',
helpDescription: 'Diff accessibility snapshot or compare screenshots pixel-by-pixel',
summary: 'Diff snapshot or screenshot',
positionalArgs: ['kind', 'current?'],
allowedFlags: [...SNAPSHOT_FLAGS, 'baseline', 'threshold', 'out', 'overlayRefs'],