@@ -31,7 +31,7 @@ import {
3131 type AndroidAdbInvocation ,
3232} from '@agent-device/platform-android/mechanics' ;
3333import { reconnectLimrunAppLogReader } from './app-log-reconnect.ts' ;
34- import { attachedLimrunInstanceId } from './instance-access .ts' ;
34+ import { attachedLimrunInstanceId } from './device .ts' ;
3535import { createInstanceClient as createIosInstanceClient } from '@limrun/api/ios-client' ;
3636import type {
3737 LimrunAdbCommandOptions ,
@@ -46,17 +46,17 @@ test('reattaches an owned Limrun instance without persisting credentials', async
4646 } ) ) ;
4747 const signal = new AbortController ( ) . signal ;
4848 const outcome = await reconnectLimrunAppLogReader ( {
49- orgClient : ( ) =>
50- ( {
51- iosInstances : {
52- get,
53- } ,
54- } ) as never ,
49+ limrun : {
50+ iosInstances : {
51+ get,
52+ } ,
53+ } as never ,
5554 descriptor : {
5655 transport : 'limrun-log-poller' ,
5756 platform : 'ios' ,
5857 leaseId : 'lease-a' ,
5958 instanceId : 'instance-a' ,
59+ ownership : 'created' ,
6060 appBundleId : 'com.example.app' ,
6161 outputPath : '/sessions/one/app.log' ,
6262 } ,
@@ -73,20 +73,20 @@ test('reattaches an owned Limrun instance without persisting credentials', async
7373
7474test ( 'fails closed when the instance labels do not match the descriptor lease' , async ( ) => {
7575 const outcome = await reconnectLimrunAppLogReader ( {
76- orgClient : ( ) =>
77- ( {
78- iosInstances : {
79- get : vi . fn ( async ( ) => ( {
80- metadata : { labels : { provider : 'limrun' , leaseId : 'another-lease' } } ,
81- status : { state : 'ready' , apiUrl : 'https://instance' , token : 'secret' } ,
82- } ) ) ,
83- } ,
84- } ) as never ,
76+ limrun : {
77+ iosInstances : {
78+ get : vi . fn ( async ( ) => ( {
79+ metadata : { labels : { provider : 'limrun' , leaseId : 'another-lease' } } ,
80+ status : { state : 'ready' , apiUrl : 'https://instance' , token : 'secret' } ,
81+ } ) ) ,
82+ } ,
83+ } as never ,
8584 descriptor : {
8685 transport : 'limrun-log-poller' ,
8786 platform : 'ios' ,
8887 leaseId : 'lease-a' ,
8988 instanceId : 'instance-a' ,
89+ ownership : 'created' ,
9090 appBundleId : 'com.example.app' ,
9191 outputPath : '/sessions/one/app.log' ,
9292 } ,
@@ -99,25 +99,25 @@ test('disconnects the Android instance client when tunnel acquisition fails', as
9999 androidClient . disconnect . mockClear ( ) ;
100100 await expect (
101101 reconnectLimrunAppLogReader ( {
102- orgClient : ( ) =>
103- ( {
104- androidInstances : {
105- get : vi . fn ( async ( ) => ( {
106- metadata : { labels : { provider : 'limrun' , leaseId : 'lease-a' } } ,
107- status : {
108- state : 'ready' ,
109- apiUrl : 'https://instance' ,
110- adbWebSocketUrl : 'wss://adb' ,
111- token : 'secret' ,
112- } ,
113- } ) ) ,
114- } ,
115- } ) as never ,
102+ limrun : {
103+ androidInstances : {
104+ get : vi . fn ( async ( ) => ( {
105+ metadata : { labels : { provider : 'limrun' , leaseId : 'lease-a' } } ,
106+ status : {
107+ state : 'ready' ,
108+ apiUrl : 'https://instance' ,
109+ adbWebSocketUrl : 'wss://adb' ,
110+ token : 'secret' ,
111+ } ,
112+ } ) ) ,
113+ } ,
114+ } as never ,
116115 descriptor : {
117116 transport : 'limrun-log-poller' ,
118117 platform : 'android' ,
119118 leaseId : 'lease-a' ,
120119 instanceId : 'instance-a' ,
120+ ownership : 'created' ,
121121 appBundleId : 'com.example.app' ,
122122 outputPath : '/sessions/one/app.log' ,
123123 } ,
@@ -141,25 +141,25 @@ test('addresses app-log adb traffic at the tunnel serial and hands cleanup a com
141141 } ) ) ;
142142 androidClient . disconnect . mockClear ( ) ;
143143 const outcome = await reconnectLimrunAppLogReader ( {
144- orgClient : ( ) =>
145- ( {
146- androidInstances : {
147- get : vi . fn ( async ( ) => ( {
148- metadata : { labels : { provider : 'limrun' , leaseId : 'lease-a' } } ,
149- status : {
150- state : 'ready' ,
151- apiUrl : 'https://instance' ,
152- adbWebSocketUrl : 'wss://adb' ,
153- token : 'secret' ,
154- } ,
155- } ) ) ,
156- } ,
157- } ) as never ,
144+ limrun : {
145+ androidInstances : {
146+ get : vi . fn ( async ( ) => ( {
147+ metadata : { labels : { provider : 'limrun' , leaseId : 'lease-a' } } ,
148+ status : {
149+ state : 'ready' ,
150+ apiUrl : 'https://instance' ,
151+ adbWebSocketUrl : 'wss://adb' ,
152+ token : 'secret' ,
153+ } ,
154+ } ) ) ,
155+ } ,
156+ } as never ,
158157 descriptor : {
159158 transport : 'limrun-log-poller' ,
160159 platform : 'android' ,
161160 leaseId : 'lease-a' ,
162161 instanceId : 'instance-a' ,
162+ ownership : 'created' ,
163163 appBundleId : 'com.example.app' ,
164164 outputPath : '/sessions/one/app.log' ,
165165 } ,
@@ -218,24 +218,23 @@ test('addresses app-log adb traffic at the tunnel serial and hands cleanup a com
218218
219219const ATTACHED_ACCESS = { apiUrl : 'https://attached.example/api' , token : 'instance-token' } ;
220220
221- function attachedDescriptor ( instanceId = attachedLimrunInstanceId ( ATTACHED_ACCESS . apiUrl ) ) {
221+ function attachedDescriptor (
222+ instanceId = attachedLimrunInstanceId ( ATTACHED_ACCESS . apiUrl ) ,
223+ ownership : 'created' | 'attached' = 'attached' ,
224+ ) {
222225 return {
223226 transport : 'limrun-log-poller' ,
224227 platform : 'ios' ,
225228 leaseId : 'lease-a' ,
226229 instanceId,
230+ ownership,
227231 appBundleId : 'com.example.app' ,
228232 outputPath : '/sessions/one/app.log' ,
229233 } as const ;
230234}
231235
232- function unavailableOrgClient ( ) : never {
233- throw new Error ( 'the organization API must not be used' ) ;
234- }
235-
236236test ( 'reattaches app logs to the attached instance the descriptor names' , async ( ) => {
237237 const outcome = await reconnectLimrunAppLogReader ( {
238- orgClient : unavailableOrgClient ,
239238 instances : { ios : ATTACHED_ACCESS } ,
240239 descriptor : attachedDescriptor ( ) ,
241240 dependencies : { } as LimrunRuntimeDependencies ,
@@ -247,7 +246,6 @@ test('reattaches app logs to the attached instance the descriptor names', async
247246 expect ( outcome . status ) . toBe ( 'opened' ) ;
248247
249248 const replaced = await reconnectLimrunAppLogReader ( {
250- orgClient : unavailableOrgClient ,
251249 instances : { ios : { ...ATTACHED_ACCESS , apiUrl : 'https://another-instance.example/api' } } ,
252250 descriptor : attachedDescriptor ( ) ,
253251 dependencies : { } as LimrunRuntimeDependencies ,
@@ -261,9 +259,9 @@ test('reattaches a created instance through the organization API while another i
261259 status : { state : 'ready' , apiUrl : 'https://created.example/api' , token : 'created-token' } ,
262260 } ) ) ;
263261 const outcome = await reconnectLimrunAppLogReader ( {
264- orgClient : ( ) => ( { iosInstances : { get } } ) as never ,
262+ limrun : { iosInstances : { get } } as never ,
265263 instances : { ios : ATTACHED_ACCESS } ,
266- descriptor : attachedDescriptor ( 'ios_created_instance' ) ,
264+ descriptor : attachedDescriptor ( 'ios_created_instance' , 'created' ) ,
267265 dependencies : { } as LimrunRuntimeDependencies ,
268266 } ) ;
269267 expect ( get ) . toHaveBeenCalledOnce ( ) ;
@@ -276,7 +274,6 @@ test('does not connect once the reconnect request is aborted', async () => {
276274 vi . mocked ( createIosInstanceClient ) . mockClear ( ) ;
277275 await expect (
278276 reconnectLimrunAppLogReader ( {
279- orgClient : unavailableOrgClient ,
280277 instances : { ios : ATTACHED_ACCESS } ,
281278 descriptor : attachedDescriptor ( ) ,
282279 dependencies : { } as LimrunRuntimeDependencies ,
0 commit comments