11import { AppError } from '@agent-device/kernel/errors' ;
22import { createAndroidInteractor } from '../core/interactors/android.ts' ;
3- import {
4- androidAdbResultError ,
5- createAndroidPortReverseManager ,
6- } from '../platforms/android/adb-executor.ts' ;
7- import {
8- getAndroidAppStateWithAdb ,
9- listAndroidAppsWithAdb ,
10- } from '../platforms/android/app-helpers.ts' ;
11- import { inferAndroidAppName } from '../platforms/android/app-lifecycle.ts' ;
12- import {
13- dismissAndroidKeyboardWithAdb ,
14- getAndroidKeyboardStatusWithAdb ,
15- } from '../platforms/android/device-input-state.ts' ;
16- import { captureAndroidLogcatWithAdb } from '../platforms/android/logcat.ts' ;
17- import { resolveIosAppAlias } from '../platforms/apple/core/app-resolution.ts' ;
18- import { readIosBundleInfo } from '../platforms/apple/core/install-artifact.ts' ;
193import type { LimrunRuntimeDependencies } from '../providers/limrun/runtime-dependencies.ts' ;
204import { execFailureDetails , runCmd } from '../utils/exec.ts' ;
215import { readVersion } from '../utils/version.ts' ;
@@ -25,27 +9,50 @@ export function createLimrunRuntimeDependencies(): LimrunRuntimeDependencies {
259 clientVersion : readVersion ( ) ,
2610 android : {
2711 createInteractor : ( device , adb ) => createAndroidInteractor ( device , adb ) ,
28- createPortReverse : ( adb ) => createAndroidPortReverseManager ( adb ) ,
29- inferAppName : inferAndroidAppName ,
30- listApps : async ( adb , filter ) =>
31- (
12+ createPortReverse : async ( adb ) => {
13+ const { createAndroidPortReverseManager } =
14+ await import ( '../platforms/android/adb-executor.ts' ) ;
15+ return createAndroidPortReverseManager ( adb ) ;
16+ } ,
17+ inferAppName : async ( packageName ) => {
18+ const { inferAndroidAppName } = await import ( '../platforms/android/app-lifecycle.ts' ) ;
19+ return inferAndroidAppName ( packageName ) ;
20+ } ,
21+ listApps : async ( adb , filter ) => {
22+ const { listAndroidAppsWithAdb } = await import ( '../platforms/android/app-helpers.ts' ) ;
23+ return (
3224 await listAndroidAppsWithAdb ( adb , {
3325 filter,
3426 target : 'mobile' ,
3527 } )
36- ) . map ( ( app ) => ( { id : app . package , name : app . name } ) ) ,
28+ ) . map ( ( app ) => ( { id : app . package , name : app . name } ) ) ;
29+ } ,
3730 getForegroundApp : async ( adb ) => {
31+ const { getAndroidAppStateWithAdb } = await import ( '../platforms/android/app-helpers.ts' ) ;
3832 const app = await getAndroidAppStateWithAdb ( adb ) ;
3933 return app . package ? { appId : app . package , activity : app . activity } : undefined ;
4034 } ,
41- getKeyboardState : getAndroidKeyboardStatusWithAdb ,
42- dismissKeyboard : dismissAndroidKeyboardWithAdb ,
43- readLogs : async ( adb , lineLimit ) =>
44- await captureAndroidLogcatWithAdb ( adb , {
35+ getKeyboardState : async ( adb ) => {
36+ const { getAndroidKeyboardStatusWithAdb } =
37+ await import ( '../platforms/android/device-input-state.ts' ) ;
38+ return await getAndroidKeyboardStatusWithAdb ( adb ) ;
39+ } ,
40+ dismissKeyboard : async ( adb ) => {
41+ const { dismissAndroidKeyboardWithAdb } =
42+ await import ( '../platforms/android/device-input-state.ts' ) ;
43+ return await dismissAndroidKeyboardWithAdb ( adb ) ;
44+ } ,
45+ readLogs : async ( adb , lineLimit ) => {
46+ const { captureAndroidLogcatWithAdb } = await import ( '../platforms/android/logcat.ts' ) ;
47+ return await captureAndroidLogcatWithAdb ( adb , {
4548 lines : lineLimit ,
4649 timeoutMs : 5_000 ,
47- } ) ,
48- adbError : androidAdbResultError ,
50+ } ) ;
51+ } ,
52+ adbError : async ( message , result , details ) => {
53+ const { androidAdbResultError } = await import ( '../platforms/android/adb-executor.ts' ) ;
54+ return androidAdbResultError ( message , result , details ) ;
55+ } ,
4956 } ,
5057 host : {
5158 runAdb : async ( args , options ) => await runCmd ( 'adb' , args , options ) ,
@@ -64,8 +71,14 @@ export function createLimrunRuntimeDependencies(): LimrunRuntimeDependencies {
6471 } ,
6572 } ,
6673 ios : {
67- resolveAppAlias : resolveIosAppAlias ,
68- readBundleAppName : async ( appPath ) => ( await readIosBundleInfo ( appPath ) ) . appName ,
74+ resolveAppAlias : async ( app ) => {
75+ const { resolveIosAppAlias } = await import ( '../platforms/apple/core/app-resolution.ts' ) ;
76+ return resolveIosAppAlias ( app ) ;
77+ } ,
78+ readBundleAppName : async ( appPath ) => {
79+ const { readIosBundleInfo } = await import ( '../platforms/apple/core/install-artifact.ts' ) ;
80+ return ( await readIosBundleInfo ( appPath ) ) . appName ;
81+ } ,
6982 } ,
7083 } ;
7184}
0 commit comments