agent-device 0.12.4 → 0.12.5

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.
@@ -1,3 +1,28 @@
1
+ export declare type AgentDevice = AgentDeviceRuntime & BoundAgentDeviceCommands;
2
+
3
+ export declare type AgentDeviceBackend = {
4
+ platform: AgentDeviceBackendPlatform;
5
+ capabilities?: BackendCapabilitySet;
6
+ escapeHatches?: BackendEscapeHatches;
7
+ captureSnapshot?(context: BackendCommandContext, options?: BackendSnapshotOptions): Promise<BackendSnapshotResult>;
8
+ captureScreenshot?(context: BackendCommandContext, outPath: string, options?: BackendScreenshotOptions): Promise<BackendScreenshotResult | void>;
9
+ readText?(context: BackendCommandContext, node: SnapshotNode): Promise<BackendReadTextResult>;
10
+ findText?(context: BackendCommandContext, text: string): Promise<BackendFindTextResult>;
11
+ tap?(context: BackendCommandContext, point: Point, options?: BackendTapOptions): Promise<BackendActionResult>;
12
+ fill?(context: BackendCommandContext, point: Point, text: string, options?: BackendFillOptions): Promise<BackendActionResult>;
13
+ typeText?(context: BackendCommandContext, text: string, options?: {
14
+ delayMs?: number;
15
+ }): Promise<BackendActionResult>;
16
+ pressKey?(context: BackendCommandContext, key: string, options?: {
17
+ modifiers?: string[];
18
+ }): Promise<BackendActionResult>;
19
+ openApp?(context: BackendCommandContext, target: BackendOpenTarget): Promise<BackendActionResult>;
20
+ closeApp?(context: BackendCommandContext, app?: string): Promise<BackendActionResult>;
21
+ installApp?(context: BackendCommandContext, target: BackendInstallTarget): Promise<BackendActionResult>;
22
+ };
23
+
24
+ export declare type AgentDeviceBackendPlatform = 'ios' | 'android' | 'macos' | 'linux';
25
+
1
26
  export declare type AgentDeviceClient = {
2
27
  command: AgentDeviceCommandClient;
3
28
  devices: {
@@ -108,6 +133,38 @@ export declare type AgentDeviceCommandClient = {
108
133
  clipboard: (options: ClipboardCommandOptions) => Promise<ClipboardCommandResult>;
109
134
  };
110
135
 
136
+ declare type AgentDeviceCommands = {
137
+ capture: {
138
+ screenshot: RuntimeCommand<ScreenshotCommandOptions, ScreenshotCommandResult>;
139
+ diffScreenshot: RuntimeCommand<DiffScreenshotCommandOptions, DiffScreenshotCommandResult>;
140
+ snapshot: RuntimeCommand<SnapshotCommandOptions, SnapshotCommandResult>;
141
+ diffSnapshot: RuntimeCommand<DiffSnapshotCommandOptions, DiffSnapshotCommandResult>;
142
+ };
143
+ selectors: {
144
+ find: RuntimeCommand<FindReadCommandOptions, FindReadCommandResult>;
145
+ get: RuntimeCommand<GetCommandOptions, GetCommandResult>;
146
+ getText: RuntimeCommand<GetTextCommandOptions, Extract<GetCommandResult, {
147
+ kind: 'text';
148
+ }>>;
149
+ getAttrs: RuntimeCommand<GetAttrsCommandOptions, Extract<GetCommandResult, {
150
+ kind: 'attrs';
151
+ }>>;
152
+ is: RuntimeCommand<IsCommandOptions, IsCommandResult>;
153
+ isVisible: RuntimeCommand<IsSelectorCommandOptions, IsCommandResult>;
154
+ isHidden: RuntimeCommand<IsSelectorCommandOptions, IsCommandResult>;
155
+ wait: RuntimeCommand<WaitCommandOptions_2, WaitCommandResult_2>;
156
+ waitForText: RuntimeCommand<WaitForTextCommandOptions, Extract<WaitCommandResult_2, {
157
+ kind: 'text';
158
+ }>>;
159
+ };
160
+ interactions: {
161
+ click: RuntimeCommand<ClickCommandOptions, PressCommandResult>;
162
+ press: RuntimeCommand<PressCommandOptions, PressCommandResult>;
163
+ fill: RuntimeCommand<FillCommandOptions, FillCommandResult>;
164
+ typeText: RuntimeCommand<TypeTextCommandOptions, TypeTextCommandResult>;
165
+ };
166
+ };
167
+
111
168
  export declare type AgentDeviceDaemonTransport = (req: Omit<DaemonRequest, 'token'>) => Promise<DaemonResponse>;
112
169
 
113
170
  export declare type AgentDeviceDevice = {
@@ -139,6 +196,26 @@ export declare type AgentDeviceIdentifiers = {
139
196
 
140
197
  export declare type AgentDeviceRequestOverrides = Pick<AgentDeviceClientConfig, 'session' | 'lockPolicy' | 'lockPlatform' | 'requestId' | 'daemonBaseUrl' | 'daemonAuthToken' | 'daemonTransport' | 'daemonServerMode' | 'tenant' | 'sessionIsolation' | 'runId' | 'leaseId' | 'leaseBackend' | 'cwd' | 'debug'>;
141
198
 
199
+ export declare type AgentDeviceRuntime = {
200
+ backend: AgentDeviceBackend;
201
+ artifacts: ArtifactAdapter;
202
+ sessions: CommandSessionStore;
203
+ policy: CommandPolicy;
204
+ diagnostics?: DiagnosticsSink;
205
+ clock?: CommandClock;
206
+ signal?: AbortSignal;
207
+ };
208
+
209
+ export declare type AgentDeviceRuntimeConfig = {
210
+ backend: AgentDeviceBackend;
211
+ artifacts: ArtifactAdapter;
212
+ sessions?: CommandSessionStore;
213
+ policy?: CommandPolicy;
214
+ diagnostics?: DiagnosticsSink;
215
+ clock?: CommandClock;
216
+ signal?: AbortSignal;
217
+ };
218
+
142
219
  export declare type AgentDeviceSelectionOptions = {
143
220
  platform?: PlatformSelector;
144
221
  target?: DeviceTarget;
@@ -212,7 +289,7 @@ export declare class AppError extends Error {
212
289
  constructor(code: AppErrorCode, message: string, details?: AppErrorDetails, cause?: unknown);
213
290
  }
214
291
 
215
- declare type AppErrorCode = 'INVALID_ARGS' | 'DEVICE_NOT_FOUND' | 'TOOL_MISSING' | 'APP_NOT_INSTALLED' | 'UNSUPPORTED_PLATFORM' | 'UNSUPPORTED_OPERATION' | 'COMMAND_FAILED' | 'SESSION_NOT_FOUND' | 'UNAUTHORIZED' | 'UNKNOWN';
292
+ export declare type AppErrorCode = 'INVALID_ARGS' | 'DEVICE_NOT_FOUND' | 'TOOL_MISSING' | 'APP_NOT_INSTALLED' | 'UNSUPPORTED_PLATFORM' | 'UNSUPPORTED_OPERATION' | 'NOT_IMPLEMENTED' | 'COMMAND_FAILED' | 'SESSION_NOT_FOUND' | 'UNAUTHORIZED' | 'UNKNOWN';
216
293
 
217
294
  declare type AppErrorDetails = Record<string, unknown> & {
218
295
  hint?: string;
@@ -293,6 +370,30 @@ export declare type AppTriggerEventOptions = ClientCommandBaseOptions & {
293
370
  payload?: Record<string, unknown>;
294
371
  };
295
372
 
373
+ export declare type ArtifactAdapter = {
374
+ resolveInput(ref: FileInputRef, options: ResolveInputOptions): Promise<ResolvedInputFile>;
375
+ reserveOutput(ref: FileOutputRef | undefined, options: ReserveOutputOptions): Promise<ReservedOutputFile>;
376
+ createTempFile(options: CreateTempFileOptions): Promise<TemporaryFile>;
377
+ };
378
+
379
+ export declare type ArtifactDescriptor = {
380
+ kind: 'localPath';
381
+ field: string;
382
+ path: string;
383
+ fileName?: string;
384
+ metadata?: Record<string, unknown>;
385
+ } | {
386
+ kind: 'artifact';
387
+ field: string;
388
+ artifactId: string;
389
+ fileName?: string;
390
+ url?: string;
391
+ clientPath?: string;
392
+ metadata?: Record<string, unknown>;
393
+ };
394
+
395
+ export declare function assertBackendCapabilityAllowed(runtime: Pick<AgentDeviceRuntime, 'backend' | 'policy'>, capability: BackendCapabilityName): void;
396
+
296
397
  export declare type BackCommandOptions = DeviceCommandBaseOptions & {
297
398
  mode?: 'in-app' | 'system';
298
399
  };
@@ -301,6 +402,112 @@ export declare type BackCommandResult = CommandActionResult<'back'> & {
301
402
  mode?: 'in-app' | 'system';
302
403
  };
303
404
 
405
+ declare const BACKEND_CAPABILITY_NAMES: readonly ["android.shell", "ios.runnerCommand", "macos.desktopScreenshot"];
406
+
407
+ export declare type BackendActionResult = Record<string, unknown> | void;
408
+
409
+ export declare type BackendCapabilityName = (typeof BACKEND_CAPABILITY_NAMES)[number];
410
+
411
+ export declare type BackendCapabilitySet = readonly BackendCapabilityName[];
412
+
413
+ export declare type BackendCommandContext = {
414
+ session?: string;
415
+ requestId?: string;
416
+ appId?: string;
417
+ appBundleId?: string;
418
+ signal?: AbortSignal;
419
+ metadata?: Record<string, unknown>;
420
+ };
421
+
422
+ export declare type BackendEscapeHatches = {
423
+ androidShell?(context: BackendCommandContext, args: readonly string[]): Promise<BackendShellResult>;
424
+ iosRunnerCommand?(context: BackendCommandContext, command: BackendRunnerCommand): Promise<BackendActionResult>;
425
+ macosDesktopScreenshot?(context: BackendCommandContext, outPath: string, options?: BackendScreenshotOptions): Promise<BackendScreenshotResult | void>;
426
+ };
427
+
428
+ export declare type BackendFillOptions = {
429
+ delayMs?: number;
430
+ };
431
+
432
+ export declare type BackendFindTextResult = {
433
+ found: boolean;
434
+ };
435
+
436
+ export declare type BackendInstallTarget = {
437
+ app: string;
438
+ artifactPath: string;
439
+ };
440
+
441
+ export declare type BackendOpenTarget = {
442
+ app?: string;
443
+ url?: string;
444
+ activity?: string;
445
+ };
446
+
447
+ export declare type BackendReadTextResult = {
448
+ text: string;
449
+ };
450
+
451
+ export declare type BackendRunnerCommand = {
452
+ command: string;
453
+ args?: readonly string[];
454
+ payload?: Record<string, unknown>;
455
+ };
456
+
457
+ export declare type BackendScreenshotOptions = {
458
+ fullscreen?: boolean;
459
+ overlayRefs?: boolean;
460
+ surface?: 'app' | 'frontmost-app' | 'desktop' | 'menubar';
461
+ };
462
+
463
+ export declare type BackendScreenshotResult = {
464
+ path?: string;
465
+ overlayRefs?: ScreenshotOverlayRef[];
466
+ };
467
+
468
+ export declare type BackendShellResult = {
469
+ exitCode: number;
470
+ stdout: string;
471
+ stderr: string;
472
+ };
473
+
474
+ export declare type BackendSnapshotAnalysis = {
475
+ rawNodeCount?: number;
476
+ maxDepth?: number;
477
+ };
478
+
479
+ export declare type BackendSnapshotFreshness = {
480
+ action: string;
481
+ retryCount: number;
482
+ staleAfterRetries: boolean;
483
+ reason?: 'empty-interactive' | 'sharp-drop' | 'stuck-route';
484
+ };
485
+
486
+ export declare type BackendSnapshotOptions = SnapshotOptions & {
487
+ outPath?: string;
488
+ };
489
+
490
+ export declare type BackendSnapshotResult = {
491
+ nodes?: SnapshotNode[];
492
+ truncated?: boolean;
493
+ backend?: string;
494
+ snapshot?: SnapshotState;
495
+ analysis?: BackendSnapshotAnalysis;
496
+ freshness?: BackendSnapshotFreshness;
497
+ warnings?: string[];
498
+ appName?: string;
499
+ appBundleId?: string;
500
+ };
501
+
502
+ export declare type BackendTapOptions = {
503
+ button?: 'primary' | 'secondary' | 'middle';
504
+ count?: number;
505
+ intervalMs?: number;
506
+ holdMs?: number;
507
+ jitterPx?: number;
508
+ doubleTap?: boolean;
509
+ };
510
+
304
511
  export declare type BatchRunOptions = AgentDeviceRequestOverrides & {
305
512
  steps: BatchStep[];
306
513
  onError?: 'stop';
@@ -314,6 +521,40 @@ export declare type BatchStep = {
314
521
  flags?: Record<string, unknown>;
315
522
  };
316
523
 
524
+ export declare type BoundAgentDeviceCommands = {
525
+ capture: {
526
+ screenshot: BoundRuntimeCommand<ScreenshotCommandOptions, ScreenshotCommandResult>;
527
+ diffScreenshot: BoundRuntimeCommand<DiffScreenshotCommandOptions, DiffScreenshotCommandResult>;
528
+ snapshot: BoundRuntimeCommand<SnapshotCommandOptions, SnapshotCommandResult>;
529
+ diffSnapshot: BoundRuntimeCommand<DiffSnapshotCommandOptions, DiffSnapshotCommandResult>;
530
+ };
531
+ selectors: {
532
+ find: BoundRuntimeCommand<FindReadCommandOptions, FindReadCommandResult>;
533
+ get: BoundRuntimeCommand<GetCommandOptions, GetCommandResult>;
534
+ getText: (target: ElementTarget_2, options?: Omit<GetTextCommandOptions, 'target'>) => Promise<Extract<GetCommandResult, {
535
+ kind: 'text';
536
+ }>>;
537
+ getAttrs: (target: ElementTarget_2, options?: Omit<GetAttrsCommandOptions, 'target'>) => Promise<Extract<GetCommandResult, {
538
+ kind: 'attrs';
539
+ }>>;
540
+ is: BoundRuntimeCommand<IsCommandOptions, IsCommandResult>;
541
+ isVisible: (target: SelectorTarget, options?: Omit<IsSelectorCommandOptions, 'target'>) => Promise<IsCommandResult>;
542
+ isHidden: (target: SelectorTarget, options?: Omit<IsSelectorCommandOptions, 'target'>) => Promise<IsCommandResult>;
543
+ wait: BoundRuntimeCommand<WaitCommandOptions_2, WaitCommandResult_2>;
544
+ waitForText: (text: string, options?: Omit<WaitForTextCommandOptions, 'text'>) => Promise<Extract<WaitCommandResult_2, {
545
+ kind: 'text';
546
+ }>>;
547
+ };
548
+ interactions: {
549
+ click: (target: InteractionTarget_2, options?: Omit<ClickCommandOptions, 'target'>) => Promise<PressCommandResult>;
550
+ press: (target: InteractionTarget_2, options?: Omit<PressCommandOptions, 'target'>) => Promise<PressCommandResult>;
551
+ fill: (target: InteractionTarget_2, text: string, options?: Omit<FillCommandOptions, 'target' | 'text'>) => Promise<FillCommandResult>;
552
+ typeText: (text: string, options?: Omit<TypeTextCommandOptions, 'text'>) => Promise<TypeTextCommandResult>;
553
+ };
554
+ };
555
+
556
+ export declare type BoundRuntimeCommand<TOptions = Record<string, unknown>, TResult = CommandResult> = (options: TOptions) => Promise<TResult>;
557
+
317
558
  export declare type CaptureDiffOptions = ClientCommandBaseOptions & Pick<CaptureSnapshotOptions, 'interactiveOnly' | 'compact' | 'depth' | 'scope' | 'raw'> & {
318
559
  kind: 'snapshot';
319
560
  out?: string;
@@ -323,6 +564,7 @@ export declare type CaptureScreenshotOptions = AgentDeviceRequestOverrides & {
323
564
  path?: string;
324
565
  overlayRefs?: boolean;
325
566
  fullscreen?: boolean;
567
+ surface?: 'app' | 'frontmost-app' | 'desktop' | 'menubar';
326
568
  };
327
569
 
328
570
  export declare type CaptureScreenshotResult = {
@@ -351,6 +593,8 @@ export declare type CaptureSnapshotResult = {
351
593
 
352
594
  export declare function centerOfRect(rect: Rect): Point;
353
595
 
596
+ declare type ClickCommandOptions = PressCommandOptions;
597
+
354
598
  export declare type ClickOptions = ClientCommandBaseOptions & SelectorSnapshotCommandOptions & InteractionTarget & RepeatedPressOptions & {
355
599
  button?: 'primary' | 'secondary' | 'middle';
356
600
  };
@@ -376,12 +620,143 @@ declare type CommandActionResult<T extends string> = DaemonResponseData & {
376
620
  action?: T;
377
621
  };
378
622
 
623
+ export declare const commandCatalog: readonly CommandCatalogEntry[];
624
+
625
+ export declare type CommandCatalogEntry = {
626
+ command: string;
627
+ category: 'portable-runtime' | 'backend-admin' | 'transport-session' | 'environment' | 'capability-gated';
628
+ status: 'implemented' | 'planned';
629
+ };
630
+
631
+ export declare type CommandClock = {
632
+ now(): number;
633
+ sleep(ms: number): Promise<void>;
634
+ };
635
+
636
+ export declare type CommandContext = {
637
+ session?: string;
638
+ requestId?: string;
639
+ signal?: AbortSignal;
640
+ metadata?: Record<string, unknown>;
641
+ };
642
+
643
+ export declare type CommandPolicy = {
644
+ allowLocalInputPaths: boolean;
645
+ allowLocalOutputPaths: boolean;
646
+ maxImagePixels: number;
647
+ allowNamedBackendCapabilities: readonly BackendCapabilityName[];
648
+ };
649
+
379
650
  export declare type CommandRequestResult = DaemonResponseData;
380
651
 
652
+ export declare type CommandResult = Record<string, unknown>;
653
+
654
+ export declare type CommandRouter<TContext = unknown> = {
655
+ dispatch(request: CommandRouterRequest<TContext>): Promise<CommandRouterResponse>;
656
+ };
657
+
658
+ export declare type CommandRouterConfig<TContext = unknown> = {
659
+ createRuntime(request: CommandRouterRequest<TContext>): AgentDeviceRuntime | Promise<AgentDeviceRuntime>;
660
+ beforeDispatch?(request: CommandRouterRequest<TContext>): void | Promise<void>;
661
+ formatError?(error: unknown, request: CommandRouterRequest<TContext>): NormalizedError;
662
+ };
663
+
664
+ export declare type CommandRouterRequest<TContext = unknown> = {
665
+ command: 'capture.screenshot';
666
+ options: ScreenshotCommandOptions;
667
+ context?: TContext;
668
+ } | {
669
+ command: 'capture.diffScreenshot';
670
+ options: DiffScreenshotCommandOptions;
671
+ context?: TContext;
672
+ } | {
673
+ command: 'capture.snapshot';
674
+ options: SnapshotCommandOptions;
675
+ context?: TContext;
676
+ } | {
677
+ command: 'capture.diffSnapshot';
678
+ options: DiffSnapshotCommandOptions;
679
+ context?: TContext;
680
+ } | {
681
+ command: 'selectors.find';
682
+ options: FindReadCommandOptions;
683
+ context?: TContext;
684
+ } | {
685
+ command: 'selectors.get';
686
+ options: GetCommandOptions;
687
+ context?: TContext;
688
+ } | {
689
+ command: 'selectors.is';
690
+ options: IsCommandOptions;
691
+ context?: TContext;
692
+ } | {
693
+ command: 'selectors.wait';
694
+ options: WaitCommandOptions_2;
695
+ context?: TContext;
696
+ } | {
697
+ command: 'interactions.click';
698
+ options: ClickCommandOptions;
699
+ context?: TContext;
700
+ } | {
701
+ command: 'interactions.press';
702
+ options: PressCommandOptions;
703
+ context?: TContext;
704
+ } | {
705
+ command: 'interactions.fill';
706
+ options: FillCommandOptions;
707
+ context?: TContext;
708
+ } | {
709
+ command: 'interactions.typeText';
710
+ options: TypeTextCommandOptions;
711
+ context?: TContext;
712
+ };
713
+
714
+ export declare type CommandRouterResponse = {
715
+ ok: true;
716
+ data: CommandRouterResult;
717
+ } | {
718
+ ok: false;
719
+ error: NormalizedError;
720
+ };
721
+
722
+ export declare type CommandRouterResult = ScreenshotCommandResult | DiffScreenshotCommandResult | SnapshotCommandResult | DiffSnapshotCommandResult | FindReadCommandResult | GetCommandResult | IsCommandResult | WaitCommandResult_2 | PressCommandResult | FillCommandResult | TypeTextCommandResult;
723
+
724
+ export declare const commands: AgentDeviceCommands;
725
+
726
+ export declare type CommandSessionRecord = {
727
+ name: string;
728
+ appId?: string;
729
+ appBundleId?: string;
730
+ appName?: string;
731
+ backendSessionId?: string;
732
+ snapshot?: SnapshotState;
733
+ metadata?: Record<string, unknown>;
734
+ };
735
+
736
+ export declare type CommandSessionStore = {
737
+ get(name: string): CommandSessionRecord | undefined | Promise<CommandSessionRecord | undefined>;
738
+ set(record: CommandSessionRecord): void | Promise<void>;
739
+ delete?(name: string): void | Promise<void>;
740
+ list?(): readonly CommandSessionRecord[] | Promise<readonly CommandSessionRecord[]>;
741
+ };
742
+
743
+ export declare function createAgentDevice(config: AgentDeviceRuntimeConfig): AgentDevice;
744
+
381
745
  export declare function createAgentDeviceClient(config?: AgentDeviceClientConfig, deps?: {
382
746
  transport?: AgentDeviceDaemonTransport;
383
747
  }): AgentDeviceClient;
384
748
 
749
+ export declare function createCommandRouter<TContext = unknown>(config: CommandRouterConfig<TContext>): CommandRouter<TContext>;
750
+
751
+ export declare function createLocalArtifactAdapter(options?: LocalArtifactAdapterOptions): ArtifactAdapter;
752
+
753
+ export declare function createMemorySessionStore(records?: readonly CommandSessionRecord[]): CommandSessionStore;
754
+
755
+ export declare type CreateTempFileOptions = {
756
+ prefix: string;
757
+ ext: string;
758
+ };
759
+
385
760
  declare type DaemonArtifact = {
386
761
  field: string;
387
762
  artifactId?: string;
@@ -466,7 +841,41 @@ declare type DeviceKind = 'simulator' | 'emulator' | 'device';
466
841
 
467
842
  declare type DeviceTarget = 'mobile' | 'tv' | 'desktop';
468
843
 
469
- export declare type ElementTarget = RefTarget | SelectorTarget;
844
+ export declare type DiagnosticsSink = {
845
+ emit(event: {
846
+ level: 'debug' | 'info' | 'warn' | 'error';
847
+ message: string;
848
+ data?: unknown;
849
+ }): void;
850
+ };
851
+
852
+ declare type DiffScreenshotCommandOptions = CommandContext & {
853
+ baseline: FileInputRef;
854
+ current?: FileInputRef | LiveScreenshotInputRef;
855
+ out?: FileOutputRef;
856
+ currentOverlayOut?: FileOutputRef;
857
+ threshold?: number;
858
+ overlayRefs?: boolean;
859
+ surface?: BackendScreenshotOptions['surface'];
860
+ };
861
+
862
+ declare type DiffScreenshotCommandResult = ScreenshotDiffResult & {
863
+ artifacts?: ArtifactDescriptor[];
864
+ };
865
+
866
+ declare type DiffSnapshotCommandOptions = SnapshotCommandOptions;
867
+
868
+ declare type DiffSnapshotCommandResult = {
869
+ mode: 'snapshot';
870
+ baselineInitialized: boolean;
871
+ summary: SnapshotDiffSummary;
872
+ lines: SnapshotDiffLine[];
873
+ warnings?: string[];
874
+ };
875
+
876
+ export declare type ElementTarget = RefTarget_2 | SelectorTarget_2;
877
+
878
+ declare type ElementTarget_2 = SelectorTarget | RefTarget;
470
879
 
471
880
  export declare type EnsureSimulatorOptions = AgentDeviceRequestOverrides & {
472
881
  device: string;
@@ -486,11 +895,61 @@ export declare type EnsureSimulatorResult = {
486
895
  identifiers: AgentDeviceIdentifiers;
487
896
  };
488
897
 
898
+ export declare type FileInputRef = {
899
+ kind: 'path';
900
+ path: string;
901
+ } | {
902
+ kind: 'uploadedArtifact';
903
+ id: string;
904
+ };
905
+
906
+ export declare type FileOutputRef = {
907
+ kind: 'path';
908
+ path: string;
909
+ } | {
910
+ kind: 'downloadableArtifact';
911
+ clientPath?: string;
912
+ fileName?: string;
913
+ };
914
+
915
+ declare type FillCommandOptions = CommandContext & {
916
+ target: InteractionTarget_2;
917
+ text: string;
918
+ delayMs?: number;
919
+ };
920
+
921
+ declare type FillCommandResult = ResolvedInteractionTarget & {
922
+ text: string;
923
+ warning?: string;
924
+ backendResult?: Record<string, unknown>;
925
+ };
926
+
489
927
  export declare type FillOptions = ClientCommandBaseOptions & SelectorSnapshotCommandOptions & InteractionTarget & {
490
928
  text: string;
491
929
  delayMs?: number;
492
930
  };
493
931
 
932
+ declare type FindAction = {
933
+ kind: 'click';
934
+ } | {
935
+ kind: 'focus';
936
+ } | {
937
+ kind: 'fill';
938
+ value: string;
939
+ } | {
940
+ kind: 'type';
941
+ value: string;
942
+ } | {
943
+ kind: 'get_text';
944
+ } | {
945
+ kind: 'get_attrs';
946
+ } | {
947
+ kind: 'exists';
948
+ } | {
949
+ kind: 'wait';
950
+ timeoutMs?: number;
951
+ };
952
+
494
953
  declare type FindBaseOptions = ClientCommandBaseOptions & FindSnapshotCommandOptions & {
495
954
  locator?: FindLocator;
496
955
  query: string;
@@ -500,6 +959,8 @@ declare type FindBaseOptions = ClientCommandBaseOptions & FindSnapshotCommandOpt
500
959
 
501
960
  export declare type FindLocator = 'any' | 'text' | 'label' | 'value' | 'role' | 'id';
502
961
 
962
+ declare type FindLocator_2 = 'any' | 'text' | 'label' | 'value' | 'role' | 'id';
963
+
503
964
  export declare type FindOptions = (FindBaseOptions & {
504
965
  action?: 'click' | 'focus' | 'exists' | 'getText' | 'getAttrs';
505
966
  }) | (FindBaseOptions & {
@@ -510,6 +971,28 @@ export declare type FindOptions = (FindBaseOptions & {
510
971
  value: string;
511
972
  });
512
973
 
974
+ declare type FindReadCommandOptions = CommandContext & {
975
+ locator?: FindLocator_2;
976
+ query: string;
977
+ action: Extract<FindAction['kind'], 'exists' | 'wait' | 'get_text' | 'get_attrs'>;
978
+ timeoutMs?: number;
979
+ } & SelectorSnapshotOptions;
980
+
981
+ declare type FindReadCommandResult = {
982
+ kind: 'found';
983
+ found: true;
984
+ waitedMs?: number;
985
+ } | {
986
+ kind: 'text';
987
+ ref: string;
988
+ text: string;
989
+ node: SnapshotNode;
990
+ } | {
991
+ kind: 'attrs';
992
+ ref: string;
993
+ node: SnapshotNode;
994
+ };
995
+
513
996
  declare type FindSnapshotCommandOptions = Pick<CaptureSnapshotOptions, 'depth' | 'raw'>;
514
997
 
515
998
  declare type FocusOptions_2 = ClientCommandBaseOptions & {
@@ -518,18 +1001,67 @@ declare type FocusOptions_2 = ClientCommandBaseOptions & {
518
1001
  };
519
1002
  export { FocusOptions_2 as FocusOptions }
520
1003
 
1004
+ declare type GetAttrsCommandOptions = CommandContext & SelectorSnapshotOptions & {
1005
+ target: ElementTarget_2;
1006
+ };
1007
+
1008
+ declare type GetCommandOptions = CommandContext & SelectorSnapshotOptions & {
1009
+ property: 'text' | 'attrs';
1010
+ target: ElementTarget_2;
1011
+ };
1012
+
1013
+ declare type GetCommandResult = {
1014
+ kind: 'text';
1015
+ target: ResolvedTarget;
1016
+ text: string;
1017
+ node: SnapshotNode;
1018
+ selectorChain?: string[];
1019
+ } | {
1020
+ kind: 'attrs';
1021
+ target: ResolvedTarget;
1022
+ node: SnapshotNode;
1023
+ selectorChain?: string[];
1024
+ };
1025
+
521
1026
  export declare type GetOptions = ClientCommandBaseOptions & SelectorSnapshotCommandOptions & ElementTarget & {
522
1027
  format: 'text' | 'attrs';
523
1028
  };
524
1029
 
1030
+ declare type GetTextCommandOptions = CommandContext & SelectorSnapshotOptions & {
1031
+ target: ElementTarget_2;
1032
+ };
1033
+
525
1034
  export declare type HomeCommandOptions = DeviceCommandBaseOptions;
526
1035
 
527
1036
  export declare type HomeCommandResult = CommandActionResult<'home'>;
528
1037
 
529
- export declare type InteractionTarget = PointTarget | RefTarget | SelectorTarget;
1038
+ export declare type InteractionTarget = PointTarget_2 | RefTarget_2 | SelectorTarget_2;
1039
+
1040
+ declare type InteractionTarget_2 = ElementTarget_2 | PointTarget;
1041
+
1042
+ export declare function isAgentDeviceError(err: unknown): err is AppError;
1043
+
1044
+ declare type IsCommandOptions = CommandContext & SelectorSnapshotOptions & {
1045
+ predicate: 'visible' | 'hidden' | 'exists' | 'editable' | 'selected' | 'text';
1046
+ selector: string;
1047
+ expectedText?: string;
1048
+ };
1049
+
1050
+ declare type IsCommandResult = {
1051
+ predicate: IsCommandOptions['predicate'];
1052
+ pass: true;
1053
+ selector: string;
1054
+ matches?: number;
1055
+ text?: string;
1056
+ selectorChain?: string[];
1057
+ };
530
1058
 
531
1059
  export declare type IsOptions = IsTextPredicateOptions | IsStatePredicateOptions;
532
1060
 
1061
+ declare type IsSelectorCommandOptions = CommandContext & SelectorSnapshotOptions & {
1062
+ target: SelectorTarget;
1063
+ };
1064
+
533
1065
  declare type IsStatePredicateOptions = ClientCommandBaseOptions & SelectorSnapshotCommandOptions & {
534
1066
  predicate: 'visible' | 'hidden' | 'exists' | 'editable' | 'selected';
535
1067
  selector: string;
@@ -585,6 +1117,18 @@ declare type LeaseScopedOptions = LeaseOptions & {
585
1117
  leaseId: string;
586
1118
  };
587
1119
 
1120
+ declare type LiveScreenshotInputRef = {
1121
+ kind: 'live';
1122
+ };
1123
+
1124
+ export declare type LocalArtifactAdapterOptions = {
1125
+ cwd?: string;
1126
+ tempDir?: string;
1127
+ rootDir?: string;
1128
+ };
1129
+
1130
+ export declare function localCommandPolicy(overrides?: Partial<CommandPolicy>): CommandPolicy;
1131
+
588
1132
  export declare type LogsOptions = AgentDeviceRequestOverrides & {
589
1133
  action?: 'path' | 'start' | 'stop' | 'doctor' | 'mark' | 'clear';
590
1134
  message?: string;
@@ -666,6 +1210,22 @@ export declare type NetworkOptions = AgentDeviceRequestOverrides & {
666
1210
  include?: 'summary' | 'headers' | 'body' | 'all';
667
1211
  };
668
1212
 
1213
+ export declare function normalizeAgentDeviceError(err: unknown, context?: {
1214
+ diagnosticId?: string;
1215
+ logPath?: string;
1216
+ }): NormalizedError;
1217
+
1218
+ export declare type NormalizedError = {
1219
+ code: string;
1220
+ message: string;
1221
+ hint?: string;
1222
+ diagnosticId?: string;
1223
+ logPath?: string;
1224
+ details?: Record<string, unknown>;
1225
+ };
1226
+
1227
+ export declare type OutputVisibility = 'client-visible' | 'internal';
1228
+
669
1229
  export declare type PerfOptions = ClientCommandBaseOptions;
670
1230
 
671
1231
  export declare type PermissionTarget = 'camera' | 'microphone' | 'photos' | 'contacts' | 'contacts-limited' | 'notifications' | 'calendar' | 'location' | 'location-always' | 'media-library' | 'motion' | 'reminders' | 'siri' | 'accessibility' | 'screen-recording' | 'input-monitoring';
@@ -686,6 +1246,12 @@ export declare type Point = {
686
1246
  };
687
1247
 
688
1248
  declare type PointTarget = {
1249
+ kind: 'point';
1250
+ x: number;
1251
+ y: number;
1252
+ };
1253
+
1254
+ declare type PointTarget_2 = {
689
1255
  x: number;
690
1256
  y: number;
691
1257
  ref?: never;
@@ -709,6 +1275,20 @@ declare type PrepareMetroRuntimeResult = {
709
1275
  bridge: MetroBridgeResult | null;
710
1276
  };
711
1277
 
1278
+ declare type PressCommandOptions = CommandContext & {
1279
+ target: InteractionTarget_2;
1280
+ button?: 'primary' | 'secondary' | 'middle';
1281
+ count?: number;
1282
+ intervalMs?: number;
1283
+ holdMs?: number;
1284
+ jitterPx?: number;
1285
+ doubleTap?: boolean;
1286
+ };
1287
+
1288
+ declare type PressCommandResult = ResolvedInteractionTarget & {
1289
+ backendResult?: Record<string, unknown>;
1290
+ };
1291
+
712
1292
  export declare type PressOptions = ClientCommandBaseOptions & SelectorSnapshotCommandOptions & InteractionTarget & RepeatedPressOptions;
713
1293
 
714
1294
  declare type RawSnapshotNode = {
@@ -734,10 +1314,13 @@ declare type RawSnapshotNode = {
734
1314
  hiddenContentBelow?: boolean;
735
1315
  };
736
1316
 
1317
+ declare type RecordingQuality = 5 | 6 | 7 | 8 | 9 | 10;
1318
+
737
1319
  export declare type RecordOptions = AgentDeviceRequestOverrides & {
738
1320
  action: 'start' | 'stop';
739
1321
  path?: string;
740
1322
  fps?: number;
1323
+ quality?: RecordingQuality;
741
1324
  hideTouches?: boolean;
742
1325
  };
743
1326
 
@@ -748,7 +1331,17 @@ export declare type Rect = {
748
1331
  height: number;
749
1332
  };
750
1333
 
1334
+ export declare function ref(refInput: string, options?: {
1335
+ fallbackLabel?: string;
1336
+ }): RefTarget;
1337
+
751
1338
  declare type RefTarget = {
1339
+ kind: 'ref';
1340
+ ref: string;
1341
+ fallbackLabel?: string;
1342
+ };
1343
+
1344
+ declare type RefTarget_2 = {
752
1345
  ref: string;
753
1346
  label?: string;
754
1347
  x?: never;
@@ -779,8 +1372,65 @@ export declare type ReplayTestOptions = AgentDeviceRequestOverrides & AgentDevic
779
1372
  reportJunit?: string;
780
1373
  };
781
1374
 
1375
+ export declare type ReservedOutputFile = {
1376
+ path: string;
1377
+ visibility: OutputVisibility;
1378
+ publish: () => Promise<ArtifactDescriptor | undefined>;
1379
+ cleanup?: () => Promise<void>;
1380
+ };
1381
+
1382
+ export declare type ReserveOutputOptions = {
1383
+ field: string;
1384
+ ext: string;
1385
+ requestedClientPath?: string;
1386
+ visibility?: OutputVisibility;
1387
+ };
1388
+
1389
+ export declare type ResolvedInputFile = {
1390
+ path: string;
1391
+ cleanup?: () => Promise<void>;
1392
+ };
1393
+
1394
+ declare type ResolvedInteractionTarget = {
1395
+ kind: 'point';
1396
+ point: Point;
1397
+ } | {
1398
+ kind: 'ref';
1399
+ point: Point;
1400
+ target: Extract<ResolvedTarget, {
1401
+ kind: 'ref';
1402
+ }>;
1403
+ node: SnapshotNode;
1404
+ selectorChain: string[];
1405
+ refLabel?: string;
1406
+ } | {
1407
+ kind: 'selector';
1408
+ point: Point;
1409
+ target: Extract<ResolvedTarget, {
1410
+ kind: 'selector';
1411
+ }>;
1412
+ node: SnapshotNode;
1413
+ selectorChain: string[];
1414
+ refLabel?: string;
1415
+ };
1416
+
782
1417
  declare type ResolvedMetroKind = Exclude<MetroPrepareKind, 'auto'>;
783
1418
 
1419
+ declare type ResolvedTarget = {
1420
+ kind: 'selector';
1421
+ selector: string;
1422
+ } | {
1423
+ kind: 'ref';
1424
+ ref: string;
1425
+ };
1426
+
1427
+ export declare type ResolveInputOptions = {
1428
+ usage: string;
1429
+ field?: string;
1430
+ };
1431
+
1432
+ export declare function restrictedCommandPolicy(overrides?: Partial<CommandPolicy>): CommandPolicy;
1433
+
784
1434
  export declare type RotateCommandOptions = DeviceCommandBaseOptions & {
785
1435
  orientation: 'portrait' | 'portrait-upside-down' | 'landscape-left' | 'landscape-right';
786
1436
  };
@@ -789,6 +1439,131 @@ export declare type RotateCommandResult = CommandActionResult<'rotate'> & {
789
1439
  orientation?: RotateCommandOptions['orientation'];
790
1440
  };
791
1441
 
1442
+ export declare type RuntimeCommand<TOptions = Record<string, unknown>, TResult = CommandResult> = (runtime: AgentDeviceRuntime, options: TOptions) => Promise<TResult>;
1443
+
1444
+ declare type ScreenshotCommandOptions = CommandContext & {
1445
+ out?: FileOutputRef;
1446
+ fullscreen?: boolean;
1447
+ overlayRefs?: boolean;
1448
+ appId?: string;
1449
+ appBundleId?: string;
1450
+ surface?: 'app' | 'frontmost-app' | 'desktop' | 'menubar';
1451
+ };
1452
+
1453
+ declare type ScreenshotCommandResult = {
1454
+ path: string;
1455
+ artifacts?: ArtifactDescriptor[];
1456
+ message?: string;
1457
+ };
1458
+
1459
+ declare type ScreenshotDiffRegion = {
1460
+ index: number;
1461
+ rect: {
1462
+ x: number;
1463
+ y: number;
1464
+ width: number;
1465
+ height: number;
1466
+ };
1467
+ normalizedRect: {
1468
+ x: number;
1469
+ y: number;
1470
+ width: number;
1471
+ height: number;
1472
+ };
1473
+ differentPixels: number;
1474
+ shareOfDiffPercentage: number;
1475
+ densityPercentage: number;
1476
+ shape: 'compact' | 'horizontal-band' | 'vertical-band' | 'large-area';
1477
+ size: 'small' | 'medium' | 'large';
1478
+ location: string;
1479
+ averageBaselineColorHex: string;
1480
+ averageCurrentColorHex: string;
1481
+ baselineLuminance: number;
1482
+ currentLuminance: number;
1483
+ dominantChange: 'brighter' | 'darker' | 'color-shift' | 'mixed';
1484
+ currentOverlayMatches?: ScreenshotDiffRegionOverlayMatch[];
1485
+ };
1486
+
1487
+ declare type ScreenshotDiffRegionOverlayMatch = {
1488
+ ref: string;
1489
+ label?: string;
1490
+ regionCoveragePercentage: number;
1491
+ rect: {
1492
+ x: number;
1493
+ y: number;
1494
+ width: number;
1495
+ height: number;
1496
+ };
1497
+ };
1498
+
1499
+ declare type ScreenshotDiffResult = {
1500
+ diffPath?: string;
1501
+ totalPixels: number;
1502
+ differentPixels: number;
1503
+ mismatchPercentage: number;
1504
+ match: boolean;
1505
+ dimensionMismatch?: ScreenshotDimensionMismatch;
1506
+ regions?: ScreenshotDiffRegion[];
1507
+ currentOverlayPath?: string;
1508
+ currentOverlayRefCount?: number;
1509
+ ocr?: ScreenshotOcrSummary;
1510
+ nonTextDeltas?: ScreenshotNonTextDelta[];
1511
+ };
1512
+
1513
+ declare type ScreenshotDimensionMismatch = {
1514
+ expected: {
1515
+ width: number;
1516
+ height: number;
1517
+ };
1518
+ actual: {
1519
+ width: number;
1520
+ height: number;
1521
+ };
1522
+ };
1523
+
1524
+ declare type ScreenshotNonTextDelta = {
1525
+ index: number;
1526
+ regionIndex?: number;
1527
+ slot: 'leading' | 'trailing' | 'background' | 'separator' | 'unknown';
1528
+ likelyKind: 'icon' | 'toggle' | 'chevron' | 'separator' | 'visual';
1529
+ rect: Rect;
1530
+ nearestText?: string;
1531
+ };
1532
+
1533
+ declare type ScreenshotOcrMovementCluster = {
1534
+ texts: string[];
1535
+ xRange: {
1536
+ min: number;
1537
+ max: number;
1538
+ };
1539
+ yRange: {
1540
+ min: number;
1541
+ max: number;
1542
+ };
1543
+ };
1544
+
1545
+ declare type ScreenshotOcrSummary = {
1546
+ provider: 'tesseract';
1547
+ baselineBlocks: number;
1548
+ currentBlocks: number;
1549
+ matches: ScreenshotOcrTextMatch[];
1550
+ movementClusters?: ScreenshotOcrMovementCluster[];
1551
+ };
1552
+
1553
+ declare type ScreenshotOcrTextMatch = {
1554
+ text: string;
1555
+ baselineRect: Rect;
1556
+ currentRect: Rect;
1557
+ delta: {
1558
+ x: number;
1559
+ y: number;
1560
+ width: number;
1561
+ height: number;
1562
+ };
1563
+ confidence: number;
1564
+ possibleTextMetricMismatch: boolean;
1565
+ };
1566
+
792
1567
  export declare type ScreenshotOverlayRef = {
793
1568
  ref: string;
794
1569
  label?: string;
@@ -804,9 +1579,22 @@ declare type ScrollOptions_2 = ClientCommandBaseOptions & {
804
1579
  };
805
1580
  export { ScrollOptions_2 as ScrollOptions }
806
1581
 
1582
+ export declare function selector(expression: string): SelectorTarget;
1583
+
807
1584
  declare type SelectorSnapshotCommandOptions = Pick<CaptureSnapshotOptions, 'depth' | 'scope' | 'raw'>;
808
1585
 
1586
+ export declare type SelectorSnapshotOptions = {
1587
+ depth?: number;
1588
+ scope?: string;
1589
+ raw?: boolean;
1590
+ };
1591
+
809
1592
  declare type SelectorTarget = {
1593
+ kind: 'selector';
1594
+ selector: string;
1595
+ };
1596
+
1597
+ declare type SelectorTarget_2 = {
810
1598
  selector: string;
811
1599
  x?: never;
812
1600
  y?: never;
@@ -849,10 +1637,56 @@ export declare type SettingsUpdateOptions = (ClientCommandBaseOptions & {
849
1637
  mode?: 'full' | 'limited';
850
1638
  });
851
1639
 
1640
+ declare type SnapshotBackend = 'xctest' | 'android' | 'macos-helper' | 'linux-atspi';
1641
+
1642
+ declare type SnapshotCommandOptions = CommandContext & {
1643
+ interactiveOnly?: boolean;
1644
+ compact?: boolean;
1645
+ depth?: number;
1646
+ scope?: string;
1647
+ raw?: boolean;
1648
+ };
1649
+
1650
+ declare type SnapshotCommandResult = {
1651
+ nodes: SnapshotNode[];
1652
+ truncated: boolean;
1653
+ appName?: string;
1654
+ appBundleId?: string;
1655
+ visibility?: SnapshotVisibility;
1656
+ warnings?: string[];
1657
+ };
1658
+
1659
+ declare type SnapshotDiffLine = {
1660
+ kind: 'added' | 'removed' | 'unchanged';
1661
+ text: string;
1662
+ };
1663
+
1664
+ declare type SnapshotDiffSummary = {
1665
+ additions: number;
1666
+ removals: number;
1667
+ unchanged: number;
1668
+ };
1669
+
852
1670
  export declare type SnapshotNode = RawSnapshotNode & {
853
1671
  ref: string;
854
1672
  };
855
1673
 
1674
+ declare type SnapshotOptions = {
1675
+ interactiveOnly?: boolean;
1676
+ compact?: boolean;
1677
+ depth?: number;
1678
+ scope?: string;
1679
+ raw?: boolean;
1680
+ };
1681
+
1682
+ declare type SnapshotState = {
1683
+ nodes: SnapshotNode[];
1684
+ createdAt: number;
1685
+ truncated?: boolean;
1686
+ backend?: SnapshotBackend;
1687
+ comparisonSafe?: boolean;
1688
+ };
1689
+
856
1690
  export declare type SnapshotVisibility = {
857
1691
  partial: boolean;
858
1692
  visibleNodeCount: number;
@@ -885,11 +1719,30 @@ export declare type SwipeOptions = ClientCommandBaseOptions & {
885
1719
  pattern?: 'one-way' | 'ping-pong';
886
1720
  };
887
1721
 
1722
+ export declare type TemporaryFile = {
1723
+ path: string;
1724
+ visibility: 'internal';
1725
+ cleanup: () => Promise<void>;
1726
+ };
1727
+
888
1728
  export declare type TraceOptions = AgentDeviceRequestOverrides & {
889
1729
  action: 'start' | 'stop';
890
1730
  path?: string;
891
1731
  };
892
1732
 
1733
+ export declare type TypeTextCommandOptions = CommandContext & {
1734
+ text: string;
1735
+ delayMs?: number;
1736
+ };
1737
+
1738
+ export declare type TypeTextCommandResult = {
1739
+ kind: 'text';
1740
+ text: string;
1741
+ delayMs: number;
1742
+ backendResult?: Record<string, unknown>;
1743
+ message?: string;
1744
+ };
1745
+
893
1746
  export declare type TypeTextOptions = ClientCommandBaseOptions & {
894
1747
  text: string;
895
1748
  delayMs?: number;
@@ -897,12 +1750,44 @@ export declare type TypeTextOptions = ClientCommandBaseOptions & {
897
1750
 
898
1751
  export declare type WaitCommandOptions = DeviceCommandBaseOptions & WaitCommandTarget;
899
1752
 
1753
+ declare type WaitCommandOptions_2 = CommandContext & SelectorSnapshotOptions & {
1754
+ target: {
1755
+ kind: 'sleep';
1756
+ durationMs: number;
1757
+ } | {
1758
+ kind: 'text';
1759
+ text: string;
1760
+ timeoutMs?: number | null;
1761
+ } | {
1762
+ kind: 'ref';
1763
+ ref: string;
1764
+ timeoutMs?: number | null;
1765
+ } | {
1766
+ kind: 'selector';
1767
+ selector: string;
1768
+ timeoutMs?: number | null;
1769
+ };
1770
+ };
1771
+
900
1772
  export declare type WaitCommandResult = DaemonResponseData & {
901
1773
  waitedMs?: number;
902
1774
  text?: string;
903
1775
  selector?: string;
904
1776
  };
905
1777
 
1778
+ declare type WaitCommandResult_2 = {
1779
+ kind: 'sleep';
1780
+ waitedMs: number;
1781
+ } | {
1782
+ kind: 'text';
1783
+ waitedMs: number;
1784
+ text: string;
1785
+ } | {
1786
+ kind: 'selector';
1787
+ waitedMs: number;
1788
+ selector: string;
1789
+ };
1790
+
906
1791
  declare type WaitCommandTarget = {
907
1792
  durationMs: number;
908
1793
  text?: never;
@@ -929,6 +1814,11 @@ declare type WaitCommandTarget = {
929
1814
  timeoutMs?: number;
930
1815
  });
931
1816
 
1817
+ declare type WaitForTextCommandOptions = CommandContext & SelectorSnapshotOptions & {
1818
+ text: string;
1819
+ timeoutMs?: number | null;
1820
+ };
1821
+
932
1822
  declare type WaitSnapshotOptions = Pick<CaptureSnapshotOptions, 'depth' | 'scope' | 'raw'>;
933
1823
 
934
1824
  export { }